首页 > 代码库 > 中小企业openstack私有云布署实践【9.1 Glance镜像管理(科兴环境)】
中小企业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上
[root@kxcontroller1 ~]# 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:venic8888@kxcontroller/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上
[root@kxcontroller2 ~]# 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:venic8888@kxcontroller/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:venic8888@kxcontroller/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:venic8888@kxcontroller/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
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
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镜像管理(科兴环境)】
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。