cinder块存储服务的安装部署
admin
2023-03-26 10:01:38
0次

简介

Cinder块存储是虚拟基础架构中必不可少的组件,是存储虚拟机镜像文件及虚拟机使用的数据的基础。Cinder提供对块存储的管理支持,通过使用iSCSI, 光纤通道或者NFS协议,以及若干私有协议提供后端连接,展现给计算层(Nova)。

Cinder接口提供了一些标准功能,允许创建和附加块设备到虚拟机,如"创建卷","删除卷"和"附加卷"。还有更多高级的功能,支持扩展容量的能力,快照和创建虚拟机镜像克隆。

cinder以挂接的方式加入到现有的openstack环境中。
cinder块存储服务需要至少一个额外的存储节点,该节点为实例提供卷。
本实验搭建一个专门的存储节点及使用其之上的一块空白磁盘(/dev/sdb),以卷的形式,向实例提供数据盘。

安装好存储节点的centos系统,并配置好IP和主机名,编辑hosts文件加入主机解析等。
存储节点的管理网络的ip地址为192.168.10.44,主机名是b1。

安装和配置控制器节点
创建数据库
mysql -u root -p

创建cinder数据库
MariaDB [(none)]> CREATE DATABASE cinder;

授予对cinder数据库的适当访问权限
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'CINDER_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'CINDER_DBPASS';
MariaDB [(none)]> exit;

创建服务凭证
. admin-openrc
创建cinder用户
openstack user create --domain default --password CINDER_PASS cinder

向cinder用户添加admin角色
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

创建块存储服务API端点
openstack endpoint create --region RegionOne volumev2 public http://ct:8776/v2/%(project_id)s
openstack endpoint create --region RegionOne volumev2 internal http://ct:8776/v2/%(project_id)s
openstack endpoint create --region RegionOne volumev2 admin http://ct:8776/v2/%(project_id)s
openstack endpoint create --region RegionOne volumev3 public http://ct:8776/v3/%(project_id)s
openstack endpoint create --region RegionOne volumev3 internal http://ct:8776/v3/%(project_id)s
openstack endpoint create --region RegionOne volumev3 admin http://ct:8776/v3/%(project_id)s

安装软件包
yum install openstack-cinder
cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
grep -Ev '#|^$' /etc/cinder/cinder.conf.bak>/etc/cinder/cinder.conf
vim /etc/cinder/cinder.conf
[database]
connection = mysql+pymysql://cinder:CINDER_DBPASS@ct/cinder

[DEFAULT]
transport_url = rabbit://openstack:RABBIT_PASS@ct
auth_strategy = keystone
my_ip = 192.168.10.41

[keystone_authtoken]
www_authenticate_uri = http://ct:5000
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = CINDER_PASS

[oslo_concurrency]
lock_path = /var/lib/cinder/tmp

填充块存储数据库
su -s /bin/sh -c "cinder-manage db sync" cinder

配置计算以使用块存储
vim /etc/nova/nova.conf
[oslo_concurrency]
os_region_name = RegionOne

重新启动Compute API服务
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

安装和配置存储节点
存储节点的管理网络的ip地址为192.168.10.44

安装LVM软件包
yum install lvm2 device-mapper-persistent-data

启动LVM元数据服务,并将其配置为在系统引导时启动
systemctl enable lvm2-lvmetad.service
systemctl start lvm2-lvmetad.service

创建LVM物理卷/dev/sdb
pvcreate /dev/sdb

创建LVM卷组cinder-volumes
vgcreate cinder-volumes /dev/sdb

将LVM重新配置为仅扫描包含cinder-volumes卷组的设备
vim /etc/lvm/lvm.conf
在devices部分中,添加一个接受/dev/sdb设备并拒绝所有其他设备的过滤器:
devices {
filter = [ "a/sdb/", "r/.*/"]
a用于接受,r用于拒绝。

安装软件包
yum install centos-release-openstack-train -y
yum upgrade -y
yum install python-openstackclient -y
yum install openstack-selinux -y
yum install openstack-cinder targetcli python-keystone -y

修改配置文件
cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
grep -Ev '#|^$' /etc/cinder/cinder.conf.bak>/etc/cinder/cinder.conf
vim /etc/cinder/cinder.conf
[database]
connection = mysql+pymysql://cinder:CINDER_DBPASS@ct/cinder

[DEFAULT]
transport_url = rabbit://openstack:RABBIT_PASS@ct
auth_strategy = keystone
my_ip = 192.168.10.44
enabled_backends = lvm
glance_api_servers = http://ct:9292

[keystone_authtoken]
www_authenticate_uri = http://ct:5000
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = CINDER_PASS

[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

验证cinder块存储服务
. admin-openrc
openstack volume service list

使用块存储服务向实例提供数据盘
创建卷(volume)
. ygj-openrc
创建一个10 GB的卷:
openstack volume create --size 10 volume1
很短的时间后,卷状态应该从creating 到available
openstack volume list

将卷附加到实例
openstack server add volume INSTANCE_NAME VOLUME_NAME
将volume1卷附加到centos7-instance1实例:
openstack server add volume centos7-instance1 volume1
openstack volume list

使用SSH访问实例,并使用以下fdisk命令验证该卷是否作为/dev/vdb块存储设备:
sudo fdisk -l
分区并格式化新添加的/dev/vdb
fdisk /dev/vdb
mk2fs.ext4 /dev/vdb1

相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...