【Openstack Train安装】十二、Cinder安装

 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

一、控制节点配置

在控制节点完成以下操作。

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';

如下图:

【Openstack Train安装】十二、Cinder安装_第1张图片

2、创建用户

创建cinder用户,密码设置为:123456:

. admin-openrc
openstack user create --domain default --password-prompt cinder

添加权限:

openstack role add --project service --user cinder admin

如下图:

【Openstack Train安装】十二、Cinder安装_第2张图片

3、创建服务入口

创建cinderv2和cinderv3服务入口:

openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3

如下图:

【Openstack Train安装】十二、Cinder安装_第3张图片

4、创建block storage服务API端点

命令如下:

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

安装:

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

二、计算节点配置

在计算节点进行如下操作。

1、在计算节点添加硬盘

添加硬件:

【Openstack Train安装】十二、Cinder安装_第4张图片

添加硬盘:

【Openstack Train安装】十二、Cinder安装_第5张图片

默认类型:

【Openstack Train安装】十二、Cinder安装_第6张图片

创建新磁盘:

【Openstack Train安装】十二、Cinder安装_第7张图片

设置大小:

【Openstack Train安装】十二、Cinder安装_第8张图片

完成并关闭虚拟机管理界面:

【Openstack Train安装】十二、Cinder安装_第9张图片

如果是在虚拟机开启的情况下添加硬盘,需要重启虚拟机。

使用fdisk -l查看硬盘:

fdisk -l

如下图所示:

【Openstack Train安装】十二、Cinder安装_第10张图片

硬盘添加完毕。

2、安装lvm

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/.*/"]

如下图:

【Openstack Train安装】十二、Cinder安装_第11张图片

3、安装并配置cinder

安装包:

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

如下图所示:

【Openstack Train安装】十二、Cinder安装_第12张图片

cinder安装完成。

你可能感兴趣的:(openstack,openstack)