千家信息网

Openstack(三):glance镜像服务和placement服务

发表于:2025-01-27 作者:千家信息网编辑
千家信息网最后更新 2025年01月27日,glance镜像服务官方文档:https://docs.openstack.org/glance/stein/install/install-rdo.html#install-and-configur
千家信息网最后更新 2025年01月27日Openstack(三):glance镜像服务和placement服务

glance镜像服务

官方文档:https://docs.openstack.org/glance/stein/install/install-rdo.html#install-and-configure-components

一、数据库

1、 创建数据库

mysql -uroot -p123456MariaDB [(none)]> CREATE DATABASE glance;

2、 创建用户

GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance123';

测试能否连接# mysql -uglance -pglance123 -hopenstack-mysql.heng.net

二、创建相应的服务并注册api

1、导入admin账号的变量,创建glance用户,并加入admin角色组

source scripts/admin-stein.shopenstack user create --domain default --password-prompt glance密码glanceopenstack role add --project service --user glance admin

2、创建image服务

[root@controller1 ~]#openstack service create --name glance --description "OpenStack Image" image

+-------------+----------------------------------+

| Field | Value |

+-------------+----------------------------------+

| description | OpenStack Image |

| enabled | True |

| id | 1616cdd9d4f54f87812dc183321cdcf1 |

| name | glance |

| type | image |

+-------------+----------------------------------+

3、注册后端api

openstack endpoint create --region RegionOne image public http://openstack-vip.heng.net:9292

openstack endpoint create --region RegionOne image internal http://openstack-vip.heng.net:9292

openstack endpoint create --region RegionOne image admin http://openstack-vip.heng.net:9292

三、安装对应服务的软件包并修改配置文件

1、安装openstack-glance客户端(先安装后注册服务也可以)

yum install openstack-glance

2、为了实现以后实现控制端的高可用,将镜像放在nfs上,配置nfs

在数据库和控制端上安装nfs

yum install nfs-utils -y

vi /etc/exports

/data/openstack/images *(rw,no_root_squash)

mkdir -p /data/openstack/images

systemctl start nfs

systemctl enable nfs

控制端测试

showmount -e 192.168.12.19

3、修改配置文件glance-api.conf

vi /etc/glance/glance-api.conf

[database]connection = mysql+pymysql://glance:glance123@openstack-mysql.heng.net/glance [keystone_authtoken]www_authenticate_uri = http://openstack-vip.heng.net:5000auth_url = http://openstack-vip.heng.net:5000memcached_servers = openstack-mysql.heng.net:11211   memcached在mysql上auth_type = passwordproject_domain_name = Defaultuser_domain_name = Defaultproject_name = serviceusername = glancepassword = glance   glance账户的密码 [paste_deploy]flavor = keystone   认证方式取消注释即可,所有服务认证方式都是keystone [glance_store]stores = file,httpdefault_store = filefilesystem_store_datadir = /var/lib/glance/images/

4、修改配置文件/etc/glance/glance-registry.conf

vi /etc/glance/glance-registry.conf

[database]connection = mysql+pymysql://glance:glance123@openstack-mysql.heng.net/glance [keystone_authtoken] www_authenticate_uri = http://openstack-vip.heng.net:5000auth_url = http://openstack-vip.heng.net:5000memcached_servers = openstack-mysql.heng.net:11211auth_type = passwordproject_domain_name = Defaultuser_domain_name = Defaultproject_name = serviceusername = glancepassword = glance [paste_deploy] flavor = keystone

5、初始化数据库

su -s /bin/sh -c "glance-manage db_sync" glance

6、启动服务,并设置开机启动

systemctl enable openstack-glance-api.service openstack-glance-registry.servicesystemctl start openstack-glance-api.service openstack-glance-registry.service

7、挂载nfs

启动服务之后自动生成/var/lib/glance/images

ll /var/lib/glance/images -d

停止第6步的服务再挂载

vi /etc/fstab 设置自动挂载, _netdev表示无法挂载跳过,不影响开机

192.168.12.19:/data/openstack/images /var/lib/glance/images/ nfs defaults,_netdev 0 0

mount -a

注意/var/lib/glance/images的权限必须是glance

8、验证glance能否上传

wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img[root@controller1 ~]# openstack image create "cirros-0.4.0" \  --file /root/cirros-0.4.0-x86_64-disk.img \  --disk-format qcow2 --container-format bare \  --public
openstack image list

cat /var/log/glance/*.log 日志 用于排错

placement服务

官方文档:https://docs.openstack.org/placement/stein/install/install-rdo.html

一、数据库

1、创建数据库授权

mysql -uroot -p123456MariaDB [(none)]> CREATE DATABASE placement;GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'placement123';

2、在控制端连接测试

mysql -uplacement -pplacement123 -h292.168.12.19

二、创建相应的服务并注册api

1、创建placement用户

source scripts/admin-stein.shopenstack user create --domain default --password-prompt placement

2、将placement用户加入admin角色组

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

3、创建placement服务

openstack service create --name placement --description "Placement API" placement

4、注册api到服务

openstack endpoint create --region RegionOne placement public http://openstack-vip.heng.net:8778

openstack endpoint create --region RegionOne placement internal http://openstack-vip.heng.net:8778

openstack endpoint create --region RegionOne placement admin http://openstack-vip.heng.net:8778


openstack endpoint list 现在就有3组endpoint

三、安装对应服务的软件包并修改配置文件

1、 安装包

yum install openstack-placement-api

2、 修改配置文件

vi /etc/placement/placement.conf

[placement_database]connection=mysql+pymysql://placement:placement123@openstack-mysql.heng.net/placement [api]auth_strategy = keystone  去掉注释 [keystone_authtoken] auth_url = http://openstack-vip.heng.net:5000/v3memcached_servers = openstack-mysql.heng.net:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = placementpassword = placement

3、初始化数据库

su -s /bin/sh -c "placement-manage db sync" placement

重启httpd

source scripts/admin-stein.shplacement-status upgrade check


0