【N版】openstack——鏡像服務glance
一.openstack之glance鏡像服務
1.1glance介紹
glance主要是由三部分組成
glance-api:接收雲系統鏡像的創建,刪除,讀取請求,類似nova-api,通過其他模塊(glance-registry及image store)來完成諸如鏡像的查找、獲取、上傳、刪除等操作,api監聽端口9292。
glance-registry:雲系統的鏡像註冊服務,用於與mysql數據庫交互,存儲或獲取鏡像的元數據(metadata);提供鏡像元數據相關的REST接口,通過glance-registry,可以向數據庫中寫入或獲取鏡像各種數據,glance-registry監聽端口9191,glance數據庫中有兩張表,一張是image表,另一張是image property表。image表保存了鏡像格式、大小等信息;image property表則主要保存鏡像的定製化信息。
image store:是一個存儲的接口層,通過這個接口,glance可以獲取鏡像,imagestore支持的存儲有Amazon的S3、Openstack本身的Swift還有注入ceph,sheepdog,GFS等分佈式存儲。image store是鏡像保存與獲取的接口,它僅僅是一個接口層,具體的實現需要外部的存儲支持。
glance配置
項目及端點配置
[root@linux-node1 ~]# openstack service create --nameglance --description "OpenStack Image" image <- 創建glance服務實體 ->
[root@linux-node1 ~]# openstack endpoint create --regionRegionOne \
image public http://192.168.56.11:9292
[root@linux-node1 ~]# openstack endpoint create --regionRegionOne \
image internal http://192.168.56.11:9292
[root@linux-node1 ~]# openstack endpoint create --regionRegionOne \
image admin http://192.168.56.11:9292
<-創建鏡像服務API端點 ->
[root@linux-node1 ~]# openstack endpoint list <- 查看列表->
1.2 連接數據庫配置
[root@linux-node1 ~]# vim /etc/glance/glance-api.conf <- glance-api配置->
1748 connection = mysql+pymysql://glance:[email protected]/glance
[root@linux-node1 ~]# vim/etc/glance/glance-registry.conf <- registry配置->
1038 connection =mysql+pymysql://glance:[email protected]/glance
[root@linux-node1 ~]# su -s /bin/sh -c"glance-manage db_sync" glance <- 同步->
[root@linux-node1 ~]# mysql -uglance -pglance-h192.168.56.11 -e "use glance;show tables" <-檢查->
1.3連接keystone配置
[root@linux-node1 ~]# vim /etc/glance/glance-api.conf <- glance-api配置->
3178 [keystone_authtoken] 下面添加 <- 連接keystone配置->
3179 auth_uri = http://192.168.56.11:5000
3180 auth_url = http://192.168.56.11:35357
3181 memcached_servers = 192.168.56.11:11211
3182 auth_type = password
3183 project_domain_name = default
3184 user_domain_name = default
3185 project_name = service
3186 username = glance
3187 password = glance
打開3990 flavor = keystone的註釋 <- 配置認證服務訪問->
打開1864 stores = file,http的註釋 <- 配置本地文件系統和鏡像存儲位置>
打開1896 default_store = file的註釋
打開2196 filesystem_store_datadir = /var/lib/glance/images的註釋
[root@linux-node1 ~]# vim/etc/glance/glance-registry.conf <- registry配置->
1127 [keystone_authtoken] 下面添加
1128 auth_uri = http://192.168.56.11:5000
1129 auth_url = http://192.168.56.11:35357
1130 memcached_servers = 192.168.56.11:11211
1131 auth_type = password
1132 project_domain_name = default
1133 user_domain_name = default
1134 project_name = service
1135 username = glance
1136 password = glance
打開 1910 flavor = keystone 註釋 <- 配置認證服務訪問->
1.4 檢查配置文件
[root@linux-node1 ~]# grep '^[a-z]'/etc/glance/glance-api.conf
connection =mysql+pymysql://glance:[email protected]/glance
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
memcached_servers = 192.168.56.11:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
flavor = keystone
[root@linux-node1 ~]# grep '^[a-z]'/etc/glance/glance-registry.conf
connection =mysql+pymysql://glance:[email protected]/glance
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
memcached_servers = 192.168.56.11:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
flavor = keystone
1.5 啓動服務
[root@linux-node1 ~]# systemctl enableopenstack-glance-api.service \
openstack-glance-registry.service
[root@linux-node1 ~]# systemctl startopenstack-glance-api.service \
openstack-glance-registry.service
1.6上傳鏡像
注: 把鏡像放到任意目錄下,執行以下命令,進入那個目錄,否則要加絕對路徑
[root@linux-node1 ~]# openstack image create"cirros" \
--file cirros-0.3.4-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--public
1.7查看鏡像列表
[root@linux-node1 ~]# openstack image list
[root@linux-node1 ~]# glance image-list <- 老版本命令 ->