Cinder在块存储资源和计算服务(Nova)之间提供了一个抽象层。通过Cinder API,块存储可以被管理(创建、销毁和分配等),而不需要知道提供存储的底层资源。
本文介绍Cinder安装步骤,Cinder需在控制节点和计算节点安装(官网教程中包含了block节点,但是个人电脑性能有限,将compute节点作block节点之用)。
在按照本教程安装之前,请确保完成以下配置:
【Openstack Train安装】三、openstack安装
【Openstack Train安装】四、MariaDB/RabbitMQ 安装
【Openstack Train安装】五、Memcached/Etcd安装
【Openstack Train安装】六、Keystone安装
【Openstack Train安装】八、placement安装
【Openstack Train安装】十、Neutron安装
【Openstack Train安装】十一、Dashboard 安装
安装环境如下
|--------------------|------------|
| VMware Workstation | V17.0 |
| 本机系统 | win11 |
| 虚拟机系统 | CentOS 7.5 |
本文对应的视频教程:【Openstack Train安装】十二、Cinder安装
一、控制节点配置
在控制节点完成以下操作。
1、配置数据库
进入数据库控制台(密码:123456):
mysql -u root -p
创建数据库并授予权限,退出:
CREATE DATABASE cinder;
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY '123456';
如下图:
2、创建用户
创建cinder用户,密码设置为:123456:
bash
. admin-openrc
openstack user create --domain default --password-prompt cinder
添加权限:
bash
openstack role add --project service --user cinder admin
如下图:
3、创建服务入口
创建cinderv2和cinderv3服务入口:
bash
openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
如下图:
4、创建block storage服务API端点
命令如下:
bash
openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 public http://controller:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 internal http://controller:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 admin http://controller:8776/v3/%\(project_id\)s
5、安装cinder
安装:
bash
yum install openstack-cinder -y
备份并删除/etc/cinder/cinder.conf
的注释:
bash
mv /etc/cinder/cinder.conf /etc/cinder/cinder.conf.source
cat /etc/cinder/cinder.conf.source | grep -Ev "^#|^$" > /etc/cinder/cinder.conf
编辑 /etc/cinder/cinder.conf ,进行如下配置:
bash
[DEFAULT]
# ...
transport_url = rabbit://openstack:123456@controller
auth_strategy = keystone
my_ip = 10.0.0.11
[database]
# ...
connection = mysql+pymysql://cinder:123456@controller/cinder
[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
同步数据库:
bash
su -s /bin/sh -c "cinder-manage db sync" cinder
编辑/etc/nova/nova.conf,添加如下配置:
bash
[cinder]
os_region_name = RegionOne
重启并设置开机启动:
bash
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、在计算节点添加硬盘
添加硬件:
添加硬盘:
默认类型:
创建新磁盘:
设置大小:
完成并关闭虚拟机管理界面:
如果是在虚拟机开启的情况下添加硬盘,需要重启虚拟机。
使用fdisk -l查看硬盘:
bash
fdisk -l
如下图所示(如果不显示,可以是用命令"echo "- - -" > /sys/class/scsi_host/host0/scan"扫描硬盘):
硬盘添加完毕。
2、安装lvm
bash
yum install lvm2 device-mapper-persistent-data -y
systemctl enable lvm2-lvmetad.service
systemctl start lvm2-lvmetad.service
创建volume(上面步骤添加的硬盘是/dev/sdb):
bash
pvcreate /dev/sdb
如下图:
创建volumes:
bash
vgcreate cinder-volumes /dev/sdb
如下图:
编辑/etc/lvm/lvm.conf,在130行下方插入以下内容:
bash
filter = [ "a/sdb/", "r/.*/"]
如下图:
3、安装并配置cinder
安装包:
bash
yum install openstack-cinder targetcli python-keystone -y
备份并删除/etc/cinder/cinder.conf
的注释:
bash
mv /etc/cinder/cinder.conf /etc/cinder/cinder.conf.source
cat /etc/cinder/cinder.conf.source | grep -Ev "^#|^$" > /etc/cinder/cinder.conf
编辑 /etc/cinder/cinder.conf ,进行如下配置:
bash
[DEFAULT]
# ...
glance_api_servers = http://controller:9292
auth_strategy = keystone
enabled_backends = lvm
my_ip = 10.0.0.31
transport_url = rabbit://openstack:123456@controller
[database]
# ...
connection = mysql+pymysql://cinder:123456@controller/cinder
[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]
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
设置开机自启,并启动服务:
bash
systemctl enable openstack-cinder-volume.service target.service
systemctl start openstack-cinder-volume.service target.service
三、验证
在控制节点进行以下操作。
登录admin:
bash
. admin-openrc
查看volume服务:
bash
openstack volume service list
如下图所示:
cinder安装完成。