您的位置:首页 > 其它

MooseFS 分布式文件系统的安装(三)

2010-07-24 14:50 375 查看
客户端的安装
本例中客户端为linux5.5
为了挂接基于MooseFS 分布式文件,客户端主机必须安装FUSE 软件包( fuse 版本号至少
2.6,推荐使用版本号大于2.7.2 的fuse)。如果系统没有安装fuse,你必须手动对其进行安装。
一种常见的安装方式是从源码进行编译安装-我们可以从http://sourceforge.net/projects/fuse/取得安装源码
cd /usr/local/src
tar -zxvf fuse-2.8.4.tar.gz
cd fuse-2.8.4 && ./configure && make && make install
修改环境变量文件/etc/profile
vim /etc/profile 追加这一行
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
然后让配置生效
source /etc/profile
如果不执行这个操作,在后面安装MFS 的过程中,执行命令
./configure --enable-mfsmount 时可能出现"checking for FUSE... no configure:
error: mfsmount build was forced, but fuse development package is not
installed"这样的错误,而不能正确安装MFS 客户端程序。
tar -zxvf mfs-1.6.16.tar.gz
cd mfs-1.6.16
./configure --prefix=/usr --sysconfdir=/etc \
--localstatedir=/var/lib --with-default-user=mfs \
--with-default-group=mfs --disable-mfsmaster \
--disable-mfschunkserver
make && make install
假定客户端的挂接点是/mnt/mfs,我们将以下面的指令来使用MooseFS 分布式共享文件系
mkdir -p /mnt/mfs //创建挂载点
/usr/bin/mfsmount /mnt/mfs -H 10.80.11.203 //挂载
[root@localhost mfs-1.6.16]# /usr/bin/mfsmount /mnt/mfs -H 10.80.11.203
mfsmaster accepted connection with parameters: read-write,restricted_ip ; root mapped to root:root
注意,所有的MFS 都是挂接同一个元数据服务器master,而不是其他数据存储服务器chunkserver

查看空间
[root@localhost mfs-1.6.16]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 285G 2.3G 268G 1% /
/dev/sda1 99M 12M 83M 12% /boot
tmpfs 1014M 0 1014M 0% /dev/shm
mfs#10.80.11.203:9421
15G 0 15G 0% /mnt/mfs
MooseFS 基础用法
在mfs下建立2个文件夹1和2
设置文件夹1备份2次
文件夹2备份3次
cd /mnt/mfs
mkdir 1
mkdir 2
mfssetgoal 2 /mnt/mfs/1
mfssetgoal 3 /mnt/mfs/2
然后在文件夹1创建一个100M的文件
cd /mnt/mfs/1
dd if=/dev/zero of=1.img bs=1M count=100;
在文件夹2创建1G的文件
cd /mnt/mfs/2
dd if=/dev/zero of=2.img bs=1M count=1000;
设定、查看的目标mfssetgoal、mfsgetgoal副本数
mfssetgoal 2 /mnt/mfs/1 //设定副本数为2
mfssetgoal /mnt/mfs/1 //查看副本数
mfsdirinfo 显示了目录、文件及 chunks 的数目,还有整个目录占用磁盘空间的情况[root@localhost mfs]# mfsdirinfo /mnt/mfs/1
/mnt/mfs/1:
inodes: 2
directories: 1
files: 1
chunks: 2
length: 104857600
size: 104867840
realsize: 314603520

[root@localhost mfs]# mfsdirinfo /mnt/mfs/2
/mnt/mfs/2:
inodes: 2
directories: 1
files: 1
chunks: 16
length: 1048576000
size: 1048657920
realsize: 3145973760
表示文件夹2中的文件分成了16个块
mfsfileinfo 显示文件基本信息。
[root@localhost mfs]# mfsfileinfo /mnt/mfs/1/1.img
/mnt/mfs/1/1.img:
chunk 0: 0000000000000014_00000001 / (id:20 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 1: 0000000000000015_00000001 / (id:21 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
[root@localhost mfs]# mfsfileinfo /mnt/mfs/2/2.img
/mnt/mfs/2/2.img:
chunk 0: 0000000000000016_00000001 / (id:22 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 1: 0000000000000017_00000001 / (id:23 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 2: 0000000000000018_00000001 / (id:24 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 3: 0000000000000019_00000001 / (id:25 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 4: 000000000000001A_00000001 / (id:26 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 5: 000000000000001B_00000001 / (id:27 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 6: 000000000000001C_00000001 / (id:28 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 7: 000000000000001D_00000001 / (id:29 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 8: 000000000000001E_00000001 / (id:30 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 9: 000000000000001F_00000001 / (id:31 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 10: 0000000000000020_00000001 / (id:32 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 11: 0000000000000021_00000001 / (id:33 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 12: 0000000000000022_00000001 / (id:34 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 13: 0000000000000023_00000001 / (id:35 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 14: 0000000000000024_00000001 / (id:36 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
chunk 15: 0000000000000025_00000001 / (id:37 ver:1)
copy 1: 10.80.11.205:9422
copy 2: 10.80.11.206:9422
mfsgettrashtime 验证、查看数据删除回收时间,默认为86400(1天)
mfsgettrashtime -r /mnt/mfs/1 我事先已经改成10分钟了
/mnt/mfs/1:
files with trashtime 600 : 1
directories with trashtime 600 : 1
mfssettrashtime 300 /mnt/mfs/1 //设置文件夹1的删除回收时间为300秒
建立回收站
mkdir /mnt/mfsmeta
mfsmount -o nonempty -m /mnt/mfsmeta -H 10.80.11.203
测试在1文件夹下建立1.txt,然后删除,进入回收站看到如下
cd /mnt/mfsmeta/trash
[root@localhost trash]# ls -alt
total 5
drwx------ 3 root root 0 Jul 24 16:14 .
dr-xr-xr-x 4 root root 0 Jul 24 16:14 ..
d-w------- 2 root root 0 Jul 24 16:14 undel
-rw------- 1 root root 4096 Jul 24 16:12 00000015|1|.1.txt.swp
-rw-r--r-- 1 root root 12 Jul 24 16:12 00000016|1|1.txt
-rw------- 1 root root 0 Jul 24 16:12 00000013|1|.1.txt.swp
-rw------- 1 root root 0 Jul 24 16:12 00000014|1|.1.txt.swx
恢复文件的话就执行这样的操作,把结尾是1.txt启动到undel文件夹中就还原了
mv '0000001F|1|1.txt' ./undel
把挂接命令追加到文件/etc/rc.local,可实现开机自动启动挂接MFS
停止 MooseFS
为了安全停止MooseFS 集群,建议执行如下的步骤:
停止chunk server 进程: /usr/sbin/mfschunkserver stop
停止 metalogger 进程: /usr/sbin/mfsmetalogger stop
停止主控 master server 进程: /usr/sbin/mfsmaster stop
在所有客户端用Unmount 命令先卸载文件系统(本例将是: umount /mnt/mfs)
本文出自 “无云安全技术站” 博客,请务必保留此出处http://hx100.blog.51cto.com/44326/358207
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: