4.GlusterFS 常見故障處理


  一般硬盤也要備用幾塊,因為隨着發展,可能這些型號的硬盤不好買到了,一般的事故不會在開始一兩年出,在硬件老化的時候出故障的頻率高。

4.1 硬盤故障

如果底層做了 RAID 配置,有硬件故障,直接更換硬盤,會自動同步數據。
如果沒有做 RAID,處理方法如下:

正常節點上執行 gluster volume status,記錄故障節點 uuid
執行:getfattr -d -m ‘.*’ /brick 記錄 trusted.gluster.volume-id 及 trusted.gfid

以下為故障模擬及修復過程:

在 VMware Workstation 上移除 mystorage1 主機的第三塊硬盤(對應 sdc /storage/brick2),相當於硬盤故障

# 系統提示如下:
Message from syslogd@linux-node01 at Jul 30 08:41:46 ...
 storage-brick2[5893]: [2016-07-30 00:41:46.729896] M [MSGID: 113075] [posix-helpers.c:1844:posix_health_check_thread_proc] 0-gv2-posix: health-check failed, going down

Message from syslogd@linux-node01 at Jul 30 08:42:16 ...
 storage-brick2[5893]: [2016-07-30 00:42:16.730518] M [MSGID: 113075] [posix-helpers.c:1850:posix_health_check_thread_proc] 0-gv2-posix: still alive! -> SIGTERM

 # 查看卷狀態,mystorage1:/storage/brick2 不在線了,不過這是分布式復制卷,還可以訪問另外 brick 上的數據
[root@mystorage1 ~]# gluster volume status gv2 
Status of volume: gv2
Gluster process                             TCP Port  RDMA Port  Online  Pid
------------------------------------------------------------------------------
Brick mystorage1:/storage/brick2            N/A       N/A        N       N/A  

在 VMware Workstation 上新增 mystorage1 一塊硬盤,相當於更換了新硬盤,下面先格式掛載新硬盤:

 
# mkfs.xfs -f /dev/sdc
# mkdir -p /storage/brick2
# mount -a
# df -h

# 新硬盤掛載后目錄為空
[root@mystorage1 ~]# ll /storage/brick2
total 0

開始手動配置新增硬盤的 gluster 參數

# 在 mystorage2 是獲取 glusterfs 相關參數:
[root@mystorage2 tmp]# getfattr -d -m '.*'  /storage/brick2
getfattr: Removing leading '/' from absolute path names
# file: storage/brick2
trusted.gfid=0sAAAAAAAAAAAAAAAAAAAAAQ==
trusted.glusterfs.dht=0sAAAAAQAAAAAAAAAAf////g==
trusted.glusterfs.dht.commithash="3168624641"
trusted.glusterfs.quota.dirty=0sMAA=
trusted.glusterfs.quota.size.1=0sAAAAAATiAAAAAAAAAAAAAwAAAAAAAAAE
trusted.glusterfs.volume-id=0sEZKGliY6THqhVVEVrykiHw==

# 在 mystorage1 上執行配置 glusterfs 參數和上述一樣

setfattr -n trusted.gfid -v 0sAAAAAAAAAAAAAAAAAAAAAQ== /storage/brick2
setfattr -n trusted.glusterfs.dht -v 0sAAAAAQAAAAAAAAAAf////g== /storage/brick2
setfattr -n trusted.glusterfs.dht.commithash -v "3168624641" /storage/brick2
setfattr -n trusted.glusterfs.quota.dirty -v 0sMAA= /storage/brick2
setfattr -n trusted.glusterfs.quota.size.1 -v 0sAAAAAATiAAAAAAAAAAAAAwAAAAAAAAAE /storage/brick2
setfattr -n trusted.glusterfs.volume-id -v 0sEZKGliY6THqhVVEVrykiHw== /storage/brick2

[root@mystorage1 ~]# /etc/init.d/glusterd restart
Starting glusterd:                                         [  OK  ]


[root@mystorage1 ~]# gluster volume heal gv2 info
Brick mystorage1:/storage/brick2
Status: Connected
Number of entries: 0

Brick mystorage2:/storage/brick2
/data 
Status: Connected
Number of entries: 1        # 顯示一個條目在修復,自動修復完成后會為 0

Brick mystorage3:/storage/brick1
Status: Connected
Number of entries: 0

Brick mystorage4:/storage/brick1
Status: Connected
Number of entries: 0

# 自動修復同步完成后,查看新硬盤的數據同步過來了
[root@mystorage1 ~]# ll /storage/brick2
total 40012
-rw-r--r-- 2 root root 20480000 Jul 30 02:41 20M.file
-rw-r--r-- 2 root root 20480000 Jul 30 03:13 20M.file1
drwxr-xr-x 2 root root       21 Jul 30 09:14 data

4.2 一台主機故障

一台節點故障的情況包含以下情況:

  • 物理故障
  • 同時有多塊硬盤故障,造成數據丟失
  • 系統損壞不可修復

解決方法:

找一台完全一樣的機器,至少要保證硬盤數量和大小一致,安裝系統,配置和故障機同樣的 IP,安裝 gluster 軟件,
保證配置一樣,在其他健康節點上執行命令 gluster peer status,查看故障服務器的 uuid

[root@mystorage2 ~]# gluster peer status
Number of Peers: 3

Hostname: mystorage3
Uuid: 36e4c45c-466f-47b0-b829-dcd4a69ca2e7
State: Peer in Cluster (Connected)

Hostname: mystorage4
Uuid: c607f6c2-bdcb-4768-bc82-4bc2243b1b7a
State: Peer in Cluster (Connected)

Hostname: mystorage1
Uuid: 6e6a84af-ac7a-44eb-85c9-50f1f46acef1
State: Peer in Cluster (Disconnected)

修改新加機器的 /var/lib/glusterd/glusterd.info 和 故障機器一樣

[root@mystorage1 ~]# cat /var/lib/glusterd/glusterd.info
UUID=6e6a84af-ac7a-44eb-85c9-50f1f46acef1
operating-version=30712

在信任存儲池中任意節點執行

# gluster volume heal gv2 full

就會自動開始同步,但在同步的時候會影響整個系統的性能。

可以查看狀態

# gluster volume heal gv2 info

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM