本次实验使用最简单的MFS分布式存储
192.168.122.1 mfsclient
192.168.122.2 mfsmaster
192.168.122.3 mfschunekserver
192.168.122.4 mfschunekserver
使用二进制包构建rpm包
[root@server2 ~]# rpmbuild -tb moosefs-3.0.80.tar.gz
大概会生成这些东西,都是rpm包
Wrote: /root/rpmbuild/RPMS/x86_64/moosefs-master-3.0.80-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/moosefs-metalogger-3.0.80-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/moosefs-chunkserver-3.0.80-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/moosefs-client-3.0.80-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/moosefs-cli-3.0.80-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/moosefs-cgi-3.0.80-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/moosefs-cgiserv-3.0.80-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/moosefs-netdump-3.0.80-1.x86_64.rpm
master上直接安装这三个rpm包,
[root@server2 x86_64]# yum install -y moosefs-master-3.0.80-1.x86_64.rpm moosefs-cgi-3.0.80-1.x86_64.rpm moosefs-cgiserv-3.0.80-1.x86_64.rpm
将chunkserver发送给server机,将client发送给客户机
[root@server2 x86_64]# scp moosefs-chunkserver-3.0.80-1.x86_64.rpm root@192.168.122.3:/root/
root@192.168.122.3's password: moosefs-chunkserver-3.0.80-1.x86_64.rpm 100% 195KB 195.0KB/s 00:00 [root@server2 x86_64]# scp moosefs-chunkserver-3.0.80-1.x86_64.rpm root@192.168.122.4:/root/ root@192.168.122.4's password:
moosefs-chunkserver-3.0.80-1.x86_64.rpm 100% 195KB 195.0KB/s 00:00
[root@server2 x86_64]# scp moosefs-client-3.0.80-1.x86_64.rpm root@192.168.122.1:/root/
root@192.168.122.1's password: moosefs-client-3.0.80-1.x86_64.rpm 100% 265KB 264.9KB/s 00:00
安装
[root@server3 ~]# yum install -y moosefs-chunkserver-3.0.80-1.x86_64.rpm
[root@server4 ~]# yum install -y moosefs-chunkserver-3.0.80-1.x86_64.rpm
[root@server ~]# yum install -y moosefs-client-3.0.80-1.x86_64.rpm
修改配置文件,添加要分享的目录,三和四都要这样
[root@server3 ~]# cat /etc/mfs/mfshdd.cfg
/mnt/chunk2
[root@server3 ~]# mkdir /mnt/chunk2
[root@server3 ~]# chown mfs.mfs /mnt/chunk2
启动 三和四一样
[root@server3 ~]# mfschunkserver
open files limit has been set to: 16384 working directory: /var/lib/mfs lockfile created and locked setting glibc malloc arena max to 8 setting glibc malloc arena test to 1 initializing mfschunkserver modules ... hdd space manager: path to scan: /mnt/chunk2/ hdd space manager: start background hdd scanning (searching for available chunks) main server module: listen on *:9422 stats file has been loaded mfschunkserver daemon initialized properly
master也启动
[root@server2 ~]# mfsmaster
open files limit has been set to: 16384
working directory: /var/lib/mfs
lockfile created and locked
initializing mfsmaster modules ...
exports file has been loaded
topology file has been loaded
loading metadata ...
loading sessions data ... ok (0.0000)
loading storage classes data ... ok (0.0000)
loading objects (files,directories,etc.) ... ok (0.0165)
loading names ... ok (0.0151)
loading deletion timestamps ... ok (0.0000)
loading quota definitions ... ok (0.0000)
loading xattr data ... ok (0.0000)
loading posix_acl data ... ok (0.0000)
loading open files data ... ok (0.0000)
loading flock_locks data ... ok (0.0000)
loading posix_locks data ... ok (0.0000)
loading chunkservers data ... ok (0.0000)
loading chunks data ... ok (0.0162)
checking filesystem consistency ... ok
connecting files and chunks ... ok
all inodes: 5
directory inodes: 3
file inodes: 2
chunks: 2
metadata file has been loaded
stats file has been loaded
master <-> metaloggers module: listen on *:9419
master <-> chunkservers module: listen on *:9420
main master server module: listen on *:9421
mfsmaster daemon initialized properly
[root@server2 ~]# mfscgiserv
lockfile created and locked
starting simple cgi server (host: any , port: 9425 , rootpath: /usr/share/mfscgi)
查看网页
server的使用
写入需要挂载的目录
[root@server ~]# cat /etc/mfs/mfsmount.cfg
# The optional mfsmount.cfg file can be used to specify defaults for mfsmount.
# Default mount options can be specified on one line separated by commas or
# over several lines.
#
# Examples:
#
# nosuid,nodev
# mfsmaster=mfsmaster
# mfspassword=secret
#
# The default mount point can also be set. The default mount point must begin
# with a "/" and be a fully qualified path.
#
# Example:
#
/mnt/mfs
挂载
[root@server ~]# mfsmount
mfsmaster accepted connection with parameters: read-write,restricted_ip,admin ; root mapped to root:root
开始使用
[root@server mfs]# mkdir dir{1,2}
[root@server mfs]# mfssetgoal -r 1 dir1/
[root@server mfs]# cp /etc/passwd dir1/
[root@server mfs]# cp /etc/shadow dir2/
[root@server mfs]# mfsfileinfo dir1/passwd
dir1/passwd:
chunk 0: 0000000000000005_00000001 / (id:5 ver:1)
copy 1: 192.168.122.3:9422 (status:VALID)
[root@server mfs]# mfsfileinfo dir2/shadow
dir2/shadow:
chunk 0: 0000000000000004_00000001 / (id:4 ver:1)
copy 1: 192.168.122.3:9422 (status:VALID)
copy 2: 192.168.122.4:9422 (status:VALID
删除与恢复
[root@server dir1]# ls
passwd
[root@server dir1]# rm -rf passwd
[root@server dir1]# mfsgettrashtime .
.: 86400
[root@server dir1]# mkdir /mnt/mfsmeta/
[root@server dir1]# mfsmount -m /mnt/mfsmeta/ -H mfsmaster
mfsmaster accepted connection with parameters: read-write,restricted_ip
[root@server dir1]# cd /mnt/mfsmeta/trash/
[root@server trash]# find -name *passwd*
./004/00000004|dir1|passwd
./00A/0000000A|dir1|passwd
[root@server trash]# mv ./004/00000004\|dir1\|passwd undel/
[root@server trash]# ll /mnt/mfs/dir1/
total 3
-rw-r--r-- 1 root root 2246 Jun 10 09:35 passwd