布署glance
Glance是Openstack镜像服务组件,监听在9292端口,接收REST API请求,通过其它模块来完成镜像的获取,上传,删除等。
在创建虚拟机的时候,先把镜像上传到glace,
glance-api接收镜像的删除、上传和读取;
glance-registry(port:9191)与mysql交互,存储获取镜像的元数据。
glance数据库有两张表,一张image表,一张image property表:保存了镜像格式、大小等信息
image store是一个存储的接口层,通过这个接口glance可以获取镜像
1. 控制端安装glance
yum -y install openstack-glance
2. 在数据库数据库与用户
mysql -uroot -p123
MariaDB [(none)]> create database glance;
MariaDB [(none)]> grant all on glance.* to 'glance'@'%' identified by '123';
验证glance用户连接
mysql -hopenvip.com -uglance -p123
3. 编辑配置文件/etc/glance/glance-api.conf
sed -i -e '/^#/d' -e '/^$/d' /etc/glance/glance-api.conf
最终如下
[DEFAULT] [cinder] [cors] [database] connection = mysql+pymysql://glance:123@openvip.com/glance [file] [glance.store.http.store] [glance.store.rbd.store] [glance.store.sheepdog.store] [glance.store.swift.store] [glance.store.vmware_datastore.store] [glance_store] stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/images [image_format] [keystone_authtoken] www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = openvip.com:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = 123 [oslo_concurrency] [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_middleware] [oslo_policy] [paste_deploy] flavor = keystone [profiler] [store_type_location_strategy] [task] [taskflow_executor]
4. 编辑配置文件/etc/glance/glance-registry.conf
sed -i -e '/^#/d' -e '/^$/d' /etc/glance/glance-registry.conf
最终如下
[DEFAULT] [database] connection = mysql+pymysql://glance:123@openvip.com/glance [keystone_authtoken] www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = openvip.com:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = 123 [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_policy] [paste_deploy] flavor = keystone [profiler]
6. 初始化glance数据库
su -s /bin/sh -c "glance-manage db_sync" glance
验证数据库
7. 启动glance并设置为开机启动
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service
验证glance端口(9191,9292)
7. glance服务注册(设置环境变量)
source keystone_admin.sh
8. 创建用户glance
openstack user create --domain default --password-prompt glance
9. 给service添加glance用户并授权admin角色
openstack role add --project service --user glance admin
创建glance服务
openstack service create --name glance \ --description "OpenStack Image" image
创建公有endpoint
openstack endpoint create --region RegionOne image public http://controller:9292
创建私有endpoint
openstack endpoint create --region RegionOne image internal http://controller:9292
创建管理endpoint
openstack endpoint create --region RegionOne image admin http://controller:9292
验证以上步骤
openstack endpoint list
验证glance服务
glance image-list #与 openstack image list
测试glance上传镜像
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
创建
openstack image create "cirros" \ --file /root/cirros-0.3.4-x86_64-disk.img \ --disk-format qcow2 \ --container-format bare \ --public
验证glance镜像
glance image-list #和 openstack image list
查看指定镜像信息
openstack image show cirros
原文链接:https://blog.csdn.net/weixin_42758707/article/details/100054917