首页 > 数据库 > 数据库开发技术 > OpenStack离线Train版安装(十七)
在存储节点服务器安装cinder存储服务
官方参考:https://docs.openstack.org/install-guide/openstack-services.htmlhttps://docs.openstack.org/train/install/https://docs.openstack.org/cinder/train/install/https://docs.openstack.org/cinder/train/install/index-rdo.htmlhttps://docs.openstack.org/cinder/train/install/cinder-storage-install-rdo.html(可选服务)https://docs.openstack.org/cinder/train/install/cinder-backup-install-rdo.html存储节点,安装和配置备份服务,在“块存储”节点上执行这些步骤。博客:https://www.cnblogs.com/tssc/p/9877026.htmlhttps://www.cnblogs.com/wanlipenghtml/p/10721845.htmlhttps://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/cinder-storage-install.html
存储节点建议单独部署服务器(最好是物理机),测试时也可以部署在控制节点或者计算节点。在本文,存储节点使用LVM逻辑卷提供服务,需要提供一块空的磁盘用以创建LVM逻辑卷,在部署之前准备好存储设备。
在搭建的过程中使用的是共享存储来完成的,需要给存储节点在共享存储上划分一个LUN并映射到存储节点。硬盘的硬盘分区是 /dev/sdb
fdisk -l
[root@compute2 ~]# fdisk -l
Disk /dev/sda: 299.0 GB, 298999349248 bytes, 583983104 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00051094
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 583983103 290941952 8e Linux LVM
Disk /dev/sdb: 17179.9 GB, 17179869184000 bytes, 33554432000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xd4a8678a
Device Boot Start End Blocks Id System
Disk /dev/mapper/vg00-lv_root: 68.7 GB, 68719476736 bytes, 134217728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/vg00-lv_swap: 68.7 GB, 68719476736 bytes, 134217728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/vg00-lv_data: 160.5 GB, 160482459648 bytes, 313442304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@compute2 ~]#
安装LVM包
yum install lvm2 device-mapper-persistent-data -y
启动LVM的metadata服务并配置开机自启动
systemctl start lvm2-lvmetad.service
systemctl status lvm2-lvmetad.service
systemctl enable lvm2-lvmetad.service
systemctl list-unit-files |grep lvm2-lvmetad |grep enabled
创建LVM 物理卷 /dev/sdb
pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
(1)块存储服务会在这个卷组中创建逻辑卷
vgcreate cinder-volumes /dev/sdb
vgdisplay
[root@compute2 ~]# vgcreate cinder-volumes /dev/sdb
Volume group "cinder-volumes" successfully created
[root@compute2 ~]#
[root@compute2 ~]# vgdisplay
--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 277.46 GiB
PE Size 4.00 MiB
Total PE 71030
Alloc PE / Size 71030 / 277.46 GiB
Free PE / Size 0 / 0
VG UUID cKlpZk-yG3k-ymSG-TqgC-ToKf-H10b-wUCcmW
--- Volume group ---
VG Name cinder-volumes
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 15.62 TiB
PE Size 4.00 MiB
Total PE 4095999
Alloc PE / Size 0 / 0
Free PE / Size 4095999 / 15.62 TiB
VG UUID xRcasu-jvOL-diD2-ZYJY-wf97-OSeE-GG7Y6Q
[root@compute2 ~]#
只有实例可以访问块存储卷组,防止系统出错。
(1) 新增磁盘sdb为LVM卷组
默认只会有openstack实例访问块存储卷组,不过,底层的操作系统也会管理这些设备并尝试将逻辑卷与系统关联。默认情况下LVM卷扫描工具会扫描整个/dev目录,查找所有包含lvm卷的块存储设备。如果其他项目在某个磁盘设备sda,sdc等上使用了lvm卷,那么扫描工具检测到这些卷时会尝试缓存这些lvm卷,可能导致底层操作系统或者其他服务无法正常调用他们的lvm卷组,从而产生各种问题,需要手动配置LVM,让LVM卷扫描工具只扫描包含"cinder-volume"卷组的设备/dev/sdb,我这边磁盘分区都是格式化的手工分区,目前不存在这个问题,以下是配置演示将LVM重新配置为仅扫描包含cinder-volumes卷组的设备。
vim /etc/lvm/lvm.conf
devices {filter = [ "a/sdb/", "r/.*/"]
}
在devices部分中,添加一个接受/dev/sdb设备并拒绝所有其他设备的过滤器:
配置规则:a用于接受,r用于拒绝。每个过滤器组中的元素都以a开头accept接受,或以 r 开头reject拒绝,后面连接设备名称的正则表达式规则。过滤器组必须以"r/.*/"结束,过滤所有保留设备。可以使用命令:vgs -vvvv来测试过滤器。(2) 查看系统磁盘卷类型
vgdisplay
[root@compute2 ~]# vgdisplay
--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 277.46 GiB
PE Size 4.00 MiB
Total PE 71030
Alloc PE / Size 71030 / 277.46 GiB
Free PE / Size 0 / 0
VG UUID cKlpZk-yG3k-ymSG-TqgC-ToKf-H10b-wUCcmW
--- Volume group ---
VG Name cinder-volumes
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 15.62 TiB
PE Size 4.00 MiB
Total PE 4095999
Alloc PE / Size 0 / 0
Free PE / Size 4095999 / 15.62 TiB
VG UUID xRcasu-jvOL-diD2-ZYJY-wf97-OSeE-GG7Y6Q
[root@compute2 ~]#
注意:如果存储节点的操作系统磁盘/dev/sda使用的是LVM卷组,也需要将该设备添加到过滤器中,配置文件/etc/lvm/lvm.conf添加如下:
devices {
......
filter = [ "a/sda/", "a/sdb/", "r/.*/"]
......
}
如果计算节点的操作系统磁盘/dev/sda使用的是LVM卷组,也需要将该设备添加到过滤器中,配置文件/etc/lvm/lvm.conf添加如下:
devices {
......
filter = [ "a/sda/", "r/.*/"]
......
}
yum install openstack-cinder targetcli python-keystone -y
#用于快速配置
yum install openstack-utils -y
(1) 快速配置/etc/cinder/cinder.conf
cp /etc/cinder/cinder.conf{,.bak}
cd
touch storage-node-cinder.conf.sh
vim storage-node-cinder.conf.sh
storage-node-cinder.conf.sh文件内容:
#!bin/bash
#storage-node-cinder.conf.sh
openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:cinder@controller/cinder
openstack-config --set /etc/cinder/cinder.conf DEFAULT transport_url rabbit://openstack:openstack@controller
openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken www_authenticate_uri http://controller:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://controller:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_type password
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_name service
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken username cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken password cinder
openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip 10.224.24.172
openstack-config --set /etc/cinder/cinder.conf lvm volume_driver cinder.volume.drivers.lvm.LVMVolumeDriver
openstack-config --set /etc/cinder/cinder.conf lvm volume_group cinder-volumes
openstack-config --set /etc/cinder/cinder.conf lvm target_protocol iscsi
openstack-config --set /etc/cinder/cinder.conf lvm target_helper lioadm
openstack-config --set /etc/cinder/cinder.conf DEFAULT enabled_backends lvm
openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_api_servers http://controller:9292
openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
echo "Result of Configuration"
egrep -v "^#|^$" /etc/cinder/cinder.conf
(2)使配置生效
bash storage-node-cinder.conf.sh
注意:具体配置与之前版本有所变更
#[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
target_protocol = iscsi
target_helper = lioadm
egrep -v "^#|^$" /etc/cinder/cinder.conf
grep '^[a-z]' /etc/cinder/cinder.conf
需要启动2个服务:
systemctl start openstack-cinder-volume.service target.service
systemctl status openstack-cinder-volume.service target.service
systemctl enable openstack-cinder-volume.service target.service
systemctl list-unit-files |grep openstack-cinder |grep enabled
systemctl list-unit-files |grep target.service |grep enabled
至此,在存储节点安装cinder服务就完成了。
有什么吐槽或反馈意见,直接告诉我!
我会解决您说的问题,进一步更好的服务您哦!
温馨提示:如出现二维码失效也可直接添加微信号:ysc13803862469。
原文作者:超哥的IT私房菜;如有侵权,请联系管理员删除。