https://moosefs.com/download/
master 缓存到内存中 所有架构的元数据信息
如下为元数据信息
-rw-------. 1 root root 1679 Mar 31 15:32
chunkservers 存放数据 需要多核 因为是多线程
元数据服务器应该和master端一样
一般chunkserver三台
不需要多核 单核高赫兹
server1 master
写好解析master
[root@server1 3.0.103]# yum install moosefs-cgi-3.0.103-1.rhsystemd.x86_64.rpm moosefs-cgiserv-3.0.103-1.rhsystemd.x86_64.rpm moosefs-cli-3.0.103-1.rhsystemd.x86_64.rpm moosefs-master-3.0.103-1.rhsystemd.x86_64.rpm -y
vim /etc/mfs/mfsmaster.cfg
systemctl start moosefs-master
[root@server1 mfs]# systemctl start moosefs-master
[root@server1 mfs]# systemctl stop moosefs-master
[root@server1 mfs]# ls
changelog.1.mfs metadata.mfs metadata.mfs.empty
metadata.crc metadata.mfs.back.1 stats.mfs
vim /etc/hosts
172.25.11.1 mfsmaster
server2 server3
vim /etc/hosts
172.25.11.1 mfsmaster
[root@server2 3.0.103]# yum install -y moosefs-chunkserver-3.0.103-1.rhsystemd.x86_64.rpm
[root@server2 mfs]# vim /etc/mfs/mfshdd.cfg
/mnt/chunk1
mkdir /mnt/chunk1
chown mfs.mfs /mnt/chunk1/
[root@server2 mfs]# systemctl start moosefs-chunkserver
server1
systemctl start moosefs-cgiserv
http://172.25.11.1:9425/mfs.cgi
yum install moosefs-client-3.0.103-1.rhsystemd.x86_64.rpm -y
vim /etc/mfs/mfsmount.cfg
/mnt/mfs
mkdir /mnt/mfs
mfsmount
mfsgetgoal dir1/
[root@foundation11 mfs]# mfsgetgoal dir1/
dir1/: 2
[root@foundation11 mfs]# mkdir dir2
[root@foundation11 mfs]# mfsgetgoal dir2/
dir2/: 2
保持一份数据 dir1
[root@foundation11 mfs]# mfsgetgoal -r 1 dir1/
1: realpath error on (/mnt/mfs/1): ENOENT (No such file or directory)
dir1/:
files with goal 2 : 2
directories with goal 2 : 1
cd dir1
touch 123
mfsfileinfo 123
[root@foundation11 dir1]# mfsfileinfo 123
123:
no chunks - empty file
[root@foundation11 dir1]# mfsfileinfo passwd
passwd:
chunk 0: 0000000000000001_00000001 / (id:1 ver:1)
copy 1: 172.25.11.2:9422 (status:VALID)
copy 2: 172.25.11.3:9422 (status:VALID)
两个节点都会放进去 但是是一份副本,分布式存,任何一个目录都不能损坏
如果是两个副本就可以
[root@server3 3.0.103]# systemctl stop moosefs-chunkserver
[root@foundation11 dir1]# mfsfileinfo fstab
fstab:
chunk 0: 0000000000000002_00000001 / (id:2 ver:1)
copy 1: 172.25.11.2:9422 (status:VALID)
说明 chunk server2 3 都存了 你的文件
client -> master -> chunkserver
恢复删除的文件
client 端
我这里删除的是dir2下的shadow
mkdir /mnt/mfs/mfsmeta
mfsmount -m /mnt/mfs/mfsmeta
cd mfsmeta/trash
[root@foundation11 trash]# find -name *shadow*
./007/00000007|dir2|shadow
^[[A[root@foundation11 trash]# cd 00
000/ 001/ 002/ 003/ 004/ 005/ 006/ 007/ 008/ 009/ 00A/ 00B/ 00C/ 00D/ 00E/ 00F/
[root@foundation11 trash]# cd 007
[root@foundation11 007]# ls
00000007|dir2|shadow undel
[root@foundation11 007]# mv 00000007\|dir2\|shadow undel/
[root@foundation11 007]# ll /mnt/mfs/dir2
total 2
----------. 1 root root 1424 Apr 5 10:37 shadow
就会恢复了
需要master端
mfsmaster -a 启动 ;内部自己恢复机制
可以更改脚本
/usr/lib/systemd/system/moosefs-master.service
ExecStart=/usr/sbin/mfsmaster -a
systemctl daemon-reload
自动恢复
[root@server1 mfs]# systemctl start moosefs-master