天天看點

OpenStack 最小化安裝配置(六):Glance服務配置

       上一集介紹了Keystone的服務配置,并且已經添加成功。上面建立的服務使用者包括了Glance,Nova換言之就是需要上面配置的MySQL還有Keystone後面的服務才可以進行,我們需要MySQL的存儲服務,還有Keystone 的認證服務。

       接下來需要做的是對鏡像伺服器的配置,鏡像伺服器的IP位址為192.168.137.105,内部通信的IP位址為192.168.1.105首先是安裝

       安裝腳本glance_install.sh  

apt-get update
apt-get install -y glance glance-api glance-common glance-registry python-glance python-keystone python-mysqldb python-glanceclient
           

一.

接着要做的是修改配置檔案第一個/etc/glance/glance-api.conf

修改的地方有

1.找到[database]

#sqlite_db = /var/lib/glance/glance.sqlite
           

把跟sqlite有關的這條語句注釋掉。

然後添加MySQL的連接配接字元串。跟keystone差不多。

connection = mysql://glanceUser:[email protected]/glance
           

2.找到rabbit相關的句子有這樣一個叢集。

# Configuration options if sending notifications via rabbitmq (these are
# the defaults)
rabbit_host = 192.168.1.103
rabbit_port = 5672
rabbit_use_ssl = false
rabbit_userid = guest
rabbit_password = guest
rabbit_virtual_host = /
rabbit_notification_exchange = glance
rabbit_notification_topic = notifications
rabbit_durable_queues = False
           

原來的rabbit_host 是等于localhost的,我們要修改它讓他指向實際上rabbit所在的伺服器ip位址

3.找到[keystone_authtoken]下面有個叢集要修改

auth_host = 192.168.1.104 #認證服務在的IP
auth_port = 35357  #服務認證的端口
auth_protocol = http #消息送出方式
admin_tenant_name = serviceTenant #服務使用者所在的租戶
admin_user = glance  #服務使用者
admin_password = Glance_Pass #服務使用者的密碼
           

以上資訊是用來跟keystone服務認證用的。

4.找到[paste_deploy]

# Name of the paste configuration file that defines the available pipelines
config_file = /etc/glance/glance-api-paste.ini

# Partial name of a pipeline in your paste configuration file with the
# service name removed. For example, if your paste section name is
# [pipeline:glance-api-keystone], you would configure the flavor below
# as 'keystone'.
flavor=keystone
           

取消了兩行注釋,把config_file本身的相對路徑改成絕對路徑,不然服務沒法啟動。flavor=keystone

然後儲存,第一個配置檔案修改完畢。

第二個配置檔案修改方式與第一個配置檔案一樣。/etc/glance/glance-registry.conf

1.找到[database]添加上連接配接語句。

#sqlite_db = /var/lib/glance/glance.sqlite
           

把跟sqlite有關的這條語句注釋掉。

然後添加MySQL的連接配接字元串。跟keystone差不多。

connection = mysql://glanceUser:[email protected]/glance
           

2.找到[keystone_authtoken]

修改相關資訊。

auth_host = 192.168.1.104 #認證服務在的IP
auth_port = 35357  #服務認證的端口
auth_protocol = http #消息送出方式
admin_tenant_name = serviceTenant #服務使用者所在的租戶
admin_user = glance  #服務使用者
admin_password = Glance_Pass #服務使用者的密碼
           

要跟keystone中建立的以及第一個配置檔案中的對應,不然的話會有認證失敗的可能。

3.找到[paste_deploy]

# Name of the paste configuration file that defines the available pipelines
config_file = /etc/glance/glance-api-paste.ini

# Partial name of a pipeline in your paste configuration file with the
# service name removed. For example, if your paste section name is
# [pipeline:glance-api-keystone], you would configure the flavor below
# as 'keystone'.
flavor=keystone
           

取消了兩行注釋,把config_file本身的相對路徑改成絕對路徑,不然服務沒法啟動。flavor=keystone

完畢之後重新開機服務

[email protected]:/home/lan# service glance-api restart && service glance-registry restart
glance-api stop/waiting
glance-api start/running, process 4039
glance-registry stop/waiting
glance-registry start/running, process 4049
           

還要檢視服務

ps -e | grep glance
           
4039 ?        00:00:00 glance-api
4049 ?        00:00:00 glance-registry
4056 ?        00:00:00 glance-registry
4059 ?        00:00:00 glance-api
           

服務啟動成功了。

接着同步資料庫

glance-manager db-sync
           

如果上面沒什麼問題這一步應該是沒什麼問題了。

現在試一下功能。

glance image-list   #列出鏡像
           

注意:這裡現在出問題了。

You must provide a username via either --os-username or env[OS_USERNAME]
           

很遺憾的我們有一些環境變量沒有設定。包括keystone,nova重新開機後也會有環境變量丢失的問題。我們編寫一個腳本。export_glance.sh

export OS_TENANT_NAME=serviceTenant
export OS_USERNAME=glance
export OS_PASSWORD=Glance_Pass
export OS_AUTH_URL=http://192.168.1.104:35357/v2.0/
           

其他兩個服務跟此相似,用來設定環境變量。導入後運作有如下效果。

OpenStack 最小化安裝配置(六):Glance服務配置

有個空的表。這就是鏡像表。鏡像服務搭建完成。