镜像glance部署

一、环境配置

控制节点ct

CPU 双核双线程-CPU虚拟化开启
内存 8G
硬盘 300G+1024G(CEPH块存储)
双网卡 VM1-(局域网)192.168. 86.11/NAT-192.168.109.12
操作系统 Centos 7.6(1810)-最小化安装

控制节点c1

CPU 双核双线程-CPU虚拟化开启
内存 8G
硬盘 300G+1024G(CEPH块存储)
双网卡 VM1-(局域网)192.168.86.22 /NAT-192.168.109.22
操作系统 Centos 7.6(1810)-最小化安装

控制节点c2

CPU 双核双线程-CPU虚拟化开启
内存 8G
硬盘 300G+1024G(CEPH块存储)
双网卡 VM1-(局域网)192.168.86.33 /NAT-192.168.109.32
操作系统 Centos 7.6(1810)-最小化安装

二、部署思路

  • 1、创建数据库、授权
  • 2、创建openstack用户、授权、管理
  • 3、修改配置文件(glance-api.conf、glance-registry.conf)
  • 4、初始化数据库、上传实例镜像

三、实际部署操作

ct

创建数据库实例和数据库用户

mysql -u root -p
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';
flush privileges;
exit

在这里插入图片描述

创建用户、修改配置文件

#创建OpenStack的Glance用户
openstack user create --domain default --password GLANCE_PASS glance

openstack role add --project service --user glance admin

openstack service create --name glance --description "OpenStack Image" image


#创建镜像服务 API 端点,OpenStack使用三种API端点代表三种服务:admin、internal、public
openstack endpoint create --region RegionOne image public http://ct:9292

openstack endpoint create --region RegionOne image internal http://ct:9292

openstack endpoint create --region RegionOne image admin http://ct:9292

在这里插入图片描述

修改glance配置文件,glance有两个配置文件

#安装 openstack-glance 软件包
yum -y install openstack-glance 


#修改glance配置文件,glance有两个配置文件:/etc/glance/glance-api.conf  /etc/glance/glance-registry.conf
===添加glance-api.conf配置===
cp -a /etc/glance/glance-api.conf{
    
    ,.bak}
grep -Ev '^$|#' /etc/glance/glance-api.conf.bak > /etc/glance/glance-api.conf

在这里插入图片描述

#传参
openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers ct:11211
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password GLANCE_PASS
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/

cd /etc/glance
cat glance-api.conf

在这里插入图片描述

#修改glance-registry.conf 配置文件
===添加glance-registry.conf配置===
cp -a /etc/glance/glance-registry.conf{
    
    ,.bak}
grep -Ev '^$|#' /etc/glance/glance-registry.conf.bak > /etc/glance/glance-registry.conf

在这里插入图片描述

openstack-config --set /etc/glance/glance-registry.conf database connection  mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken www_authenticate_uri   http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url  http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers  ct:11211
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type  password
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name  Default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name  Default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name  service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username  glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password  GLANCE_PASS
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor  keystone

cat /etc/glance/glance-registry.conf

在这里插入图片描述

初始化glance数据库,生成相关表结构

#初始化glance数据库,生成相关表结构;(不管有多少个controler,只需要初始化一次即可)
su -s /bin/sh -c "glance-manage db_sync" glance

在这里插入图片描述

开启glance服务

#开启glance服务
systemctl enable openstack-glance-api.service
systemctl start openstack-glance-api.service

在这里插入图片描述

#查看端口
netstat -natp | grep 9292

yum -y install lsof   #losf查看更详细
lsof -i:9292

在这里插入图片描述

chown -hR glance:glance /var/lib/glance/
#赋予openstack-glance-api.service服务对存储设备的可写权限(-h:值对符号连接/软链接的文件修改)

在这里插入图片描述

导入镜像

测试镜像cirros
先上传cirros-0.3.5-x86_64-disk.img镜像到控制节点的/root,然后导入glance,最后查看是否创建成功

openstack image create --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public cirros

在这里插入图片描述

查看镜像

#查看镜像的两种方式
openstack image list
或
glance image-list

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_51616026/article/details/114988194