提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
针对于nfsd,通常可以在配置文件中做配置如下:
$ cat/etc/exports
/mnt/待暴露卷1 *(rw,async,no_root_squash,no_subtree_check,fsid=唯一的一个id号)
/mnt/待暴露卷2 *(rw,async,no_root_squash,no_subtree_check,fsid=唯一的一个id号)
...
就可以通过启动一个nfsd server,对外export多个挂载卷。那么,nfs-ganesha是如何做的呢?在ganesha配置文件中,添加EXPORT条目就可以。
$ df -h
Filesystem Size Used Avail Use% Mounted on
...
ceph-fuse 8.5G 0 8.5G 0% /mnt/mycephfs
$ tree /mnt/mycephfs/
/mnt/mycephfs/
├── dir1
│ └── file1
└── dir2
└── file2
2 directories, 2 files
EXPORT
{
Export_ID=100;
Protocols = 4;
Transports = TCP;
Path = /dir1;
pseudo = /cephfs1;
Access_Type = RW;
Squash = No_root_squash;
FSAL {
Name = CEPH;
Filesystem = "cephfs";
User_Id = "admin";
Secret_Access_Key = "/etc/ceph/ceph.client.admin.keyring中key值";
}
}
EXPORT
{
Export_ID=200;
Protocols = 4;
Transports = TCP;
Path = /dir2;
pseudo = /cephfs2;
Access_Type = RW;
Squash = No_root_squash;
FSAL {
Name = CEPH;
Filesystem = "cephfs";
User_Id = "admin";
Secret_Access_Key = "/etc/ceph/ceph.client.admin.keyring中key值";
}
}
选择另外一台节点,挂载export出来的目录。
$ mount -t nfs -o nfsvers=4.1,proto=tcp ganesha-IP:/cephfs2 /nfs-ganesha-cephfs2
$ mount -t nfs -o nfsvers=4.1,proto=tcp ganesha-IP:/cephfs1 /nfs-ganesha-cephfs1
$ df -h
ganesha-IP:/cephfs2 8.5G 0 8.5G 0% /nfs-ganesha-cephfs2
ganesha-IP:/cephfs1 8.5G 0 8.5G 0% /nfs-ganesha-cephfs1
$ ls /nfs-ganesha-cephfs1/
file1
$ ls /nfs-ganesha-cephfs2/
file2
$ dd if=/dev/zero of=/nfs-ganesha-cephfs1/dd1 bs=4K count=1024
1024+0 records in
1024+0 records out
4194304 bytes (4.2 MB) copied, 0.0288327 s, 145 MB/s
$ dd if=/dev/zero of=/nfs-ganesha-cephfs2/dd2 bs=4K count=1024
1024+0 records in
1024+0 records out
4194304 bytes (4.2 MB) copied, 0.0322968 s, 130 MB/s
$ tree /mnt/mycephfs/
/mnt/mycephfs/
├── dir1
│ ├── dd1
│ └── file1
└── dir2
├── dd2
└── file2
2 directories, 4 files