glance系列二:glance部署及操作

linhaifeng發表於2017-02-12

一 簡單架構圖示參考

更新中...

二 部署glance

yum install memcached python-memcached
systemctl enable memcached.service
systemctl start memcached.service

step 1:glance關於資料庫的操作

mysql -u root -p #登入資料庫
CREATE DATABASE glance; #新建庫keystone
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
  IDENTIFIED BY '123'; #新建本地訪問glance庫的賬號
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
  IDENTIFIED BY '123'; #新建遠端訪問glance庫的賬號

step 2:glance關於keystone的操作

soure admin-openrc #執行管理員指令碼
#為glance的使用者建立使用者
openstack user create --domain default --password-prompt glance 

#對glance-service新增role角色,提示:使用者glance只有在一個確定的專案service內才有角色的概念,單獨的使用者或者單獨的專案都是無法繫結角色的。
openstack role add --project service --user glance admin 


#建立glance服務的catalog:service+endpoint
openstack service create --name glance \
--description "OpenStack Image" image

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

step 3:安裝軟體包

yum -y install openstack-glance

step 4:配置/etc/glance/glance.conf

大前提:每一條配置都應該新增到檔案中,一定不要開啟註釋在原有的基礎上修改。

建立本地儲存:

1.一定要在opesntack-glance-api.service服務啟動之前部署好儲存裝置,因為該服務在啟動時會載入儲存驅動檢索儲存裝置,如果事先不存在,就意味著該服務沒有識別到任何可用的儲存裝置,即便是後來你又新增了儲存,仍然是無效的,最終導致你上傳映象失敗;

2.一定要賦予opesntack-glance-api.service服務對儲存裝置的可寫許可權。

mkdir -p /var/lib/glance/images
chown -R glance.glance /var/lib/glance/images

 

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

[database]
connection = mysql+pymysql://glance:123@192.168.31.57/glance

[keystone_authtoken]
auth_uri = http://192.168.31.57:5000
auth_url = http://192.168.31.57:35357
memcached_servers = 192.168.31.57:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = 123

[paste_deploy]
flavor = keystone

[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

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

[database]
connection = mysql+pymysql://glance:123@192.168.31.57/glance

[keystone_authtoken]
auth_uri = http://192.168.31.57:5000
auth_url = http://192.168.31.57:35357
memcached_servers = 192.168.31.57:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = 123

[paste_deploy]
flavor = keystone

step 5: 初始化資料庫glance

su -s /bin/sh -c "glance-manage db_sync" glance
'''
忽略以下列印,此乃正常性行為:
Option "verbose" from group "DEFAULT" is deprecated for removal.  Its value may be silently ignored in the future.
/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py:1171:...... oslo_db.sqlalchemy.enginefacade
...... a future release.")
  result = self._query(query)
'''

step 6:啟動glance且設定開機啟動

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

三 驗證

source admin-openrc

#如果沒有wget則必須yum -y install wget
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

openstack image create "cirros" \
  --file cirros-0.3.4-x86_64-disk.img \
  --disk-format qcow2 --container-format bare \
  --public
  
  
openstack image list

 


For information about the openstack image create parameters, see Create or update an image (glance) in the OpenStack User Guide.

For information about disk and container formats for images, see Disk and container formats for images in the OpenStack Virtual Machine Image Guide.

 

相關文章