首页 > 其他分享 >cinder对接NFS后端存储

cinder对接NFS后端存储

时间:2022-08-30 22:00:58浏览次数:73  
标签:后端 share nfs controller NFS cinder tmpfs root

配置NFS服务

安装NFS服务

查询是否安装

[root@nfs ~]# rpm -qa |grep nfs
nfs-utils-1.3.0-0.8.el7.x86_64

如没有安装,执行以下命令

[root@nfs ~]# yum install -y nfs-utils

关闭防火墙及SELinux

[root@nfs ~]# setenforce 0
[root@nfs ~]# vi /etc/selinux/config
[root@nfs ~]# cat /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
[root@nfs ~]# systemctl stop firewalld
[root@nfs ~]# systemctl disable firewalld

创建共享目录

[root@nfs ~]# mkdir /nfs_share
[root@nfs ~]# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0   50G  0 disk 
├─sda1          8:1    0  500M  0 part /boot
└─sda2          8:2    0 49.5G  0 part 
  ├─rhel-swap 253:0    0    2G  0 lvm  [SWAP]
  └─rhel-root 253:1    0 47.5G  0 lvm  /
sdb             8:16   0   50G  0 disk 
└─sdb1          8:17   0   30G  0 part 
sr0            11:0    1  3.6G  0 rom  
[root@nfs ~]# mount /dev/sdb1 /nfs_share/
[root@nfs ~]# df -hT
Filesystem            Type      Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs        48G  1.1G   47G   3% /
devtmpfs              devtmpfs  985M     0  985M   0% /dev
tmpfs                 tmpfs     994M     0  994M   0% /dev/shm
tmpfs                 tmpfs     994M  8.4M  986M   1% /run
tmpfs                 tmpfs     994M     0  994M   0% /sys/fs/cgroup
/dev/sda1             xfs       497M  102M  395M  21% /boot
/dev/sdb1             xfs        30G   33M   30G   1% /nfs_share
[root@nfs ~]# chmod -R 777 /nfs_share/

修改配置文件

[root@nfs ~]# vi /etc/exports
[root@nfs ~]# cat /etc/exports
/nfs_share	192.168.100.0/24(rw)
## 重启服务
```bash
[root@nfs ~]# systemctl restart nfs-server.service

客户端测试挂载

使用控制节点测试挂载

[root@controller ~]# rpm -qa|grep nfs
nfs-utils-1.3.0-0.8.el7.x86_64
libnfsidmap-0.25-11.el7.x86_64
[root@controller ~]# systemctl start nfs
[root@controller ~]# mkdir /nfs_test
[root@controller ~]# mount -t nfs 192.168.100.40:/nfs_share /nfs_test
[root@controller ~]# df -hT
Filesystem                Type      Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root     xfs        50G  2.6G   48G   6% /
devtmpfs                  devtmpfs  3.9G     0  3.9G   0% /dev
tmpfs                     tmpfs     3.9G  4.0K  3.9G   1% /dev/shm
tmpfs                     tmpfs     3.9G   17M  3.9G   1% /run
tmpfs                     tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0                ext4      1.9G   22M  1.7G   2% /srv/node/swiftloopback
/dev/mapper/rhel-home     xfs        42G   33M   42G   1% /home
/dev/sda1                 xfs       497M  104M  394M  21% /boot
tmpfs                     tmpfs     3.9G   17M  3.9G   1% /run/netns
192.168.100.40:/nfs_share nfs4       30G   32M   30G   1% /nfs_test
[root@controller ~]# cd /nfs_test/
[root@controller nfs_test]# touch {a,b}{1,2}.txt
[root@controller nfs_test]# ls
a1.txt  a2.txt  b1.txt  b2.txt
[root@controller ~]# umount /nfs_test/

控制节点配置NFS共享

创建文件并配置

[root@controller ~]# vim /etc/cinder/nfs_share
[root@controller ~]# cat /etc/cinder/nfs_share 
192.168.100.40:/nfs_share

修改文件权限

[root@controller ~]# chown root:cinder /etc/cinder/nfs_share 
[root@controller ~]# chmod 0640 /etc/cinder/nfs_share 
[root@controller ~]# ll /etc/cinder/
total 96
-rw------- 1 cinder cinder  2117 Aug 30 23:17 api-paste.ini
-rw------- 1 cinder cinder 79364 Aug 30 23:17 cinder.conf
-rw-r----- 1 root   cinder    26 Aug 31 21:17 nfs_share
-rw-r----- 1 root   cinder  3200 Feb  6  2015 policy.json
-rw-r----- 1 root   cinder   942 Feb  6  2015 rootwrap.conf
drwxr-xr-x 2 cinder root       6 Feb  7  2015 volumes

创建新的后端定义

增加 NFS 后端参数

增加 nfs 后端参数,其中 lvm 默认存在,nfs 为新增

[root@controller ~]# vim /etc/cinder/cinder.conf 
[root@controller ~]# cat /etc/cinder/cinder.conf 
enabled_backends=lvm,nfs

[lvm]
iscsi_helper=lioadm
volume_group=cinder-volumes
iscsi_ip_address=192.168.100.10
volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver
volume_backend_name=lvm

[nfs]
nfs_shares_config=/etc/cinder/nfs_share  
volume_driver=cinder.volume.drivers.nfs.NfsDriver  
volume_backend_name=nfsbackend

重启卷服务

[root@controller ~]# source keystonerc_admin 
[root@controller ~(keystone_admin)]# systemctl restart openstack-cinder-scheduler.service openstack-cinder-volume.service

创建云硬盘类型

创建云硬盘类型

[root@controller ~(keystone_admin)]# cinder type-create nfstype
+--------------------------------------+---------+
|                  ID                  |   Name  |
+--------------------------------------+---------+
| fb317c86-7941-4643-ba3b-c93491a80ada | nfstype |
+--------------------------------------+---------+
[root@controller ~(keystone_admin)]# cinder type-list 
+--------------------------------------+---------+
|                  ID                  |   Name  |
+--------------------------------------+---------+
| d172a274-12e0-4d04-ad9a-8ae6bbd0060c |  iscsi  |
| fb317c86-7941-4643-ba3b-c93491a80ada | nfstype |
+--------------------------------------+---------+

设置后端名称

[root@controller ~(keystone_admin)]# cinder type-key nfstype set volume_backend_name=nfsbackend

创建云硬盘

使用 NFS 类型创建云硬盘

[root@controller ~(keystone_admin)]# source keystonerc_user 
[root@controller ~(keystone_user)]# cinder create --display-name evs01 --volume-type nfstype 2
+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|       bootable      |                false                 |
|      created_at     |      2022-08-31T13:26:38.207154      |
| display_description |                 None                 |
|     display_name    |                evs01                 |
|      encrypted      |                False                 |
|          id         | 466c3fec-1cbd-403c-89cb-9cd2aefb9b65 |
|       metadata      |                  {}                  |
|         size        |                  2                   |
|     snapshot_id     |                 None                 |
|     source_volid    |                 None                 |
|        status       |               creating               |
|     volume_type     |               nfstype                |
+---------------------+--------------------------------------+

尝试挂载给主机

[root@controller ~(keystone_user)]# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 9d31905f-6420-47e2-b75b-2b419882fa69 | available |    evs01     |  2   |   nfstype   |  false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
[root@controller ~(keystone_user)]# nova list
+--------------------------------------+-------+--------+------------+-------------+--------------------+
| ID                                   | Name  | Status | Task State | Power State | Networks           |
+--------------------------------------+-------+--------+------------+-------------+--------------------+
| 26ac424c-7417-42a7-bbbc-016c5aab0ac4 | ecs01 | ACTIVE | -          | Running     | pri2=192.168.200.4 |
+--------------------------------------+-------+--------+------------+-------------+--------------------+
[root@controller ~(keystone_user)]# nova volume-attach ecs01 9d31905f-6420-47e2-b75b-2b419882fa69
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdb                             |
| id       | 9d31905f-6420-47e2-b75b-2b419882fa69 |
| serverId | 26ac424c-7417-42a7-bbbc-016c5aab0ac4 |
| volumeId | 9d31905f-6420-47e2-b75b-2b419882fa69 |
+----------+--------------------------------------+

标签:后端,share,nfs,controller,NFS,cinder,tmpfs,root
From: https://www.cnblogs.com/kongshuo/p/16640943.html

相关文章

  • Linux的NFS的配置
    快速代码#nfs的Server配置文件和配置方法echo'/newnfs192.168.3.*rw,sync,no_root_squash)'>>/etc/exports#根目录新建文件夹,权限777mkdir/newnfs&&chmod77......
  • 后端程序员生产力工具合集
    后端程序员除了写代码,也难免要写设计文档,画各种图。因此掌握各种生产力工具,是很有必要的,可以达到事半功倍的效果。下面结合楼主亲身体验,推荐一些生产力工具,欢迎探讨和补充......
  • 前后端展示时间字段
    <vxe-table-columnfield="plan_shipment_date":title="$t('IncomingInspection.要求交货时间')"min-width="100":formatter="['formatDate','yyyy-MM-ddHH:mm:ss......
  • ZOOM后端开发实习面经(2021/06/03)
    Java熟悉Java哪些部分面向对象介绍,作用继承的缺点,举例继承在什么情况下使用读过源码没,HashMap结构,什么时候扩容,加载因子,初始长度,扩容流程为什么HashMap不安全,有哪些......
  • EvaluationSystem:后端业务接口(js同步操作数据库)
    1、用户业务接口(services/user.js)用户相关业务:注册账号登录账号查看用户信息修改个人资料2、数据业务接口(services/data.js)添加一条数据查询一条数据所有数据......
  • k8s(kubernetes)基于(NFS+PV+PVC)部署jenkins
    #部署流程:(系统:centos7.9)一、设置存储目录1、安装NFS服务端2、挂载NFS并设置存储文件夹二、创建PV&PVC1、准备PV&PVC部署文件2、创建PV&PVC......
  • Centos7下NFS服务搭建详细介绍
    目录一、服务端二、客户端 三、测试服务一、服务端1.用YUM源下载NFS相关服务 2.创造共享目录并在NFS相关配置文件写入共享目录 3.使用exportfs使设置立......
  • 从前端获取数据发送到后端 存入数据库
    前端{%extends'home.html'%}{%blockcontant%}<h1class="center">添加图书</h1>{##method一定要加上post并先在setting里注掉中间件#}<formacti......
  • 前后端分离怎么实现?
    前后端分离,相信这是很多人都听到的一个词,那么,前后端分离怎么实现?大家理解的前后端分离指的又是什么?作为低代码研发平台,针对客户心心念念想了解的问题,今天,我们就与大家一起......
  • 运维篇 后端开发后期
          例:  taskkill-f-pid “9740”    ......