首先登录controller1创建glance数据库,并赋于远程和本地访问的权限。
mysql -u root -p
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'venic8888';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'venic8888';
flush PRIVILEGES;
二、身份认证调用创建
只在controller1一台上执行即可
source admin-openrc.sh
创建glance用户的密码,我统一配glance
openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | e38230eeff474607805b596c91fa15d9 |
| name | glance |
+-----------+----------------------------------+
openstack role add --project service --user glance admin
openstack service create --name glance --description "OpenStack Image service" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image service |
| enabled | True |
| id | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| name | glance |
| type | image |
+-------------+----------------------------------+
openstack endpoint create --region RegionOne image public http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 340be3625e9b4239a6415d034e98aace |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
openstack endpoint create --region RegionOne image internal http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | a6e4b153c2ae4c919eccfdbb7dceb5d2 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
openstack endpoint create --region RegionOne image admin http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 0c37ed58103f4300a84ff125a539032d |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
三、下载安装glance组件
2台controller
yum install openstack-glance python-glance python-glanceclient -y
2台controller修改配置api文件
vi /etc/glance/glance-api.conf
[DEFAULT]
notification_driver = noop
verbose = True
rpc_backend = rabbit
#针对IP配置
bind_host = 10.40.42.1
bind_port = 9292
#如果这里不声明注册IP,它调用本地的注册时使用的是127.0.0.1的IP,跟glance-registry.conf不同,那个是外部调用,所以这两个地方都要配,不然会报http 500错误
registry_host=10.40.42.10
registry_port=9191
[database]
connection = mysql://glance:venic8888@controller/glance
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance
[paste_deploy]
flavor = keystone
[glance_store]
default_store = file
filesystem_store_datadir = /home/local/glance/images/
[oslo_messaging_rabbit]
rabbit_host=controller
rabbit_userid = openstack
rabbit_password = openstack
rabbit_retry_interval=1
rabbit_retry_backoff=2
rabbit_max_retries=0
rabbit_durable_queues=true
rabbit_ha_queues=true
配置完成后,两台controller需要创建目录
mkdir -p /home/local/glance/images/
chown -R glance:glance /home/local/glance
两台controller修改配置registry文件
vi /etc/glance/glance-registry.conf
[DEFAULT]
notification_driver = noop
verbose = True
rpc_backend = rabbit
bind_host = 10.40.42.1
bind_port = 9191
[database]
connection = mysql://glance:venic8888@controller/glance
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance
[paste_deploy]
flavor = keystone
[oslo_messaging_rabbit]
rabbit_host=controller
rabbit_userid = openstack
rabbit_password = openstack
rabbit_retry_interval=1
rabbit_retry_backoff=2
rabbit_max_retries=0
rabbit_durable_queues=true
rabbit_ha_queues=true
其中一台controller同步数据库
su -s /bin/sh -c "glance-manage db_sync" glance
2台controller都启动服务,加入开机自启
# systemctl enable openstack-glance-api.service openstack-glance-registry.service
# systemctl start openstack-glance-api.service openstack-glance-registry.service
TIPS:是否要使用rabiitmq队列呢?官网没有提到配置,这里我测试加了但没有功能影响,这是一个纯属个人行为的验证
验证,查看haproxy工作是否正常。
在其中带有VIP的controller上创建一个镜像,介时镜像包会放置在主用的controller的/home/local/glance/images/下,另外2台没有。
echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh
source admin-openrc.sh
glance image-create --name "cirros" \
--file cirros-0.3.4-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--visibility public --progress
[=============================>] 100%
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | 133eae9fb1c98f45894a4e60d8736619 |
| container_format | bare |
| created_at | 2015-03-26T16:52:10Z |
| disk_format | qcow2 |
| id | 38047887-61a7-41ea-9b49-27987d5e8bb9 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | ae7a98326b9c455588edd2656d723b9d |
| protected | False |
| size | 13200896 |
| status | active |
| tags | [] |
| updated_at | 2015-03-26T16:52:10Z |
| virtual_size | None |
| visibility | public |
+------------------+--------------------------------------+
验证镜像文件是否存在,以备后续调用
glance image-list