MooseFS基础

介绍

安装

环境

hostname IP CPU 内存 角色
node1 10.10.1.31 4核 8G mfsmaster
node2 10.10.1.32 4核 8G Metalogger
node3 10.10.1.33 4核 8G check servers
node4 10.10.1.21 4核 8G check servers
node5 10.10.0.138 4核 8G 挂载客户端

步骤

安装mfsmaster(node1)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
### 下载环境包
$ yum install zlib-devel
### 安装moose
$ cd /usr/local/
$ wget https://github.com/moosefs/moosefs/archive/v3.0.96.tar.gz
$ useradd mfs
$ tar -xf v3.0.96.tar.gz
$ cd moosefs-3.0.96/
$ ./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --disable-mfsmount
$ make && make install
### 配置master
$ ls /usr/local/mfs/
$ cd /usr/local/mfs/etc/mfs
$ cp mfsexports.cfg.sample mfsexports.cfg
$ cp mfsmaster.cfg.sample mfsmaster.cfg
### 修改控制文件
$ vi mfsexports.cfg
* / rw,alldirs,mapall=mfs:mfs,password=wanglibing
* . rw
### 开启元数据文件(默认是empty文件)
$ cp /usr/local/mfs/var/mfs/metadata.mfs.empty /usr/local/mfs/var/mfs/metadata.mfs
### 启动master
$ /usr/local/mfs/sbin/mfsmaster start
### 检查进程是否启动
$ ps -ef | grep mfs
mfs 8293 1 0 19:40 ? 00:00:14 /usr/local/mfs/sbin/mfsmaster start
root 17433 17418 0 20:41 pts/0 00:00:00 grep --color=auto mfs
### 查看端口
$ netstat -ntlp
tcp 0 0 0.0.0.0:9419 0.0.0.0:* LISTEN 8293/mfsmaster
tcp 0 0 0.0.0.0:9420 0.0.0.0:* LISTEN 8293/mfsmaster
tcp 0 0 0.0.0.0:9421 0.0.0.0:* LISTEN 8293/mfsmaster

安装Metalogger(node2)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ ### 下载环境包
$ yum install zlib-devel
### 安装moose
$ cd /usr/local/
$ wget https://github.com/moosefs/moosefs/archive/v3.0.96.tar.gz
$ useradd mfs
$ tar -xf v3.0.96.tar.gz
$ cd moosefs-3.0.96/
$ ./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --disable-mfsmount
$ make && make install
### 配置Metalogger Server
$ cd /usr/local/mfs/etc/mfs/
$ cp mfsmetalogger.cfg.sample mfsmetalogger.cfg
$ vi mfsmetalogger.cfg
MASTER_HOST = 10.10.1.31
### 启动Metalogger Server
$ /usr/local/mfs/sbin/mfsmetalogger start
$ netstat -lantp|grep metalogger
tcp 0 0 10.10.1.32:48122 10.10.1.31:9419 ESTABLISHED 8278/mfsmetalogger
### 查看一下生成的日志文件
$ ls /usr/local/mfs/var/mfs/

安装check servers(node3、node4)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$ ### 下载环境包
$ yum install zlib-devel
### 安装moose
$ cd /usr/local/
$ wget https://github.com/moosefs/moosefs/archive/v3.0.96.tar.gz
$ useradd mfs
$ tar -xf v3.0.96.tar.gz
$ cd moosefs-3.0.96/
$ ./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfsmaster --disable-mfsmount
$ make && make install
### 配置check server
$ cd /usr/local/mfs/etc/mfs/
$ cp mfschunkserver.cfg.sample mfschunkserver.cfg
$ vi mfschunkserver.cfg
MASTER_HOST = 10.10.1.31
### 配置mfshdd.cfg主配置文件
$ cp /usr/local/mfs/etc/mfs/mfshdd.cfg.sample /usr/local/mfs/etc/mfs/mfshdd.cfg
$ vi /usr/local/mfs/etc/mfs/mfshdd.cfg
/mfsdata
### 启动check Server
$ mkdir /mfsdata
$ chown mfs:mfs /mfsdata/
$ /usr/local/mfs/sbin/mfschunkserver start
### 检查监听端口
$ netstat -lantp|grep 9420
tcp 0 0 10.10.1.33:36664 10.10.1.31:9420 ESTABLISHED 8126/mfschunkserver

挂载客户端(node5)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$ ### 下载环境包
$ yum install zlib-devel
### 安装moose
$ cd /usr/local/
$ wget https://github.com/moosefs/moosefs/archive/v3.0.96.tar.gz
$ useradd mfs
$ tar -xf v3.0.96.tar.gz
$ cd moosefs-3.0.96/
$ ./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfsmaster --disable-mfschunkserver --enable-mfsmount
$ make && make install
### 安装FUSE
$ lsmod|grep fuse
$ yum install fuse fuse-devel -y
$ modprobe fuse
$ lsmod |grep fuse
### 在客户端上挂载文件系统
$ mkdir /mfsdata
$ chown -R mfs:mfs /mfsdata/
$ /usr/local/mfs/bin/mfsmount /mfsdata -H 10.10.1.31 -p
MFS Password:
mfsmaster accepted connection with parameters: read-write,restricted_ip,map_all ; root mapped to mfs:mfs ; users mapped to mfs:mfs
$ df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.4M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 1.4G 49G 3% /
/dev/sda1 1014M 172M 843M 17% /boot
/dev/mapper/centos-home 27G 33M 27G 1% /home
vagrant 141G 19G 122G 14% /vagrant
tmpfs 789M 0 789M 0% /run/user/0
10.10.1.31:9421 100G 3.3G 97G 4% /mfsdata
### 本地文件写入测试
$ cd /mfsdata/
$ touch wanglibing.txt
$ echo "test" > wanglibing.txt
$ cat wanglibing.txt
test

参考

坚持原创技术分享,您的支持将鼓励我继续创作!