openstack(Pike 版)集群部署(三)--- Glance 部署
一、介绍
参照官网部署:https://docs.openstack.org/glance/queens/install/
继续上一博客进行部署:http://www.cnblogs.com/weijie0717/p/8556939.html
二、部署 Glance
1、配置数据库 (任意controller 节点操作)
# mysql -uroot -p
mysql> CREATE DATABASE glance;
mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';
2、配置glance 用户和 API 信息 (任意controller 节点操作)
a、获取管理员认证权限
# source admin-openrc
b、创建用户
# openstack user create --domain default --password-prompt glance (新用户需要配置密码)
c、分配 Glance到 指定project 和 role
# openstack role add --project service --user glance admin
d、创建 openstack Glance 服务
# openstack service create --name glance --description "OpenStack Image" image
e、创建 GLance API (admin,public,internal)
# openstack endpoint create --region RegionOne image public http://controller:9292 #(controller为 Glance-haproxy-vip)
# openstack endpoint create --region RegionOne image internal http://controller:9292 #(controller为 Glance-haproxy-vip)
# openstack endpoint create --region RegionOne image admin http://controller:9292 #(controller为 Glance-haproxy-vip)
3、 Glance 包安装 (所有controller-node)
# yum install -y openstack-glance
4、编辑配置文件 (所有controller-node)
a、编辑 /etc/glance/glance-api.conf 文件 # 标红区域为需要特别关注的地方
# vim /etc/glance/glance-api.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <code-pre class = "code-pre" id= "pre-3Fc6CW" ><code-line class = "line-numbers-rows" ></code-line>[DEFAULT] # 集群中此配置文件唯一不一样的区域,为避免后期 HAproxy 端口冲突 <code-line class = "line-numbers-rows" ></code-line>bind_host = 网卡IP <code-line class = "line-numbers-rows" ></code-line>bind_port = 9292 <code-line class = "line-numbers-rows" ></code-line> <code-line class = "line-numbers-rows" ></code-line>[database] <code-line class = "line-numbers-rows" ></code-line># ... <code-line class = "line-numbers-rows" ></code-line>connection = mysql+pymysql: //glance:GLANCE_PASS@controller/glance <code-line class = "line-numbers-rows" ></code-line> <code-line class = "line-numbers-rows" ></code-line> [keystone_authtoken] <code-line class = "line-numbers-rows" ></code-line># ... <code-line class = "line-numbers-rows" ></code-line>auth_uri = http: //controller:5000 <code-line class = "line-numbers-rows" ></code-line>auth_url = http: //controller:35357 <code-line class = "line-numbers-rows" ></code-line>memcached_servers = controller1:11211,controller2:11211,controller3:11211 <code-line class = "line-numbers-rows" ></code-line>auth_type = password <code-line class = "line-numbers-rows" ></code-line>project_domain_name = default <code-line class = "line-numbers-rows" ></code-line>user_domain_name = default <code-line class = "line-numbers-rows" ></code-line>project_name = service <code-line class = "line-numbers-rows" ></code-line>username = glance <code-line class = "line-numbers-rows" ></code-line>password = GLANCE_PASS <code-line class = "line-numbers-rows" ></code-line> <code-line class = "line-numbers-rows" ></code-line> [paste_deploy] <code-line class = "line-numbers-rows" ></code-line># ... <code-line class = "line-numbers-rows" ></code-line>flavor = keystone <code-line class = "line-numbers-rows" ></code-line> <code-line class = "line-numbers-rows" ></code-line>[glance_store] # 以下为Glance 本地存储配置 <code-line class = "line-numbers-rows" ></code-line># ... <code-line class = "line-numbers-rows" ></code-line>stores = file,http <code-line class = "line-numbers-rows" ></code-line>default_store = file <code-line class = "line-numbers-rows" ></code-line>filesystem_store_datadir = / var /lib/glance/images/</code-pre> |
如下图:
b、编辑 /etc/glance/glance-registry.conf 文件 # 标红区域为需要特别关注的地方
# vim /etc/glance/glance-registry.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <code-pre class = "code-pre" id= "pre-TrZ7bc" ><code-line class = "line-numbers-rows" ></code-line>[DEFAULT] # 整个集群文件中唯一不同的区域 <code-line class = "line-numbers-rows" ></code-line># ... <code-line class = "line-numbers-rows" ></code-line>bind_host = 网卡ip <code-line class = "line-numbers-rows" ></code-line>bind_port = 9191 <code-line class = "line-numbers-rows" ></code-line> <code-line class = "line-numbers-rows" ></code-line> [database] <code-line class = "line-numbers-rows" ></code-line> connection = mysql+pymysql: //glance:GLANCE_PASS@controller/glance <code-line class = "line-numbers-rows" ></code-line> <code-line class = "line-numbers-rows" ></code-line> [keystone_authtoken] <code-line class = "line-numbers-rows" ></code-line># ... <code-line class = "line-numbers-rows" ></code-line>auth_uri = http: //controller:5000 <code-line class = "line-numbers-rows" ></code-line>auth_url = http: //controller:35357 <code-line class = "line-numbers-rows" ></code-line>memcached_servers = controller1:11211,controller2:11211,controller3:11211 <code-line class = "line-numbers-rows" ></code-line>auth_type = password <code-line class = "line-numbers-rows" ></code-line>project_domain_name = default <code-line class = "line-numbers-rows" ></code-line>user_domain_name = default <code-line class = "line-numbers-rows" ></code-line>project_name = service <code-line class = "line-numbers-rows" ></code-line>username = glance <code-line class = "line-numbers-rows" ></code-line>password = GLANCE_PASS <code-line class = "line-numbers-rows" ></code-line> <code-line class = "line-numbers-rows" ></code-line>[paste_deploy] <code-line class = "line-numbers-rows" ></code-line># ... <code-line class = "line-numbers-rows" ></code-line>flavor = keystone </code-pre> |
5、初始化 Glance 数据库 (任意controller 节点操作)
# su -s /bin/sh -c "glance-manage db_sync" glance
# (忽略此处输出所有信息)
6、启动服务并设置开机自启动 (all-controller-node)
# systemctl enable openstack-glance-api.service openstack-glance-registry.service
# systemctl start openstack-glance-api.service openstack-glance-registry.service
# 查看端口,如下:服务启动正常
7、配置 Glance-Haproxy
博客:http://www.cnblogs.com/weijie0717/p/8530102.html
注:必须保证 单controller -node 认证 Glance 和 Keystone 时访问的是同一个节点,否则为认证失败。
三、测试 (任意 controller-node)
1、下载镜像
# cd /root
# wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
2、上传镜像到Image server
# openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public
3、查看
1、查看镜像上传情况
# openstack image list
上传成功
2、查看openstack集群 当前支持服务
# openstack service list
到此处,openstack集群 Glance-server 使用本地存储 部署成功。
续: openstack集群 Glance-server 使用Ceph 存储。
1、删除之前上传的本地镜像。(任意 controller-node)
a、查看镜像ID
# openstack image list
b、删除镜像
# openstack image delete image-ID
2、拷贝ceph集群配置文件到所有controller 节点 /etc/ceph/ceph.conf (ceph 集群 任意节点)
# scp /etc/ceph/ceph.conf root@controller1:/etc/ceph/ceph.conf
# scp /etc/ceph/ceph.conf root@controller2:/etc/ceph/ceph.conf
# scp /etc/ceph/ceph.conf root@controller3:/etc/ceph/ceph.conf
3、创建 Glance 所需要的ceph 存储池:images (任意ceph-mon 节点 )
# ceph osd pool create images 64 64
4、生成和导出证书到 controller节点 (任意ceph-mon 节点 )
a、生成key
# ceph auth get-or-create client.glance mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=images'
b、查看
# ceph auth list
c、导出 key,并拷贝至所有controller 节点 /etc/ceph/文件中
# ceph auth get-or-create client.glance | tee /etc/ceph/ceph.client.glance.keyring
# scp /etc/ceph/ceph.client.glance.keyring root@controller-all:/etc/ceph/ceph.client.glance.keyring
d、修改ceph.conf 和 key 文件 权限 (所有controller节点操作)
# chown glance:glance /etc/ceph/ceph.client.glance.keyring
# chown glance:glance /etc/ceph/ceph.conf
5、安装 rbd 驱动包 (all-controller-node)
# yum install python-rbd -y
6、修改 glance-api 配置文件 (all-controller-node)
a、备份配置,便于恢复
# cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak
b、修改配置文件
# vim /etc/glance/glance-api.conf
1 2 3 4 5 6 7 8 9 10 11 12 | <code-pre class = "code-pre" id= "pre-iWXMfY" ><code-line class = "line-numbers-rows" ></code-line>[DEFAULT] <code-line class = "line-numbers-rows" ></code-line>show_image_direct_url = True #启动镜像的写时复制功能 <code-line class = "line-numbers-rows" ></code-line> <code-line class = "line-numbers-rows" ></code-line>[glance_store] <code-line class = "line-numbers-rows" ></code-line>stores = rbd <code-line class = "line-numbers-rows" ></code-line>default_store = rbd <code-line class = "line-numbers-rows" ></code-line>#filesystem_store_datadir = / var /lib/glance/images/ #注释此行,本地存储配置行 <code-line class = "line-numbers-rows" ></code-line>rbd_store_chunk_size = 8 <code-line class = "line-numbers-rows" ></code-line>rbd_store_pool = images <code-line class = "line-numbers-rows" ></code-line>rbd_store_user = glance <code-line class = "line-numbers-rows" ></code-line>rbd_store_ceph_conf = /etc/ceph/ceph.conf </code-pre> |
7、重启服务 (all-controller-node)
# systemctl restart openstack-glance-api.service openstack-glance-registry.service
8、上传镜像进行测试。(任意 controller-node)
a、获取认证权限
# source admin-openrc
b、下载镜像
# wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
c、上传镜像
# openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public
d、查看镜像上传情况
#openstack image list
9、ceph 查看镜像上传情况和处理告警
a、镜像已上传至ceph,ceph会有告警
b、告警信息查看
c、按照提示处理告警
# ceph osd pool application enable images rbd
Openstack Glance server 到此处部署完毕。
__EOF__

本文链接:https://www.cnblogs.com/weijie0717/p/8563294.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· Qt个人项目总结 —— MySQL数据库查询与断言