解锁高效存储管理:OpenStack Cinder与NFS的完美结合

这篇具有很好参考价值的文章主要介绍了解锁高效存储管理:OpenStack Cinder与NFS的完美结合。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

OpenStack Cinder 对接 NFS 后端存储

准备好磁盘

[root@cloud ~]# fdisk /dev/nvme0n3

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x1d9ab064.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):

Using default response p.
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039):

Created a new partition 1 of type 'Linux' and of size 20 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[root@cloud ~]# fdisk -l
Disk /dev/nvme0n1: 40 GiB, 42949672960 bytes, 83886080 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
Disklabel type: dos
Disk identifier: 0x9243f6eb

Device         Boot    Start      End  Sectors  Size Id Type
/dev/nvme0n1p1 *        2048  1026047  1024000  500M 83 Linux
/dev/nvme0n1p2       1026048 17803263 16777216    8G 82 Linux swap / Solaris
/dev/nvme0n1p3      17803264 83886079 66082816 31.5G 83 Linux


Disk /dev/nvme0n2: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0x87cd3c01

Device         Boot Start      End  Sectors Size Id Type
/dev/nvme0n2p1       2048 41943039 41940992  20G 83 Linux


Disk /dev/nvme0n3: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0x1d9ab064

Device         Boot Start      End  Sectors Size Id Type
/dev/nvme0n3p1       2048 41943039 41940992  20G 83 Linux

[root@cloud ~]# mkfs.xfs /dev/nvme0n3p1
meta-data=/dev/nvme0n3p1         isize=512    agcount=4, agsize=1310656 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=5242624, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0


[root@cloud ~]# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  1.9G     0  1.9G   0% /dev
tmpfs          tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs          tmpfs     2.0G   10M  2.0G   1% /run
tmpfs          tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/nvme0n1p3 xfs        32G   13G   20G  39% /
/dev/nvme0n1p1 ext4      477M  171M  278M  39% /boot
tmpfs          tmpfs     392M  1.2M  391M   1% /run/user/42
tmpfs          tmpfs     392M  4.6M  387M   2% /run/user/0
/dev/sr0       iso9660   7.7G  7.7G     0 100% /run/media/root/CentOS-8-2-2004-x86_64-dvd
/dev/nvme0n3p1 xfs        20G  175M   20G   1% /nfs_share

配置NFS服务

安装NFS

查询是否安装

[root@cloud ~]# rpm -qa |grep nfs
sssd-nfs-idmap-2.2.3-20.el8.x86_64
libnfsidmap-2.3.3-31.el8.x86_64
nfs-utils-2.3.3-31.el8.x86_64

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

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

启动NFS服务

[root@cloud ~]# systemctl start nfs-server.service
[root@cloud ~]# systemctl enable nfs-server.service
Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service → /usr/lib/systemd/system/nfs-server.service.
[root@cloud ~]# systemctl status nfs-server.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)
   Active: active (exited) since Thu 2023-08-17 18:56:44 CST; 11s ago
 Main PID: 2486 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 24696)
   Memory: 0B
   CGroup: /system.slice/nfs-server.service

Aug 17 18:56:44 cloud systemd[1]: Starting NFS server and services...
Aug 17 18:56:44 cloud systemd[1]: Started NFS server and services.

关闭防火墙及SELinux

[root@cloud ~]# setenforce 0
[root@cloud ~]# vim /etc/selinux/config
[root@cloud ~]# 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
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


[root@cloud ~]# systemctl stop firewalld.service
[root@cloud ~]# systemctl disable firewalld.service

创建共享目录

[root@cloud ~]# mkdir /nfs_share
[root@cloud ~]# mount /dev/nvme0n3p1 /nfs_share/
[root@cloud ~]# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  1.9G     0  1.9G   0% /dev
tmpfs          tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs          tmpfs     2.0G   10M  2.0G   1% /run
tmpfs          tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/nvme0n1p3 xfs        32G   13G   20G  39% /
/dev/nvme0n1p1 ext4      477M  171M  278M  39% /boot
tmpfs          tmpfs     392M  1.2M  391M   1% /run/user/42
tmpfs          tmpfs     392M  4.6M  387M   2% /run/user/0
/dev/sr0       iso9660   7.7G  7.7G     0 100% /run/media/root/CentOS-8-2-2004-x86_64-dvd
/dev/nvme0n3p1 xfs        20G  175M   20G   1% /nfs_share
[root@cloud ~]# chmod 777 -R /nfs_share/

修改配置文件

[root@cloud ~]# vim /etc/exports
[root@cloud ~]# cat /etc/exports
/nfs_share 192.168.129.0/24(rw)

重启服务

[root@cloud ~]# systemctl restart nfs-server.service

客户端测试挂载

使用控制节点测试挂载

[root@controller ~]# rpm -qa | grep nfs
libnfsidmap-2.3.3-59.el8.x86_64
sssd-nfs-idmap-2.9.1-1.el8.x86_64
nfs-utils-2.3.3-59.el8.x86_64
[root@controller ~]# systemctl start nfs-utils.service 
[root@controller ~]# mkdir /nfs_test
[root@controller ~]# mount -t nfs 192.168.129.141:/nfs_share /nfs_test
[root@controller ~]# df -Th
Filesystem                 Type      Size  Used Avail Use% Mounted on
devtmpfs                   devtmpfs  1.9G     0  1.9G   0% /dev
tmpfs                      tmpfs     1.9G  4.0K  1.9G   1% /dev/shm
tmpfs                      tmpfs     1.9G   26M  1.9G   2% /run
tmpfs                      tmpfs     1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/nvme0n1p3             xfs        92G  5.8G   86G   7% /
/dev/nvme0n1p1             xfs       794M  193M  602M  25% /boot
/dev/loop0                 ext4      1.9G   28K  1.7G   1% /srv/node/swiftloopback
tmpfs                      tmpfs     390M     0  390M   0% /run/user/0
192.168.129.141:/nfs_share nfs4       20G  175M   20G   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 nfs_test]# umount /nfs_test 

控制节点配置NFS共享

创建文件并配置

[root@controller ~]# vim /etc/cinder/nfs_share
[root@controller ~]# cat /etc/cinder/nfs_share
192.168.129.141:/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 204
-rw-r-----. 1 root   cinder   2391 Apr 27  2022 api-paste.ini
-rw-r-----. 1 root   cinder 189072 Aug  6 15:28 cinder.conf
-rw-r-----  1 root   cinder     27 Aug 17 17:33 nfs_share
-rw-r-----. 1 root   cinder    659 Apr 27  2022 resource_filters.json
-rw-r-----. 1 root   cinder    991 Apr 27  2022 rootwrap.conf
drwxr-xr-x. 2 root   root       30 Aug  6 15:24 rootwrap.d
drwxr-xr-x. 2 cinder root        6 Apr 27  2022 volumes

创建新的后端定义

增加NFS后端定义

修改参数 enabled_backends

## 修改之前建议先备份文件
[root@controller ~]# cp /etc/cinder/cinder.conf  /etc/cinder/cinder.conf.bak
[root@controller ~]# vim /etc/cinder/cinder.conf 

436 enabled_backends=lvm,nfs

增加NFS后端参数

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


5261 [lvm]
5262 volume_backend_name=lvm
5263 volume_driver=cinder.volume.drivers.lvm.LVMVolumeDriver
5264 target_ip_address=192.168.129.185
5265 target_helper=lioadm
5266 volume_group=cinder-volumes
5267 volumes_dir=/var/lib/cinder/volumes
5268 
5269 [nfs]
5270 nfs_shares_config = /etc/cinder/nfs_share
5271 volume_driver = cinder.volume.drivers.nfs.NfsDriver
5272 volume_backend_name = nfsbackend

重启卷服务

[root@controller ~]# source keystonerc_admin 
[root@controller ~(keystone_admin)]# systemctl restart openstack-cinder-*

创建云硬盘类型

创建云硬盘类型

[root@controller ~(keystone_admin)]# cinder type-create nfstype
+--------------------------------------+---------+-------------+-----------+
| ID                                   | Name    | Description | Is_Public |
+--------------------------------------+---------+-------------+-----------+
| eb057bfe-8a7a-4a84-a9f7-6da60b44ce00 | nfstype | -           | True      |
+--------------------------------------+---------+-------------+-----------+
[root@controller ~(keystone_admin)]# cinder type-list
+--------------------------------------+-------------+---------------------+-----------+
| ID                                   | Name        | Description         | Is_Public |
+--------------------------------------+-------------+---------------------+-----------+
| 3a808ce2-ba85-4748-aa65-215c44539818 | iscsi       | -                   | True      |
| b54b4912-3d9a-47cc-a434-b760a74f60cc | __DEFAULT__ | Default Volume Type | True      |
| eb057bfe-8a7a-4a84-a9f7-6da60b44ce00 | nfstype     | -                   | True      |
+--------------------------------------+-------------+---------------------+-----------+

设置后端名称

[root@controller ~(keystone_admin)]# cinder type-key nfstype set volume_backend_name=nfsbackend
[root@controller ~(keystone_admin)]# cinder type-show nfstype
+---------------------------------+--------------------------------------+
| Property                        | Value                                |
+---------------------------------+--------------------------------------+
| description                     | None                                 |
| extra_specs                     | volume_backend_name : nfsbackend     |
| id                              | eb057bfe-8a7a-4a84-a9f7-6da60b44ce00 |
| is_public                       | True                                 |
| name                            | nfstype                              |
| os-volume-type-access:is_public | True                                 |
| qos_specs_id                    | None                                 |
+---------------------------------+--------------------------------------+

创建云硬盘

使用 NFS 类型创建云硬盘

[root@controller ~(keystone_admin)]# source keystonerc_cloud01 
[root@controller ~(keystone_cloud01)]# cinder create --display-name evs01 --volume-type nfstype 2
+------------------------------+--------------------------------------+
| Property                     | Value                                |
+------------------------------+--------------------------------------+
| attachments                  | []                                   |
| availability_zone            | nova                                 |
| bootable                     | false                                |
| consistencygroup_id          | None                                 |
| created_at                   | 2023-08-17T10:23:33.000000           |
| description                  | None                                 |
| encrypted                    | False                                |
| group_id                     | None                                 |
| id                           | 360aed1c-76f1-4640-9870-de9a3fbd5647 |
| metadata                     | {}                                   |
| multiattach                  | False                                |
| name                         | evs01                                |
| os-vol-tenant-attr:tenant_id | 1e3e8546921043b19b28a8ded2f22c82     |
| replication_status           | None                                 |
| service_uuid                 | None                                 |
| shared_targets               | True                                 |
| size                         | 2                                    |
| snapshot_id                  | None                                 |
| source_volid                 | None                                 |
| status                       | creating                             |
| updated_at                   | None                                 |
| user_id                      | a662677ef7474ba1b654a3460190f306     |
| volume_type                  | nfstype                              |
+------------------------------+--------------------------------------+

尝试挂载给主机

[root@controller ~(keystone_cloud01)]# cinder list
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID                                   | Status    | Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| 360aed1c-76f1-4640-9870-de9a3fbd5647 | available | evs01 | 2    | nfstype     | false    |             |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
[root@controller ~(keystone_cloud01)]# nova list
+--------------------------------------+---------+--------+------------+-------------+------------------------+
| ID                                   | Name    | Status | Task State | Power State | Networks               |
+--------------------------------------+---------+--------+------------+-------------+------------------------+
| 5ce35ff8-aa1f-4459-a5a6-50c7c3ea05bc | Linux01 | ACTIVE | -          | Running     | private=192.168.88.146 |
+--------------------------------------+---------+--------+------------+-------------+------------------------+
[root@controller ~(keystone_cloud01)]# nova volume-attach Linux01 360aed1c-76f1-4640-9870-de9a3fbd5647
+-----------------------+--------------------------------------+
| Property              | Value                                |
+-----------------------+--------------------------------------+
| delete_on_termination | False                                |
| device                | /dev/vdb                             |
| id                    | 360aed1c-76f1-4640-9870-de9a3fbd5647 |
| serverId              | 5ce35ff8-aa1f-4459-a5a6-50c7c3ea05bc |
| tag                   | -                                    |
| volumeId              | 360aed1c-76f1-4640-9870-de9a3fbd5647 |
+-----------------------+--------------------------------------+

V版可能存在一些bug,不对接也可以直接创建成功。文章来源地址https://www.toymoban.com/news/detail-672194.html

  • END

到了这里,关于解锁高效存储管理:OpenStack Cinder与NFS的完美结合的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 华为HCIE学习之Openstack Cinder组件(cinder对接glusterfs)

    服务内各组件交互通过MQ进行 IET,Linux用软件做存储,CNA识别过去就是IET TGT,物理存储,CNA识别过去就是TGT cinder-api :cinder模块对外唯一接口,cinder的endpoint,接收和处理rest请求。 cinder-scheduler : 根据预定的调度过滤策略以及权重计算策略,选择出合适的后端来处理任务。

    2024年02月13日
    浏览(23)
  • glance对接nfs,cinder,swift 后端

    配置该主机为nfs的server端,将该云主机中的/mnt/test目录进行共享(目录不存在可自行创建)。然后配置controller节点为nfs的client端,要求将/mnt/test目录作为glance后端存储的挂载目录。 环境 系统 角色 ip centos7.9 nfs 10.196.110.86 centos7.9 controller 10.196.110.32 安装步骤 安装nfs服务 修改

    2024年01月19日
    浏览(26)
  • Spring Boot进阶(74):轻松实现高效SOAP服务! Spring Boot与CXF完美结合

            SOAP(简单对象访问协议)是一种基于XML的通信协议,它常用于Web服务的实现。在Java中,Apache CXF是一个流行的实现SOAP的框架,它实现了JAX-WS和JAX-RS标准。Spring Boot是一个快速开发Web应用的框架,它提供了许多自动化的配置和依赖注入的功能。在本文中,我们将要探

    2024年02月06日
    浏览(38)
  • ForkBase:结合区块链实现高效存储引擎

    ForkBase: 结合区块链实现高效存储引擎 摘要:现有的数据存储系统提供了多种的功能,以适应多样化的应用程序。然而,新的应用程序类型已经出现,例如 区块链 和协作分析, featuring data versioning, fork semantics, tamper-evidence 或它们的任意组合。它们为存储系统提供了新的机会,

    2024年02月04日
    浏览(33)
  • 从零开始搭建高效的文件服务器:FastDFS与Nginx完美结合,内网穿透实现公网访问

    目录 前言 1. 本地搭建FastDFS文件系统 1.1 环境安装 1.2 安装libfastcommon 1.3 安装FastDFS 1.4 配置Tracker 1.5 配置Storage 1.6 测试上传下载 1.7 与Nginx整合 1.8 安装Nginx 1.9 配置Nginx 2. 局域网测试访问FastDFS 3. 安装cpolar内网穿透 4. 配置公网访问地址 5. 固定公网地址 5.1 保留二级子域名 5.2 配置

    2024年02月03日
    浏览(44)
  • OpenStack介绍说明、OpenStack架构说明、OpenStack核心服务详细说明【keystone,nova,cinder,neutron...】、OpenStack创建VM,服务间交互示例

    2006年亚马逊推出AWS,正式开启云计算的新纪元 2010年7月美国国家航空航天局(NASA)与Rackspace合作,共同宣布OpenStack开放源码计划,由此开启了属于OpenStack的时代 OpenStack从诞生之初对标AWS,一直在向AWS学习,同时开放接口去兼容各种AWS服务 OpenStack是什么? OpenStack是一种云操

    2024年01月15日
    浏览(36)
  • 探秘C语言数组:解锁高效数据管理与多维空间编程技巧"

    ✨✨ 欢迎大家来到贝蒂大讲堂✨✨ 🎈🎈养成好习惯,先赞后看哦~🎈🎈 所属专栏:C语言学习 贝蒂的主页:Betty‘s blog 前面贝蒂给大家介绍了选择结构与循环结构,今天,贝蒂准备给大家介绍C语言中一个非常重要的结构——数组 数组到底是什么呢,顾名思义就是很多数的

    2024年03月09日
    浏览(40)
  • Spring Boot进阶(58):轻松搞定数据存储!Spring Boot与PostgreSQL完美集成,让你的应用更稳定更高效!

            PostgreSQL是一种广泛使用的开源关系型数据库,具有可靠性高、性能优异、拥有丰富的数据类型和扩展等优点,越来越多的企业和开发者开始使用它来存储和管理数据。而Spring Boot是一种快速开发的框架,可以简化开发过程并提高开发效率。本文将介绍如何使用Sp

    2024年02月10日
    浏览(40)
  • 【K8s】3# 使用kuboard管理K8s集群(NFS存储安装)

    最完整的学习文档莫过于官网:直达地址:Kuboard for K8S Kubernetes 对 Pod 进行调度时,以当时集群中各节点的可用资源作为主要依据,自动选择某一个可用的节点,并将 Pod 分配到该节点上。在这种情况下,Pod 中容器数据的持久化如果存储在所在节点的磁盘上,就会产生不可预

    2024年01月20日
    浏览(32)
  • 区块链:OpenDataPlatform如何与区块链结合用于数据存储和管理

    作者:禅与计算机程序设计艺术 区块链(Blockchain)近年来受到越来越多人的关注,因为其能够提供不可篡改、透明、安全、高效率的数据存证功能。随着其功能的不断完善,越来越多的创业公司都开始使用区块链技术进行数据存证及管理。然而,不同于传统互联网应用中的数据

    2024年02月12日
    浏览(39)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包