在安装StackStorm之前,需要安装MongoDB,RabbitMQ,and PostgreSQL。根据官网介绍,目前支持的MongoDB 的版本是3.4,MongoDB 3.6与StackStorm还不兼容。StackStorm的后续版本会对3.6进行兼容。
1、安装MongoDB,RabbitMQ,and PostgreSQL
在/etc/yum.repos.d目录下创建一个文件mongodb-org-3.4.repo。
vim mongodb-org-3.4.repo
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
#gpgcheck=1
enabled=1
注意,这里注释掉了gpgcheck,不注释掉的话会报错,如下:
[root@spurman yum.repos.d]# sudo yum install -y mongodb-org
Loaded plugins: changelog, priorities
https://repo.mongodb.org/yum/redhat/6/mongodb-org/3.4/x86_64/repodata/repomd.xml: [Errno 14] problem making ssl connection
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: mongodb-org-3.4. Please verify its path and try again
MongoDB yum源解决后,直接安装mongodb-org,rabbitmq-server,并启动:
sudo yum -y install mongodb-org
sudo yum -y install rabbitmq-server
sudo yum -y localinstall http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-2.noarch.rpm
sudo yum -y install postgresql94-server postgresql94-contrib postgresql94-devel
# Initialize PostgreSQL
sudo service postgresql-9.4 initdb
# Make localhost connections to use an MD5-encrypted password for authentication
sudo sed -i "s/\(host.*all.*all.*127.0.0.1\/32.*\)ident/\1md5/" /var/lib/pgsql/9.4/data/pg_hba.conf
sudo sed -i "s/\(host.*all.*all.*::1\/128.*\)ident/\1md5/" /var/lib/pgsql/9.4/data/pg_hba.conf
sudo service mongod start
sudo service rabbitmq-server start
sudo chkconfig mongod on
sudo chkconfig rabbitmq-server on
sudo service postgresql-9.4 start
sudo chkconfig postgresql-9.4 on
2、安装StackStorm
执行一下命令:
curl -s https://packagecloud.io/install/repositories/StackStorm/stable/script.rpm.sh | sudo bash
执行完后,在/etc/yum.repos.d目录下会生成一个文件StackStorm_stable.repo,其内容如下(注意:生成的源文件没有注释掉任何一行,为了解决问题,暂且注释掉了相关的check):
[StackStorm_stable]
name=StackStorm_stable
baseurl=https://packagecloud.io/StackStorm/stable/el/6/$basearch
#repo_gpgcheck=1
gpgcheck=0
enabled=1
#gpgkey=https://packagecloud.io/StackStorm/stable/gpgkey
#sslverify=1
#sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
[StackStorm_stable-source]
name=StackStorm_stable-source
baseurl=https://packagecloud.io/StackStorm/stable/el/6/SRPMS
#repo_gpgcheck=1
gpgcheck=0
enabled=1
#gpgkey=https://packagecloud.io/StackStorm/stable/gpgkey
#sslverify=1
#sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
安装st2命令
yum install -y st2 st2mistral
在没有注释掉相关行之前,安装时st2 st2mistral时报错,如下:
yum install -y st2 st2mistral
Loaded plugins: changelog, priorities
Setting up Install Process
Percona | 1.9 kB 00:00
Percona/primary_db | 84 kB 00:00
https://packagecloud.io/StackStorm/stable/el/6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7 - "Failed to connect to 2600:1fa0:c040:101:34db:181c::: Network is unreachable"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: StackStorm_stable. Please verify its path and try again
查看st2
[root@spurman yum.repos.d]# which st2
/usr/bin/st2
[root@spurman yum.repos.d]# whereis st2
st2: /usr/bin/st2 /etc/st2
至此,StackStorm安装成功,后续介绍配置问题。
3、启动st2服务
启动服务
sudo st2ctl start
注册传感器、规则、动作
sudo st2ctl reload
启动后,进程如下:
[root@spurman ~]# ps aux | grep st2
root 101154 2.3 1.6 318452 31044 pts/0 S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
root 101167 2.3 1.6 318456 31320 pts/0 S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
root 101184 2.4 1.6 318616 31448 pts/0 S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
root 101207 2.3 1.6 318472 31376 pts/0 S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
root 101226 2.3 1.6 318476 31324 pts/0 S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
root 101261 2.3 2.1 318476 41272 pts/0 S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
root 101282 2.3 2.1 318612 41656 pts/0 S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
root 101317 2.3 2.7 318460 52748 pts/0 S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
root 101350 2.4 2.8 318464 55104 pts/0 S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
root 101371 2.5 2.8 318624 55120 pts/0 S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
st2 101403 0.7 1.2 239464 23456 ? S 10:59 0:00 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/gunicorn st2api.wsgi:application -k eventlet -b 127.0.0.1:9101 --workers 1 --threads 1 --graceful-timeout 10 --timeout 30 --pid /var/run/st2/st2api.pid
st2 101486 1.0 1.2 239464 23480 ? S 10:59 0:00 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/gunicorn st2stream.wsgi:application -k eventlet -b 127.0.0.1:9102 --workers 1 --threads 10 --graceful-timeout 10 --timeout 30 --pid /var/run/st2/st2stream.pid
st2 101494 4.9 4.0 340576 77744 ? S 10:59 0:03 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/gunicorn st2api.wsgi:application -k eventlet -b 127.0.0.1:9101 --workers 1 --threads 1 --graceful-timeout 10 --timeout 30 --pid /var/run/st2/st2api.pid
st2 101568 0.9 1.2 239464 23520 ? S 10:59 0:00 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/gunicorn st2auth.wsgi:application -k eventlet -b 127.0.0.1:9100 --workers 1 --threads 1 --graceful-timeout 10 --timeout 30 --pid /var/run/st2/st2auth.pid
st2 101582 4.3 3.9 329072 74732 ? S 10:59 0:02 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/gunicorn st2stream.wsgi:application -k eventlet -b 127.0.0.1:9102 --workers 1 --threads 10 --graceful-timeout 10 --timeout 30 --pid /var/run/st2/st2stream.pid
st2 101616 4.1 4.0 342024 76816 ? S 10:59 0:02 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/gunicorn st2auth.wsgi:application -k eventlet -b 127.0.0.1:9100 --workers 1 --threads 1 --graceful-timeout 10 --timeout 30 --pid /var/run/st2/st2auth.pid
st2 101647 2.5 2.4 298944 46728 ? S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2garbagecollector --config-file /etc/st2/st2.conf
st2 101671 4.3 2.5 307820 49164 ? S 10:59 0:02 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2notifier --config-file /etc/st2/st2.conf
st2 101695 2.8 2.4 299216 47312 ? S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2resultstracker --config-file /etc/st2/st2.conf
st2 101723 3.4 2.9 312852 55628 ? S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2rulesengine --config-file /etc/st2/st2.conf
st2 101757 2.5 2.4 298136 45832 ? S 10:59 0:01 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2sensorcontainer --config-file /etc/st2/st2.conf
root 102261 0.0 0.0 103248 880 pts/0 S+ 11:00 0:00 grep st2
4、其他配置
4.1 Setup Datastore Encryption
参照官网配置即可
4.2 Setup Mistral Database
参照官网配置即可
4 .3 Configure SSH and SUDO
参照官网配置即可
结果
[root@spurman st2]# st2 action list --pack=core
+-------------------+------+-------------------------------------------------------------------+
| ref | pack | description |
+-------------------+------+-------------------------------------------------------------------+
| core.announcement | core | Action that broadcasts the announcement to all stream consumers. |
| core.ask | core | Action for initiating an Inquiry (usually in a workflow) |
| core.http | core | Action that performs an http request. |
| core.local | core | Action that executes an arbitrary Linux command on the localhost. |
| core.local_sudo | core | Action that executes an arbitrary Linux command on the localhost. |
| core.noop | core | Action that does nothing |
| core.pause | core | Action to pause current thread of workflow/sub-workflow. |
| core.remote | core | Action to execute arbitrary linux command remotely. |
| core.remote_sudo | core | Action to execute arbitrary linux command remotely. |
| core.sendmail | core | This sends an email |
| core.uuid | core | Generate a new UUID (default uuid4) |
| core.windows_cmd | core | Action to execute arbitrary Windows command remotely. |
+-------------------+------+-------------------------------------------------------------------+
[root@spurman st2]# st2 run core.local -- date -R
.
id: 5af50f95b37e23ada34d198a
status: succeeded
parameters:
cmd: date -R
result:
failed: false
return_code: 0
stderr: ''
stdout: Fri, 11 May 2018 11:35:51 +0800
succeeded: true
[root@spurman st2]# st2 run core.remote hosts='localhost' -- uname -a
..
id: 5af51319b37e23ada34d1996
status: succeeded
parameters:
cmd: uname -a
hosts: localhost
result:
localhost:
failed: false
return_code: 0
stderr: ''
stdout: 'Linux spurman.office.mos 2.6.32-431.20.3.el6.mt20140703.x86_64 #1 SMP Thu Jul 3 16:57:03 CST 2014 x86_64 x86_64 x86_64 GNU/Linux'
succeeded: true
参考文献:
【1】https://docs.stackstorm.com/install/rhel6.html
【2】https://packagecloud.io/StackStorm/stable