创建测试文件#
挂载 gluster 卷并创建一个文件
1
2
3
4
| [root@client-1 ~]# mount -t glusterfs gluster-node-1:/vol /mnt
[root@client-1 ~]# mkdir -p /mnt/hoge/hello-gluster/
[root@client-1 ~]# touch /mnt/hoge/hello-gluster/file
[root@client-1 ~]# umount /mnt/
|
获取 Gluster 卷内文件的 GFID#
从 brick 目录获取#
登录 gluster 节点,在 brick 目录中定位文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| [root@gluster-node-1 ~]# gluster volume info vol
Volume Name: vol
Type: Replicate
Volume ID: 4ac36bcc-7127-48c4-ac21-421850d8bc47
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 3 = 3
Transport-type: tcp,rdma
Bricks:
Brick1: gluster-node-1:/gluster/brick-vol <-- 确认 brick 路径
Brick2: gluster-node-2:/gluster/brick-vol
Brick3: gluster-node-3:/gluster/brick-vol
Options Reconfigured:
performance.readdir-ahead: on
nfs.disable: off
cluster.server-quorum-ratio: 51%
|
确认 brick 内的文件路径,通过 “trusted.gfid” 查看 GFID。
1
2
3
4
5
6
7
| [root@gluster-node-1 ~]# ls /gluster/brick-vol/hoge/hello-gluster/file
/gluster/brick-vol/hoge/hello-gluster/file
[root@gluster-node-1 ~]# getfattr -d -m . -e hex /gluster/brick-vol/hoge/hello-gluster/file
getfattr: Removing leading '/' from absolute path names
# file: gluster/brick-vol/hoge/hello-gluster/file
security.selinux=0x73797374656d5f753a6f626a6563745f723a756e6c6162656c65645f743a733000
trusted.gfid=0xd8efc4c4d6204170ad293eda97d3d2e4
|
从客户端获取#
使用 -o aux-gfid-mount
选项挂载 gluster 卷
1
| [root@gluster-node-1 ~]# mount -t glusterfs -o aux-gfid-mount gluster-node-1:/vol /mnt
|
在挂载点确认文件路径,通过 glusterfs.gfid.string
查看 GFID。
1
2
3
4
| [root@gluster-node-1 ~]# getfattr -n glusterfs.gfid.string /mnt/hoge/hello-gluster/file
getfattr: Removing leading '/' from absolute path names
# file: mnt/hoge/hello-gluster/file
glusterfs.gfid.string="d8efc4c4-d620-4170-ad29-3eda97d3d2e4"
|
GFID 转换为路径名#
使用工具#
使用 https://gist.github.com/semiosis/4392640。
注意,GFID 必须为 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 格式。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| bash gfid-resolver.sh -h
Glusterfs GFID resolver -- turns a GFID into a real file path
Usage: gfid-resolver.sh <brick-path> <gfid> [-q]
<brick-path> : the path to your glusterfs brick (required)
<gfid> : the gfid you wish to resolve to a real path (required)
-q : quieter output (optional)
with this option only the actual resolved path is printed.
without this option gfid-resolver.sh will print the GFID,
whether it identifies a file or directory, and the resolved
path to the real file or directory.
Theory:
The .glusterfs directory in the brick root has files named by GFIDs
If the GFID identifies a directory, then this file is a symlink to the
actual directory. If the GFID identifies a file then this file is a
hard link to the actual file.
[root@gluster-node-1 ~]# bash gfid-resolver.sh /gluster/brick-vol d8efc4c4-d620-4170-ad29-3eda97d3d2e4
d8efc4c4-d620-4170-ad29-3eda97d3d2e4 == File: /gluster/brick-vol/hoge/hello-gluster/file
|