OpenStack(Kilo版本)镜像服务glance的安装部署
??? OpenStack鏡像服務(wù)(glance)允許用戶發(fā)現(xiàn)、注冊(cè)和恢復(fù)虛擬機(jī)鏡像。Glance提供Rest API可以查詢虛擬機(jī)鏡像的metadata并且可以獲取鏡像。通過(guò)Glance,虛擬機(jī)鏡像可以被存儲(chǔ)到多種存儲(chǔ)上,比如簡(jiǎn)單的文件存儲(chǔ)或者對(duì)象存儲(chǔ)(比如OpenStack中swift項(xiàng)目)。
一、OpenStack 鏡像服務(wù)包含組件
??????????????????????????????????? 圖1.1. OpenStack glance組件
?
二、OpenStack 鏡像服務(wù)安裝
??? 下面介紹如何安裝和配置鏡像服務(wù),即glance。這個(gè)配置將鏡像保存到本地文件系統(tǒng)中,默認(rèn)存儲(chǔ)在/var/lib/glance/p_w_picpaths/目錄中。所有的步驟將在控制節(jié)點(diǎn)(Controller Node)上面進(jìn)行操作。
1.安裝前的準(zhǔn)備
安裝和配置鏡像服務(wù)之前,必須創(chuàng)建數(shù)據(jù)庫(kù)、服務(wù)證書和API端點(diǎn)。
1.1數(shù)據(jù)庫(kù)配置
1)創(chuàng)建數(shù)據(jù)庫(kù)
2)給數(shù)據(jù)庫(kù)授權(quán)
MariaDB?[(none)]>?GRANT?ALL?PRIVILEGES?ON?glance.*?TO?'glance'@'localhost'?IDENTIFIED?BY?'sfzhang1109'; Query?OK,?0?rows?affected?(0.45?sec) MariaDB?[(none)]>?GRANT?ALL?PRIVILEGES?ON?glance.*?TO?'glance'@'%'?IDENTIFIED?BY?'sfzhang1109'; Query?OK,?0?rows?affected?(0.00?sec) MariaDB?[(none)]>?flush?privileges; Query?OK,?0?rows?affected?(0.06?sec)3)退出數(shù)據(jù)庫(kù)客戶端
MariaDB?[(none)]>?exit Bye1.2 導(dǎo)入admin身份憑證以便執(zhí)行管理命令
root@controller:~#?source?admin-openrc.sh1.3 創(chuàng)建服務(wù)證書
1)創(chuàng)建glance用戶(密碼:glance)
2)將glance用戶和租戶服務(wù)添加管理員角
root@controller:~#?openstack?role?add?--project?service?--user?glance?admin +-------+----------------------------------+ |?Field?|?Value????????????????????????????| +-------+----------------------------------+ |?id????|?05616505a61c4aa78f43fba9e60ba7fc?| |?name??|?admin????????????????????????????| +-------+----------------------------------+3)創(chuàng)建glance服務(wù)實(shí)體
root@controller:~#?openstack?service?create?--name?glance?--description?"OpenStack?Image?service"?p_w_picpath +-------------+----------------------------------+ |?Field???????|?Value????????????????????????????| +-------------+----------------------------------+ |?description?|?OpenStack?Image?service??????????| |?enabled?????|?True?????????????????????????????| |?id??????????|?e448c04b115a4cd3b745b70b17fa95b3?| |?name????????|?glance???????????????????????????| |?type????????|?p_w_picpath????????????????????????????| +-------------+----------------------------------+1.4 創(chuàng)建鏡像服務(wù)API端點(diǎn)
root@controller:~#?openstack?endpoint?create?\--publicurl?http://controller:9292?\--internalurl?http://controller:9292?\--adminurl?http://controller:9292?\--region?RegionOne?\p_w_picpath +--------------+----------------------------------+ |?Field????????|?Value????????????????????????????| +--------------+----------------------------------+ |?adminurl?????|?http://controller:9292???????????| |?id???????????|?aa4ac4216c7a41fd8452c7186c9493ac?| |?internalurl??|?http://controller:9292???????????| |?publicurl????|?http://controller:9292???????????| |?region???????|?RegionOne????????????????????????| |?service_id???|?e448c04b115a4cd3b745b70b17fa95b3?| |?service_name?|?glance???????????????????????????| |?service_type?|?p_w_picpath????????????????????????????| +--------------+----------------------------------+2.安裝和配置鏡像服務(wù)組件
2.1安裝軟件包
2.2編輯/etc/glance/glance-api.conf配置文件,完成下面的配置
1)在[database]部分配置數(shù)據(jù)庫(kù)訪問(wèn)
2)在[keystone_authtoken] 和[paste_deploy]部分配置身份認(rèn)證入口
[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 [paste_deploy] … flavor?=?keystone3)在[glance_store]部分配置本地文件系統(tǒng)存儲(chǔ)和鏡像文件的位置
[glance_store] ... default_store?=?file filesystem_store_datadir?=?/data/glance/p_w_picpaths/4)在[DEFAULT]部分禁用noop消息驅(qū)動(dòng),因?yàn)樵撨x項(xiàng)只和可選的Telemetry服務(wù)有關(guān)
[DEFAULT] ... notification_driver?=?noop5)在[DEFAULT]部分開啟詳細(xì)日志配置,方便故障分析和排查
[DEFAULT] ... verbose?=?True2.3編輯/etc/glance/glance-registry.conf配置文件,完成下面的配置
1)在[database]部分配置數(shù)據(jù)庫(kù)訪問(wèn)
2)在[keystone_authtoken] 和[paste_deploy]部分配置身份認(rèn)證入口
[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?=?glance3)在[DEFAULT]部分禁用noop消息驅(qū)動(dòng),因?yàn)樵撨x項(xiàng)只和可選的Telemetry服務(wù)有關(guān)
[paste_deploy] ... flavor?=?keystone4)在[DEFAULT]部分開啟詳細(xì)日志配置,方便故障分析和排查
[DEFAULT] ... verbose?=?True2.4 初始化鏡像服務(wù)數(shù)據(jù)庫(kù)
root@controller:~#?su?-s?/bin/sh?-c?"glance-manage?db_sync"?glance 2015-09-01?06:17:25.166?18641?INFO?migrate.versioning.api?[-]?0?->?1...? 2015-09-01?06:17:25.193?18641?INFO?glance.db.sqlalchemy.migrate_repo.schema?[-]?creating?table?p_w_picpaths …3.安裝完成
1)重啟Image service的服務(wù)
2默認(rèn)會(huì)創(chuàng)建SQLite數(shù)據(jù)庫(kù),因?yàn)槭褂玫氖荕YSQL數(shù)據(jù)庫(kù),因此要?jiǎng)h除QLite數(shù)據(jù)庫(kù)文件
三、OpenStack Image service服務(wù)驗(yàn)證
1)配置鏡像服務(wù)客戶端使用API的版本為2.0
2)執(zhí)行admin身份憑證
root@controller:~#?source?admin-openrc.sh3)在本地創(chuàng)建臨時(shí)目錄
root@controller:~#?mkdir?/tmp/p_w_picpaths4)下載鏡像到該目錄
root@controller:~#?wget?-P?/tmp/p_w_picpaths?http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img5)上傳鏡像到Image service,鏡像格式為QCOW2。
root@controller:~#?glance?p_w_picpath-create?--name?"cirros-0.3.4-x86_64"?--file?/tmp/p_w_picpaths/cirros-0.3.4-x86_64-disk.img???--disk-format?qcow2?--container-format?bare??--progress [=============================>]?100% +------------------+--------------------------------------+ |?Property?????????|?Value????????????????????????????????| +------------------+--------------------------------------+ |?checksum?????????|?ee1eca47dc88f4879d8a229cc70a07c6?????| |?container_format?|?bare?????????????????????????????????| |?created_at???????|?2015-09-11T07:04:31.000000???????????| |?deleted??????????|?False????????????????????????????????| |?deleted_at???????|?None?????????????????????????????????| |?disk_format??????|?qcow2????????????????????????????????| |?id???????????????|?df54ff49-b167-4fed-987a-0ade3cbc9aca?| |?is_public????????|?False????????????????????????????????| |?min_disk?????????|?0????????????????????????????????????| |?min_ram??????????|?0????????????????????????????????????| |?name?????????????|?cirros-0.3.4-x86_64??????????????????| |?owner????????????|?d04d4985d62f42e2af2ddc35f442ffd9?????| |?protected????????|?False????????????????????????????????| |?size?????????????|?13287936?????????????????????????????| |?status???????????|?active???????????????????????????????| |?updated_at???????|?2015-09-11T07:04:32.000000???????????| |?virtual_size?????|?None?????????????????????????????????| +------------------+--------------------------------------+6)確認(rèn)鏡像上傳并驗(yàn)證屬性
7)刪除臨時(shí)目錄的鏡像文件
備注:
1)OpenStack官方文檔:
??? http://docs.openstack.org/kilo/install-guide/install/apt/content/
轉(zhuǎn)載于:https://blog.51cto.com/sfzhang88/1693834
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的OpenStack(Kilo版本)镜像服务glance的安装部署的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: static成员函数不能调用non-st
- 下一篇: SQL Server镜像自动生成脚本