OpenStack安裝流程(juno版)- 添加鏡像服務(glance)

OpenStack鏡像服務(glance)可讓用戶查詢,存取虛擬機。python

安裝和配置

glance安裝在controller節點上。mysql

建立配置glance所需的數據庫,服務證書和API端點

  1. 建立glance數據庫:
    用root身份進入數據庫:
    $ 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

  1. 啓動admin證書:
    $ source admin-openrc.sh
  2. 建立glance的服務證書:

    建立glance用戶:
    <pre>$ keystone user-create --name glance --pass GLANCE_PASSide

Property Value
email
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>

  1. 建立鏡像服務的API端點:
    <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>

安裝和配置鏡像服務的組件

  1. 安裝所需包:
    # apt-get install glance python-glanceclient
  2. 編輯# 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]
...
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = glance
admin_password = GLANCE_PASS
</pre>

<pre>[paste_deploy]
...
flavor = keystone
</pre>
GLANCE_PASS爲建立glance用戶時使用的密碼。在[keystone_authtoken]部分,註釋掉 auth_host,auth_port,和auth_protocol的選項,由於identity_uri選項是直接代替它們的。

[glance_store]部分,設定本地文件系統存儲方式(local file system store)和鏡像文件的存儲位置:
<pre>[glance_store]
...
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
</pre>

[DEFAULT]部分,將notification driver設定爲noop來關閉通知,由於通知服務將由Telemetry服務來提供:
<pre>[DEFAULT]
...
notification_driver = noop
</pre>
繼續在[DEFAULT]部分,開啓「詳細輸出日誌」選項:
<pre>[DEFAULT]
...
verbose = True
</pre>

  1. 編輯# 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]
...
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = glance
admin_password = GLANCE_PASS
</pre>

<pre>[paste_deploy]
...
flavor = keystone
</pre>
GLANCE_PASS爲建立glance用戶時使用的密碼。在[keystone_authtoken]部分,註釋掉 auth_host,auth_port,和auth_protocol的選項,由於identity_uri選項是直接代替它們的。

[DEFAULT]部分,將notification driver設定爲noop來關閉通知,由於通知服務將由Telemetry服務來提供:
<pre>[DEFAULT]
...
notification_driver = noop
</pre>
繼續在[DEFAULT]部分,開啓「詳細輸出日誌」選項:
<pre>[DEFAULT]
...
verbose = True
</pre>

  1. 同步數據庫:
    # glance-manage db_sync

完成安裝

  1. 重啓鏡像服務:

# service glance-registry restart
# service glance-api restart

  1. 刪除Ubuntu默認產生的SQLite數據庫:

# rm -f /var/lib/glance/glance.sqlite

驗證操做

這節採用CirrOS,一種很是小的Linux鏡像,來進行驗證。

  1. 下載鏡像:
    鏡像的下載地址爲:http://download.cirros-cloud....
    $ wget http://download.cirros-cloud....
  2. 啓動admin證書:
    $ source admin-openrc.sh
  3. 上傳鏡像文件到鏡像服務上:
    <pre>$ 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>

  1. 確認上傳的鏡像文件:
    <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的安裝,本節安裝較爲簡單通常不會出現問題。

相關文章
相關標籤/搜索