cinder存储服务
安装配置(控制节点)
- 创建cinder数据库并授权,自定义帐号密码cinder/cinder
mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE cinder;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'cinder';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'cinder';
MariaDB [(none)]> FLUSH PRIVILEGES;
- 加载临时环境变量
. keystonerc_admin
- 创建服务凭据
[root@controller-01 ~]# openstack user create --domain default --password-prompt cinder
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 586034dc84fa427baec593ed32501d28 |
| name | cinder |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
- 给cinder用户添加admin角色,命令不输出结果:
openstack role add --project service --user cinder admin
[root@controller-01 ~]# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | 08c72135ddcb46fda290c6ec94b270ed |
| name | cinderv2 |
| type | volumev2 |
+-------------+----------------------------------+
[root@controller-01 ~]# openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | 671d97addc654760be943446f9c158f6 |
| name | cinderv3 |
| type | volumev3 |
+-------------+----------------------------------+
- 创建块存储服务API端点:
[root@controller-01 ~]# openstack endpoint create --region RegionOne volumev2 public http://controller-01:8776/v2/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | 7a53221557e04a619dc0c32f8c7317d0 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 08c72135ddcb46fda290c6ec94b270ed |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller-01:8776/v2/%(project_id)s |
+--------------+---------------------------------------------+
[root@controller-01 ~]# openstack endpoint create --region RegionOne volumev2 internal http://controller-01:8776/v2/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | 09a252a768084d889d512fcc9d2a654a |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 08c72135ddcb46fda290c6ec94b270ed |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller-01:8776/v2/%(project_id)s |
+--------------+---------------------------------------------+
[root@controller-01 ~]# openstack endpoint create --region RegionOne volumev2 admin http://controller-01:8776/v2/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | b9f21f762ce841bba9d54611bd2ecd42 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 08c72135ddcb46fda290c6ec94b270ed |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller-01:8776/v2/%(project_id)s |
+--------------+---------------------------------------------+
[root@controller-01 ~]# openstack endpoint create --region RegionOne volumev3 public http://controller-01:8776/v3/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | d7e6dffcafbb4c4f807808c834af160a |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 671d97addc654760be943446f9c158f6 |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller-01:8776/v3/%(project_id)s |
+--------------+---------------------------------------------+
[root@controller-01 ~]# openstack endpoint create --region RegionOne volumev3 internal http://controller-01:8776/v3/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | ac3c4e5395cc4b82b0ffa3af5548c69c |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 671d97addc654760be943446f9c158f6 |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller-01:8776/v3/%(project_id)s |
+--------------+---------------------------------------------+
[root@controller-01 ~]# openstack endpoint create --region RegionOne volumev3 admin http://controller-01:8776/v3/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | a6479e61952b4e7a85719195c4ac5728 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 671d97addc654760be943446f9c158f6 |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller-01:8776/v3/%(project_id)s |
+--------------+---------------------------------------------+
安装配置组件
- 安装包
yum install openstack-cinder
- 编辑
/etc/cinder/cinder.conf
文件,修改如下配置:
[database]
connection = mysql+pymysql://cinder:cinder@controller-01/cinder
[DEFAULT]
transport_url = rabbit://openstack:openstack@controller-01
auth_strategy = keystone
my_ip = 192.168.1.10
[keystone_authtoken]
auth_uri = http://controller-01:5000
auth_url = http://controller-01:5000
memcached_servers = controller-01: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
egrep -v "^$|^#" /etc/cinder/cinder.conf
- 同步块存储数据库
su -s /bin/sh -c "cinder-manage db sync" cinder
mysql -ucinder -pcinder cinder -e "show tables;"
配置计算使用块存储
- 编辑
/etc/nova/nova.conf
文件,添加修改如下配置:
[cinder]
os_region_name = RegionOne
最后安装
- 重启计算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
安装配置(存储节点)
- 安装工具包
yum install lvm2 device-mapper-persistent-data
systemctl enable lvm2-lvmetad.service
systemctl start lvm2-lvmetad.service
- 创建LVM物理卷/dev/sdb(测试可以通过虚拟机再添加一块磁盘)
pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
- 创建LVM卷组cinder-volumes
vgcreate cinder-volumes /dev/sdb
Volume group "cinder-volumes" successfully created
- 只有实例可以访问块存储卷。但是,底层操作系统管理与卷关联的设备。默认情况下,LVM 卷扫描工具会扫描 /dev包含卷的块存储设备的目录。如果项目在其卷上使用 LVM,则扫描工具会检测到这些卷并尝试缓存它们,这可能会导致底层操作系统和项目卷出现各种问题。您必须重新配置 LVM 以仅扫描包含cinder-volumes卷组的设备。编辑 /etc/lvm/lvm.conf文件并完成以下操作:
- 在devices部分,添加一个过滤接受/dev/sdb设备并且拒绝所有其他设备:
devices {
filter = [ "a/sdb/", "r/.*/"]
# 每个过滤器组中的元素都以a开头accept接受,或以 r 开头reject拒绝,后面连接设备名称的正则表达式规则。
# 过滤器组必须以"r/.*/"结束,过滤所有保留设备。
# 可以使用命令:vgs -vvvv来测试过滤器。
- 假如你的存储节点系统盘也使用的LVM,你也必须添加该设备到过滤器。举例,假如设备/dev/sda是系统盘:
filter = [ "a/sda/", "a/sdb/", "r/.*/"]
- 假如你的计算节点系统盘也使用的LVM,你也必须在/etc/lvm/lvm.conf中添加系统盘的过滤器。举例,假如/dev/sda是系统盘:
filter = [ "a/sda/", "r/.*/"]
安装配置组件
- 安装包
yum install openstack-cinder targetcli python-keystone
- 编辑
/etc/cinder/cinder.conf
文件,修改如下配置:
[database]
connection = mysql+pymysql://cinder:cinder@controller-01/cinder
[DEFAULT]
transport_url = rabbit://openstack:openstack@controller-01
auth_strategy = keystone
my_ip = 10.0.0.12 # 这里IP填写网卡二IP
enabled_backends = lvm
glance_api_servers = http://controller-01:9292
[keystone_authtoken]
auth_uri = http://controller-01:5000
auth_url = http://controller-01:5000
memcached_servers = controller-01: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
egrep -v "^$|^#" /etc/cinder/cinder.conf
最后安装
- 启动服务并开机自启
systemctl enable openstack-cinder-volume.service target.service
systemctl start openstack-cinder-volume.service target.service
验证(控制节点)
- 加载临时环境变量
. keystonerc_admin
- 查看存储卷列表
[root@controller-01 ~]# openstack volume service list
+------------------+----------------+------+---------+-------+----------------------------+
| Binary | Host | Zone | Status | State | Updated At |
+------------------+----------------+------+---------+-------+----------------------------+
| cinder-scheduler | controller-01 | nova | enabled | up | 2023-01-07T11:15:38.000000 |
| cinder-volume | storage-01@lvm | nova | enabled | up | 2023-01-07T11:15:32.000000 |
+------------------+----------------+------+---------+-------+----------------------------+
参考文档
https://docs.openstack.org