NFS作为glance存储后端

NFS是网络文件系统

NFS主要由这两个组件(工具)构成(大意)

服务端布置:

查看是否安装 (centos7默认拥有此服务)

rpm -qa |grep nfs-utils

rpm -qa |grep rpcbind

创建共享目录

mkdir 共享目录

修改NFS的配置文件/etc/exports,其默认里面是没有内容的

共享目录(空格)    哪个网段接收(如10.26.0.0/16)(跟着写不要空格)(可读写rm,no_root_squash(root具有完全权限),no_all_squash(保留共享文件的用户id组id),sync(同时写入硬盘和内存),anonuid=501(匿名用户的uid,自行设置),anongid=501(匿名用户的gid,自行设置)

 

/opt/nfs 10.26.0.0/16(rw,no_root_squash,no_all_squash,sync,anonuid=501,anongid=501)

修改完重载文件

exportfs -r不重启就能重载文件NFS配置文件

重启服务

systemctl start nfs-utils

systemctl start rpcbind

查看可挂载目录

showmount -e 做nfs服务节点ip ,显示结果如下:

Export list for 10.26.10.9:
/opt/nfs 10.26.0.0/16

-e很重要,没有显示不出来具体是哪个目录作为的共享目录

[root@nfs-server ~]# showmount 10.26.10.9
Hosts on 10.26.10.9:

客户端布置:

查看是否安装服务 (centos7默认拥有此服务)

rpm -qa |grep nfs-utils

 

rpm -qa |grep rpcbind

挂载,因为NFS要作为glance后端存储,Glance存储的是镜像,所以要知道镜像存放在哪个目录,/var/lib/glance/images/

mount nfs服务的ip:共享目录  /var/lib/glance/images/

查看挂载

df -h

在做完挂载操作后,此时Glance服务还不能正常使用,若使用glance image-create命令上传镜像的话,会报错,因为此时images目录的用户与用户组不是glance,而是root,需要把images目录的用户与用户组进行修改

 

[root@controller ~]# cd /var/lib/glance/
[root@controller glance]# chown glance:glance images/
[root@controller glance]# ll
total 0
drwxr-xr-x. 2 glance glance 6 Feb  9 05:56 images

 

这个时候,Glance服务就可以正常使用了,使用cirros镜像进行测试,将cirros-0.3.4-x86_64-disk.img上传至Controller节点,并上传,命令如下:

 
[root@controller ~]# curl -O  http://mirrors.douxuedu.com/competition/cirros-0.3.4-x86_64-disk.img
[root@controller ~]# source /etc/keystone/admin-openrc.sh 
[root@controller ~]# glance image-create --name cirros --disk-format qcow2 --container-format bare --progress < cirros-0.3.4-x86_64-disk.img 
[=============================>] 100%
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6     |
| container_format | bare                                 |
| created_at       | 2022-02-09T06:22:39Z                 |
| disk_format      | qcow2                                |
| id               | a59c327b-0c0d-44e7-a0f2-f9d53761c2b4 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | cirros                               |
| owner            | 55b50cbb4dd4459b873cb15a8b03db43     |
| protected        | False                                |
| size             | 13287936                             |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2022-02-09T06:22:40Z                 |
| virtual_size     | None                                 |
| visibility       | shared                               |
+------------------+--------------------------------------+

可以看到上传镜像成功。查看images目录下的文件,命令如下:

 
[root@controller ~]# ll /var/lib/glance/images/
total 12980
-rw-r-----. 1 glance glance 13287936 Feb  9 06:22 a59c327b-0c0d-44e7-a0f2-f9d53761c2b4

然后回到nfs-server节点,查看/mnt/test下的文件,命令如下:

 
[root@nfs-server ~]# ll /mnt/test/
total 12980
-rw-r-----. 1 161 161 13287936 Feb  9 06:22 a59c327b-0c0d-44e7-a0f2-f9d53761c2b4

文件的ID相同,验证NFS作为Glance镜像服务的后端存储成功。

 

posted @ 2022-10-01 18:11  王静WJ  阅读(286)  评论(0)    收藏  举报