注意要 按顺序 搭建服务,在 CentOS 7 安装 Openstack Rocky 版本 - 环境搭建 的基础上安装服务。

Block Storage service - 块存储服务(Cinder)

控制节点块存储节点 安装

For simplicity, this configuration references one storage node with an empty local block storage device. The instructions use /dev/sdb, but you can substitute a different value for your particular node.

控制节点

数据库配置

连接数据库

1
2
# 连接数据库
mysql -u root -p

数据库操作

1
2
3
4
5
6
7
8
9
-- 创建数据库
CREATE DATABASE cinder;

-- 创建用户 neutron ,密码为 mariadb-cinder,并授予权限
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'mariadb-cinder';
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'mariadb-cinder';

-- 创建完毕后退出
exit

身份认证和 API 配置

创建用户 cinder 并添加到 admin 角色

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 更新环境变量
. admin-openrc

# 创建用户,设置密码为 cinder
openstack user create --domain default --password-prompt cinder
# User Password:
# Repeat User Password:
# +---------------------+----------------------------------+
# | Field | Value |
# +---------------------+----------------------------------+
# | domain_id | default |
# | enabled | True |
# | id | 069404f6673a405ca34f0acc1463f16a |
# | name | cinder |
# | options | {} |
# | password_expires_at | None |
# +---------------------+----------------------------------+


# 将用户添加到 admin 角色
openstack role add --project service --user cinder admin
# 无输出

创建 cinder 服务实体和端点(endpoint)

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# 创建服务实体 cinderv2
openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
# +-------------+----------------------------------+
# | Field | Value |
# +-------------+----------------------------------+
# | description | OpenStack Block Storage |
# | enabled | True |
# | id | cefbb91e803947c5ae2972a09d2cfa25 |
# | name | cinderv2 |
# | type | volumev2 |
# +-------------+----------------------------------+


# 创建服务实体 cinderv3
openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
# +-------------+----------------------------------+
# | Field | Value |
# +-------------+----------------------------------+
# | description | OpenStack Block Storage |
# | enabled | True |
# | id | 9e31cba4693c41b59c21d6ed1ef22cd6 |
# | name | cinderv3 |
# | type | volumev3 |
# +-------------+----------------------------------+


# 创建 cinderv2 服务 API 端点(endpoint)
openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(project_id\)s
# +--------------+------------------------------------------+
# | Field | Value |
# +--------------+------------------------------------------+
# | enabled | True |
# | id | b4365adc6dc34c06958eba5024c54691 |
# | interface | public |
# | region | RegionOne |
# | region_id | RegionOne |
# | service_id | cefbb91e803947c5ae2972a09d2cfa25 |
# | service_name | cinderv2 |
# | service_type | volumev2 |
# | url | http://controller:8776/v2/%(project_id)s |
# +--------------+------------------------------------------+


openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(project_id\)s
# +--------------+------------------------------------------+
# | Field | Value |
# +--------------+------------------------------------------+
# | enabled | True |
# | id | 342d8880b6c04b78acab56e404b85b02 |
# | interface | internal |
# | region | RegionOne |
# | region_id | RegionOne |
# | service_id | cefbb91e803947c5ae2972a09d2cfa25 |
# | service_name | cinderv2 |
# | service_type | volumev2 |
# | url | http://controller:8776/v2/%(project_id)s |
# +--------------+------------------------------------------+


openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(project_id\)s
# +--------------+------------------------------------------+
# | Field | Value |
# +--------------+------------------------------------------+
# | enabled | True |
# | id | 45ff36d1c3e74ef882d83dfb4e1ad998 |
# | interface | admin |
# | region | RegionOne |
# | region_id | RegionOne |
# | service_id | cefbb91e803947c5ae2972a09d2cfa25 |
# | service_name | cinderv2 |
# | service_type | volumev2 |
# | url | http://controller:8776/v2/%(project_id)s |
# +--------------+------------------------------------------+


# 创建 cinderv3 服务 API 端点(endpoint)
openstack endpoint create --region RegionOne volumev3 public http://controller:8776/v3/%\(project_id\)s
# +--------------+------------------------------------------+
# | Field | Value |
# +--------------+------------------------------------------+
# | enabled | True |
# | id | af6abd5a53bf476db2f7eb1b9e9d6359 |
# | interface | public |
# | region | RegionOne |
# | region_id | RegionOne |
# | service_id | 9e31cba4693c41b59c21d6ed1ef22cd6 |
# | service_name | cinderv3 |
# | service_type | volumev3 |
# | url | http://controller:8776/v3/%(project_id)s |
# +--------------+------------------------------------------+


openstack endpoint create --region RegionOne volumev3 internal http://controller:8776/v3/%\(project_id\)s
# +--------------+------------------------------------------+
# | Field | Value |
# +--------------+------------------------------------------+
# | enabled | True |
# | id | dca35a674a0b420d96b89f6b153e5120 |
# | interface | internal |
# | region | RegionOne |
# | region_id | RegionOne |
# | service_id | 9e31cba4693c41b59c21d6ed1ef22cd6 |
# | service_name | cinderv3 |
# | service_type | volumev3 |
# | url | http://controller:8776/v3/%(project_id)s |
# +--------------+------------------------------------------+


openstack endpoint create --region RegionOne volumev3 admin http://controller:8776/v3/%\(project_id\)s
# +--------------+------------------------------------------+
# | Field | Value |
# +--------------+------------------------------------------+
# | enabled | True |
# | id | 12b4ebc4e54b40b9a23887382def72e6 |
# | interface | admin |
# | region | RegionOne |
# | region_id | RegionOne |
# | service_id | 9e31cba4693c41b59c21d6ed1ef22cd6 |
# | service_name | cinderv3 |
# | service_type | volumev3 |
# | url | http://controller:8776/v3/%(project_id)s |
# +--------------+------------------------------------------+

安装和配置 cinder

安装软件包

1
2
# 安装
yum install openstack-cinder -y

编辑配置文件 /etc/cinder/cinder.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[database]
connection = mysql+pymysql://cinder:mariadb-cinder@controller/cinder

[DEFAULT]
transport_url = rabbit://openstack:rabbitmq@controller
auth_strategy = keystone
my_ip = 10.0.0.11

[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_id = default
user_domain_id = default
project_name = service
username = cinder
password = cinder

[oslo_concurrency]
lock_path = /var/lib/cinder/tmp

填充数据库

1
2
# 填充数据库
su -s /bin/sh -c "cinder-manage db sync" cinder

让计算节点使用块存储,编辑配置文件 /etc/nova/nova.conf

1
2
[cinder]
os_region_name = RegionOne

完成安装

1
2
3
4
5
6
# 重启计算服务 API
systemctl restart openstack-nova-api.service

# 启用块存储服务
systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service

块存储节点

添加 1 块新硬盘

安装并配置 LVM

1
2
3
4
5
6
7
8
9
10
11
12
# 安装 LVM 包
yum install lvm2 device-mapper-persistent-data -y

# 启用 LVM 元数据服务
systemctl enable lvm2-lvmetad.service
systemctl start lvm2-lvmetad.service

# 创建 LVM 物理卷 /dev/sdb
pvcreate /dev/sdb

# 创建 LVM 卷组
vgcreate cinder-volumes /dev/sdb

编辑配置文件 /etc/lvm/lvm.conf ,添加过滤条件

1
2
devices {
filter = [ "a/sda/", "a/sdb/", "r/.*/"]

计算节点 上修改配置文件 /etc/lvm/lvm.conf

1
2
devices {
filter = [ "a/sda/", "r/.*/"]

安装并配置 cinder

安装软件包

1
2
# 安装
yum install openstack-cinder targetcli python-keystone -y

编辑配置文件 /etc/cinder/cinder.conf ,没有的选项需要添加到相应的小节,[lvm] 小节直接添加即可

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
[database]
connection = mysql+pymysql://cinder:mariadb-cinder@controller/cinder

[DEFAULT]
transport_url = rabbit://openstack:rabbitmq@controller
auth_strategy = keystone
my_ip = 10.0.0.41
enabled_backends = lvm
glance_api_servers = http://controller:9292

[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_id = default
user_domain_id = default
project_name = service
username = cinder
password = cinder

[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm

[oslo_concurrency]
lock_path = /var/lib/cinder/tmp

完成安装

1
2
3
# 启用服务
systemctl enable openstack-cinder-volume.service target.service
systemctl start openstack-cinder-volume.service target.service

备份服务(可选)

For simplicity, this configuration uses the Block Storage node and the Object Storage (swift) driver, thus depending on the Object Storage service.

控制节点 查看对象存储服务 API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 查看对象存储
openstack catalog show object-store
# +-----------+-----------------------------------------------------------------------------+
# | Field | Value |
# +-----------+-----------------------------------------------------------------------------+
# | endpoints | RegionOne |
# | | admin: http://controller:8080/v1 |
# | | RegionOne |
# | | public: http://controller:8080/v1/AUTH_052158381fee46e693571c9dfb6ae3f5 |
# | | RegionOne |
# | | internal: http://controller:8080/v1/AUTH_052158381fee46e693571c9dfb6ae3f5 |
# | | |
# | id | cd7bec7ce2e34ab894977827cb87f064 |
# | name | swift |
# | type | object-store |
# +-----------+-----------------------------------------------------------------------------+

块存储节点 上执行操作,修改配置文件 /etc/cinder/cinder.conf

  • backup_swift_urlpublic 端点
1
2
3
[DEFAULT]
backup_driver = cinder.backup.drivers.swift
backup_swift_url = http://controller:8080/v1/AUTH_eb296de9a0e64b2a9243ad58f0805746

启用备份

1
2
3
# 启用服务
systemctl enable openstack-cinder-backup.service
systemctl start openstack-cinder-backup.service

验证

控制节点 上执行操作

1
2
3
4
5
6
7
8
9
10
11
12
# 更新环境变量
. admin-openrc

# 列出服务组件,验证进程是否成功启动
openstack volume service list
# +------------------+------------+------+---------+-------+----------------------------+
# | Binary | Host | Zone | Status | State | Updated At |
# +------------------+------------+------+---------+-------+----------------------------+
# | cinder-scheduler | controller | nova | enabled | up | 2020-12-27T10:29:12.000000 |
# | cinder-volume | block1@lvm | nova | enabled | up | 2020-12-27T10:29:18.000000 |
# | cinder-backup | block1 | nova | enabled | up | 2020-12-27T10:29:13.000000 |
# +------------------+------------+------+---------+-------+----------------------------+