公司使用MFS分佈式搭建共享存儲,默認副本數設置爲2,數據節點(chunkserver)目前爲6臺。
近日因爲某些原因需要替換掉一臺存儲節點。
在不影響使用的前提下進行替換。通過官方文檔的提示建議先remove磁盤之後在停掉節點。
參考MFS官方地址:https://moosefs.com/documentation/faq.html
Is it possible to add/remove chunkservers and disks on the fly?
You can add/remove chunk servers on the fly. But keep in mind that it is not wise to disconnect a chunk server if this server contains the only copy of a chunk in the file system (the CGI monitor will mark these in orange). You can also disconnect (change) an individual hard drive. The scenario for this operation would be:
Mark the disk(s) for removal (see How to mark a disk for removal?)
Reload the chunkserver process
Wait for the replication (there should be no "undergoal" or "missing" chunks marked in yellow, orange or red in CGI monitor)
Stop the chunkserver process
Delete entry(ies) of the disconnected disk(s) in mfshdd.cfg
Stop the chunkserver machine
Remove hard drive(s)
Start the machine
Start the chunkserver process
When you want to mark a disk for removal from a chunkserver, you need to edit the chunkserver's mfshdd.cfg configuration file and put an asterisk '*' at the start of the line with the disk that is to be removed. For example, in this mfshdd.cfg we have marked "/mnt/hdd" for removal:
/mnt/hda
/mnt/hdb
/mnt/hdc
*/mnt/hdd
/mnt/hde
After changing the mfshdd.cfg you need to reload chunkserver (on Linux Debian/Ubuntu: service moosefs-pro-chunkserver reload).
簡單來說就是讓你編輯存儲節點的“mfshdd.cfg”這個文件在被掛載的磁盤前面添加一個 * 號,之後重啓進程。
這裏我使用ps查看mfs進程 並使用kill -9 殺掉進程 之後啓動mfschunkserver start
通過訪問mfsmaster CGI web界面得知:
紅框內可以看到這裏已經顯示這臺存儲節點上面有一塊10TB的盤被remove
這種方法經過我個人的測試發覺遷移數據異常的緩慢,so 決定直接幹掉這個節點!殺掉進程觀察mfs集羣發覺並沒有影響到我正常使用。
接下來新增節點:
# tar -xf mfs-1.6.27-1.tar.gz # cd mfs-1.6.27 # useradd mfs -s /sbin/nologin # ./configure --prefix=/opt/mfs-1.6.27 --with-default-user=mfs --with-default-group=mfs # make && make install
完畢(安裝軟件這裏不再多說,太簡單)
cd /opt/mfs-1.6.27/etc/mfs 注意這兩個文件: -rw-r--r--. 1 root root 534 1月 6 09:36 mfschunkserver.cfg -rw-r--r--. 1 root root 78 1月 6 09:37 mfshdd.cfg # grep -v "^#" mfschunkserver.cfg MASTER_HOST = 192.168.0.100
這裏填寫master地址,其他默認即可。
# grep -v "^#" mfshdd.cfg /data1 /data2 /data3 以上三個目錄爲我的掛載點,這裏需要注意更改屬組和屬主 chown -R mfs.mfs /data1 /data2 /data3
接下來啓動chunkserver
# /opt/mfs-1.6.27/sbin/mfschunkserver start
在web界面查看,已經新增的節點。這裏可以看出mfs已經自動的開始了數據的遷移了。
說到這裏不得不提的一點“副本數”!!!!注意如果你設置的副本爲1的話不建議使用直接幹掉一個節點這種粗魯的辦法。
在web見面info選項卡中可以看出,這個矩陣橫座標表示現在已經存在磁盤上的副本數,縱座標表示你設置的副本數。
最後溫馨提示:數據有風險 操作需謹慎!!