这里写自定义目录标题
1.mfs部署
机器 | IP |
---|---|
server5 | 172.25.14.5 |
server6 | 172.25.14.6 |
server7 | 172.25.14.7 |
物理机 | 172.25.254.14 |
配置server5仓库,并将仓库文件传给server6,server7
[mfd]
name=mfs
baseurl=http://172.25.14.250/3.0.115
gpgcheck=0
[root@server5~]scp /etc/yum.repos.d/mfs.repo server6:/etc/yum.repos.d/
[root@server5~]scp /etc/yum.repos.d/mfs.repo server7:/etc/yum.repos.d/
1.server5(mfsmaster)
[root@server5 ~]# yum list moosefs-* #列出相关软件
[root@server5 ~]# yum install -y moosefs-master.x86_64 moosefs-cgiserv.x86_64 #安装
[root@server5 ~]# vim /etc/hosts #配置解析
[root@server5 ~]# systemctl start moosefs-master #启动服务
[root@server5 ~]# netstat -antlp #查看端口
[root@server5 ~]# systemctl start moosefs-cgiserv.service #配置完成 可在浏览器访问172.25.14.5:9425
2.server6
[root@server6 ~]# yum install -y moosefs-chunkserver.x86_64
[root@server6 ~]# cd /etc/mfs/
[root@server6 mfs]# ls
mfschunkserver.cfg mfschunkserver.cfg.sample mfshdd.cfg mfshdd.cfg.sample
[root@server6 mfs]# vim mfshdd.cfg #配置文件,说明挂载目录
[root@server6 mfs]# tail -n1 mfshdd.cfg
/mnt/chunk1 #挂载目录
[root@server6 mfs]# mkdir /mnt/chunk1 #创建挂载目录
给server6添加一块硬盘
[root@server6 mfs]# fdisk -l #查看添加的硬盘
[root@server6 mfs]# fdisk /dev/vdb #硬盘分区
[root@server6 mfs]# mkfs.xfs /dev/vdb1 #格式化
[root@server6 mfs]# mount /dev/vdb1 /mnt/chunk1/ #挂载
[root@server6 mfs]# df #查看挂载
[root@server6 mfs]# vim /etc/hosts #配置解析设置server5为mfsmaster
[root@server6 mfs]# tail -n8 /etc/hosts #查看配置内容
172.25.14.5 server1 mfsmaster
[root@server5 mfs]# chown mfs.mfs /mnt/chunk1/ #权限
[root@server5 mfs]# id mfs
uid=997(mfs) gid=995(mfs) groups=995(mfs)
[root@server5 mfs]# systemctl start moosefs-chunkserver #启动服务
[root@server5 mfs]#
[root@server5 mfs]# cd /mnt/chunk1/
[root@server5 chunk1]# ls
浏览器查看
3.server7
[root@server7 local]# yum install -y moosefs-chunkserver.x86_64
[root@server7 local]# vim /etc/hosts #配置解析
[root@server7 local]# tail -n8 /etc/hosts #查看配置内容
172.25.14.5 server1 mfsmaster
[root@server7 local]# cd /etc/mfs/
[root@server7 mfs]# vim mfshdd.cfg #配置
[root@server7 mfs]# tail -n1 mfshdd.cfg
/mnt/chunk2
[root@server7 mfs]# mkdir /mnt/chunk2
[root@server7 mfs]# chown mfs.mfs /mnt/chunk2/
[root@server7 mfs]# systemctl start moosefs-chunkserver #启动服务
浏览器查看
4.物理机
[root@foundation14 ~]#
[root@foundation14 ~]# cd 3.0.115/
[root@foundation14 3.0.115]# cd rhel8/
[root@foundation14 rhel8]# ls
moosefs-client-3.0.115-1.rhsystemd.x86_64.rpm
[root@foundation14 rhel8]# rpm -ivh moosefs-client-3.0.115-1.rhsystemd.x86_64.rpm #安装
warning: moosefs-client-3.0.115-1.rhsystemd.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID cf82adba: NOKEY
Verifying... ################################# [100%])
Preparing... ################################# [100%])
Updating / installing...
1:moosefs-client-3.0.115-1.rhsyste################################# [100%])
[root@foundation14 rhel8]#
[root@foundation14 rhel8]# cd /etc/mfs/
[root@foundation14 mfs]# ls
mfsmount.cfg mfsmount.cfg.sample
[root@foundation14 mfs]# vim mfsmount.cfg
[root@foundation14 mfs]# tail -n4 mfsmount.cfg
#
# Example:
#
/mnt/mfs #开启
[root@foundation14 mfs]# mkdir /mnt/mfs/
[root@foundation14 mfs]# cd /mnt/mfs
[root@foundation14 mfs]# vim /etc/hosts #配置解析
[root@foundation14 mfs]# tail -n2 /etc/hosts
172.25.14.5 mfsmaster
[root@foundation14 mfs]# mfsmount
mfsmaster accepted connection with parameters: read-write,restricted_ip,admin ; root mapped to root:root
[root@foundation14 mfs]# ls
[root@foundation14 mfs]# mkdir dir1
[root@foundation14 mfs]# mkdir dir2
[root@foundation14 mfs]# ls
dir1 dir2
[root@foundation14 mfs]# mfssetgoal -r 1 dir1
dir1:
inodes with goal changed: 1
inodes with goal not changed: 0
inodes with permission denied: 0
[root@foundation14 mfs]# mfsgetgoal dir1/
dir1/: 1
[root@foundation14 mfs]# mfsgetgoal dir2/
dir2/: 2
[root@foundation14 mfs]# cd dir1/
[root@foundation14 dir1]# ls
[root@foundation14 dir1]# cp /etc/passwd .
[root@foundation14 dir1]# ls
passwd
[root@foundation14 dir1]# mfsfileinfo passwd
passwd:
chunk 0: 0000000000000001_00000001 / (id:1 ver:1)
copy 1: 172.25.14.7:9422 (status:VALID)
[root@foundation14 dir1]# cd ..
[root@foundation14 mfs]# cd dir2/
[root@foundation14 dir2]# cp /etc/fstab .
[root@foundation14 dir2]# ls
fstab
[root@foundation14 dir2]# mfsfileinfo fstab
配置完成浏览器查看
172.25.14.5:9425
2.文件存储与恢复
[root@foundation14 dir2]# cd ../dir1
[root@foundation14 dir1]# dd if=/dev/zero of=bigfile bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 0.190595 s, 550 MB/s
[root@foundation14 dir1]# ls
bigfile passwd
[root@foundation14 dir1]# mfsfileinfo bigfile
bigfile:
chunk 0: 0000000000000003_00000001 / (id:3 ver:1)
copy 1: 172.25.14.8:9422 (status:VALID)
chunk 1: 0000000000000004_00000001 / (id:4 ver:1)
copy 1: 172.25.14.7:9422 (status:VALID)
[root@foundation14 dir1]# ls
bigfile passwd
[root@foundation14 dir1]# rm -f passwd #删除文件
[root@foundation14 dir1]# ls
bigfile
[root@foundation14 dir1]# cd
[root@foundation14 ~]# mkdir /mnt/mfsmeta/ -p
[root@foundation14 ~]# cd /mnt/mfs
mfs/ mfsmeta/
[root@foundation14 ~]# cd /mnt/mfsmeta/
[root@foundation14 mfsmeta]# ls
[root@foundation14 mfsmeta]# pwd
/mnt/mfsmeta
[root@foundation14 mfsmeta]# mfsmount -m /mnt/mfsmeta/
mfsmaster accepted connection with parameters: read-write,restricted_ip
[root@foundation14 mfsmeta]# cd
[root@foundation14 ~]# cd /mnt/mfsmeta/
[root@foundation14 mfsmeta]# ls
sustained trash
[root@foundation14 mfsmeta]# cd trash/
[root@foundation14 trash]# find -name *passwd*
./004/00000004|dir1|passwd
[root@foundation14 trash]# cd 00
[root@foundation14 00]# cd -
/mnt/mfsmeta/trash
[root@foundation14 trash]# cd 004
[root@foundation14 004]# ls
'00000004|dir1|passwd' undel
[root@foundation14 004]# mv 00000004\|dir1\|passwd undel/ #移动回去
[root@foundation14 004]# ls
undel
[root@foundation14 004]# cd
[root@foundation14 ~]# cd /mnt/mfs
[root@foundation14 mfs]# cd dir1/
[root@foundation14 dir1]# ls #查看,文件恢复
bigfile passwd
3.根据标签修改存储
1.分别设定chunk端的标签
vim /etc/mfs/mfschunkserver.cfg
server5:LABELS = A S
server6:LABELS = A B H S
server7:LABELS = A H
修改后每次重启服务
systemctl reload moosefs-chunkserver.service
物理机
mfsscadmin create -C 2AS -K AS,BS -A AH,BH -d 7 classABS #需要在文件目录中进行
mfssetsclass -r classABS passwd #将passwd转换存储为2A方式
mfsfileinfo passwd #查看文件passwd存储方式
4.通过iscsi实现mfs高可用
server7:为iscis主机,为其添加虚拟磁盘
yum install -y targetcli
systemctl start target
targetcli
cd backstores/block
create my_disk /dev/vdb
cd iscsi
create iqn.2021-07.org.westos:target1
cd iqn.2021-07.org.westos:target1/tpg1/luns
create /backstores/block/my_disk
/iscsi/iqn.20...et1/tpg1/acls> create iqn.2021-07.org.westos:client
server5:master需要备份的机器
yum install -y iscsi-*
cd /etc/iscsi/
vim initiatorname.iscsi
内容改为InitiatorName=iqn.2021-07.org.westos:client
iscsiadm -m discovery -t st -p 172.25.14.7
iscsiadm -m node -l
磁盘分区并挂载
fdisk /dev/sda
mkfs.xfs /dev/sda1
mount /dev/sda1 /mnt
查看文件,并将master文件复制到iscsi的挂载目录中
cd /var/lib/mfs/
ls
cp -p * /mnt/
cd /mnt/
ls
ll
chown mfs.mfs /mnt/ -R
umount /mnt/
server6:负责备份server5中的master信息
yum install -y moosefs-master.x86_64
yum install -y iscsi-*
配置iscsi,内容同上
vim /etc/iscsi/initiatorname.iscsi
cat /etc/iscsi/initiatorname.iscsi
连接iscsi主机server7
iscsiadm -m discovery -t st -p 172.25.14.7
iscsiadm -m node -l
磁盘分区并挂载
mount /dev/sda1 /var/mfs
启动master服务
cd /var/lib/mfs/
ls
systemctl start moosefs-master
启动失败,原因:master启动时,/var/lib/mfs/metadata.mfs必须存在,而启动后会变为metadata.mfs.back
修改文件mfsmaster -a
重启成功