MFS(文件分布式存储系统)拓扑
操作系统
Centos6.6 x86_64
安装需求:
mfs-1.6.27-5.tar.gz
fuse-2.9.2.tar.gz
系统光盘
虚拟的ip地址如下:
master server 99.99.99.35 mfs-1.6.27-5.tar.gz
master log 99.99.99.36 mfs-1.6.27-5.tar.gz
chunk server1 99.99.99.37 mfs-1.6.27-5.tar.gz
chunk server1 99.99.99.38 mfs-1.6.27-5.tar.gz
chunk server1 99.99.99.39 mfs-1.6.27-5.tar.gz
client 99.99.99.40 mfs-1.6.27-5.tar.gz fuse-2.9.2.tar.gz
保证实验效果最好
关闭iptables
关闭selinux
部署MFS Master Server
安装依赖
[root@cjl ~]# /etc/init.d/iptables stop iptables:将链设置为政策 ACCEPT:filter [确定] iptables:清除防火墙规则: [确定] iptables:正在卸载模块: [确定] [root@cjl ~]# setenforce 0 [root@cjl ~]# mount /dev/cdrom /mnt/ mount: block device /dev/sr0 is write-protected, mounting read-only [root@cjl ~]# yum -y install zlib-devel
创建mfs用户
[root@cjl ~]# useradd -s /sbin/nologin mfs
源码包安装
[root@cjl ~]# ls anaconda-ks.cfg install.log install.log.syslog mfs-1.6.27-5.tar.gz [root@cjl ~]# tar zxf mfs-1.6.27-5.tar.gz &>/dev/null [root@cjl ~]# cd mfs-1.6.27 [root@cjl mfs-1.6.27]# ./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --disable-mfsmount &&make &&make install
复制配置文件
[root@cjl mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/ [root@cjl mfs]# ll 总用量 16 -rw-r--r--. 1 root root 4060 9月 11 12:16 mfsexports.cfg.dist -rw-r--r--. 1 root root 1020 9月 11 12:16 mfsmaster.cfg.dist -rw-r--r--. 1 root root 417 9月 11 12:16 mfsmetalogger.cfg.dist -rw-r--r--. 1 root root 1123 9月 11 12:16 mfstopology.cfg.dist cp配置文件 [root@cjl mfs]# cp mfsexports.cfg.dist mfsexports.cfg [root@cjl mfs]# cp mfsmaster.cfg.dist mfsmaster.cfg [root@cjl mfs]# cp mfsmetalogger.cfg.dist mfsmetalogger.cfg [root@cjl mfs]# cp mfstopology.cfg.dist mfstopology.cfg [root@cjl mfs]# ll 总用量 32 -rw-r--r--. 1 root root 4060 9月 11 12:18 mfsexports.cfg -rw-r--r--. 1 root root 4060 9月 11 12:16 mfsexports.cfg.dist -rw-r--r--. 1 root root 1020 9月 11 13:45 mfsmaster.cfg -rw-r--r--. 1 root root 1020 9月 11 12:16 mfsmaster.cfg.dist -rw-r--r--. 1 root root 417 9月 11 12:18 mfsmetalogger.cfg -rw-r--r--. 1 root root 417 9月 11 12:16 mfsmetalogger.cfg.dist -rw-r--r--. 1 root root 1123 9月 11 12:19 mfstopology.cfg -rw-r--r--. 1 root root 1123 9月 11 12:16 mfstopology.cfg.dist [root@cjl mfs]# cd /usr/local/mfs/var/mfs/ [root@cjl mfs]# ll 总用量 4 -rw-r--r--. 1 root root 8 9月 11 12:16 metadata.mfs.empty [root@cjl mfs]# cp metadata.mfs.empty metadata.mfs [root@cjl ~]# /usr/local/mfs/sbin/mfsmaster start working directory: /usr/local/mfs/var/mfs lockfile created and locked initializing mfsmaster modules ... loading sessions ... ok sessions file has been loaded exports file has been loaded mfstopology: incomplete definition in line: 7 mfstopology: incomplete definition in line: 7 mfstopology: incomplete definition in line: 22 mfstopology: incomplete definition in line: 22 mfstopology: incomplete definition in line: 28 mfstopology: incomplete definition in line: 28 topology file has been loaded loading metadata ... loading objects (files,directories,etc.) ... ok loading names ... ok loading deletion timestamps ... ok loading chunks data ... ok checking filesystem consistency ... ok connecting files and chunks ... ok all inodes: 2 directory inodes: 1 file inodes: 1 chunks: 0 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@cjl ~]# ps -ef |grep mfs mfs 1230 1 1 17:51 ? 00:00:00 /usr/local/mfs/sbin/mfsmaster start root 1232 1200 1 17:51 pts/0 00:00:00 grep mfs
部署MFS Metalogger Server
[root@cjl ~]# /etc/init.d/iptables stop [root@cjl ~]# yum -y install zlib-devel [root@cjl ~]# useradd mfs -s /sbin/nologin [root@cjl ~]# tar zxf mfs-1.6.27-5.tar.gz [root@cjl ~]# cd mfs-1.6.27 [root@cjl mfs-1.6.27]# ./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --disable-mfsmount &&make &&make install [root@cjl mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/ cp模板文件为配置文件 [root@cjl mfs]# ll 总用量 20 -rw-r--r--. 1 root root 4060 9月 11 17:40 mfsexports.cfg.dist -rw-r--r--. 1 root root 1020 9月 11 17:40 mfsmaster.cfg.dist -rw-r--r--. 1 root root 417 9月 11 17:44 mfsmetalogger.cfg -rw-r--r--. 1 root root 417 9月 11 17:40 mfsmetalogger.cfg.dist -rw-r--r--. 1 root root 1123 9月 11 17:40 mfstopology.cfg.dist [root@cjl mfs]# vim mfsmetalogger.cfg 修改一行配置如下: # WORKING_USER = mfs # WORKING_GROUP = mfs # SYSLOG_IDENT = mfsmetalogger # LOCK_MEMORY = 0 # NICE_LEVEL = -19 # DATA_PATH = /usr/local/mfs/var/mfs # BACK_LOGS = 50 # BACK_META_KEEP_PREVIOUS = 3 # META_DOWNLOAD_FREQ = 24 # MASTER_RECONNECTION_DELAY = 5 MASTER_HOST = 99.99.99.35 # MASTER_PORT = 9419 # MASTER_TIMEOUT = 60 # deprecated, to be removed in MooseFS 1.7 # LOCK_FILE = /var/run/mfs/mfsmetalogger.lock [root@cjl mfs]# /usr/local/mfs/sbin/mfsmetalogger restart working directory: /usr/local/mfs/var/mfs sending SIGTERM to lock owner (pid:1265) waiting for termination ... terminated initializing mfsmetalogger modules ... mfsmetalogger daemon initialized properly [root@cjl mfs]# ps -ef |grep mfs mfs 1270 1 0 18:04 ? 00:00:00 /usr/local/mfs/sbin/mfsmetalogger restart root 1272 1201 0 18:04 pts/0 00:00:00 grep mfs
部署MFS chunk Server(搭建方法一致,可以无限添加。)
[root@cjl ~]# /etc/init.d/iptables stop [root@cjl ~]# setenforce 0 [root@cjl ~]# mount /dev/cdrom /mnt/ mount: block device /dev/sr0 is write-protected, mounting read-only [root@cjl ~]# yum -y install zlib-devel [root@cjl ~]# useradd mfs -s bin/nologin [root@cjl ~]# tar zxf mfs-1.6.27-5.tar.gz [root@cjl ~]# cd mfs-1.6.27 [root@cjl mfs-1.6.27]# ./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfsmaster --disable-mfsmount &&make &&make install [root@cjl mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/ cp模板为配置文件 [root@cjl mfs]# ll 总用量 16 -rw-r--r--. 1 root root 531 9月 11 18:39 mfschunkserver.cfg -rw-r--r--. 1 root root 531 9月 11 18:37 mfschunkserver.cfg.dist -rw-r--r--. 1 root root 63 9月 11 18:39 mfshdd.cfg -rw-r--r--. 1 root root 57 9月 11 18:37 mfshdd.cfg.dist 编辑配置文件内容如下: [root@cjl mfs]# vim mfschunkserver.cfg # WORKING_USER = mfs # WORKING_GROUP = mfs # SYSLOG_IDENT = mfschunkserver # LOCK_MEMORY = 0 # NICE_LEVEL = -19 # DATA_PATH = /usr/local/mfs/var/mfs # MASTER_RECONNECTION_DELAY = 5 # BIND_HOST = * MASTER_HOST = 99.99.99.35 # MASTER_PORT = 9420 # MASTER_TIMEOUT = 60 # CSSERV_LISTEN_HOST = * # CSSERV_LISTEN_PORT = 9422 # HDD_CONF_FILENAME = /usr/local/mfs/etc/mfs/mfshdd.cfg # HDD_TEST_FREQ = 10 # deprecated, to be removed in MooseFS 1.7 # LOCK_FILE = /var/run/mfs/mfschunkserver.lock 添加共享目录 [root@cjl mfs]# vim mfshdd.cfg # mount points of HDD drives # #/mnt/hd1 #/mnt/hd2 #etc. /data [root@cjl mfs]# mkdir /data [root@cjl mfs]# chown -R mfs:mfs /data [root@cjl mfs]# /usr/local/mfs/sbin/mfschunkserver start working directory: /usr/local/mfs/var/mfs lockfile created and locked initializing mfschunkserver modules ... hdd space manager: path to scan: /data/ 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 [root@cjl mfs]# ps -ef |grep mfs mfs 1277 1 1 18:17 ? 00:00:00 /usr/local/mfs/sbin/mfschunkserver start root 1303 1200 0 18:17 pts/0 00:00:00 grep mfs
配置MFS客户端
[root@cjl ~]# /etc/init.d/iptables stop [root@cjl ~]# setenforce 0 [root@cjl ~]# yum -y install zlib-devel
安装FUSE依赖软件网址如下:
http://nchc.dl.sourceforge.net/project/buluoos/0.2/src/fuse-2.8.5.tar.gz
[root@cjl ~]# tar zxf fuse-2.9.2.tar.gz [root@cjl ~]# cd fuse-2.9.2 [root@cjl fuse-2.9.2]# ./configure &&make &&make install [root@cjl fuse-2.9.2]# vim /etc/profile [root@cjl fuse-2.9.2]# tail -1 /etc/profile export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH [root@cjl fuse-2.9.2]# source /etc/profil
安装MFS客户端
[root@cjl ~]# useradd mfs -s /sbin/nologin [root@cjl ~]# tar zxf mfs-1.6.27-5.tar.gz [root@cjl ~]# cd mfs-1.6.27 [root@cjl mfs-1.6.27]# ./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfsmaster --disable-mfsmount &&make &&make install [root@cjl ~]# mkdir /mnt/mfs/ #创建目录 [root@cjl ~]# modprobe fuse #加载模块 [root@cjl ~]# /usr/local/mfs/bin/mfsmount /mnt/mfs/ -H 99.99.99.35 #挂载 mfsmaster accepted connection with parameters: read-write,restricted_ip ; root mapped to root:root [root@cjl ~]# df -TH #查看挂载情况 Filesystem Type Size Used Avail Use% Mounted on /dev/sda3 ext4 32G 1.6G 28G 6% / tmpfs tmpfs 258M 0 258M 0% /dev/shm /dev/sda1 ext4 500M 30M 445M 7% /boot 99.99.99.35:9421 fuse.mfs 28G 0 28G 0% /mnt/mfs 方便管理添加环境变量 [root@cjl ~]# vim /etc/profile [root@cjl ~]# tail -1 /etc/profile export PATH=/usr/local/mfs/bin:$PATH [root@cjl ~]# source /etc/profile [root@cjl ~]# mfsgetgoal -r /mnt/mfs/ /mnt/mfs/: files with goal 1 : 1 directories with goal 1 : 1 [root@cjl ~]# mfssetgoal -r 3 /mnt/mfs/ /mnt/mfs/: inodes with goal changed: 2 inodes with goal not changed: 0 inodes with permission denied: 0 [root@cjl ~]# mfsgetgoal -r /mnt/mfs/ /mnt/mfs/: files with goal 3 : 1 directories with goal 3 : 1
创建测试文件:
[root@cjl mfs]# touch 123.txt #创建测试文件 [root@cjl mfs]# mfsgetgoal 123.txt 123.txt: 3 #说明测试文件创建了三份
MFS监控
开启监听文件是
[root@cjl mfs]# /usr/local/mfs/sbin/mfscgiserv start lockfile created and locked starting simple cgi server (host: any , port: 9425 , rootpath: /usr/local/mfs/share/mfscgi) [root@cjl mfs]# netstat -utpln |grep 9425 tcp 0 0 0.0.0.0:9425 0.0.0.0:* LISTEN 1305/python
监听端口是9425
下图基本解释:
info部分:显示MFS的基本信息。
Servers部分:列出所有的Chunk Server。
Disks部分:列出所有chunk Server硬盘信息。
Exports部分:列出可被挂载目录。
Mounts部分:列出被挂载目录。
Operations部分:显示正在执行的操作。
Master charts部分:显示Master Server的操作情况,读 写 删除等操作。
Server charts部分:显示Chunk Server的操作情况,数据传输率及系统状态。
停止的命令例如:/usr/local/mfs/sbin/mfsmetalogger -s
启动Chunk Server时如果报错试试停掉selinux。
如有报错请留言!