鏡像中的幾種狀態(tài):
active 鏡像已經(jīng)在正確的上傳并可以使用了
saving 鏡像正在被上傳
queued 這個(gè)鏡像的ID已經(jīng)被記錄了,但是鏡像并沒(méi)有真的上傳
killed 上傳失敗,完全不可用
glance主要的兩個(gè)服務(wù):
glance-api 接收用戶的各種請(qǐng)求
glance-registry 和后臺(tái)數(shù)據(jù)庫(kù)進(jìn)行交互
軟件安裝:
yum list *glance*
yum install -y *glance*
image
創(chuàng)建服務(wù)同名用戶并添加admin權(quán)限:
image
創(chuàng)建服務(wù):
image
創(chuàng)建endpoint:
http://192.168.179.140:9292
http://192.168.179.140:9292
http://192.168.179.140:9292
image
配置文件:
image
從模板復(fù)制過(guò)來(lái),如下:
image
image
修改配置文件,[DEFAULT]下面需要添加rabbitmq的數(shù)據(jù),從keystone復(fù)制出來(lái)
rabbit_host = 192.168.179.140
rabbit_port = 5672
rabbit_hosts = $rabbit_host:$rabbit_port
rabbit_use_ssl = false
rabbit_userid = guest
rabbit_password = guest
rabbit_virtual_host = /
image
vim glance_api.conf
image
添加auth_uri
image
vim glance_registry.conf
image
創(chuàng)建數(shù)據(jù)庫(kù):
> grant all privileges on glance.* to glance@'%' identified by 'redhat';
> grant all privileges on glance.* to glance@'localhost' identified by 'redhat';
> grant all privileges on glance.* to glance@'192.168.179.140' identified by 'redhat';
image
更新下數(shù)據(jù)庫(kù):
sh -c 'glance-manage db_sync' glance
image
啟動(dòng)服務(wù)但是出錯(cuò),查看權(quán)限:
image
成功啟動(dòng)glance服務(wù):
# systemctl start openstack-glance-api.service openstack-glance-registry.service
# systemctl enable openstack-glance-api.service openstack-glance-registry.service
image
創(chuàng)建鏡像:(正常非swift存儲(chǔ)的情況)
openstack image create small --file small.img --disk-format qcow2 --container-format bare --public
image
鏡像存放位置:/var/lib/glance/images
image
配置swift后端存儲(chǔ):
配置文件
配置如下:不是default下面的存儲(chǔ)
下面是配置以swift作為后端存儲(chǔ):
[glance_store]
default_store=swift
stores = glance.store.swift.Store
swift_store_auth_address = <u style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; overflow-wrap: break-word;">[http://192.168.179.140:5000/v2.0/](http://192.168.179.140:5000/v2.0/)</u>
swift_store_user = services:swift
swift_store_key = redhat
swift_store_create_container_on_put = True
image
image
新建glance的keystone
unset OS_TOKEN
unset OS_URL
unset OS_IDENTITY_API_VERSION
export OS_TENANT_NAME=services
export OS_USERNAME=glance
export OS_PASSWORD=redhat
export OS_IDENTITY_API_VERSION=2
export OS_AUTH_URL=http://192.168.179.140:5000/v2.0
export OS_IMAGE_API_VERSION=2
export PS1='[\u@\h \W(keystone_glancev2)]\$ '
image
重啟服務(wù)
image
上傳新鏡像測(cè)試:
image
上傳:
image
上傳之后,因?yàn)檫x擇的是swift作為后端存儲(chǔ),并且配置文件有寫(xiě)自動(dòng)創(chuàng)建container,所以會(huì)出現(xiàn)如下的顯示以及鏡像
image
NOTE:
swift是對(duì)象存儲(chǔ),創(chuàng)建一個(gè)容器,容器里創(chuàng)建一個(gè)個(gè)的對(duì)象,當(dāng)我們把swift作為存儲(chǔ)的時(shí)候,則當(dāng)我們上傳一個(gè)鏡像的時(shí)候,會(huì)為glance用戶創(chuàng)建一個(gè)glance容器,上傳的鏡像會(huì)保存在這個(gè)glance容器里。