openstack controller ha测试环境搭建记录(七)——配置glance

在所有集群安装glance软件:
yum install -y openstack-glance python-glanceclient

在任一节点创建glance用户:
mysql -u root -p
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '123456';
quit

在任一节点设置环境变量:
source admin-openrc.sh

在任一节点创建keystone中的相关用户、服务、endpoint等:
keystone user-create --name=glance --pass=123456
keystone user-role-add --user=glance --tenant=service --role=admin
keystone service-create --name=glance --type=image --description="OpenStack Image Service"
keystone endpoint-create \
--service-id=$(keystone service-list | awk '/ image / {print $2}') \
--publicurl=http://myvip:9292 \
--internalurl=http://myvip:9292 \
--adminurl=http://myvip:9292

在所有节点修改配置文件:
openstack-config --set /etc/glance/glance-api.conf database connection mysql://glance:123456@myvip/glance
openstack-config --set /etc/glance/glance-registry.conf database connection mysql://glance:123456@myvip/glance

openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://myvip:5000/v2.0
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken identity_uri http://myvip:35357
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_tenant_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_user glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_password 123456
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-api.conf DEFAULT notification_driver noop
openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
openstack-config --set /etc/glance/glance-api.conf DEFAULT verbose True

openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://myvip:5000/v2.0
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken identity_uri http://myvip:35357
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_tenant_name service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_user glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_password 123456
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-registry.conf DEFAULT notification_driver noop
openstack-config --set /etc/glance/glance-registry.conf DEFAULT verbose True

openstack-config --set /etc/glance/glance-api.conf DEFAULT rpc_backend rabbit
openstack-config --set /etc/glance/glance-api.conf DEFAULT rabbit_password 123456
openstack-config --set /etc/glance/glance-api.conf DEFAULT rabbit_hosts controller1:5672,controller2:5672,controller3:5672
openstack-config --set /etc/glance/glance-api.conf DEFAULT rabbit_retry_interval 1
openstack-config --set /etc/glance/glance-api.conf DEFAULT rabbit_retry_backoff 2
openstack-config --set /etc/glance/glance-api.conf DEFAULT rabbit_max_retries 0
openstack-config --set /etc/glance/glance-api.conf DEFAULT rabbit_durable_queues true
openstack-config --set /etc/glance/glance-api.conf DEFAULT rabbit_ha_queues true

openstack-config --set /etc/glance/glance-registry.conf DEFAULT rpc_backend rabbit
openstack-config --set /etc/glance/glance-registry.conf DEFAULT rabbit_password 123456
openstack-config --set /etc/glance/glance-registry.conf DEFAULT rabbit_hosts controller1:5672,controller2:5672,controller2:5673
openstack-config --set /etc/glance/glance-registry.conf DEFAULT rabbit_retry_interval 1
openstack-config --set /etc/glance/glance-registry.conf DEFAULT rabbit_retry_backoff 2
openstack-config --set /etc/glance/glance-registry.conf DEFAULT rabbit_max_retries 0
openstack-config --set /etc/glance/glance-registry.conf DEFAULT rabbit_durable_queues true
openstack-config --set /etc/glance/glance-registry.conf DEFAULT rabbit_ha_queues true

疑问:/etc/glance/glance-api.conf中的filesystem_store_datadirs指向的是本地路径,是否有官方的说法来消除此问题。

在任一节点初始化glance数据库:
su -s /bin/sh -c "glance-manage db_sync" glance

在所有节点设置服务自动启动并启动服务:
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service

---------------------------------------------------------------------------------
由于在初始化glance数据库时,有问题,该问题是由未配置完.conf文件就执行初始化数据库的动作造成:
# su -s /bin/sh -c "glance-manage db_sync" glance
# echo $?
1

在网络上查找另外一种初始化数据库的方法:
# openstack-db --init --service glance --password 123456 --rootpw 123456

注:该命令会自动在glance-api.conf和glance-registry.conf添加“connection=”,一般需要手动删除。
或:
mysql -u glance -p -e 'drop database glance;'
mysql -u glance -p -e 'create database glance;'
su -s /bin/sh -c "glance-manage db sync" glance

在配置时,尝试在glance-api.conf和glance-registry.conf中设置bind_host,出现HTTPInternalServerError (HTTP 500)错误。取消该配置项才解决问题:
http://www.gossamer-threads.com/lists/openstack/operators/26429

上一篇:openstack controller ha测试环境搭建记录(三)——配置haproxy


下一篇:openstack controller ha测试环境搭建记录(五)——配置rabbitmq集群