CentOS7.1 Liberty雲平臺之Image篇(4)

控制節點:

一、安裝及配置

1.創建數據庫及管理用戶

登錄數據庫

mysql -u root -p

執行以下命令:

CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';

2.生效admin變量

source admin-openrc.sh

3.創建glance用戶

openstack user create --domain default --password-prompt glance
添加admin角色到glance用戶及service項目

openstack role add --project service --user glance admin
創建glance服務實體

openstack service create --name glance --description "OpenStack Image service" image

4.創建服務API端點

openstack endpoint create --region RegionOne image public http://controller:9292
openstack endpoint create --region RegionOne image internal http://controller:9292
openstack endpoint create --region RegionOne image admin http://controller:9292

5.安裝glance相關包

yum install openstack-glance python-glance python-glanceclient -y

6.配置/etc/glance/glance-api.conf

[database]
...
connection = mysql://glance:GLANCE_DBPASS@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 = 111111

[paste_deploy]
...
flavor = keystone
[glance_store]
...
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[DEFAULT]
...
notification_driver = noop
verbose = True

7.配置/etc/glance/glance-registry.conf

[database]
...
connection = mysql://glance:GLANCE_DBPASS@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 = 111111

[paste_deploy]
...
flavor = keystone
[DEFAULT]
...
notification_driver = noop
verbose = True

8.同步glance數據庫

su -s /bin/sh -c "glance-manage db_sync" glance

9.開啓glance相關服務,並設置開機自啓

systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service

二、驗證

1.客戶端環境變量腳本增加Image服務變量

echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh

2.生效客戶端admin環境變量腳本

source admin-openrc.sh

3.下載鏡像文件到本地

wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

4.上傳鏡像到image服務

glance image-create --name "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --visibility public --progress

5.查看上載的鏡像

glance image-list


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章