一.Glance環境
參考文檔:http://www.aboutyun.com/thread-13080-1-1.html
http://docs.openstack.org/mitaka/install-guide-ubuntu/glance-install.html
1.創建glance的數據庫並授權
- 創建
mysql -u root -p
CREATE DATABASE glance;
- 授權(自己設定密碼,連接數據庫時用,我的glance)
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_PASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_PASS';
- 退出
exit
2.生效admin環境變量
source admin-openrc.sh
3.創建認證服務
- 創建glance用戶
openstack user create --password-prompt glance
User Password:(我的設置glance)
Repeat User Password:
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | e0353a670a9e496da891347c589539e9 |
| enabled | True |
| id | e38230eeff474607805b596c91fa15d9 |
| name | glance |
+-----------+----------------------------------+
- 添加 admin 角色 到 glance 用戶 和 service 租戶(project)
openstack role add --project service --user glance admin
- 創建glance的服務實例
openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| name | glance |
| type | image |
+-------------+----------------------------------+
- 創建鏡像服務的API endpoint
openstack endpoint create --publicurl http://controller:9292 --internalurl http://controller:9292 --adminurl http://controller:9292 --region RegionOne image
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| adminurl | http://controller:9292 |
| id | 340be3625e9b4239a6415d034e98aace |
| internalurl | http://controller:9292 |
| publicurl | http://controller:9292 |
| region_id | RegionOne |
| service_id | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
| service_name | glance |
| service_type | image |
+--------------+----------------------------------+
二.安裝Glance
1.安裝
apt-get install glance python-glanceclient -y
2.修改配置
vim /etc/glance/glance-api.conf
[DEFAULT]
verbose = True
notification_driver = noop
[database]
connection = mysql://glance:GLANCE_DBPASS(glance數據庫密碼)@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 = GLANCE_PASS(glance密碼)
[paste_deploy]
flavor = keystone
[glance_store]
#配置本地文件系統存儲和image文件路徑
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
保存退出。
vim /etc/glance/glance-registry.conf
[DEFAULT]
verbose = True
notification_driver = noop
[database]
connection = mysql://glance:GLANCE_DBPASS(glance數據庫密碼)@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 = GLANCE_PASS(glance密碼)
[paste_deploy]
flavor = keystone
保存退出。
3.同步數據庫(同步之後,可以看看數據庫中是否存在表,有則成功,沒有則表明可能sqlite數據庫沒刪,刪除後在同步rm -f /var/lib/glance/glance.sqlite
)
su -s /bin/sh -c "glance-manage db_sync" glance
4.重啓glance服務
service glance-registry restart
service glance-api restart
三.Glance驗證
1.在每一個客戶端腳本,配置鏡像服務客戶端使用 API version 2.0
echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh
2.source admin環境變量
source admin-openrc.sh
3.創建一個臨時目錄,下載鏡像
mkdir /tmp/images
wget -P /tmp/images http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
4.上傳鏡像到glance,鏡像使用qcow2 格式
glance image-create --name "cirros-0.3.4-x86_64" --file /tmp/
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-0.3.4-x86_64 |
| owner | ae7a98326b9c455588edd2656d723b9d |
| protected | False |
| size | 13200896 |
| status | active |
| tags | [] |
| updated_at | 2015-03-26T16:52:10Z |
| virtual_size | None |
| visibility | public |
+------------------+--------------------------------------+
5.驗證成功,並移除臨時目錄
glance image-list
+--------------------------------------+--------+
| ID | Name |
+--------------------------------------+--------+
| 38047887-61a7-41ea-9b49-27987d5e8bb9 | cirros |
+--------------------------------------+--------+
rm -r /tmp/images
注意:以前搭建的,可以運行,如果上面寫的有一些問題,謝謝指出來。