glance服务介绍及配置swift作为后端存储

2019-07-18  本文已影响0人  zwb_jianshu

镜像中的几种状态:

active 镜像已经在正确的上传并可以使用了
saving 镜像正在被上传
queued 这个镜像的ID已经被记录了,但是镜像并没有真的上传
killed 上传失败,完全不可用
glance主要的两个服务:
glance-api     接收用户的各种请求
glance-registry  和后台数据库进行交互
软件安装:
yum list *glance*
yum install -y *glance*
image

创建服务同名用户并添加admin权限:

image

创建服务:

image

创建endpoint:
http://192.168.179.140:9292
http://192.168.179.140:9292
http://192.168.179.140:9292

image

配置文件:

image

从模板复制过来,如下:

image image
修改配置文件,[DEFAULT]下面需要添加rabbitmq的数据,从keystone复制出来
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

创建数据库:

> 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 -c 'glance-manage db_sync' glance

image

启动服务但是出错,查看权限:

image

成功启动glance服务:

# systemctl start openstack-glance-api.service openstack-glance-registry.service
# systemctl enable openstack-glance-api.service openstack-glance-registry.service
image

创建镜像:(正常非swift存储的情况)
openstack image create small --file small.img --disk-format qcow2 --container-format bare --public

image

镜像存放位置:/var/lib/glance/images

image
配置swift后端存储:
配置文件
配置如下:不是default下面的存储
下面是配置以swift作为后端存储:
[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

重启服务

image

上传新镜像测试:

image

上传:

image

上传之后,因为选择的是swift作为后端存储,并且配置文件有写自动创建container,所以会出现如下的显示以及镜像

image
NOTE:
swift是对象存储,创建一个容器,容器里创建一个个的对象,当我们把swift作为存储的时候,则当我们上传一个镜像的时候,会为glance用户创建一个glance容器,上传的镜像会保存在这个glance容器里。
上一篇 下一篇

猜你喜欢

热点阅读