B07-openstack高可用(t版)-glance集群部署

1. 创建glance数据库

[root@controller01 ~]# mysql -uroot -phuayun -e "CREATE DATABASE glance;"
[root@controller01 ~]# mysql -uroot -phuayun -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'huayun';"
[root@controller01 ~]# mysql -uroot -phuayun -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'huayun';"

 

2. 创建glance-api

1)创建glance用户

[root@controller01 ~]# openstack user create --domain default --password=huayun glance

 

 

 

2)glance用户赋权

分配admin权限给glance用户,并指定所属service项目

[root@controller01 ~]#  openstack role add --project service --user glance admin

 

3)创建glance服务实体

# 服务实体类型”image”

[root@controller01 ~]# openstack service create --name glance   --description "OpenStack Image" image

 

 

4)创建glance-api

[root@controller01 ~]# openstack endpoint create --region RegionOne image public http://10.100.214.200:9292

 

[root@controller01 ~]# openstack endpoint create --region RegionOne image internal  http://10.100.214.200:9292

 

[root@controller01 ~]# openstack endpoint create --region RegionOne  image admin http://10.100.214.200:9292

 

 

查看创建之后的api:

[root@controller01 ~]# openstack endpoint list

 

 

3. 安装glance

[root@controller01 ~]# yum install openstack-glance python-glance python-glanceclient -y

 

4. 配置glance-api.conf

 [root@controller01 ~]# cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak

[root@controller01 ~]# egrep -v "^#|^$" /etc/glance/glance-api.conf
[DEFAULT]
enable_v1_api = false
bind_host = 10.100.214.201
[cinder]
[cors]
[database]
connection = mysql+pymysql://glance:huayun@10.100.214.200/glance
[file]
[glance.store.http.store]
[glance.store.rbd.store]
[glance.store.sheepdog.store]
[glance.store.swift.store]
[glance.store.vmware_datastore.store]
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[image_format]

[keystone_authtoken]
www_authenticate_uri = http://10.100.214.200:5000
auth_url = http://10.100.214.200:5000
memcached_servers = 10.100.214.201:11211,10.100.214.202:11211,10.100.214.203:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = huayun

[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]

 

[root@controller01 ~]# scp /etc/glance/glance-api.conf 10.100.214.202:/etc/glance/
[root@controller01 ~]# scp /etc/glance/glance-api.conf 10.100.214.203:/etc/glance/

5. 配置glance-registry.conf(optional-忽略)

复制代码
# 官方文档指出:glance-registry服务与其api在Q版已经弃用,并且在S版时完全删除,本章节可忽略;
# 在全部控制节点操作,以controller01节点为例;
# 注意”bind_host”参数,根据节点修改;
# 注意glance-registry.conf文件的权限:root:glance
[root@controller01 ~]# cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak
[root@controller01 ~]# egrep -v "^$|^#" /etc/glance/glance-registry.conf
[DEFAULT]
bind_host = 10.100.214.201
[database]
connection = mysql+pymysql://glance:glance_dbpass@controller/glance
[keystone_authtoken]
auth_uri = http://10.100.214.200:5000
auth_url = http://10.100.214.200:35357
memcached_servers = controller01:11211,controller02:11211,controller03:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = huayun
[matchmaker_redis]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]

 

6. 同步glance数据库

[root@controller01 ~]# su -s /bin/sh -c "glance-manage db_sync" glance
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
/usr/lib/python2.7/site-packages/pymysql/cursors.py:170: Warning: (1280, u"Name 'alembic_version_pkc' ignored for PRIMARY key.")
result = self._query(query)
INFO [alembic.runtime.migration] Running upgrade -> liberty, liberty initial
INFO [alembic.runtime.migration] Running upgrade liberty -> mitaka01, add index on created_at and updated_at columns of 'images' table
INFO [alembic.runtime.migration] Running upgrade mitaka01 -> mitaka02, update metadef os_nova_server
INFO [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_expand01, add visibility to images
INFO [alembic.runtime.migration] Running upgrade ocata_expand01 -> pike_expand01, empty expand for symmetry with pike_contract01
INFO [alembic.runtime.migration] Running upgrade pike_expand01 -> queens_expand01
INFO [alembic.runtime.migration] Running upgrade queens_expand01 -> rocky_expand01, add os_hidden column to images table
INFO [alembic.runtime.migration] Running upgrade rocky_expand01 -> rocky_expand02, add os_hash_algo and os_hash_value columns to images table
INFO [alembic.runtime.migration] Running upgrade rocky_expand02 -> train_expand01, empty expand for symmetry with train_contract01
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Upgraded database to: train_expand01, current revision(s): train_expand01
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Database migration is up to date. No migration needed.
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_contract01, remove is_public from images
INFO [alembic.runtime.migration] Running upgrade ocata_contract01 -> pike_contract01, drop glare artifacts tables
INFO [alembic.runtime.migration] Running upgrade pike_contract01 -> queens_contract01
INFO [alembic.runtime.migration] Running upgrade queens_contract01 -> rocky_contract01
INFO [alembic.runtime.migration] Running upgrade rocky_contract01 -> rocky_contract02
INFO [alembic.runtime.migration] Running upgrade rocky_contract02 -> train_contract01
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Upgraded database to: train_contract01, current revision(s): train_contract01
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Database is synced successfully.

 

验证

[root@controller01 ~]# mysql -h controller01 -uglance -phuayun -e "use glance;show tables;"

 

 

7. 启动服务

[root@controller01 ~]# systemctl enable openstack-glance-api.service && systemctl start  openstack-glance-api.service

 

8. 验证

[root@controller01 ~]# wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img

[root@controller01 ~]# glance image-create --name "cirros" \
> --file cirros-0.4.0-x86_64-disk.img \
> --disk-format qcow2 --container-format bare \
> --visibility public

[root@controller01 ~]# openstack image list

 

 

9. 设置pcs资源

# 在任意控制节点操作;
# 添加资源openstack-glance-api与openstack-glance-registry
# 添加资源openstack-glance-api与openstack-glance-registry(前面没有配置,后面也不需要)
[root@controller01 ~]# pcs resource create openstack-glance-api systemd:openstack-glance-api --clone interleave=true
[root@controller01 ~]# pcs resource create openstack-glance-registry systemd:openstack-glance-registry --clone interleave=true

[root@controller01 ~]# pcs resource
vip (ocf::heartbeat:IPaddr2): Started controller01
Clone Set: lb-haproxy-clone [lb-haproxy]
Started: [ controller01 ]
Stopped: [ controller02 controller03 ]
Clone Set: openstack-keystone-clone [openstack-keystone]
Started: [ controller01 controller02 controller03 ]
Clone Set: openstack-glance-api-clone [openstack-glance-api]
Started: [ controller01 controller02 controller03 ]

 

posted @ 2020-06-13 17:41  Mr-呵呵哒  阅读(687)  评论(0编辑  收藏  举报