這篇文章是延伸inode用完了的問題.
延伸原因產生原因:
glusterfs 本身高可用性,集合分散空間,self-health,但正因為如此,
如果對檔案的操作是在server端,則不會同步到其他的node,
並且glusterfs server端用來控管文件的hardlink也不會對應變動. (.glusterfs folder內的資料)
所以乍看之下是刪除了,但實際上並非如此,所有的資料都還在.glusterfs中,
按照官方文件所說,過陣子資料就會自動回復到未刪除的情況了.(但這方面似乎只有少數資料有自動回復,很多資料沒有回復)
以下以一個檔案說明:
------檔案對應到.glusterfs的gfid
[root@xxx]# getfattr -m . -d -e hex 02/01.log
# file: 02/01.log
trusted.afr.datavol-client-0=0x000000000000000000000000
trusted.afr.datavol-client-1=0x000000000000000000000000
trusted.afr.dirty=0x000000000000000000000000
trusted.gfid=0x6b9e5b80252541c78bf0098e31bed467
=>這個gfid對應到 .glusterfs/6b/9e/6b9e5b80-2525-41c7-8bf0-098e31bed467
-----從fs-node-1刪除前
[root@oooo]# stat 6b9e5b80-2525-41c7-8bf0-098e31bed467
File: `6b9e5b80-2525-41c7-8bf0-098e31bed467'
Size: 864505 Blocks: 1712 IO Block: 4096 regular file
Device: 811h/2065d Inode: 636785 Links: 2
Access: (0664/-rw-rw-r--) Uid: ( 48/ UNKNOWN) Gid: ( 48/ UNKNOWN)
Access: 2016-02-25 10:33:57.774854711 +0800
Modify: 2015-02-01 23:58:52.369337000 +0800
Change: 2016-02-25 10:08:02.221287906 +0800
-----從fs-node-1刪除02/01.log後
[root@oooo]# stat 6b9e5b80-2525-41c7-8bf0-098e31bed467
File: `6b9e5b80-2525-41c7-8bf0-098e31bed467'
Size: 864505 Blocks: 1712 IO Block: 4096 regular file
Device: 811h/2065d Inode: 636785 Links: 1 (檔案還是在的,先前刪除的只是link)
Access: (0664/-rw-rw-r--) Uid: ( 48/ UNKNOWN) Gid: ( 48/ UNKNOWN)
Access: 2016-02-25 10:33:57.774854711 +0800
Modify: 2015-02-01 23:58:52.369337000 +0800
Change: 2016-02-25 10:45:58.237298561 +0800
------從fs-node-1刪除後,fs-node-2狀態不變,沒有同步過去
[root@oxox]# stat 6b9e5b80-2525-41c7-8bf0-098e31bed467
File: `6b9e5b80-2525-41c7-8bf0-098e31bed467'
Size: 864505 Blocks: 1712 IO Block: 4096 regular file
Device: 811h/2065d Inode: 1161137 Links: 2
Access: (0664/-rw-rw-r--) Uid: ( 48/ UNKNOWN) Gid: ( 48/ UNKNOWN)
Access: 2016-02-25 10:09:31.966806293 +0800
Modify: 2015-02-01 23:58:52.369337919 +0800
Change: 2016-02-25 10:08:02.223209402 +0800
問題如何解
1. 重作glusterfs :
搬完檔案 -> fs-node-2 停止&移出 glusterfs -> fs-node-2 格式化磁碟
-> 再次加入glusterfs 同步 fs-node-1 ->
-> fs-node-1 停止&移出 glusterfs -> fs-node-1 格式化磁碟
-> 再次加入glusterfs 同步 fs-node-2
==>> 但不能確定能有用,同步時.glusterfs不知道會不會檢查link有被刪除,並且不知道會不會同步.glusterfs (我沒驗證過,但應該可行)
2. 加硬碟至brick
這邊沒辦法把原本node-1和node-2的磁碟加大,因為它們的類型不是lvm
那麼就是新增brick到glusterfs,因為目前gluterfs replica count = 2,
所以新增的bricks會自動轉成distributed的用途,
對應目前的結構最好是新增兩個64G 的磁碟,
直接放在node-1和node-2,在加入glusterfs
參考 Gluster_3.1:_Expanding_Volumes
3. 找出.glusterfs 中哪些資料是必須刪除的
特點是沒有link到其他地方,並且其 stat找出來的links 為1
其中有幾個folder是必須避開的
參考 https://www.gluster.org/pipermail/gluster-users/2014-March/016726.html
作法2就是不管既有問題,給他更大的空間讓服務存到那邊去.(太鴕鳥了 PASS
作法1太廢工,等於重作了,並且能否有效不是很確定,要實作才知道. (PASS
所以就嘗試作法3.
fs-node-1 & fs-node-2
找出那些Links為1,且不是連結(->)的檔案,記錄在gfs_garbage內
find /Path/.glusterfs -path "/Path/.glusterfs/indices" -prune -o -path "/Path/.glusterfs/landfill" -prune -o -path "/Path/.glusterfs/changelogs" -prune -o -path "/Path/.glusterfs/health_check" -prune -o -path "/Path/.glusterfs/Spay.db" -prune -o -links 1 -ls | grep -v ' -> ' > gfs_garbage
參考unix-how-to-delete-files-listed-in-a-file
分別對node-1與node-2內的gfs_garbage作處理,只截取檔案的絕對路徑
./handle_file.sh gfs_garbage | awk -F " " '{ print $11 }' >> gfs_garbage_simple
其中handle_file.sh
#!/bin/bash
READFILE=$1
while read line; do
echo "$line";
done < $READFILE
接著逐行刪除gfs_garbage_simple記錄的檔案,
xargs rm -f < gfs_garbage_simple
檢查,完成,在另一個node上,重複相同步驟
df -ih