1.镜像上传:
上传制作好的centos-senlin.img镜像文件到目标环境。
sudo scp centos-senlin.img 172.28.229.197:/root
2.创建senlin数据库:
eldon@ubuntu:~/github/cmss$ mysql -uroot #<password>替换成自己的密码
mysql>CREATE DATABASE senlin;
mysql>GRANT ALL PRIVILEGES ON senlin.* TO 'senlin'@'localhost' IDENTIFIED BY '<password>';
mysql>GRANT ALL PREVILEGES ON senlin.* TO 'senlin'@'%' IDENTIFIED BY '<password>';
mysql> exit
Bye
3.在keystone中注册senlin用户:
source admin-openrc.sh
openstack user create --password-prompt senlin
openstack role add --project service --user senlin admin
openstack service create --name senlin --description "Senlin Clustering Service" clustering
openstack endpoint create --region RegionOne --publicurl http://vip:8778/v1 --adminurl http://vip:8778/v1 --internalurl http://vip:8778/v1 senlin
#用实际ip替换vip
4.载入docker镜像:
docker load -i centos-senlin.img
5.创建相关目录:
mkdir -p /etc/senlin /var/log/senlin /var/cache/senlin
6.添加用户组
useradd --user-group senlin
7.修改目录及用户组权限:
chown -R senlin:senlin /etc/senlin /var/log/senlin /var/cache/senlin
echo "senlin ALL = (root) NOPASSWD: ALL" > /etc/sudoers.d/senlin
8.创建并编辑/etc/senlin/api-paste.ini文件:
# senlin-api pipeline
[pipeline:senlin-api]
pipeline = request_id faultwrap ssl versionnegotiation webhook authtoken context trust apiv1app
#pipeline = request_id faultwrap ssl versionnegotiation authtoken context apiv1app
[app:apiv1app]
paste.app_factory = senlin.common.wsgi:app_factory
senlin.app_factory = senlin.api.openstack.v1:API
# Middleware to set x-openstack-request-id in http response header
[filter:request_id]
paste.filter_factory = oslo_middleware.request_id:RequestId.factory
[filter:faultwrap]
paste.filter_factory = senlin.common.wsgi:filter_factory
senlin.filter_factory = senlin.api.openstack:faultwrap_filter
[filter:context]
paste.filter_factory = senlin.common.wsgi:filter_factory
senlin.filter_factory = senlin.api.openstack:contextmiddleware_filter
[filter:ssl]
paste.filter_factory = oslo_middleware.ssl:SSLMiddleware.factory
[filter:versionnegotiation]
paste.filter_factory = senlin.common.wsgi:filter_factory
senlin.filter_factory = senlin.api.openstack:version_negotiation_filter
[filter:trust]
paste.filter_factory = senlin.common.wsgi:filter_factory
senlin.filter_factory = senlin.api.openstack:trustmiddleware_filter
[filter:webhook]
paste.filter_factory = senlin.common.wsgi:filter_factory
senlin.filter_factory = senlin.api.openstack:webhookmiddleware_filter
[filter:authtoken]
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
9.创建并编辑/etc/senlin/policy.json文件:
{
"context_is_admin": "role:admin",
"deny_everybody": "!",
"build_info:build_info": "",
"profile_types:index": "",
"profile_types:get": "",
"policy_types:index": "",
"policy_types:get": "",
"clusters:index": "",
"clusters:create": "",
"clusters:delete": "",
"clusters:get": "",
"clusters:action": "",
"clusters:update": "",
"profiles:index": "",
"profiles:create": "",
"profiles:get": "",
"profiles:delete": "",
"profiles:update": "",
"nodes:index": "",
"nodes:create": "",
"nodes:get": "",
"nodes:action": "",
"nodes:update": "",
"nodes:delete": "",
"policies:index": "",
"policies:create": "",
"policies:get": "",
"policies:update": "",
"policies:delete": "",
"cluster_policies:index": "",
"cluster_policies:attach": "",
"cluster_policies:detach": "",
"cluster_policies:update": "",
"cluster_policies:get": "",
"receivers:index": "",
"receivers:create": "",
"receivers:get": "",
"receivers:delete": "",
"actions:index": "",
"actions:get": "",
"events:index": "",
"events:get": "",
"webhooks:trigger": ""
}
10.创建并编辑/etc/senlin/senlin.conf文件:
[DEFAULT]
rpc_backend = rabbit
logging_exception_prefix = %(color)s%(asctime)s.%(msecs)03d TRACE %(name)s ^[[01;35m%(instance)s^[[00m
logging_debug_format_suffix = ^[[00;33mfrom (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d^[[00m
use_syslog = False
region_name_for_services = RegionOne
debug = True
verbose = True
log_dir = /var/log/senlin
num_engine_workers = 1 #可配置
[senlin_api]
bind_port = 8778
workers = 4
[database]
connection = mysql+pymysql://root:123456@10.133.6.80/senlin?charset=utf8
#connection = mysql://senlin:123456@vip/senlin?charset=utf8 #vip替换成数据库ip
[keystone_authtoken]
admin_tenant_name = service
admin_password = 28f0b976d0b4 #senlin用户在keystone中的密码
admin_user = senlin #senlin用户在keystone中的用户名
auth_uri = http://vip:35357/v3 #keystone vip地址
signing_dir = /var/cache/senlin
identity_uri = http://vip:35357 #keystone vip地址
[authentication]
service_project_name = service
service_password = 28f0b976d0b4 #senlin用户在keystone中的密码
service_username = senlin
auth_url = http://controller-1:35357/v3 #keystone vip地址
[oslo_messaging_rabbit]
rabbit_userid=nova #rabbit的userid
rabbit_password=D36tiX3x#rabbit的密码
rabbit_hosts=pm.rabbit1.bcec.core:5672,pm.rabbit2.bcec.core:5672,pm.rabbit3.bcec.core:5672 #RabbitMQ集群的IP
[webhook]
host = localhost
port = 8778
11.在/usr/lib/systemd/system目录下创建对应的unit文件:
- 创建并编辑openstack-senlin-api.service文件:
[Unit]
Description=OpenStack Senlin api Service
After=syslog.target network.target docker
[Service]
ExecStart=/usr/bin/docker start -a senlin-api
ExecStop=/usr/bin/docker stop -t 2 senlin-api
Restart=always
[Install]
WantedBy=multi-user.target
- 创建并编辑openstack-senlin-engine.service文件:
[Unit]
Description=OpenStack Senlin engine Service
After=syslog.target network.target docker
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a senlin-engine
ExecStop=/usr/bin/docker stop -t 2 senlin-engine
[Install]
WantedBy=multi-user.target
12.创建senlin-api和senlin-engine容器:
sudo docker create --name senlin-api --net=host -v /etc/senlin:/etc/senlin -v /var/log/senlin/:/var/log/senlin -u senlin centos-senlin:1.0.0 senlin-api
sudo docker create --name senlin-engine --net=host -v /etc/senlin:/etc/senlin -v /var/log/senlin/:/var/log/senlin -u senlin centos-senlin:1.0.0 senlin-engine
13.创建并启动senlin-client容器:
eldon@ubuntu:~/github/cmss$ sudo docker run -it --name senlin-client --net host -v /etc/senlin:/etc/senlin -v /var/log/senlin/:/var/log/senlin centos-senlin:1.0.0 bash
[root@ubuntu /]# exit
eldon@ubuntu:~/github/cmss$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
42f86330f288 centos-senlin:1.0.0 "bash" 4 minutes ago Exited (0) 7 seconds ago senlin-client
aa06369be822 67591570dd29 "/bin/bash" 46 hours ago Up About an hour modest_lamport
eldon@ubuntu:~/github/cmss$ sudo docker start 42f86330f288
42f86330f288
eldon@ubuntu:~/github/cmss$ sudo docker exec -ti 42f86330f288 bash
senlin-client服务是个bash进程,由于bash不是循环服务,所以不能用create的方式创建container,再用docker start
启动,docker start <container-id>
后容器启动瞬间就stop了。
14.同步数据库:
[root@ubuntu /]# senlin-manage db_sync
[root@ubuntu /]# exit
15.启动senlin-api,senlin-engine服务:
eldon@ubuntu:~/github/cmss$ systemctl start openstack-senlin-api
eldon@ubuntu:~/github/cmss$ systemctl start openstack-senlin-engine