OpenStack鏡像服務(glance)可讓用戶查詢,存取虛擬機。python
glance安裝在controller節點上。mysql
$ mysql -u root -p
建立glance數據庫:
<pre>CREATE DATABASE glance;
</pre>sql
把glance數據庫的訪問權限賦予名爲glance,來自任何主機地址的用戶,並設定訪問密碼爲GLANCE_DBPASS(替換爲合適的密碼):
<pre>GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
數據庫
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';</pre>api
退出數據庫。curl
admin
證書:$ source admin-openrc.sh
建立glance
用戶:
<pre>$ keystone user-create --name glance --pass GLANCE_PASS
ide
Property | Value |
---|---|
enabled | True |
id | 9d458c5ef8854904ae279f25bbbc5b8b |
name | glance |
username | glance |
+----------+----------------------------------+</pre>
用合適的密碼替換GLANCE_PASS。oop
把admin
角色賦予給glance
用戶:$ keystone user-role-add --user glance --tenant service --role admin
這條命令不產生輸出顯示。url
建立glance
服務實體:
<pre>$ keystone service-create --name glance --type image \
.net
--description "OpenStack Image Service" | |
---|---|
Property | Value |
description | OpenStack Image Service |
enabled | True |
id | 8247ab1fa1be4b75aef86889ad66698d |
name | glance |
type | image |
+-------------+----------------------------------+</pre>
$ keystone endpoint-create \
--service-id $(keystone service-list | awk '/ image / {print $2}') \
--publicurl http://controller:9292 \
--internalurl http://controller:9292 \
--adminurl http://controller:9292 \
--region regionOne | |
---|---|
Property | Value |
adminurl | http://controller:9292 |
id | ac47c90ff5c842eda22e59d408bc5bbf |
internalurl | http://controller:9292 |
publicurl | http://controller:9292 |
region | regionOne |
service_id | 8247ab1fa1be4b75aef86889ad66698d |
+-------------+----------------------------------+</pre>
# apt-get install glance python-glanceclient
# vi /etc/glance/glance-api.conf
文件:在[database]
部分,設定數據庫的訪問選項:
<pre>[database]
...
connection = mysql://glance:GLANCE_DBPASS@controller/glance</pre>
GLANCE_DBPASS爲建立glance數據庫時設立的密碼。
在[keystone_authtoken]
和[paste_deploy]
部分,設定認證服務的選項:
<pre>[keystone_authtoken]
</pre>
...
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = glance
admin_password = GLANCE_PASS
<pre>[paste_deploy]
</pre>
...
flavor = keystone
GLANCE_PASS爲建立glance
用戶時使用的密碼。在[keystone_authtoken]
部分,註釋掉 auth_host,auth_port,和auth_protocol的選項,由於identity_uri選項是直接代替它們的。
在[glance_store]
部分,設定本地文件系統存儲方式(local file system store)和鏡像文件的存儲位置:
<pre>[glance_store]
</pre>
...
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
在[DEFAULT]
部分,將notification driver設定爲noop來關閉通知,由於通知服務將由Telemetry服務來提供:
<pre>[DEFAULT]
</pre>
...
notification_driver = noop
繼續在[DEFAULT]
部分,開啓「詳細輸出日誌」選項:
<pre>[DEFAULT]
</pre>
...
verbose = True
# vi /etc/glance/glance-registry.conf
文件:在[database]
部分,設定數據庫的訪問選項:
<pre>[database]
...
connection = mysql://glance:GLANCE_DBPASS@controller/glance</pre>
GLANCE_DBPASS爲建立glance數據庫時設立的密碼。
在[keystone_authtoken]
和[paste_deploy]
部分,設定認證服務的選項:
<pre>[keystone_authtoken]
</pre>
...
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = glance
admin_password = GLANCE_PASS
<pre>[paste_deploy]
</pre>
...
flavor = keystone
GLANCE_PASS爲建立glance
用戶時使用的密碼。在[keystone_authtoken]
部分,註釋掉 auth_host,auth_port,和auth_protocol的選項,由於identity_uri選項是直接代替它們的。
在[DEFAULT]
部分,將notification driver設定爲noop來關閉通知,由於通知服務將由Telemetry服務來提供:
<pre>[DEFAULT]
</pre>
...
notification_driver = noop
繼續在[DEFAULT]
部分,開啓「詳細輸出日誌」選項:
<pre>[DEFAULT]
</pre>
...
verbose = True
# glance-manage db_sync
# service glance-registry restart
# service glance-api restart
# rm -f /var/lib/glance/glance.sqlite
這節採用CirrOS,一種很是小的Linux鏡像,來進行驗證。
$ wget http://download.cirros-cloud....
admin
證書:$ source admin-openrc.sh
$ glance image-create --name "cirros-0.3.3-x86_64" --file /home/controller/Downloads/cirros-0.3.3-x86_64-disk.img \
--disk-format qcow2 --container-format bare --is-public True --progress
[=============================>] 100% | |
---|---|
Property | Value |
checksum | 133eae9fb1c98f45894a4e60d8736619 |
container_format | bare |
created_at | 2015-11-25T03:04:22 |
deleted | False |
deleted_at | None |
disk_format | qcow2 |
id | 6db9f9c9-4011-4cf5-a12b-dc70423ec0c3 |
is_public | True |
min_disk | 0 |
min_ram | 0 |
name | cirros-0.3.3-x86_64 |
owner | 4f7806287c9a437e9cd912504ff71727 |
protected | False |
size | 13200896 |
status | active |
updated_at | 2015-11-25T03:04:22 |
virtual_size | None |
+------------------+--------------------------------------+</pre>
$ glance image-list
ID | Name | Disk Format | Container Format | Size | Status |
---|---|---|---|---|---|
6db9f9c9-4011-4cf5-a12b-dc70423ec0c3 | cirros-0.3.3-x86_64 | qcow2 | bare | 13200896 | active |
+--------------------------------------+---------------------+-------------+------------------+----------+--------+</pre>
至此完成glance的安裝,本節安裝較爲簡單通常不會出現問題。