1.部署配置流程
1.安装nfs服务端
- 可以新增一个节点,或直接使用计算节点,因为存储节点上已经有lvm了
- 这里直接
使用计算节点
来安装
yum install nfs-utils -y
2.修改配置
vi /etc/exports
# 要共享的目录 允许的网络1(操做权限) 允许的网络2(操做权限) ...
/data 192.168.200.0/24(rw,async,no_root_squash,no_all_squash) 192.168.100.0/24(rw,async,no_root_squash,no_all_squash)
- 创建共享目录
mkdir /data
3.启动服务
systemctl enable rpcbind
systemctl enable nfs
systemctl restart rpcbind
systemctl restart nfs
4.控制节点安装nfs客户端
- 1.安装
yum install nfs-utils.x86_64 -y
- 2.验证
[root@controller ~]# showmount -e 192.168.100.20
# showmount -e compute
# showmount -e 192.168.200.20
Export list for 192.168.100.20:
/data 192.168.100.0/24,192.168.200.0/24
5.存储节点修改配置文件
- 1.修改
/etc/cinder/cinder.conf
[DEFAULT]
# 最开始只有lvm
enabled_backends = lvm,nfs
# 增加一个nfs的配置
[nfs]
volume_driver = cinder.volume.drivers.nfs.NfsDriver
# 指定nfs挂载路径
nfs_shares_config = /etc/cinder/nfs_shares
volume_backend_name = nfs
- 2.新建
vi /etc/cinder/nfs_shares
文件,内容如下
# 效果:mount -t nfs 192.168.200.20:/data /etc/cinder/nfs_shares
192.168.200.20:/data
compute:/data
- 3.重启
cinder-volume
服务
systemctl restart openstack-cinder-volume.service
6.检查是否配置成功
- 在控制节点执行以下命令,如果出现
block@nfs
,状态为up
即表示成功
[root@controller ~]# cinder service-list
+------------------+------------+------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler | controller | nova | enabled | up | 2023-01-09T19:10:40.000000 | - |
| cinder-volume | block@lvm | nova | enabled | up | 2023-01-09T19:10:20.000000 | - |
| cinder-volume | block@nfs | nova | enabled | up | 2023-01-09T19:10:11.000000 | - |
+------------------+------------+------+---------+-------+----------------------------+-----------------+
2.创建nfs类型的卷
- 存储节点查看详情
[root@block ~]# df -h
Filesystem Size Used Avail Use% Mounted on
192.168.200.20:/data 56G 1.6G 55G 3% /var/lib/cinder/mnt/6cb62e47ea772e32b455a494d80cb65f
[root@block ~]# ll -h /var/lib/cinder/mnt/6cb62e47ea772e32b455a494d80cb65f
total 0
-rw-rw-rw- 1 root root 1.0G Jan 10 04:22 volume-4799890d-9469-4239-9259-2fd5e9cf1975
- 计算节点(部署了nfs服务)
[root@compute ~]# ll -h /data/volume-4799890d-9469-4239-9259-2fd5e9cf1975
-rw-rw-rw- 1 root root 1.0G Jan 10 04:22 /data/volume-4799890d-9469-4239-9259-2fd5e9cf1975
[root@compute ~]# qemu-img info /data/volume-4799890d-9469-4239-9259-2fd5e9cf1975
image: /data/volume-4799890d-9469-4239-9259-2fd5e9cf1975
file format: raw
virtual size: 1.0G (1073741824 bytes)
disk size: 0
3.将nfs类型的卷挂给实例
- 进入虚机,可以看到刚刚挂在的卷:vdb
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 1G 0 disk
`-vda1 253:1 0 1011.9M 0 part /
vdb 253:16 0 1G 0 disk
- 格式化磁盘
$ mkfs.ext4 /dev/vdb
- 将/dev/vdb挂载到
/mnt
下
$ mount /dev/vdb /mnt
$ df -h
Filesystem Size Used Available Use% Mounted on
/dev 242.3M 0 242.3M 0% /dev
/dev/vda1 23.2M 18.0M 4.0M 82% /
tmpfs 245.8M 0 245.8M 0% /dev/shm
tmpfs 200.0K 68.0K 132.0K 34% /run
/dev/vdb 1007.9M 33.3M 923.4M 3% /mnt
- 在
/mnt
目录下创建一个文件
$ cd /mnt
$ echo This is a test >> test.txt
$ ls
lost+found test.txt
4.在计算节点(部署了nfs服务)查看挂在的nfs卷信息
- 1.将
/data
目录下的nfs类型的存储卷,挂在到/srv
路径下
[root@compute ~]# mount -o loop /data/volume-4799890d-9469-4239-9259-2fd5e9cf1975 /srv
- 2.进入
/srv
,查看刚刚创建的文件是否能展示出来
[root@compute ~]# cd /srv
[root@compute srv]# ls
lost+found test.txt