公司使用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:

  1. Mark the disk(s) for removal (see How to mark a disk for removal?)

  2. Reload the chunkserver process

  3. Wait for the replication (there should be no "undergoal" or "missing" chunks marked in yellow, orange or red in CGI monitor)

  4. Stop the chunkserver process

  5. Delete entry(ies) of the disconnected disk(s) in mfshdd.cfg

  6. Stop the chunkserver machine

  7. Remove hard drive(s)

  8. Start the machine

  9. 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界面得知:


MFS如何迁移数据之替换存储节点_第1张图片


红框内可以看到这里已经显示这台存储节点上面有一块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已经自动的开始了数据的迁移了。


wKiom1hvZtDyB_PoAAAiForG9uc817.png-wh_50


说到这里不得不提的一点“副本数”!!!!注意如果你设置的副本为1的话不建议使用直接干掉一个节点这种粗鲁的办法。


MFS如何迁移数据之替换存储节点_第2张图片


在web见面info选项卡中可以看出,这个矩阵横坐标表示现在已经存在磁盘上的副本数,纵坐标表示你设置的副本数。

那个橙色的数字就表示,设置的副本数是2。



最后温馨提示:数据有风险 操作需谨慎!!