【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 |

本文对应的视频教程:【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安装完成。

相关推荐
mqiqe3 天前
云计算Openstack 虚拟机调度策略
云计算·openstack
小安运维日记7 天前
Linux云计算 |【第五阶段】CLOUD-DAY2
linux·运维·云计算·openstack
南宫乘风15 天前
OpenStack将运行的系统导出 QCOW2 镜像并导入阿里云
阿里云·云计算·openstack
学习向前冲17 天前
开源OpenStack
openstack
suum1 个月前
openstack-swift.18421165
openstack
极客先躯1 个月前
开源的云平台有哪些?
kubernetes·开源·openstack·cloudstack·云平台·docker swarm·opennebula
mqiqe1 个月前
云计算Openstack Horizon
云计算·openstack·perl
zkyqss1 个月前
OpenStack Yoga版安装笔记(十六)Openstack网络理解
笔记·openstack
mqiqe1 个月前
云计算Openstack Neutron
云计算·openstack·perl
mqiqe1 个月前
云计算Openstack Keystone
数据库·云计算·openstack