此篇的調試信息和內容主要參考大神https://blog.csdn.net/a1454927420/article/details/79381134的這篇文章,進行驗證。
在繼上一篇,單機上利用docker部署ceph集群環境搭建筆記之后,我們來看一下cephfs的元數據和數據對象信息:
# 16、ceph -s命令解釋
當我們執行ceph -s的時候,其實ceph -s的全稱是:
ceph \
--name client.admin \
--keyring /etc/ceph/ceph.client.admin.keyring \
--conf /etc/ceph/ceph.conf
--cluster ceph \
-s
上面參數很好理解,Ceph內部自身使用CephX進行認證,和普通的認證沒什么區別,同樣需要用戶名和密碼進行認證,那么這里默認的用戶名就叫做client.admin,而默認的秘鑰保存位置就位於以下幾個位置任一:
/etc/ceph/ceph.client.admin.keyring
/etc/ceph/ceph.keyring
/etc/ceph/keyring
/etc/ceph/keyring.bin
一般我們選擇第一個,因為秘鑰的命名規則采用/etc/ceph/$cluster.$name.keyring也就是集群名加上用戶名再加上keyring的后綴組成。所以在我們執行ceph -s的時候,默認使用的是client.admin用戶,同時會去那四個默認位置搜索該用戶的秘鑰,如果和集群保存的認證信息一致,那么就會顯示出集群的狀態。
因為我們上面在進行docker部署的時候,這些秘鑰信息,是用的/www/這個目錄,所以我們如果想要簡單的執行ceph -s,就需要將/www/ceph/*目錄下的秘鑰文件拷貝到/etc/ceph目錄下來;
# 17、查看cephfs文件系統的元數據
當我們創建完cephfs以后(執行完步驟11以后),我們來看一下元數據池中存儲的元數據:
root@ybelzjlpa9xmngcb-0315223:~/ceph_cluster/mycephfs# rados ls -p cephfs_metadata
2021-10-26 11:14:17.865896 7f57437be700 0 monclient: hunting for new mon
mds0_openfiles.0
609.00000000
mds0_sessionmap
mds_snaptable
608.00000000
400.00000000
601.00000000
602.00000000
600.00000000
603.00000000
mds0_inotable
100.00000000
1.00000000.inode
200.00000000
200.00000001
606.00000000
604.00000000
500.00000000
607.00000000
605.00000000
100.00000000.inode
1.00000000
root@ybelzjlpa9xmngcb-0315223:~/ceph_cluster/mycephfs#
上面的展示的元數據為一個初創文件系統的元數據相關對象。
由此可知,當我們在創建cephfs文件系統后,即使不往文件系統里面寫數據,他也是會存在一些對象數據的,這部分對象保存的就是文件系統本身的元數據,對應於我們常說的superblock,根目錄的元數據,等相關信息。
這些對象里除了保存了文件系統的元數據,還用做保存cephfs日志,日志是用來恢復mds里的元數據緩存,和還沒有應用成對象的元數據。
然后我們在掛載的目錄下,創建一個新的目錄:
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# mkdir test_dir
然后再查看下文件系統的元數據:
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# rados ls -p cephfs_metadata
2021-10-26 14:13:55.415477 7fc62defc700 0 monclient: hunting for new mon
mds0_openfiles.0
609.00000000
mds0_sessionmap
mds_snaptable
608.00000000
400.00000000
601.00000000
602.00000000
600.00000000
603.00000000
mds0_inotable
100.00000000
1.00000000.inode
200.00000000
200.00000001
606.00000000
604.00000000
500.00000000
607.00000000
605.00000000
100.00000000.inode
1.00000000
//在查看一下創建目錄的inode號:
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# ll -i
total 5
1 drwxr-xr-x 1 root root 0 Oct 26 14:13 ./
915713 drwxr-xr-x 3 root root 4096 Oct 26 10:47 ../
1099511627776 drwxr-xr-x 1 root root 0 Oct 26 14:13 test_dir/
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs#
可以看到test_dir目錄的inode號為1099511627776;然后他的hex為100 0000 0000;
然后再來看一下metadata中保存的元數據:
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# rados ls -p cephfs_metadata
2021-10-26 14:27:36.970190 7f21be598700 0 monclient: hunting for new mon
mds0_openfiles.0
609.00000000
mds0_sessionmap
mds_snaptable
608.00000000
400.00000000
601.00000000
602.00000000
10000000000.00000000
600.00000000
603.00000000
mds0_inotable
100.00000000
1.00000000.inode
200.00000000
200.00000001
606.00000000
604.00000000
500.00000000
607.00000000
605.00000000
100.00000000.inode
1.00000000
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs#
可以看到多了一個10000000000.00000000的對象,這個對象就是我們剛剛創建的目錄的test_dir的元數據對象,對象的名稱為文件的inode號.偏移值,其中偏移值是在內核里切割文件時給出的。(具體怎么切割和發送數據的,且聽下回分解)
然后我們再在test_dir目錄下創建一個空文件:
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# cd test_dir/
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs/test_dir# ls
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs/test_dir#
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs/test_dir# touch test_file
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs/test_dir# ll -i
total 1
1099511627776 drwxr-xr-x 1 root root 0 Oct 26 14:35 ./
1 drwxr-xr-x 1 root root 0 Oct 26 14:13 ../
1099511627777 -rw-r--r-- 1 root root 0 Oct 26 14:35 test_file
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs/test_dir#
然后看下這個文件的元數據信息:
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs/test_dir# rados ls -p cephfs_metadata
2021-10-26 14:36:16.600448 7fc7e539a700 0 monclient: hunting for new mon
mds0_openfiles.0
609.00000000
mds0_sessionmap
mds_snaptable
608.00000000
400.00000000
601.00000000
602.00000000
10000000000.00000000
600.00000000
603.00000000
mds0_inotable
100.00000000
1.00000000.inode
200.00000000
200.00000001
606.00000000
604.00000000
500.00000000
607.00000000
605.00000000
100.00000000.inode
1.00000000
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs/test_dir#
並沒有新的元數據對象生成,即使我們上去到mds的服務器容器上強制刷新元數據:
[root@dd2f52aeb014 /]# ceph daemon /run/ceph/ceph-mds.dd2f52aeb014.asok flush journal
{
"message": "",
"return_code": 0
}
然后在看元數據對象信息,還是一樣的,跟之前,如下:
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# rados ls -p cephfs_metadata
2021-10-26 14:39:09.128725 7f7a3673f700 0 monclient: hunting for new mon
mds0_openfiles.0
609.00000000
mds0_sessionmap
mds_snaptable
608.00000000
400.00000000
601.00000000
602.00000000
10000000000.00000000
600.00000000
603.00000000
mds0_inotable
100.00000000
1.00000000.inode
200.00000000
200.00000001
606.00000000
604.00000000
500.00000000
607.00000000
605.00000000
100.00000000.inode
1.00000000
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs#
然后再創建一個test_dir2目錄,然后再看下元數據信息:
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs/test_dir# cd ..
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# mkdir test_dir2
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs#
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs#
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs#
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# ll -i
total 6
1 drwxr-xr-x 1 root root 0 Oct 26 14:38 ./
915713 drwxr-xr-x 3 root root 4096 Oct 26 10:47 ../
1099511627776 drwxr-xr-x 1 root root 0 Oct 26 14:35 test_dir/
1099511627778 drwxr-xr-x 1 root root 0 Oct 26 14:38 test_dir2/
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# rados ls -p cephfs_metadata
2021-10-26 14:39:19.046819 7ff75423c700 0 monclient: hunting for new mon
mds0_openfiles.0
609.00000000
mds0_sessionmap
mds_snaptable
608.00000000
400.00000000
601.00000000
602.00000000
10000000000.00000000
600.00000000
603.00000000
10000000002.00000000
mds0_inotable
100.00000000
1.00000000.inode
200.00000000
200.00000001
606.00000000
604.00000000
500.00000000
607.00000000
605.00000000
100.00000000.inode
1.00000000
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs#
可見,我們可以看到test_dir2和test_dir目錄的元數據,但是看不到test_dir/test_file文件的元數據。
參考(https://blog.csdn.net/a1454927420/article/details/79381134)博客的說法:
因為文件沒有下級目錄,所以沒必要單獨弄一個對象來保存元數據,只需要保存在上級目錄的元數據里面
那么我們來看下test_file的上級目錄test_dir目錄的元數據對象信息:
執行命令:
rados -p cephfs_metadata listomapvals 10000000000.00000000
元數據對象信息:
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# rados -p cephfs_metadata listomapvals 10000000000.00000000
2021-10-26 14:46:24.565441 7fd6eb8de700 0 monclient: hunting for new mon
test_file_head
value (488 bytes) :
00000000 02 00 00 00 00 00 00 00 69 02 01 d9 01 00 00 00 |........i.......|
00000010 00 00 00 06 04 cf 01 00 00 11 06 ad 01 00 00 01 |................|
00000020 00 00 00 00 01 00 00 00 00 00 00 b5 a1 77 61 07 |.............wa.|
00000030 5b af 31 a4 81 00 00 00 00 00 00 00 00 00 00 01 |[.1.............|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 02 02 18 00 |................|
00000050 00 00 00 00 40 00 01 00 00 00 00 00 40 00 05 00 |....@.......@...|
00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000070 00 00 01 00 00 00 ff ff ff ff ff ff ff ff 00 00 |................|
00000080 00 00 00 00 00 00 00 00 00 00 b5 a1 77 61 31 8d |............wa1.|
00000090 7b 31 b5 a1 77 61 31 8d 7b 31 01 00 00 00 00 00 |{1..wa1.{1......|
000000a0 00 00 03 02 28 00 00 00 00 00 00 00 00 00 00 00 |....(...........|
000000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000000d0 03 02 38 00 00 00 00 00 00 00 00 00 00 00 00 00 |..8.............|
000000e0 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 |................|
000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000100 00 00 00 00 00 00 b5 a1 77 61 07 5b af 31 03 02 |........wa.[.1..|
00000110 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |8...............|
00000120 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 |................|
00000130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000140 00 00 00 00 b5 a1 77 61 07 5b af 31 04 00 00 00 |......wa.[.1....|
00000150 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 |................|
00000160 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 |................|
00000170 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff |................|
00000180 00 00 00 00 01 01 10 00 00 00 00 00 00 00 00 00 |................|
00000190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 b5 a1 |................|
000001b0 77 61 c8 fb f4 2a 00 00 00 00 00 00 00 00 ff ff |wa...*..........|
000001c0 ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001d0 00 00 00 00 00 00 00 00 00 00 00 00 fe ff ff ff |................|
000001e0 ff ff ff ff 00 00 00 00 |........|
000001e8
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs#
我們可以看到test_dir目錄的對象里保存了子目錄和子文件的名稱和inode編號(注意:因為linux是小端模式,看內存數據得倒着看),這樣就可以建立一個文件系統數的元數據對應關系。
# 18、查看cephfs文件系統的數據池中的數據
我們在上一步中,在test_dir目錄下創建一個一個空的test_file文件,
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# ll -i test_dir
total 1
1099511627776 drwxr-xr-x 1 root root 0 Oct 26 14:35 ./
1 drwxr-xr-x 1 root root 0 Oct 26 14:38 ../
1099511627777 -rw-r--r-- 1 root root 0 Oct 26 14:35 test_file
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs#
可以看到test_file文件的inode號為1099511627777;換算成16進制hex=10000000001.00000000;
接下來我們來看下數據池中目前有那些對象數據:
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# rados ls -p cephfs_data
2021-10-26 15:04:31.269499 7f3fa6bfe700 0 monclient: hunting for new mon
10000000001.00000000
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs#
可以明顯的看到數據池中的數據,存在10000000001.00000000對象數據,他就是test_file文件的對象,所以即使是空文件,也會在數據池中有記錄。
所以不管是元數據池還是數據池,對象的名稱都為文件的inode號.偏移值。偏移值是在內核里切割文件時給出的。
然后再來看一下這個對象的數據內容:
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs# rados -p cephfs_data listomapvals 10000000001.00000000
2021-10-26 15:11:52.115247 7f0eab644700 0 monclient: hunting for new mon
root@ybelzjlpa9xmngcb-0315223:/mnt/mycephfs#
可以看到這個對象中沒有數據。
