二、先电openstack部署cinder块存储服务并对接nfs后端存储
cinder部署对接nfs存储cinder基本概念安装cinder块存储服务controller节点compute节点配置NFS网络存储作为cinder的后端存储cinder基本概念在Openstack中提供对卷从创建到删除整个生命周期的管理,从虚拟机实例的角度来看,挂载的每一个卷都是一块硬盘。Openstack提供块存储服务的是cinder,具体功能如下:提供API使用户能够查询和管理卷、...
·
cinder部署对接nfs存储
cinder基本概念
在Openstack中提供对卷从创建到删除整个生命周期的管理,从虚拟机实例的角度来看,挂载的每一个卷都是一块硬盘。Openstack提供块存储服务的是cinder,具体功能如下:
提供API使用户能够查询和管理卷、卷快照以及卷类型
提供scheuler调用卷创建请求,合理优化存储资源的分配
通过driver架构支持多种后端存储的方式
用户请求volume流程
1、用户向API发送请求
2、API对请求做一些必要的处理后,向messaging(rabbitmq)发送信息,
让scheduler创建一个volume
3、scheduler从messaging获取到API发送的信息,然后执行调度算法,从若干存储节点选出节点A
4、scheduler向messaging发送一条信息,让存储节点创建volume
5、存储节点的volume从messaging中获取到scheduler发送给他的消息,
然后通过driver在volume provider上创建volume
安装cinder块存储服务
controller节点
openstack除了支持nfs为后端存还支持以下存储方式:
glusterfs 分布式存储 基于文件存储
ceph 分布式存储 支持块存储、文件存储、对象存储
cinder-api: 接收和响应外部有关块存储请求
cinder-volume: 提供存储空间
cinder-scheduler: 调度器,负责分配存储资源
cinder-backup: 备份存储
1、创建cinder数据库并授权
[root@controller ~]# mysql -uroot -p000000
MariaDB [(none)]> create database cinder;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on cinder.* to 'cinder'@'localhost' identified by '000000';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> grant all privileges on cinder.* to 'cinder'@'%' identified by '000000';
Query OK, 0 rows affected (0.00 sec)
2.创建cinder用户,并赋予admin角色权限
[root@controller ~]# openstack user create --domain demo --password 000000 cinder
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | 75e7789e623f4c09a6a7dd495688acfe |
| enabled | True |
| id | 60181885ff9f404685ae63ccf421ebe5 |
| name | cinder |
+-----------+----------------------------------+
[root@controller ~]# openstack role add --project service --user cinder admin
3.创建cinder和cinderv2服务实体
[root@controller ~]# openstack service create --name cinder --description "OpenStack Block Storage" volume
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | dbfad8c24fc84d77bf8b76d3b2bb4ce8 |
| name | cinder |
| type | volume |
+-------------+----------------------------------+
[root@controller ~]# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | c6c201b61fe7410a8926ba200866468c |
| name | cinderv2 |
| type | volumev2 |
+-------------+----------------------------------+
4.创建cinder服务的API注册入口
[root@controller ~]# openstack endpoint create --region RegionOne volume public http://controller:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | 4943451b11fd480ca487d93b251fe5c1 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | dbfad8c24fc84d77bf8b76d3b2bb4ce8 |
| service_name | cinder |
| service_type | volume |
| url | http://controller:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne volume internal http://controller:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | a4a43d6169df4549aafc2877132b3e05 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | dbfad8c24fc84d77bf8b76d3b2bb4ce8 |
| service_name | cinder |
| service_type | volume |
| url | http://controller:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne volume admin http://controller:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | 2d74b2136ae6449396c234b125c09b15 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | dbfad8c24fc84d77bf8b76d3b2bb4ce8 |
| service_name | cinder |
| service_type | volume |
| url | http://controller:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | a9a29e4b97b541bba1a15f4269a32e7b |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | c6c201b61fe7410a8926ba200866468c |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | 8f80dc7e8c7142d88d40b55461a160bc |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | c6c201b61fe7410a8926ba200866468c |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | dbcc255d77d14953811280615f13a725 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | c6c201b61fe7410a8926ba200866468c |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------+
5.安装软件包
[root@controller ~]# yum install openstack-cinder -y
6.编辑cinder.conf配置文件
[root@controller ~]# cat /etc/cinder/cinder.conf
[DEFAULT]
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 192.168.100.10
[BACKEND]
[BRCD_FABRIC_EXAMPLE]
[CISCO_FABRIC_EXAMPLE]
[COORDINATION]
[FC-ZONE-MANAGER]
[KEYMGR]
[cors]
[cors.subdomain]
[database]
connection = mysql+pymysql://cinder:000000@controller/cinder
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = demo
user_domain_name = demo
project_name = service
username = cinder
password = 000000
[matchmaker_redis]
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
[oslo_messaging_amqp]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = 000000
[oslo_middleware]
[oslo_policy]
[oslo_reports]
[oslo_versionedobjects]
[ssl]
7.同步信息到数据库
[root@controller ~]# su -s /bin/sh -c "cinder-manage db sync" cinder
8.nova.conf配置
[root@controller ~]# openstack-config --set /etc/nova/nova.conf cinder os_region_name RegionOne
9.重启nova-api服务,启动块存储服务
[root@controller ~]# systemctl restart openstack-nova-api.service
[root@controller ~]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
[root@controller ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
10.验证
[root@controller ~]# cinder service-list
+------------------+------------+------+---------+-------+------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+------------+------+---------+-------+------------+-----------------+
| cinder-scheduler | controller | nova | enabled | up | - | - |
+------------------+------------+------+---------+-------+------------+-----------------+
compute节点
1.安装lvm
[root@compute ~]# yum install -y lvm2
[root@compute ~]# systemctl start lvm2-lvmetad.service
[root@compute ~]# systemctl enable lvm2-lvmetad.service
2.添加两块硬盘 30+10G
[root@compute ~]# echo '- - -' > /sys/class/scsi_host/host0/scan
#若执行之后无法显示新添加的硬盘,直接reboot重启
[root@compute ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
[root@compute ~]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created
[root@compute ~]# vgcreate cinder-ssd /dev/sdb
Volume group "cinder-ssd" successfully created
[root@compute ~]# vgcreate cinder-sata /dev/sdc
Volume group "cinder-sata" successfully created
3.修改lvm.conf
[root@compute ~]# vi /etc/lvm/lvm.conf
#添加过滤器,只接受sdb、sdbc设备,拒绝其他设备
filter = [ "a/sdb/", "a/sdc/","r/.*/"]
[root@compute ~]# systemctl restart lvm2-lvmetad.service
4.安装块存储
[root@compute ~]# yum install openstack-cinder targetcli python-keystone -y
5.编辑cinder.conf
[root@compute ~]# cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf_bak
[root@compute ~]# grep -Ev '^$|#' /etc/cinder/cinder.conf_bak > /etc/cinder/cinder.conf
[root@compute ~]# cat /etc/cinder/cinder.conf
[DEFAULT]
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 192.168.100.20
glance_api_servers = http://controller:9292
enabled_backends = ssd,sata
[BACKEND]
[BRCD_FABRIC_EXAMPLE]
[CISCO_FABRIC_EXAMPLE]
[COORDINATION]
[FC-ZONE-MANAGER]
[KEYMGR]
[cors]
[cors.subdomain]
[database]
connection = mysql+pymysql://cinder:000000@controller/cinder
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = demo
user_domain_name = demo
project_name = service
username = cinder
password = 000000
[matchmaker_redis]
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
[oslo_messaging_amqp]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = 000000
[oslo_middleware]
[oslo_policy]
[oslo_reports]
[oslo_versionedobjects]
[ssl]
[ssd]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-ssd
iscsi_protocol = iscsi
iscsi_helper = lioadm
volume_backend_name = ssd
[sata]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-sata
iscsi_protocol = iscsi
iscsi_helper = lioadm
volume_backend_name = sata
6.启动块存储服务
[root@compute ~]# systemctl start openstack-cinder-volume.service target.service
[root@compute ~]# systemctl enableopenstack-cinder-volume.service target.service
7.验证
[root@controller ~]# cinder service-list
+------------------+--------------+------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+--------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler | controller | nova | enabled | up | 2020-04-10T18:08:36.000000 | - |
| cinder-volume | compute@sata | nova | enabled | up | 2020-04-10T18:08:36.000000 | - |
| cinder-volume | compute@ssd | nova | enabled | up | 2020-04-10T18:08:35.000000 | - |
+------------------+--------------+------+---------+-------+----------------------------+-----------------+
配置NFS网络存储作为cinder的后端存储
1.配置cinder.conf
[DEFAULT]
enabled_backends = ssd,sata #改为enabled_backends = nfs
state_path = /var/lib/cinder
[ssd]
#volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
#volume_group = cinder-ssd
#iscsi_protocol = iscsi
#iscsi_helper = lioadm
#volume_backend_name = ssd
[sata]
#volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
#volume_group = cinder-sata
#iscsi_protocol = iscsi
#iscsi_helper = lioadm
#volume_backend_name = sata
添加以下内容
[nfs]
volume_driver = cinder.volume.drivers.nfs.NfsDriver
nfs_shares_config = /etc/cinder/nfs_shares
volume_backend_name = nfs
nfs_mount_point_base = $state_path/mnt
2.配置连接信息
[root@compute ~]# vi/etc/cinder/nfs_shares
controller:/data
3.安装nfs服务端(controller节点)
[root@controller ~]# yum install -y nfs
[root@controller ~]# mkdir /data
[root@controller ~]# cat /etc/exports
/data 192.168.100.0/24(rw,async,no_root_squash,no_all_squash)
[root@controller ~]# systemctl restart nfs-server.service rpcbind.service
4.重启cinder服务
[root@compute ~]# systemctl restart openstack-cinder-volume.service target.service
5.检查
[root@compute01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 48G 2.6G 46G 6% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 12M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sr0 4.3G 4.3G 0 100% /mnt
tmpfs 394M 0 394M 0% /run/user/0
192.168.100.10:/data 48G 3.0G 45G 7% /var/lib/cinder/mnt/03e05619a76484935c504e586074a354
[root@controller ~]# cinder service-list
+------------------+--------------+------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+--------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler | controller | nova | enabled | up | 2020-04-10T18:33:36.000000 | - |
| cinder-volume | compute@nfs | nova | enabled | up | 2020-04-10T18:14:59.000000 | - |
| cinder-volume | compute@sata | nova | enabled | down | 2020-04-10T18:14:46.000000 | - |
| cinder-volume | compute@ssd | nova | enabled | down | 2020-04-10T18:14:46.000000 | - |
| cinder-volume | controller | nova | enabled | up | 2020-04-10T18:15:14.000000 | - |
+------------------+--------------+------+---------+-------+----------------------------+-----------------+
#cinder后端存储要修改的主要参数:
修改cinder.conf
volume_driver=xxx
volume_backend_name=xxx-Storage
更多推荐
已为社区贡献8条内容
所有评论(0)