天天看點

OpenStack之安裝glance

安裝和配置 Image service(鏡像服務)glance

1. 建立資料庫,完成下列步驟:

A. 使用資料庫指令行用戶端,以 root 身份登入資料庫伺服器。

# mysql -u root -p123

OpenStack之安裝glance

B. 建立 glance 資料庫

MariaDB [(none)]> CREATE DATABASE glance;

C. 授予資料庫使用者 glance 通路 glance 資料庫的權限。

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@’localhost’ IDENTIFIED BY ‘GLANCE_DBPASS’;

GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@’localhost’ IDENTIFIED BY ‘123456’;

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@’%’ IDENTIFIED BY ‘GLANCE_DBPASS’;

GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@’%’ IDENTIFIED BY ‘123456’;

OpenStack之安裝glance

D. 退出資料庫

exit

2. 執行 admin 憑據腳本,以便以 admin 身份執行後續指令:

/# . admin-openrc

3. 建立服務憑據,完成下列操作:

A. 建立 glance 使用者

/# openstack user create –domain default –password-prompt glance

OpenStack之安裝glance

B. 添加 admin 角色到 glance 使用者和 service 項目

/# openstack role add –project service –user glance admin

OpenStack之安裝glance

C. 建立 glance 服務實體:

/# openstack service create –name glance –description “OpenStack Image” image

OpenStack之安裝glance

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

OpenStack之安裝glance
OpenStack之安裝glance
OpenStack之安裝glance

安裝和配置元件

1. 安裝軟體包

/# yum install openstack-glance –y

OpenStack之安裝glance
OpenStack之安裝glance

2. 編輯/etc/glance/glance-api.conf 檔案并完成下列操作:

從這一步開始一定要仔細!!配置錯會出問題。error401或error500

A. 在[database]小節,配置資料庫通路:

[database]

/# …

connection = mysql+pymysql://glance:[email protected]/glance

OpenStack之安裝glance

B. 在[keystone_authtoken]和[paste_deploy]小節配置身份服務通路資訊:

[keystone_authtoken]

/# …

auth_uri = http://controller:5000

auth_url = http://controller:35357

memcached_servers = controller:11211

auth_type = password

project_domain_name = default

user_domain_name = default

project_name = service

username = glance

password = 123456

[paste_deploy]

/# …

flavor = keystone

OpenStack之安裝glance
OpenStack之安裝glance

替換 GLANCE_DBPASS 為認證服務中 glance 使用者的密碼。

C. 在[glance_store]小節,配置使用本地系統存儲和鏡像檔案存儲路徑:

[glance_store]

/# …

stores = file,http

default_store = file

filesystem_store_datadir = /var/lib/glance/images/

OpenStack之安裝glance

3. 編輯/etc/glance/glance-registry.conf 檔案并完成下列操作:

A. 在[database]小節,配置資料庫通路:

[database]

/# …

connection = mysql+pymysql://glance:[email protected]/glance

OpenStack之安裝glance

替換 GLANCE_DBPASS 為你的鏡像服務資料庫使用者 glance 的密碼。

B. 在[keystone_authtoken]和[paste_deploy]小節,配置身份服

務通路資訊:

[keystone_authtoken]

/# …

auth_uri = http://controller:5000

auth_url = http://controller:35357

memcached_servers = controller:11211

auth_type = password

project_domain_name = default

user_domain_name = default

project_name = service

username = glance

password = 123456

OpenStack之安裝glance

[paste_deploy]

/# …

flavor = keystone

OpenStack之安裝glance

替換 GLANCE_DBPASS 為認證服務中 glance 使用者的密碼。

4. 初始化鏡像服務資料庫

/# su -s /bin/sh -c “glance-manage db_sync” glance

OpenStack之安裝glance

【圖檔】

完成安裝

啟動鏡像服務并設定開機自動啟動:

/# systemctl enable openstack-glance-api.service openstack-glance-registry.service

/# systemctl start openstack-glance-api.service openstack-glance-registry.service

注意:以前沒有時時刻刻要進行服務的檢查,是以我在這上面真的吃了不少虧。。。

systemctl status openstack-glance-api.service openstack-glance-registry.service

OpenStack之安裝glance

确認安裝

使用 CirrOS 鏡像确認鏡像服務是否安裝正常。CirrOS 是一個小型Linux 鏡像,可以用來測試你的 OpenStack 環境。

1. 執行 admin 憑據腳本,以便以 admin 身份執行後續指令:

/# . admin-openrc

2. 下載下傳鏡像檔案

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

  1. 上傳鏡像檔案到鏡像服務,使用 QCOW2 磁盤格式,bare 容器格式,添加公共可見選項,是所有項目可以通路該鏡像:

    /# openstack image create “cirros” –file cirros-0.3.5-x86_64-disk.img –disk-format qcow2 –container-format bare –public

    OpenStack之安裝glance
  2. 确認鏡像已經上傳并驗證屬性:

    /# openstack image list

    OpenStack之安裝glance

疑難小結:

在倒數第二步可能會出現錯誤:

錯誤一:

OpenStack之安裝glance

k.img –disk-format qcow2 –container-format bare –public

500 Internal Server Error: The server has either erred or is incapable of performing the requested operation. (HTTP 500)

錯誤二:

OpenStack之安裝glance

401 Authorization Required

This server could not verify that you are authorized to access the document you requested.

Either you supplied the wrong credentials (e.g,bad password),or your browser doesn’t understand how to supply the credentials required.(HTTP 401)

這兩個錯誤可能是你以前的配置有錯誤,唯一的方法就是檢查以前的錯誤。改過之後記住要重新初始化資料庫,檢查一下資料庫中有沒有表,比如這樣,我檢查一下glance中的表:

OpenStack之安裝glance

然後重點檢查

1./etc/glance/glance-api.conf

2./etc/glance/glance-registry.conf

這兩個配置檔案。

如果還不對,那就是你的keystone配置的有問題。

繼續閱讀