部署OpenStack组件——Glance镜像服务

news/2024/7/18 14:24:35 标签: openstack

这里写目录标题

  • 前言
    • 一、创建数据库实例和数据库用户
    • 二、创建用户、服务
        • 2.1、创建OpenStack的Glance用户
        • 2.2、创建镜像服务API端点
        • 2.3 、安装 openstack-glance 软件包
    • 三、Glance的配置文件
        • 3.1、修改glance配置文件
        • 3.2、添加glance-api.conf配置
        • 3.3、修改glance-registry.conf配置文件
        • 3.4、 开启服务
    • 四、验证
    • 五、总结

前言

glance服务是OpenStack中负责给实例提供image镜像的服务,就是服务镜像的上传和下载操作,他可以上传各种操作系统的镜像,windows的可以,Ubuntu可以,centos可以,只要你用到的都可以传上去。而且他的镜像格式支持qcow2的,就是说你完全可以将你的KVM虚机做成镜像传上去作为镜像来启动实例。

接下来在控制节点安装glance服务,为OpenStack启动的实例提供镜像服务。

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

[root@ct ~]# mysql -u root -p
MariaDB [(none)]> CREATE DATABASE glance;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit

二、创建用户、服务

2.1、创建OpenStack的Glance用户

注意:创建用户前,需要首先执行管理员环境变量脚本(此处已经在~/.bashrc 中定义过了)

###创建glance用户
[root@ct ~]# openstack user create --domain default --password GLANCE_PASS glance

###将glance用户添加到service项目中,并且针对这个项目拥有admin权限;注册glance的API,需要对service项目有admin权限		
[root@ct ~]# openstack role add --project service --user glance admin

###创建一个service服务,service名称为glance,类型为image;
[root@ct ~]# openstack service create --name glance --description "OpenStack Image" image	
[root@ct glance]# openstack service list  ##查看,还有之前创建keystone的服务
+----------------------------------+----------+----------+
| ID                               | Name     | Type     |
+----------------------------------+----------+----------+
| 7785a4f134ad4970846b321ffe123be8 | keystone | identity |
| ed2edc3befd243499214f9afeeebe61d | glance   | image    |
+----------------------------------+----------+----------+
				

2.2、创建镜像服务API端点

OpenStack使用三种API端点代表三种服务:admin、internal、public

[root@ct ~]# openstack endpoint create --region RegionOne image public http://ct:9292
[root@ct ~]# openstack endpoint create --region RegionOne image internal http://ct:9292
[root@ct ~]# openstack endpoint create --region RegionOne image admin http://ct:9292

openstackglance__46">2.3 、安装 openstack-glance 软件包

[root@ct ~]# yum -y install openstack-glance 

三、Glance的配置文件

3.1、修改glance配置文件

glance有两个配置文件:
/etc/glance/glance-api.conf
/etc/glance/glance-registry.conf

[root@ct ~]# cp -a /etc/glance/glance-api.conf{,.bak}  ##复制
[root@ct ~]# grep -Ev '^$|#' /etc/glance/glance-api.conf.bak >  /etc/glance/glance-api.conf ##过滤

3.2、添加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/



[root@ct glance]# cat glance-api.conf
[DEFAULT]
[cinder]
[cors]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ct/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					#存储类型,file:文件,http:基于api调用的方式,把镜像放到其他存储上
default_store = file					#默认存储方式
filesystem_store_datadir = /var/lib/glance/images/	##指定镜像存放的本地目录
[image_format]
[keystone_authtoken]
www_authenticate_uri = http://ct:5000			##指定认证的keystone的URL
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service				#glance用户针对service项目拥有admin权限
username = glance
password = GLANCE_PASS
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
flavor = keystone					#指定提供认证的服务器为keystone
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]

3.3、修改glance-registry.conf配置文件

#备份、过滤注释信息

[root@ct ~]# cp -a /etc/glance/glance-registry.conf{,.bak}
[root@ct ~]# grep -Ev '^$|#' /etc/glance/glance-registry.conf.bak > /etc/glance/glance-registry.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/

#修改参数(配置与glance-api.conf相同)
[root@ct glance]# cat glance-registry.conf
[DEFAULT]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
[keystone_authtoken]
www_authenticate_uri = http://ct:5000
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]

初始化glance数据库,生成相关表结构;
不管有多少个controler,只需要初始化一次即可

[root@ct ~]# su -s /bin/sh -c "glance-manage db_sync" glance

3.4、 开启服务

此处开启之后会生成存放镜像的目录/var/lib/glance/image

[root@ct ~]# systemctl enable openstack-glance-api.service
[root@ct ~]# systemctl start openstack-glance-api.service

3种方法查看端口:

  • (1) netstat:
[root@ct glance]# netstat -natp | grep 9292
tcp        0      0 0.0.0.0:9292            0.0.0.0:*               LISTEN      62334/python2
  • (2) ss:
[root@ct ~]# ss -anpt | grep 9292
LISTEN     0      128          *:9292                     *:*                   users:(("glance-api",pid=39429,fd=4),("glance-api",pid=39428,fd=4),("glance-api",pid=39427,fd=4),("glance-api",pid=39426,fd=4),("glance-api",pid=39414,fd=4))
ESTAB      0      0      20.0.0.20:22                 20.0.0.1:60762               users:(("sshd",pid=19292,fd=3))

  • (3) lsof -i
[root@ct ~]# yum -y install lsof
[root@ct ~]# lsof -i:9292
COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
glance-ap 39414 glance    4u  IPv4 114722      0t0  TCP *:armtechdaemon (LISTEN)
glance-ap 39426 glance    4u  IPv4 114722      0t0  TCP *:armtechdaemon (LISTEN)
glance-ap 39427 glance    4u  IPv4 114722      0t0  TCP *:armtechdaemon (LISTEN)
glance-ap 39428 glance    4u  IPv4 114722      0t0  TCP *:armtechdaemon (LISTEN)
glance-ap 39429 glance    4u  IPv4 114722      0t0  TCP *:armtechdaemon (LISTEN)

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

[root@ct ~]# chown -hR glance:glance /var/lib/glance/

四、验证

先上传cirros镜像到控制节点的/root,然后导入glance,最后查看是否创建成功

[root@ct ~]# openstack image create --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public cirros

查看镜像(两种方式):
方法一:

[root@ct ~]# openstack image list
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| abb47cb6-0447-48cb-b1b2-8facea74fc3b | cirros | active |
+--------------------------------------+--------+--------+

方法二:

[root@ct ~]# glance image-list
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| abb47cb6-0447-48cb-b1b2-8facea74fc3b | cirros |
+--------------------------------------+--------+

五、总结

openstack 上创建虚拟机需要镜像的支持,所以在 keystone(之前的博客已经讲解了keystone怎么部署的) 后先行部署 glance:
1、创建数据库,授权
2、创建openstack 用户,授权,管理
3、修改配置文件(galnce-api和glance-registry)
4、初始化数据库,上传进行


http://www.niftyadmin.cn/n/1075840.html

相关文章

OpenStack组件详解——Nova

这里写目录标题前言一、Nova概述1.1 nova定义1.2、系统架构图介绍二、nova内部组件的介绍2.1、nova-api2.2、Scheduler2.2.1 调度器的类型2.2.2 过滤器类型2.3、Nova-compute2.4、Rabbitmq2.5、Nova-conductor三、Nova的工作流程前言 nova和swift是openstack最早的两个组件&am…

ERROR——redis哨兵模式主机挂掉,不能自动选举新的master

这里写目录标题实验环境报错现象解决方法实验环境 20.0.0.10 (master)20.0.0.11 (slave)20.0.0.12 (slave)报错现象 当我把master shutdown后sentinel 不能自动选举出新的master并,出现 failover-abort-no-good-slave 错误解决方法 修改redis.conf 三台全部…

5G的发展与所面对的挑战

文章目录1.移动通信发展历程2.5G技术指标和三大应用场景3.VR/AR4.智慧城市5.超密集组网6.动态自组织网络(SON)7.软件定义网络(SDN)8.网络功能虚拟化(NFV)SDN和NFV区别9.面临的挑战1.频谱资源2.新业务3.新场…

eNSP的链路聚合实现的条件

华为支持vlan数量是1-4094 Vlan:虚拟局域网,主要作用是隔离广播域、安全、便于管理。 端口划分vlan的话,需要设定端口类型,一般华为常用的端口是access、trunk、hybrid。 Trunk:单条链路可以承载多vlan的数据流量。 Hy…

ERROR——Last_IO_Errno: 1593(server-id冲突)

这里写目录标题报错现象解决方法报错现象 Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used …

Git版本号控制

Git是分布式版本号控制系统。与SVN类似的集中化版本号控制系统相比。集中化版本号控制系统尽管可以令多个团队成员一起协作开发,但有时假设中央server宕机的话,谁也无法在宕机期间提交更新和协同开发。甚至有时,中央server磁盘故障&#xff0…

综合实验 vrrp,mstp,nat,ospf,rip,单臂路由

R5配置文件 sysname R5 snmp-agent local-engineid 800007DB03000000000000 snmp-agent clock timezone China-Standard-Time minus 08:00:00 portal local-server load flash:/portalpage.zip drop illegal-mac alarm wlan ac-global carrier id other ac id 0 set cpu-usage …

详细讲解【openstack 】T版中nova组件的cell

这里写目录标题一、cell的概述1.1、 cell的定义(出现的原因)1.2、 cell的功能二、cell简介2.1 cell的两种模式架构图2.2 多cell架构图2.3 工作原理一、cell的概述 1.1、 cell的定义(出现的原因) 当openstack nova 集群的规模变大…