1 您需要了解
- 本篇为手工搭建第
3
篇,进行OpenStack Glance
组件安装 - 操作系统版本
CentOS Stream 8
,最小化安装,可参考下方相关文章G003
完成系统安装,步骤一致 - 安装源您可访问 CentOS官网 / 阿里永久镜像站 / 华为永久镜像站 或其他镜像站进行下载
- 环境用到
2台
虚拟机,单网卡,并为其配置静态 IP
及DNS
,具体规划请参考第 2 章
环境规划 - 从
Ussuri
版本开始,需要使用CentOS 8
或RHEL 8
,截至发稿前
,Stream 8 版本支持的最高版本为yoga
- 文中用到的本地源文件,如有需要请站内私信获取,手工搭建流程参考官方安装指南
- 密码约定:本文所有和数据库及消息队列相关的密码统一设定
rootroot
,openstack 组件用户密码统一设定redhat
- 为有更好的浏览体验,您可以点击文章左上方
目录
按钮来显示文章整体目录结构
- 相关文章
- G003-OS-LIN-RHEL-01 红帽 8.4 安装
- G033-OP-COA-OPEN-04 CentOS Stream 8 通过 Packstack 安装开源 OpenStack(V版)
- G041-OP-COA-OPEN-05 CentOS Stream 8 手工搭建 OpenStack V 版(01基础环境设置)
- G042-OP-COA-OPEN-06 CentOS Stream 8 手工搭建 OpenStack V 版(02 Keystone)
2 环境规划
计算节点必须开启虚拟化引擎
Intel VT-x
或AMD-V
。虚拟机配置可根据实际情况进行调整。
主机名 | IP | 网关/DNS | CPU/内存 | 磁盘 | 角色 | 备注 |
---|---|---|---|---|---|---|
controller | 192.168.100.167 | 192.168.100.2 | 4c16g | 100g | 控制/网络 | / |
compute | 192.168.100.168 | 192.168.100.2 | 4c16g | 100g | 计算节点 | 必须开启虚拟化引擎 |
3 建库及授权(仅控制节点)
官方链接:https://docs.openstack.org/glance/victoria/install/install-rdo.html
[root@controller ~]# mysql -u root -prootroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 27
Server version: 10.3.28-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE glance;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'rootroot';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'rootroot';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| glance |
| information_schema |
| keystone |
| mysql |
| performance_schema |
+--------------------+
5 rows in set (0.000 sec)
MariaDB [(none)]> exit
Bye
4 创建用户及关联角色(仅控制节点)
官方链接:https://docs.openstack.org/glance/victoria/install/install-rdo.html
[root@controller ~]# source keystonerc_admin
[root@controller ~(admin)]$ openstack user create --domain default --password-prompt glance
User Password: *** 输入密码 redhat ***
Repeat User Password: *** 输入密码 redhat ***
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | c6f9e5514aa1462f971294ce32c6e388 |
| name | glance |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[root@controller ~(admin)]$ openstack user list
+----------------------------------+--------+
| ID | Name |
+----------------------------------+--------+
| c0399b924c29406f9ae6497b07e18336 | admin |
| da641a3d01cd4a24b90f031168a528cf | myuser |
| c6f9e5514aa1462f971294ce32c6e388 | glance |
+----------------------------------+--------+
[root@controller ~(admin)]$ openstack role add --project service --user glance admin
5 创建服务及注册API(仅控制节点)
官方链接:https://docs.openstack.org/glance/victoria/install/install-rdo.html
[root@controller ~(admin)]$ openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | ceb944c6240b4cfaa19ae1376201b5e7 |
| name | glance |
| type | image |
+-------------+----------------------------------+
[root@controller ~(admin)]$ openstack endpoint create --region RegionOne image public http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 5aaca7d55ecb4957932987160285541b |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ceb944c6240b4cfaa19ae1376201b5e7 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
[root@controller ~(admin)]$ openstack endpoint create --region RegionOne image internal http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 963c5bc1374c421c8673a661de4da7cb |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ceb944c6240b4cfaa19ae1376201b5e7 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
[root@controller ~(admin)]$ openstack endpoint create --region RegionOne image admin http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 0ca7638e7fc24995a7a5a1d5f1f217ad |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ceb944c6240b4cfaa19ae1376201b5e7 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
[root@controller ~(admin)]$ openstack endpoint list
+----------------------------------+-----------+--------------+--------------+---------+-----------+----------------------------+
| ID | Region | Service Name | Service Type | Enabled | Interface | URL |
+----------------------------------+-----------+--------------+--------------+---------+-----------+----------------------------+
| 0ca7638e7fc24995a7a5a1d5f1f217ad | RegionOne | glance | image | True | admin | http://controller:9292 |
| 57e6491d6322436daf20abc223ee3c20 | RegionOne | keystone | identity | True | public | http://controller:5000/v3/ |
| 5aaca7d55ecb4957932987160285541b | RegionOne | glance | image | True | public | http://controller:9292 |
| 6c1482a035694999a56092717599d0fb | RegionOne | keystone | identity | True | internal | http://controller:5000/v3/ |
| 963c5bc1374c421c8673a661de4da7cb | RegionOne | glance | image | True | internal | http://controller:9292 |
| cd215f15d5db4a3fa6922f628c2eb959 | RegionOne | keystone | identity | True | admin | http://controller:5000/v3/ |
+----------------------------------+-----------+--------------+--------------+---------+-----------+----------------------------+
6 安装包(仅控制节点)
官方链接:https://docs.openstack.org/glance/victoria/install/install-rdo.html
[root@controller ~(admin)]$ yum install openstack-glance -y
*** 输出记录节选 ***
Last metadata expiration check: 19:52:49 ago on Thu 03 Aug 2023 06:59:08 PM CST.
Dependencies resolved.
=======================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================
Installing:
openstack-glance noarch 1:21.1.0-1.el8 centos-openstack-victoria 78 k
......
urw-base35-p052-fonts-20170801-10.el8.noarch urw-base35-standard-symbols-ps-fonts-20170801-10.el8.noarch
urw-base35-z003-fonts-20170801-10.el8.noarch userspace-rcu-0.10.1-4.el8.x86_64
xdg-utils-1.1.2-5.el8.noarch xorg-x11-font-utils-1:7.5-41.el8.x86_64
xorg-x11-fonts-ISO8859-1-100dpi-7.5-19.el8.noarch xorg-x11-server-utils-7.7-27.el8.x86_64
Complete!
7 编辑配置文件(仅控制节点)
官方链接:https://docs.openstack.org/glance/victoria/install/install-rdo.html
[root@controller ~(admin)]$ vim /etc/glance/glance-api.conf
*** 找到对应标签并编辑以下内容 ***
[database]
connection = mysql+pymysql://glance:rootroot@controller/glance
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = redhat
[paste_deploy]
flavor = keystone
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
8 初始化数据库(仅控制节点)
官方链接:https://docs.openstack.org/glance/victoria/install/install-rdo.html
[root@controller ~(admin)]$ su -s /bin/sh -c "glance-manage db_sync" glance
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> liberty, liberty initial
INFO [alembic.runtime.migration] Running upgrade liberty -> mitaka01, add index on created_at and updated_at columns of 'images' table
INFO [alembic.runtime.migration] Running upgrade mitaka01 -> mitaka02, update metadef os_nova_server
INFO [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_expand01, add visibility to images
INFO [alembic.runtime.migration] Running upgrade ocata_expand01 -> pike_expand01, empty expand for symmetry with pike_contract01
INFO [alembic.runtime.migration] Running upgrade pike_expand01 -> queens_expand01
INFO [alembic.runtime.migration] Running upgrade queens_expand01 -> rocky_expand01, add os_hidden column to images table
INFO [alembic.runtime.migration] Running upgrade rocky_expand01 -> rocky_expand02, add os_hash_algo and os_hash_value columns to images table
INFO [alembic.runtime.migration] Running upgrade rocky_expand02 -> train_expand01, empty expand for symmetry with train_contract01
INFO [alembic.runtime.migration] Running upgrade train_expand01 -> ussuri_expand01, empty expand for symmetry with ussuri_expand01
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Upgraded database to: ussuri_expand01, current revision(s): ussuri_expand01
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Database migration is up to date. No migration needed.
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_contract01, remove is_public from images
INFO [alembic.runtime.migration] Running upgrade ocata_contract01 -> pike_contract01, drop glare artifacts tables
INFO [alembic.runtime.migration] Running upgrade pike_contract01 -> queens_contract01
INFO [alembic.runtime.migration] Running upgrade queens_contract01 -> rocky_contract01
INFO [alembic.runtime.migration] Running upgrade rocky_contract01 -> rocky_contract02
INFO [alembic.runtime.migration] Running upgrade rocky_contract02 -> train_contract01
INFO [alembic.runtime.migration] Running upgrade train_contract01 -> ussuri_contract01
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Upgraded database to: ussuri_contract01, current revision(s): ussuri_contract01
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Database is synced successfully.
[root@controller ~(admin)]$ mysql -u root -prootroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 10.3.28-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| glance |
| information_schema |
| keystone |
| mysql |
| performance_schema |
+--------------------+
5 rows in set (0.001 sec)
MariaDB [(none)]> use glance;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [glance]> show tables;
+----------------------------------+
| Tables_in_glance |
+----------------------------------+
| alembic_version |
| image_locations |
| image_members |
| image_properties |
| image_tags |
| images |
| metadef_namespace_resource_types |
| metadef_namespaces |
| metadef_objects |
| metadef_properties |
| metadef_resource_types |
| metadef_tags |
| migrate_version |
| task_info |
| tasks |
+----------------------------------+
15 rows in set (0.001 sec)
9 启动服务并测试(仅控制节点)
官方链接:https://docs.openstack.org/glance/victoria/install/install-rdo.html
[root@controller ~(admin)]$ systemctl enable openstack-glance-api.service
Created symlink /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service → /usr/lib/systemd/system/openstack-glance-api.service.
[root@controller ~(admin)]$ systemctl start openstack-glance-api.service
[root@controller ~(admin)]$ source keystonerc_admin
[root@controller ~(admin)]$ ls /tmp/cir*
/tmp/cirros-0.6.2-x86_64-disk.img
*** 测试能否正常上传镜像 ***
[root@controller ~(admin)]$ openstack image create --disk-format qcow2 --container-format bare --public --file /tmp/cirros-0.6.2-x86_64-disk.img centos7
+------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
| container_format | bare |
| created_at | 2023-08-04T07:02:45Z |
| disk_format | qcow2 |
| file | /v2/images/0c208528-d76e-46c7-b068-664dbc745365/file |
| id | 0c208528-d76e-46c7-b068-664dbc745365 |
| min_disk | 0 |
| min_ram | 0 |
| name | centos7 |
| owner | 235d1d6e21254aa58f844c303edecb45 |
| properties | os_hidden='False', owner_specified.openstack.md5='', owner_specified.openstack.object='images/centos7', owner_specified.openstack.sha256='' |
| protected | False |
| schema | /v2/schemas/image |
| status | queued |
| tags | |
| updated_at | 2023-08-04T07:02:45Z |
| visibility | public |
+------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
[root@controller ~(admin)]$ openstack image list
+--------------------------------------+---------+--------+
| ID | Name | Status |
+--------------------------------------+---------+--------+
| 0c208528-d76e-46c7-b068-664dbc745365 | centos7 | active |
+--------------------------------------+---------+--------+
*** 登录数据库查看镜像 ***
[root@controller ~(admin)]$ mysql -u root -prootroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 10.3.28-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use glance;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [glance]> select * from image_locations\G
*************************** 1. row ***************************
id: 1
image_id: 0c208528-d76e-46c7-b068-664dbc745365
value: file:///var/lib/glance/images/0c208528-d76e-46c7-b068-664dbc745365
created_at: 2023-08-04 07:02:45
updated_at: 2023-08-04 07:02:45
deleted_at: NULL
deleted: 0
meta_data: {}
status: active
1 row in set (0.000 sec)
- END