中小企业openstack私有云布署实践9.1 Glance镜像管理(科兴环境)
Posted 肖冲
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了中小企业openstack私有云布署实践9.1 Glance镜像管理(科兴环境)相关的知识,希望对你有一定的参考价值。
首先登录kxcontroller1创建kx_glance数据库,并赋于远程和本地访问的权限。
mysql -u root -p
CREATE DATABASE kx_glance;
GRANT ALL PRIVILEGES ON kx_glance.* TO ‘glance‘@‘localhost‘ IDENTIFIED BY ‘venic8888‘;
GRANT ALL PRIVILEGES ON kx_glance.* TO ‘glance‘@‘%‘ IDENTIFIED BY ‘venic8888‘;
flush PRIVILEGES;
二、身份认证调用创建
只在kxcontroller1一台上执行即可
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 RegionTwo image public http://kxcontroller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 340be3625e9b4239a6415d034e98aace |
| interface | public |
| region | RegionTwo |
| region_id | RegionTwo |
| service_id | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| service_name | glance |
| service_type | image |
| url | http://kxcontroller:9292 |
+--------------+----------------------------------+
openstack endpoint create --region RegionTwo image internal http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | a6e4b153c2ae4c919eccfdbb7dceb5d2 |
| interface | internal |
| region | RegionTwo |
| region_id | RegionTwo |
| service_id | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| service_name | glance |
| service_type | image |
| url | http://kxcontroller:9292 |
+--------------+----------------------------------+
openstack endpoint create --region RegionTwo image admin http://kxcontroller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 0c37ed58103f4300a84ff125a539032d |
| interface | admin |
| region | RegionTwo |
| region_id | RegionTwo |
| service_id | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| service_name | glance |
| service_type | image |
| url | http://kxcontroller:9292 |
+--------------+----------------------------------+
三、下载安装glance组件
2台kxcontroller同时下载
yum install openstack-glance python-glance python-glanceclient -y
controller修改配置api文件
在kxcontroller1上
[[email protected] ~]# vi /etc/glance/glance-api.conf
[DEFAULT]
notification_driver = noop
verbose = True
rpc_backend = rabbit
bind_host = 10.120.42.1
bind_port = 9292
registry_host=10.120.42.10
registry_port=9191
[database]
connection = mysql://glance:[email protected]/kx_glance
[keystone_authtoken]
auth_uri = http://kxcontroller:5000
auth_url = http://kxcontroller: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/
在kxcontroller2上
[[email protected] ~]# vi /etc/glance/glance-api.conf
[DEFAULT]
notification_driver = noop
verbose = True
rpc_backend = rabbit
bind_host = 10.120.42.2
bind_port = 9292
registry_host=10.120.42.10
registry_port=9191
[database]
connection = mysql://glance:[email protected]/kx_glance
[keystone_authtoken]
auth_uri = http://kxcontroller:5000
auth_url = http://kxcontroller: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/
配置完成后,两台kxcontroller需要创建目录
mkdir -p /home/local/glance/images/
chown -R glance:glance /home/local/glance
两台kxcontroller修改配置registry文件
在kxcontroller1上
vi /etc/glance/glance-registry.conf
[DEFAULT]
notification_driver = noop
verbose = True
rpc_backend = rabbit
bind_host = 10.120.42.1
bind_port = 9191
[database]
connection = mysql://glance:[email protected]/kx_glance
[keystone_authtoken]
auth_uri = http://kxcontroller:5000
auth_url = http://kxcontroller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance
[paste_deploy]
flavor = keystone
在kxcontroller2上
vi /etc/glance/glance-registry.conf
[DEFAULT]
notification_driver = noop
verbose = True
rpc_backend = rabbit
bind_host = 10.120.42.2
bind_port = 9191
[database]
connection = mysql://glance:[email protected]/kx_glance
[keystone_authtoken]
auth_uri = http://kxcontroller:5000
auth_url = http://kxcontroller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance
[paste_deploy]
flavor = keystone
其中一台kxcontroller同步数据库
su -s /bin/sh -c "glance-manage db_sync" glance
2台kxcontroller都启动服务,加入开机自启
# systemctl enable openstack-glance-api.service openstack-glance-registry.service
# systemctl start openstack-glance-api.service openstack-glance-registry.service
注意点:
验证,查看haproxy工作是否正常,是否变绿色。
在其中带有VIP的controller上创建一个镜像,介时镜像包会放置在VIP的kxcontroller的/home/local/glance/images/下,另外1台没有。后续我们可以使用文件Rsync同步功能将他们同步
添加环境变量配置文件,2台都要加
cd /root/
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
以上是关于中小企业openstack私有云布署实践9.1 Glance镜像管理(科兴环境)的主要内容,如果未能解决你的问题,请参考以下文章
中小企业openstack私有云布署实践5 数据库MariaDB 集群
中小企业openstack私有云布署实践7.2 keystone + memcache (办公网环境)
中小企业openstack私有云布署实践3 keepalive配置(VRRP虚IP)