Cinder在块存储资源和计算服务(Nova)之间提供了一个抽象层。通过Cinder API,块存储可以被管理(创建、销毁和分配等),而不需要知道提供存储的底层资源。
本文介绍Cinder安装步骤,Cinder需在控制节点和计算节点安装(官网教程中包含了block节点,但是个人电脑性能有限,将compute节点作block节点之用)。
在按照本教程安装之前,请确保完成以下配置:
【Openstack Train安装】一、虚拟机创建
【Openstack Train安装】二、NTP安装
【Openstack Train安装】三、openstack安装
【Openstack Train安装】四、MariaDB/RabbitMQ 安装
【Openstack Train安装】五、Memcached/Etcd安装
【Openstack Train安装】六、Keystone安装
【Openstack Train安装】七、glance安装
【Openstack Train安装】八、placement安装
【Openstack Train安装】九、Nova安装
【Openstack Train安装】十、Neutron安装
【Openstack Train安装】十一、Dashboard 安装
安装环境如下
VMware Workstation | V17.0 |
本机系统 | win11 |
虚拟机系统 | CentOS 7.5 |
在控制节点完成以下操作。
进入数据库控制台(密码: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';
如下图:
创建cinder用户,密码设置为:123456:
. admin-openrc
openstack user create --domain default --password-prompt cinder
添加权限:
openstack role add --project service --user cinder admin
如下图:
创建cinderv2和cinderv3服务入口:
openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
如下图:
命令如下:
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
安装:
yum install openstack-cinder -y
备份并删除/etc/cinder/cinder.conf
的注释:
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 ,进行如下配置:
[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
同步数据库:
su -s /bin/sh -c "cinder-manage db sync" cinder
编辑/etc/nova/nova.conf,添加如下配置:
[cinder]
os_region_name = RegionOne
重启并设置开机启动:
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
在计算节点进行如下操作。
添加硬件:
添加硬盘:
默认类型:
创建新磁盘:
设置大小:
完成并关闭虚拟机管理界面:
如果是在虚拟机开启的情况下添加硬盘,需要重启虚拟机。
使用fdisk -l查看硬盘:
fdisk -l
如下图所示:
硬盘添加完毕。
yum install lvm2 device-mapper-persistent-data -y
systemctl enable lvm2-lvmetad.service
systemctl start lvm2-lvmetad.service
创建volume(上面步骤添加的硬盘是/dev/sdb):
pvcreate /dev/sdb
如下图:
创建volumes:
vgcreate cinder-volumes /dev/sdb
如下图:
编辑/etc/lvm/lvm.conf,在130行下方插入以下内容:
filter = [ "a/sdb/", "r/.*/"]
如下图:
安装包:
yum install openstack-cinder targetcli python-keystone -y
备份并删除/etc/cinder/cinder.conf
的注释:
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 ,进行如下配置:
[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
设置开机自启,并启动服务:
systemctl enable openstack-cinder-volume.service target.service
systemctl start openstack-cinder-volume.service target.service
在控制节点进行以下操作。
登录admin:
. admin-openrc
查看volume服务:
openstack volume service list
如下图所示:
cinder安装完成。