mfs分布式文件存储---部署及应用
作者:互联网
根据自己主机下载自己所需要的源
部署master端
[root@server1 ~]# curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo
修改为不检测
[root@server1 ~]# yum install moosefs-master moosefs-cgi moosefs-cgiserv moosefs-cli -y
添加解析
[root@server1 mfs]# vim /etc/hosts
172.25.4.1 mfsmaster
启动服务
[root@server1 ~]# systemctl start moosefs-master.service
[root@server1 ~]# systemctl start moosefs-cgiserv.service
[root@server1 ~]# netstat -antlp
访问http://172.25.4.1:9425/
server端部署
server2、3为server端
[root@server1 ~]# scp /etc/yum.repos.d/MooseFS.repo server2:/etc/yum.repos.d/
[root@server1 ~]# scp /etc/yum.repos.d/MooseFS.repo server3:/etc/yum.repos.d/
[root@serevr2 ~]# yum install moosefs-chunkserver -y
[root@serevr3 ~]# yum install moosefs-chunkserver -y
解析
[root@server1 ~]# scp /etc/hosts server2:/etc/hosts
[root@server1 ~]# scp /etc/hosts server3:/etc/hosts
给server2、3添加硬盘
[root@serevr2 ~]# fdisk /dev/vdb
格式化
[root@serevr2 ~]# mkfs.xfs /dev/vdb1
[root@serevr2 ~]# mkdir /mnt/chunk1
[root@serevr2 ~]# chown mfs.mfs /mnt/chunk1/
[root@serevr2 ~]# blkid
永久挂载
[root@serevr2 ~]# vim /etc/fstab
[root@serevr2 ~]# vim /etc/mfs/mfshdd.cfg
启动服务
[root@serevr2 ~]# systemctl start moosefs-chunkserver
server3端部署
[root@server3 ~]# mkdir /mnt/chunk2
[root@server3 ~]# fdisk /dev/vdb
格式化
[root@server3 ~]# mkfs.xfs /dev/vdb1
[root@server3 ~]# blkid
永久挂载
[root@server3 ~]# vim /etc/fstab
[root@server3 ~]# chown mfs.mfs /mnt/chunk2/
[root@server3 ~]# vim /etc/mfs/mfshdd.cfg
启动服务
[root@server3 ~]# systemctl start moosefs-chunkserver
客户端部署
下载源
[root@foundation4 ~]# curl "http://ppa.moosefs.com/MooseFS-3-el8.repo" > /etc/yum.repos.d/MooseFS.repo
修改为不检测
[root@foundation4 ~]# yum install moosefs-client
解析
[root@foundation4 ~]# vim /etc/hosts
172.25.4.1 mfsmaster
数据挂载
[root@foundation4 ~]# mkdir /mnt/mfs
[root@foundation4 ~]# vim /etc/mfs/mfsmount.cfg
server1查看
[root@foundation4 ~]# cd /mnt/mfs/
[root@foundation4 mfs]# mkdir dir1
[root@foundation4 mfs]# mkdir dir2
[root@foundation4 mfs]# mfssetgoal -r 1 dir1
[root@foundation4 mfs]# mfsgetgoal dir1
[root@foundation4 mfs]# mfsgetgoal dir2
[root@foundation4 mfs]# cp /etc/passwd dir1/
[root@foundation4 mfs]# cp /etc/fstab dir2/
[root@foundation4 mfs]# cd dir1/
[root@foundation4 dir1]# mfsfileinfo passwd
[root@foundation4 mfs]# cd dir2/
[root@foundation4 dir2]# mfsfileinfo fstab
如果停止server3服务
[root@server3 ~]# systemctl stop moosefs-chunkserver
宿主机查看
重启
[root@server3 ~]# systemctl start moosefs-chunkserver
恢复
数据恢复
[root@foundation4 dir2]# dd if=/dev/zero of=bigfile bs=1M count=100
[root@foundation4 dir2]# cd ..
[root@foundation4 mfs]# cd dir1
[root@foundation4 dir1]# rm -f passwd
[root@foundation4 ~]# cd /mnt/
[root@foundation4 mnt]# mkdir mfsdeta
[root@foundation4 mnt]# mfsmount -m /mnt/mfsdeta/
从垃圾文件中移出
[root@foundation4 mnt]# cd /mnt/mfsdeta/
[root@foundation4 mfsdeta]# find -name *passwd*
[root@foundation4 004]# mv 00000004\|dir1\|passwd undel/
查看已经恢复
[root@foundation4 004]# cd /mnt/mfs/dir1/
[root@foundation4 dir1]# mfsfileinfo passwd
标签
server2标签改为A
[root@serevr2 ~]# cd /etc/mfs/
[root@serevr2 mfs]# vim mfschunkserver.cfg
[root@serevr2 mfs]# systemctl reload moosefs-chunkserver.service
server3标签改为B
[root@server3 ~]# cd /etc/mfs/
[root@server3 mfs]# vim mfschunkserver.cfg
[root@server3 mfs]# systemctl reload moosefs-chunkserver.service
查看标签
部署一个server4
[root@serevr2 mfs]# scp /etc/yum.repos.d/MooseFS.repo server4:/etc/yum.repos.d/
[root@serevr2 mfs]# scp /etc/hosts server4:/etc/hosts
[root@serevr4 ~]# yum install moosefs-chunkserver -y
[root@serevr4 ~]# mkdir /mnt/chunk3
[root@serevr4 ~]# vim /etc/mfs/mfshdd.cfg
[root@serevr4 ~]# chown mfs.mfs /mnt/chunk3/
[root@serevr4 ~]# vim /etc/mfs/mfschunkserver.cfg
修改server4标签为A
[root@serevr4 ~]# systemctl start moosefs-chunkserver
查看标签
存储类
[root@foundation4 dir1]# mfsscadmin create 2A class_2A
[root@foundation4 dir1]# mfsscadmin create AB class_AB
[root@foundation4 dir1]# cd ..
[root@foundation4 mfs]# cd dir2
[root@foundation4 dir2]# mfssetsclass class_2A fstab
[root@foundation4 dir2]# mfsfileinfo fstab
[root@foundation4 dir2]# mfsscadmin create A,B classAB
[root@foundation4 dir2]# mfssetsclass classAB bigfile
[root@foundation4 dir2]# mfsfileinfo bigfile
分别修改server2、3、3的标签
[root@foundation4 dir2]# mfsscadmin create AS,BS class_ASBS
[root@foundation4 dir2]# mfssetsclass class_ASBS fstab
[root@foundation4 dir2]# mfsscadmin create BS,2A[S+H] class4
[root@foundation4 dir2]# mfssetsclass class4 fstab
[root@foundation4 dir2]# mfsfileinfo fstab
修改server3的标签为
[root@foundation4 dir2]# mfsscadmin create -C 2AS -K AS,BS -A AH,BH -d 30 class5
[root@foundation4 dir2]# mfssetsclass class5 fstab
[root@foundation4 dir2]# mfsfileinfo fstab
如果停止服务
[root@server3 mfs]# systemctl stop moosefs-chunkserver.service
[root@serevr4 mfs]# systemctl stop moosefs-chunkserver.service
查看
[root@foundation4 dir2]# mfsfileinfo fstab
重启服务
[root@server3 mfs]# systemctl start moosefs-chunkserver.service
[root@serevr4 mfs]# systemctl start moosefs-chunkserver.service
查看
[root@foundation4 dir2]# mfsfileinfo fstab
master高可用
将server4也作为master
[root@serevr4 mfs]# systemctl stop moosefs-chunkserver.service
[root@serevr4 mfs]# yum install moosefs-master moosefs-cgi moosefs-cgiserv moosefs-cli -y
[root@server3 ~]# vim /etc/fstab
删除挂载
[root@server3 ~]# systemctl stop moosefs-chunkserver.service
[root@server3 ~]# umount /mnt/chunk2/
[root@server3 ~]# chown mfs.mfs /mnt/chunk2/
[root@server3 ~]# systemctl start moosefs-chunkserver
清理分区
[root@server3 ~]# fdisk /dev/vdb
[root@server3 ~]# dd if=/dev/zero of=/dev/vdb bs=512 count=1
同步磁盘(server1、4同步server3的磁盘)
[root@server3 ~]# yum install targetcli.noarch -y
[root@server3 ~]# systemctl start target.service
[root@server3 ~]# targetcli
/> cd /backstores/block
/backstores/block> create my_disk /dev/vdb
/backstores/block> cd /iscsi
/iscsi> create iqn.2021-04.org.westos.org:storage1
/iscsi> cd iqn.2021-04.org.westos.org:storage1/tpg1/acls
/iscsi/iqn.20...ge1/tpg1/acls> create iqn.2021-04.org.westos.org:client
/iscsi/iqn.20...ge1/tpg1/acls> cd ..
/iscsi/iqn.20...storage1/tpg1> cd luns
/iscsi/iqn.20...ge1/tpg1/luns> create /backstores/block/my_disk
server1同步磁盘
[root@server1 ~]# yum install -y iscsi-*
[root@server1 ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2021-04.org.westos.org:client
[root@server1 ~]# iscsiadm -m discovery -t st -p 172.25.4.3
[root@server1 ~]# iscsiadm -m node -l
[root@server1 ~]# fdisk -l
[root@server1 ~]# fdisk /dev/sda
server4同步磁盘
[root@serevr4 mfs]# yum install -y iscsi-*
[root@serevr4 mfs]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2021-04.org.westos.org:client
[root@serevr4 mfs]# iscsiadm -m discovery -t st -p 172.25.4.3
[root@serevr4 mfs]# iscsiadm -m node -l
[root@serevr4 mfs]# partprobe
挂载server1上写入数据,在卸掉
[root@server1 ~]# mkfs.xfs /dev/sda1 -f
[root@server1 ~]# mount /dev/sda1 /mnt/
[root@server1 mnt]# cp /etc/passwd .
[root@server1 ~]# umount /mnt/
挂载server4上可以看到
[root@serevr4 ~]# mount /dev/sda1 /mnt/
[root@serevr4 ~]# cd /mnt
[root@serevr4 mnt]# ls
passwd
[root@serevr4 ~]# umount /mnt/
标签:moosefs,server3,---,etc,mfs,root,foundation4,分布式 来源: https://blog.csdn.net/m0_51140575/article/details/115819582