【编排】使用docker部署senlin服务

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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,590评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 86,808评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,151评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,779评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,773评论 5 367
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,656评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,022评论 3 398
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,678评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 41,038评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,659评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,756评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,411评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,005评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,973评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,203评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,053评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,495评论 2 343

推荐阅读更多精彩内容