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

镜像中的几种状态:

active 镜像已经在正确的上传并可以使用了

saving 镜像正在被上传

queued 这个镜像的ID已经被记录了,但是镜像并没有真的上传

killed 上传失败,完全不可用

 

glance主要的两个服务:

glance-api     接收用户的各种请求

glance-registry  和后台数据库进行交互

 

软件安装:

yum list *glance*

yum install -y *glance*

 

 

 

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

 

创建服务:

 

创建endpoint:

openstack endpoint create --region RegionOne --publicurl 'http://192.168.179.140:9292' --internalurl 'http://192.168.179.140:9292' --adminurl 'http://192.168.179.140:9292'  e9812a8fd5c14bf1b3f1291cfc58e3d2

 

配置文件:

 

从模板复制过来,如下:

 

 

 

 

修改配置文件,[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 = /

 

vim  glance_api.conf

添加auth_uri

vim glance_registry.conf

 

创建数据库:

> 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';

 

 

更新下数据库:

 sh -c 'glance-manage db_sync' glance

 

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

 

成功启动glance服务:

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

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

 

创建镜像:(正常非swift存储的情况)

openstack image create small --file small.img --disk-format qcow2 --container-format bare --public

 

 

 

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

 

配置swift后端存储:

配置文件

配置如下:不是default下面的存储

 

下面是配置以swift作为后端存储:

[glance_store]

default_store=swift

stores = glance.store.swift.Store

swift_store_auth_address = http://192.168.179.140:5000/v2.0/

swift_store_user = services:swift

swift_store_key = redhat

swift_store_create_container_on_put = True

 

新建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)]\$ '

 

重启服务

 

上传新镜像测试:

上传:

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

 

NOTE:

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

猜你喜欢

转载自blog.csdn.net/u011446736/article/details/81083202