MariaDB [(none)]> create database cinder;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \
IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \
DENTIFIED BY '123456';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> exit
Bye
[root@controller ~]# . admin-openrc.sh
[root@controller ~]# openstack user create --domain default --password-prompt cinder
User Password: ==>输入合适的密码:'123456'
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 9edea3db934e40c58aafc6f20e7cdcc3 |
| name | cinder |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[root@controller ~]# openstack role add --project service --user cinder admin
[root@controller ~]# openstack service create --name cinderv2 \
--description "OpenStack Block Storage" volumev2
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | a24218cc638049889c619435ce24f8a2 |
| name | cinderv2 |
| type | volumev2 |
+-------------+----------------------------------+
[root@controller ~]# openstack service create --name cinderv3 \
--description "OpenStack Block Storage" volumev3
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | 8af4385650af4375ba767735c987e10c |
| name | cinderv3 |
| type | volumev3 |
+-------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
volumev2 public http://controller:8776/v2/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | a90cce38306d4cd49dc20d76ce5beef8 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a24218cc638049889c619435ce24f8a2 |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(project_id)s |
+--------------+------------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
volumev2 internal http://controller:8776/v2/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | 7829d69a13d9453b9e2caed5bb20677b |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a24218cc638049889c619435ce24f8a2 |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(project_id)s |
+--------------+------------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
volumev2 admin http://controller:8776/v2/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | 6f1fd8846b0347a8a99b7a18d972cd6b |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a24218cc638049889c619435ce24f8a2 |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(project_id)s |
+--------------+------------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
volumev3 public http://controller:8776/v3/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | b7ba170a0f724873ad29631a2cd9eb65 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8af4385650af4375ba767735c987e10c |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller:8776/v3/%(project_id)s |
+--------------+------------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
volumev3 internal http://controller:8776/v3/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | 855756132107423e8a80fd935b2b2147 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8af4385650af4375ba767735c987e10c |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller:8776/v3/%(project_id)s |
+--------------+------------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
volumev3 admin http://controller:8776/v3/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | 1675f9df0c24477eae7aa23c7dc28f6c |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8af4385650af4375ba767735c987e10c |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller:8776/v3/%(project_id)s |
+--------------+------------------------------------------+
[root@controller ~]# yum install openstack-cinder -y
[root@controller ~]# cp -rp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
[root@controller ~]# cd /etc/cinder/ && cat cinder.conf.bak | grep -Ev '^#|^$' > cinder.conf
#添加配置文件
[root@controller cinder]# vim cinder.conf
#配置数据库访问密码
[database]
connection = mysql+pymysql://cinder:123456@controller/cinder
#配置消息队列访问密码、认证类型为‘keystone’、本机IP地址
[DEFAULT]
transport_url = rabbit://openstack:123456@controller
auth_strategy = keystone
my_ip = 10.0.0.20
#配置标识服务访问token
[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 = cinder
password = 123456
#配置锁定路径
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
忽略此处的命令输出消息
[root@controller ~]# su -s /bin/sh -c "cinder-manage db sync" cinder
Deprecated: Option "logdir" from group "DEFAULT" is deprecated. Use option "log-dir" from group "DEFAULT".
[root@controller ~]# vim /etc/nova/nova.conf
[cinder]
os_region_name = RegionOne
#重启计算api服务
[root@controller ~]# systemctl restart openstack-nova-api.service
#启动块存储服务并设置开机自启动
[root@controller ~]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
[root@controller ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-cinder-api.service to /usr/lib/systemd/system/openstack-cinder-api.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-cinder-scheduler.service to /usr/lib/systemd/system/openstack-cinder-scheduler.service.
OpenStack官方文档需要添加一个存储节点部署块存储,这里我直接采用计算节点作为存储节点
以下操作在计算节点实施
[root@computer ~]# yum install lvm2 device-mapper-persistent-data -y
#启动LVM元数据服务并配置开机自启动
[root@computer ~]# systemctl start lvm2-lvmetad.service
[root@computer ~]# systemctl enable lvm2-lvmetad.service
[root@computer ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 39G 0 part
├─centos-root 253:0 0 37G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
sr0 11:0 1 4.4G 0 rom
#创建LVM物理卷
[root@computer ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
#创建卷组
[root@computer ~]# vgcreate cinder-volumes /dev/sdb
Volume group "cinder-volumes" successfully created
[root@computer ~]# yum install openstack-cinder targetcli python-keystone -y
#切换到配置问价目录,备份配置文件并过滤配置文件的空行和注释行
[root@computer ~]# cd /etc/cinder/ && cp -rp cinder.conf cinder.conf.bak && cat cinder.conf.bak | grep -Ev '^#|^$' > cinder.conf
#配置数据库访问密码
[database]
connection = mysql+pymysql://cinder:123456@controller/cinder
#配置消息队列访问密码、认证类型为‘keystone’、本机IP地址、启用后端lvm、配置glance-api
[DEFAULT]
transport_url = rabbit://openstack:123456@controller
auth_strategy = keystone
my_ip = 10.0.0.10
enabled_backends = lvm
#配置标识服务访问token
[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 = cinder
password = 123456
#使用 LVM 驱动程序、卷组、iSCSI 协议和相应的 iSCSI 服务配置 LVM 后端
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
target_protocol = iscsi
target_helper = lioadm
#设置锁定路径
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
#备份配置文件
[root@computer ~]# cp -rp /etc/lvm/lvm.conf{,.bak}
#修改'lvm.conf'配置文件
[root@computer ~]# vim /etc/lvm/lvm.conf
128 # Example
129 # Accept every block device:
130 # filter = [ "a|.*/|" ]
131 filter = [ "a/sdb/", "r/.*/"] ==>在'130'行后添加
132 # Reject the cdrom drive:
133 # filter = [ "r|/dev/cdrom|" ]
#启动块存储卷服务(包括其依赖服务)
[root@computer ~]# systemctl start openstack-cinder-volume.service target.service
[root@computer ~]# systemctl enable openstack-cinder-volume.service target.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-cinder-volume.service to /usr/lib/systemd/system/openstack-cinder-volume.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service.
[root@controller ~]# cinder service-list
+------------------+--------------+------+---------+-------+----------------------------+---------+-----------------+---------------+
| Binary | Host | Zone | Status | State | Updated_at | Cluster | Disabled Reason | Backend State |
+------------------+--------------+------+---------+-------+----------------------------+---------+-----------------+---------------+
| cinder-scheduler | controller | nova | enabled | up | 2022-08-23T20:52:38.000000 | - | - | |
| cinder-volume | computer@lvm | nova | enabled | up | 2022-08-23T20:52:48.000000 | - | - | up |
+------------------+--------------+------+---------+-------+----------------------------+---------+-----------------+---------------+
[root@controller ~]# openstack volume service list
+------------------+--------------+------+---------+-------+----------------------------+
| Binary | Host | Zone | Status | State | Updated At |
+------------------+--------------+------+---------+-------+----------------------------+
| cinder-scheduler | controller | nova | enabled | up | 2022-08-23T21:03:39.000000 |
| cinder-volume | computer@lvm | nova | enabled | up | 2022-08-23T21:03:48.000000 |
+------------------+--------------+------+---------+-------+----------------------------+