天天看點

第五節 先電雲openstack手動搭建Glance鏡像服務

一、安裝Glance基本元件

-----------------controller節點---------------------------------

(1)檢視opt下的centos目錄下的安裝包是否挂載成功,沒成功重新挂載

#mount -o loop /opt/CentOS-7-x86_64-DVD-1511.iso /opt/centos/
#mount -o loop /opt/XianDian-IaaS-v2.2.iso /opt/iaas/
           

(2)安裝glance

#yum install -y openstack-glance
           

二、建立Glance資料庫并授權

(1)登入資料庫

#mysql -u root -p
           

(2)建立glance資料庫

CREATE DATABASE glance;

(3)建立glance使用者,并賦予其glance資料庫的操作權限(本地遠端都可通路)

GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '000000';

GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '000000';

(4)退出mysql指令

exit;

三、修改Glance配置檔案中資料連接配接的相關配置

(1)在glance-api.conf的[database]段落中添加資料庫連接配接配置

#

vi /etc/glance/glance-api.conf

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

(2)在glance-registry.conf的[database]段落中添加資料庫連接配接配置

#vi  /etc/glance/glance-registry.conf

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

四、同步資料庫,為Glance服務建立資料庫表

#

su -s /bin/sh -c "glance-manage db_sync" glance

----忽略關于EngineFacade is deprecated;的資訊

五、建立使用者

(1)導入環境變量

#

source admin-openrc.sh

(2)建立使用者glance密碼000000

#

openstack user create --domain default --password 000000 glance

(3)關聯角色、租戶和使用者

#

openstack role add --project service --user glance admin

(4)建立鏡像服務

#

openstack service create --name glance --description "OpenStack Image" image

(5)注冊Glance端點資訊(三種權限)

#

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

六、修改Glance配置檔案

------------------------------第一種方法-------------------------------------

注:修改以下配置檔案時如果檔案内容前面有#注釋的無須修改直接複制文章中已經修改好的内容粘貼在該段落下即可,溫馨提示要特别特别認真仔細,多數報錯問題都是配置檔案問題。

(一)修改 /etc/glance/glance-api.conf檔案

#

vi /etc/glance/glance-api.conf

找到[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 = 000000
           

找到[paste_deploy],在下面添加:

flavor = keystone
config_file = /usr/share/glance/glance-api-dist-paste.ini
           

找到[glance_store],在下面添加:

stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
           

(2)修改/etc/glance/glance-registry.conf檔案

#

vi /etc/glance/glance-registry.conf

找到[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 = 000000
           

找到[paste_deploy],在下面添加:

flavor = keystone
config_file = /usr/share/glance/glance-registry-dist-paste.ini
           

------------------------------第二種方法(指令修改配置)-------------------------------------

#

openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://controller:5000

#

openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://controller:35357

#

openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller:11211

#

openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password

#

openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name default

#

openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name default

#

openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service

#

openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance

#

openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password 000000

#

openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone

#

openstack-config --set /etc/glance/glance-api.conf paste_deploy config_file /usr/share/glance/glance-api-dist-paste.ini

#

openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http

#

openstack-config --set /etc/glance/glance-api.conf glance_store default_store file

#

openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/

#

openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://controller:5000

#

openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://controller:35357

#

openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers controller:11211

#

openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password

#

openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name default

#

openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name default

#

openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service

#

openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance

#

openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password 000000

#

openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone

#

openstack-config --set /etc/glance/glance-registry.conf paste_deploy config_file /usr/share/glance/glance-registry-dist-paste.ini

七、啟動服務

#

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

#

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

八、上傳鏡像

#

source admin-openrc.sh

glance image-create --name "CentOS7.0" --disk-format qcow2  --container-format bare --progress <       /opt/iaas/images/CentOS_7.2_x86_64_XD.qcow2
openstack image create "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --public

glance image-create --name "centos7.1" --file CentOS-7-x86_64-GenericCloud-1503.qcow2 --disk-format qcow2 --container-format bare  --visibility public --progress
           

--------------注意tab補全指令去指定鏡像名

----------------驗證鏡像是否成功上傳

#

openstack image list

有任何疑問或建議歡迎留言讨論,下一節進行Nova計算服務的安裝歡迎通路,點選傳送。

繼續閱讀