3Unison双向同步工具配置

3.1Unison简介

UnisonWindowsLinux以及其他Unix平台下都可以使用的文件同步工具,它能使两个文件夹(本地或网络上的)保持内容的一致。Unison拥有与其它一些同步工具或文件系统的相同的特性,但也有自身的特点:

1.跨平台使用;

2.对内核和用户权限没有特别要求;

3.Unison是双向的,它能自动处理两分拷贝中更新没有冲突的部分,有冲突的部分将会显示出来让用户选择更新策略;

4.只要是能连通的两台主机,就可以运行unison,可以直接使用socket连接或安全的ssh连接方式,对带宽的要求不高,使用类似rsync的压缩传输协议。

3.2、安装Unison

我们需要在主机192.168.1.237和备机192.168.1.236上分别安装unison

1、安装ocaml

Linux下通过源码安装unison的时候,需要首先安装一个名为objective caml compiler的工具,ocaml的版本应至少为3.0.7或者更高。

Ocaml下载地址 http://caml.inria.fr/pub/distrib/

Unison下载地址http://www.seas.upenn.edu/~bcpierce/unison//download/releases/

这里选择ocaml版本为ocaml-3.12.0

[root@server1~]# tar -xzvf ocaml-3.12.0.tar.gz

[root@server1~]# cd ocaml-3.12.0

[root@server1ocaml-3.12.0]# ./configure

[root@server1ocaml-3.12.0]# make world opt

[root@server1ocaml-3.12.0]# make install

1、 安装unison

[root@server1 ~]# tar -xzvfunison-2.40.63.tar.gz

[root@server1 ~]# cdunison-2.40.63

[root@server1 unison-2.40.63]#make UISTYLE=text

[root@server1unison-2.40.63]# make install

注意:在执行make install的过程中,可能会出现以下错误提示:

mv: cannot stat '/root/bin//unison': No such file or directory

make: [doinstall] Error 1 (ignored)

cp unison /root/bin/

cp: cannot create regular file '/root/bin/': Is a directory

make: *** [doinstall] Error 1

出现错误的原因在与Unison默认是将文件Copy/root/bin目录,但Linux默认是没有该目录的,因此我们需要将生成的可执行文件unison复制到系统的PATH目录。

[root@server1 unison-2.40.63]# cp unison /usr/local/bin   然后再执行make install

3.3、配置ssh双机信任

我们要配置非root用户下的普通用户的ssh双机信任。这里我们使用安装mfs文件系统的时的mfs用户

在两台服务器上创建unison用户,主机server1IP192.168.1.237,备机server2IP192.168.1.236

[root@server1~]# useradd -m mfs

[root@server1~]# passwd mfs

[root@server2~]# useradd -m mfs

[root@server2~]# passwd mfs

server1上创建key并配置server2的信任

[root@server1~]# su - mfs

[unison@server1~]$ ssh-keygen -t rsa

在提示保存私钥(key)和公钥(public key)的位置时,使用默认值;

在提示是否需要私钥密码(passphrase)时,直接敲回车,即不使用私钥密码。

之后,将生成一对密钥,id_rsa(私钥文件)和id_rsa.pub(公钥文件),保存在/home/unison/.ssh/目录下。

将公钥添加到server2 authorized_keys 文件中

[unison@server1~]$ cd  /home/mfs/.ssh/

[unison@server1~]$ ssh 192.168.1.237 cat /home/mfs/.ssh/id_rsa.pub >> authorized_keys

[unison@server1~]$ ssh 192.168.1.236 cat /home/mfs/.ssh/id_rsa.pub >> authorized_keys

[unison@server1~]$ scp authorized_keys 192.168.1.236:/home/mfs/.ssh/

两台机器上都执行chmod600 /home/mfs/.ssh/authorized_keys,这个文件的权限一定要是600,至于为什么,你知道的!!!

然后分别在两台机器上执行:

[unison@server1~]$ ssh 192.168.1.237 date

[unison@server1~]$ ssh 192.168.1.236 date

在第一次执行时,会要求输入用户密码信息,再次执行时不需要输入密码就能显示系统日期,这说明ssh互相信任成功,在正式环境中,我们需要使用mfs这个用户,而不是unison用户。

注意:如果主备机更换了IP或者使用其他用户名用来同步,则需要重新配置ssh双机信任。否则同步无法使用。

3.4Unison的使用

在正式使用unison之前最好测试一下,测试过之后它会自动在普通用户的家目录生成一个.unison的隐藏目录,这个隐藏目录里有三类文件,一种是随机命名的文件,记录文件同步实时信息,内容较少。default.prf默认配置文件,我们后面需要修改。unison.log记录所有同步事件。

在两台服务器上创建test目录,用于测试

[root@server1~]# su - mfs

[unison@server1~]$ mkdir test

[root@server2~]# su - mfs

[unison@server2~]$ mkdir test

在两台服务器上分别执行一次unison,如果出现提示确认,则直接敲回车选择默认值

需要说明的是:两台机器上需要同步的文件夹最好权限都是一样的,不然会出现错误信息。

[unison@server1~]$unison/home/mfs/test/ ssh://unison@192.168.1.236//home/mfs/test/

[unison@server2~]$unison/home/mfs/test/ ssh://unison@192.168.1.237//home/mfs/test/

注意事项:如果出现

bashunisoncommand not found

Fatal error:Lost connection with the server

查看你的unison命令是否是系统的可执行命令,如果不是,加入到系统路径中。在上面的命令末尾加入参数-servercmd=/usr/local/bin/unison来告诉unison命令的位置。

如果正式使用的话,我们需要通过配置文件来使用unison

修改两台服务器的unison配置文件,输入以下内容

[unison@server1~]$ vim /home/mfs/.unison/default.prf

#Unison preferences file

#force=/home/unison/test  local->remote

root=/usr/local/mfs/var/mfs

root=ssh://mfs@192.168.1.236//usr/local/mfs/var/mfs

#path=aaa

#path=bbb

batch=true

#maxthreads=300

owner=true

group=true

perms=-1

fastcheck=false

rsync=false

sshargs=-C

xferbycopying=true

confirmbigdel=false

log=true

logfile=/home/mfs/.unison/unison.log

                                          

[unison@server2~]$ vim /home/mfs/.unison/default.prf

#Unison preferences file

#force=/home/unison/test  local->remote

root=/usr/local/mfs/var/mfs

root=ssh://mfs@192.168.1.237//usr/local/mfs/var/mfs

#path=aaa

#path=bbb

batch=true

#maxthreads=300

owner=true

group=true

perms=-1

fastcheck=false

rsync=false

sshargs=-C

xferbycopying=true

confirmbigdel=false

log=true

logfile=/home/mfs/.unison/unison.log

 

相关注解如下:

两个root表示需要同步的文件夹。

force表示会以本地所指定文件夹为标准,将该目录同步到远端。这里需要注意,如果指定了force参数,那么Unison就变成了单项同步了,也就是说会以force指定的文件夹为准进行同步,类似与rsync

ignore = Path表示忽略指定目录,即同步时不同步它。

batch = true,表示全自动模式,接受缺省动作,并执行。

-fastcheck true 表示同步时仅通过文件的创建时间来比较,如果选项为falseUnison则将比较两地文件的内容。

log = true 表示在终端输出运行信息。

logfile 指定输出的log文件。

另外,Unison有很多参数,这里仅介绍常用的几个,详细的请参看Unison手册。

-auto //接受缺省的动作,然后等待用户确认是否执行。

-batch //batch mode, 全自动模式,接受缺省动作,并执行。

-ignore xxx //增加 xxx 到忽略列表中

-ignorecase [true|false|default] //是否忽略文件名大小写

-follow xxx //是否支持对符号连接指向内容的同步

owner = true //保持同步过来的文件属主

group = true //保持同步过来的文件组信息

perms = -1 //保持同步过来的文件读写权限

repeat = 1 //间隔1秒后,开始新的一次同步检查

retry = 3 //失败重试

sshargs = -C //使用ssh的压缩传输方式

xferbycopying = true"

-immutable xxx //不变目录,扫描时可以忽略

-silent //安静模式

-times //同步修改时间

-path xxx 参数 //只同步 -path 参数指定的子目录以及文件,而非整个目录,-path 可以多次出现。

confirmbigdel = false  #true表示当需要同步的两个目录一个为空时,unison将停止 false表示同步的某个目录为空时不会停止运转

PSWindows下的unison配置文件默认位于C:\Documentsand Settings\currentuser\.unison目录,默认的配置文件名是default.prf

Unison双向同步基本原理是:假如有A B两个文件夹,A文件夹把自己的改动同步到BB文件夹也把自己的改动同步到A,最后A B两文件夹的内容相同,是AB文件夹的合集。

Unison双向同步的一个缺点是,对于一个文件在两个同步文件夹中都被修改时,unison是不会去同步的,因为unison无法判断以那个为准,需要人工指定。

3.5Unison测试

首先分别在server1server2/usr/local/mfs/var/mfs目录下创建文件或目录,然后在server1上执行unison,接着如果在server1server2上都能看到各自创建的文件,就说明同步成功。

分别在server1server2上创建文件

[unison@server1~]$ cd /usr/local/mfs/var/mfs

[unison@server1test]$ touch 1.txt touch 3.txt

[unison@server2~]$ cd /usr/local/mfs/var/mfs

[unison@server2test]$ touch 2.txt touch 4.txt

server1上执行unison

[unison@server1~]$ unison

server1server2上查看文件是否同步

[unison@server1~]$ cd /usr/local/mfs/var/mfs

[unison@server1test]$ ls

1.txt2.txt 3.txt 4.txt

[unison@server2~]$ cd /usr/local/mfs/var/mfs

[unison@server2test]$ ls

1.txt2.txt 3.txt 4.txt

均看到了“1.txt 2.txt 3.txt4.txt”所有文件,说明文件同步已经成功!

3.6、安装inotify-tools

考虑到unison的双向同步性,我们不可能使用日常调度来执行unison同步,所以加入监控机制inotify

1、查看系统是否支持inotify

[unison@server1~]# ls -l /proc/sys/fs/inotify

total0

-rw-r--r--1 root root 0 Nov 11 11:25 max_queued_events

-rw-r--r--1 root root 0 Nov 11 11:25 max_user_instances

-rw-r--r--1 root root 0 Nov 11 11:25 max_user_watches

则说明支持inotify.

inotify可以监视的文件系统事件包括:

IN_ACCESS,即文件被访问

IN_MODIFY,文件被 write

IN_ATTRIB,文件属性被修改,如 chmodchowntouch

IN_CLOSE_WRITE,可写文件被 close

IN_CLOSE_NOWRITE,不可写文件被 close

IN_OPEN,文件被 open

IN_MOVED_FROM,文件被移走, mv

IN_MOVED_TO,文件被移来,如 mvcp

IN_CREATE,创建新文件

IN_DELETE,文件被删除,如 rm

IN_DELETE_SELF,自删除,即一个可执行文件在执行时删除自己

2、安装inotify

[unison@server1~]#  tar -zxvf inotify-tools-3.14.tar.gz

[unison@server1~]# cd inotify-tools-3.14

[root@server1 ~ inotify-tools-3.14]# ./configure --prefix=/usr/local/inotify

[root@server1 ~ inotify-tools-3.14]# make && make install

 

可能出现的问题:

Please increase the amount of inotify watches allowed per user via`/proc/sys/fs/inotify/max_user_watches'.

cat一下这个文件,默认值是8192

echo 8192000 >> /proc/sys/fs/inotify/max_user_watches

我们增大一下线程即可~,这样加入后重启后没了,需要加入开机启动中。

2、 编写inotify实时监控脚本

[unison@server1~]# vim unison.sh

#!/bin/bash

DESTHOST=192.168.1.56

DESTHOSTDIR=/home/unison/test

SRCDIR=/home/unison/test

/usr/local/inotify/bin/inotifywait-mrq  --timefmt '%d/%m/%y %H:%M' --format'%T %w %f'  -e create,delete,modify,move$SRCDIR | while read files

do

unison-servercmd=/usr/local/bin/unison

done

chmod755 unison.sh, 按同样方法在server2安装inotify和编写同步脚本

3、 分别在server1server2unison用户下让脚本在后台运行

[unison@server1 ~]$ nohup./unison.sh &

[unison@server2 ~]$nohup ./unison.sh &

在正式环境中,只在主机上执行了nohup./unison.sh &,备机不用执行,这样也是可以的,如果主机发生故障,切换到备机上,备机开始工作,数据读写记录到metadata里,当主机恢复后,备机工作那段时间内所记录的数据可能不会马上同步过来,不过不用担心,这部分数据不会丢失,只要有新数据在mfs客户端写入或者主机有变化之后,备机上那部分数据就会自动同步过来。这样在主机上执行unison同步的方式,可能会导致在故障情况下数据的不及时性,为了同步更加及时,建议主备机上都执行unison同步。

Unison因为是双向同步,必然有它的弊端,如果发生意外故障,破坏了同步目录里面的文件,那么会影响正常业务的使用的,所以做好同步目录的数据备份是很重要的。

3.7、模拟mfs故障测试

1、当主机故障时,自动切换到备机,备机正常启动了mfsmaster而且没有数据丢失。但是在恢复主机mfsmaster时,提示由于缺少metadata.mfs造成无法启动,这时我们可以在主机执行恢复性操作,让它自动产生metadata.mfs,具体方法为使用/usr/local/mfs/sbin/mfsmaster  -a 就可以启动mfsmaster,而且数据不会丢失。这是和先前的mfs1.6.27版本的恢复方式不一样的地方。

2、在同步相同文件时,如果该文件被锁定(比如mfsmaster启动时的.lock文件)或者是同时修改,unison不会对该文件进行同步,会自动跳过。

3.8mfs监控脚本

1、需在被监控机上需要安装好nagios-pluginsnrpe,我们直接编辑一个check_mfs的脚本,编写完把这个脚本复制到/usr/local/nagios/libexec/下,并赋权755,内容如下:

#!/bin/bash

#a nagios plugin for  checkmoosefs healthy

CHECK_OK=0

CHECK_WARNING=1

CHECK_CRITICAL=2

CHECK_UNKNOWN=3

 

CHECK_MASTER () {

        check_process=`psaux|grep '/usr/local/mfs/sbin/mfsmaster'|grep -v grep`

        check_port=`netstat-lunpt|grep ':9419'`

        if [ -n"$check_process" -a -n "$check_port" ]

        then

        echo "mfsmasteris OK"

        exit 0

        else

        echo "mfsmasteris not running"

        exit 2

        fi

}

 

CHECK_CHUNK () {

        check_process=`psaux|grep '/usr/local/mfs/sbin/mfschunkserver'|grep -v grep`

        check_port=`netstat-lunpt|grep ':9422'`

        if [ -n"$check_process" -a -n "$check_port" ]

        then

        echo"mfschunkserver is OK"

        exit 0

        else

        echo"mfschunkserver is not running"

        exit 2

        fi

}

CHECK_CLIENT () {

        check_process=`psaux|grep '/usr/local/mfs/bin/mfsmount'|grep -v grep`

        if [ -n"$check_process" ]

        then

        echo "mfsclientis OK"

        exit 0

        else

        echo "mfsclientis not running"

        exit 2

        fi

}

CHECK_METALOGGER () {

        check_process=`psaux|grep '/usr/local/mfs/sbin/mfsmetalogger'|grep -v grep`

        if [ -n"$check_process" ]

        then

        echo"mfschunkserver is OK"

        exit 0

        else

        echo"mfschunkserver is not running"

        exit 2

        fi

}

case "$1" in

        -M)

        CHECK_MASTER

        ;;

        -c)

        CHECK_CLIENT

        ;;

        -C)

        CHECK_CHUNK

        ;;

        -L)

        CHECK_METALOGGER

        ;;

        *)

        echo "Unknownargement: $1"

        ;;

esac

2nrpe安装目录中添加命令

  • master服务器nrpe配置文件中添加监控

command[check_mfs]=/usr/local/nagios/libexec/check_mfs  –M

  • chunkservernrpe配置文件中添加监控

command[check_mfs]=/usr/local/nagios/libexec/check_mfs  –c

  • mfsclient中的nrpe配置文件中添加监控

command[check_mfs]=/usr/local/nagios/libexec/check_mfs  –C

3、最后在nagios上添加服务和主机即可。

另外,由于192.168.1.134这台服务器,即是chunkserver又是mfsclient,而且chunkserver所分配的空间是最小的为440GiB,所以还需要单独对chunkserver所占用空间进行单独监控。在134上的nrpe配置文件中加入:

command[check_chunkserverdata_34]=/usr/local/nagios/libexec/check_disk-w 30% -c 20% -p  /databak/

3.9mfs备份脚本

一、本机备份脚本

这个相对来说很简单,不过要说明两点:

1、  在本机,备份打包的文件不要放在同步目录里。

2、  备份时间最好不要是每天的整点,因为整点的时候,正好是changelog归纳到metadata最为繁忙的时候,通过cacti流量可以看出。

 #!/bin/bash

rq=`date +"%Y%m%d"`

rq1=` date "-d 7 day ago" "+%Y%m%d"`

cp -r /usr/local/mfs/var/mfs/*/mfsdata_backup/mfsdata

cd /mfsdata_backup/mfsdata

tar -zcf mfsdata.$rq.tar.gz *

mv/mfsdata_backup/mfsdata/mfsdata.$rq.tar.gz /mfsdata_backup

chown -R ftpuser.ftpuser/mfsdata_backup/mfsdata.$rq.tar.gz

rm -rf /mfsdata_backup/mfsdata/*

FILESIZE_MFSBUCKUP=`du -sh/mfsdata_backup/mfsdata.$rq.tar.gz | awk '{print $1}' `

echo "`date  +"%Y%m%d"` "MfsMetaData sizeis" $FILESIZE_MFSBUCKUP " >> /check_mfsdatalog/mfsmeta-size.log

rm -rf /mfsdata_backup/mfsdata.$rq1.tar.gz

 二、远程拷贝脚本

因为mfs备机空间不足,需要远程拷贝到其他机器上。

 #!/bin/bash

rq=`date +%Y%m%d`

rq1=` date "-d 3 day ago""+%Y%m%d" `

rm_ipAddr=192.168.1.236

host_id="remote236"

 

runName=$host_id.sh

echo "#!/usr/bin/expect" >/root/mfs-shell/$runName

echo "set password "ftpuser#236#ftpuser"">> /root/mfs-shell/$runName

echo "spawn scpftpuser@$rm_ipAddr:/mfsdata_backup/mfsdata.$rq.tar.gz/root/mfs-shell/mfsdata" >> /root/mfs-shell/$runName

echo "sleep 30" >>/root/mfs-shell/$runName

echo "expect\"ftpuser@$rm_ipAddr's password:\r\"" >>/root/mfs-shell/$runName

echo "send\"\$password\r\"" >> /root/mfs-shell/$runName

echo "set timeout 5000" >>/root/mfs-shell/$runName

echo "send \"exit\r\"">> /root/mfs-shell/$runName

echo "expect eof" >>/root/mfs-shell/$runName

chmod 777 /root/mfs-shell/$runName

/root/mfs-shell/$runName

echo "`date`"\t\t"236baksuccess" >> /root/mfs-shell/bak_log

rm -rf/root/mfs-shell/mfsdata/mfsdata.$rq1.tar.gz                                 

4Mfs文件系统问题故障点汇总

4.1mfsmaster异常问题

4.1.1Mfsmaster意外断电恢复启动

1mfs1.6.x如果mfsmaster无法启动,需要执行.. /sbin/mfsmetarestore –a或者手动执行mfsmetarestore -m metadata.mfs.back -ometadata.mfs changelog_ml.*.mfs 的方式来恢复。而在moosefs2.0.x如果mfsmaster无法启动,只需执行.. /sbin/mfsmaster –a来恢复,这点要分清。

4.1.2、启动和停止web界面

1、防火墙问题

mfsmaster时一定要关闭防火墙,否则会出现web界面功能性错误。如果必须开启防火墙,需要开放94199420942194229425端口。
注意事项:如果在启动mfscgiserv后,无法查看web监控页面,是由于mfs版本和系统的python版本不对应造成的。因为oel5.8python版本为2.4较低,Mfs1.6.20不需要升级python,而mfs1.6.27是需要升级python2.7的的,升级时,不要卸载旧的python2.4,下面给出升级python的方法和升级后产生的问题解决方法:

Python升级步骤:python下载地址:https://www.python.org/ftp/python/

安装Pyhton2.7

wgethttp://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2

tar -xjvf Python-2.7.5.tar.bz2

cd Python-2.7.5

./configure --prefix=/usr/local/python2.7

make

make install

配置python,把Python2.7作为默认的开发生产工具

mv /usr/bin/python /usr/bin/python_old  #(这是一种好习惯,不要随便删除文件)

ln -s /usr/local/python2.7/bin/python2.7  /usr/bin/python  软链接

用这种方法升级后会导致yum不可用,将会引起开机错误提示:ImportError:NoModule named dbusyum使用python2.4工具,上面的步骤启用了python2.7python的升级将会导致yum的不可用。

  • 修改yum的配置 vim /usr/bin/yum,#!/usr/bin/python 更改为 #!/usr/bin/python_old

  • 修改yum守护进程,vim/usr/sbin/yum-updatesd #!/usr/bin/python -tt 改成#!/usr/bin/python_old -tt 

改完这两个文件后,重启进程serviceyum-updatesd restartyum即可使用了。

make install后,出现Pythonbuild finished, but the necessary bits to build these modules were not found:

_tkinter          bsddb185           dl             

p_w_picpathop           sunaudiodev                       

To find the necessary bits, look in setup.py indetect_modules() for the module's name.

这个两个模块用不着,不用管它。

另外、启动mfschunkservermfsmetaloggermfsclient时,也要关闭防火墙或者在防火墙上开启对应服务的端口,否则在web界面属于对应功能的面板会出错。

2can'tresolve master hostname and/or portname (mfsmaster:9421)

说明无法识别mfsmaster的主机名或IP,应该编辑/etc/hosts文件,添加以下语句:

主控的IP(:192.168.1.239)mfsmaster

另外在查看web界面时,新版的moosefs2.0.72需要输入DNSname,直接输入mfsmaster的名称,如不知,可以在mfsmaster输入hostname查看。

3、查看master上的/va/log/message日志出现:

     Jan 8 10:10:00 nginx mfsmaster[4845]: chunkservers status:

     Jan 8 10:10:00 nginx mfsmaster[4845]: total: usedspace: 0 (0 GB),totalspace: 0 (0 GB), usage: 0.00%

     这说明master没有发现到chunker服务器,请检查配置文件。

4.2Mfs客户端挂接类错误

4.2.1、资源暂时不可用

                            spacer.gif

注意:

1,出现这种情况是由于系统内核的版本问题,一般来说升级内核风险较大,不建议。mfsmountOEL5.8上是不支持UEK的内核的,目前测试过程中,只发现OEL5.8UEK版本不能挂接,其他版本的可以。一般系统默认有好几个内核,所有在启动是选择不是UEK的内核即可使用mfsmount,如果想自动启动,在/boot/grub/grub.conf中修改默认启动内核的default值即可。

2,  如果在挂接的时候出现:

/usr/local/mfs/bin/mfsmount/mnt/mfs -H 192.168.9.4
mfsmaster accepted connection with parameters: read-write,restricted_ip ; rootmapped to root:root
/bin/mount
:无法识别的选项“–no-canonicalize”
Usage: mount -V : print version
mount -h : print this help
mount : list mounted filesystems
mount -l : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere’.
Details found in /etc/fstab may be omitted.
mount -a [-t|-O] … : mount all stuff from /etc/fstab
mount device : mount device at the known place
mount directory : mount known device here
mount -t type dev dir : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
mount –bind olddir newdir
or move a subtree:
mount –move olddir newdir
One can change the type of mount containing the directory dir:
mount –make-shared dir
mount –make-slave dir
mount –make-private dir
mount –make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
mount –make-rshared dir
mount –make-rslave dir
mount –make-rprivate dir
mount –make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using -L label or by uuid, using -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say man 8 mount .
error in fuse_mount

mount的版本过低所导致的问题,在mfsmount的时候需要–no-canonicalize 参数支持。

解决方法:下载新版本, util-linux-ng-2.17进行安装。

[root@localhost ~]# tar -zxvf  util-linux-ng-2.17.tar.gz

[root@localhost ~]# cdutil-linux-ng-2.17

[root@localhost util-linux-ng-2.17]#./configure --prefix=/usr/local/util-linux-ng-2.17

[root@localhost util-linux-ng-2.17]#make && make install

[root@localhost util-linux-ng-2.17]# mv/bin/mount /bin/mount.old

[root@localhost util-linux-ng-2.17]# mv/bin/umount /bin/umount.old

[root@localhost util-linux-ng-2.17]# ln-s /usr/local/util-linux-ng-2.17/bin/mount /bin/mount

[root@localhost util-linux-ng-2.17]# ln-s /usr/local/util-linux-ng-2.17/bin/umount /bin/umount

[root@localhost util-linux-ng-2.17]#/usr/local/mfs/bin/mfsmount /var/www/html/ -H 192.168.1.56

mfsmaster accepted connection withparameters: read-write,restricted_ip ; root mapped to root:root

此时再次mfsmount就不会出现上述问题。

4.2.2、无法识别fuse

1、安装了fuse却无法识别

修改环境变量文件/etc/profile ,执行以下命令:

#exportPKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH

加载fuse模块到内核:

#modprobefuse(最好加入开机启动)

2error while loading sharedlibraries: libfuse.so.2: cannot open shared object file: No such file ordirectory

解决方法:输入以下命令更新/etc/ld.so.conf即可,记得在root权限下执行:

#ldconfig

3fuse: mountpoint is not empty

问题分析:挂载点不为空,看看fusemfs客户端是否已经挂载上了,或者查看挂接目录/mnt/mfs下是否已有文件。如果想强行挂接,需要在挂接命令后面加入-o nonempty选项,这样挂接后,原来目录下面的文件全部被mfs文件系统所覆盖,暂时不可查看,卸载掉mfs客户端后,原来目录下的文件会显示出来,不用担心文件丢失。

4.2.3、其他类错误

1、产生df:`/usr/xxtsrc/mfs: Transport endpoint is not connected的错误

处理的方式是umount/usr/xxtsrc/mfs,然后再重新挂载就可以了,这种                    情况用于用户MFS客户端出现误杀的情况。

2can’t  open file limited 1000

检查系统的文件描述限制,并重新设置。

3、多个mfs客户端挂接后,如果使用普通用户挂接后,对mfs文件系统的用户UIDGID要求:

在正式环境中,四台服务器在创建web用户时,系统UIDGID可能会不同,由于四个mfs客户端挂接同一个mfsmaster,共享盘里面文件的所属用户都是web,所属组是web,这个web用户的UIDGIDmfs客户端第一次挂接后根据该客户端所属的UIDGID附加的,如果挂接多个客户端,那么该UIDGID会在其他客户端显示出来,这样可能会造成其他客户端无法使用的情况,这一点是和windows不一样的。所以要挂接多个客户端,必须要求四台服务器UID,GID相同,在此,更改了38服务器web用户的UID54326GID54326 ,与34web用户UIDGID相同。下面给出稳妥的修改方法:

  groupmod –g 54326 web(修改web用户的GID

  usermod –u 54326 web(修改web用户的UID)

 然后 usermod  -g web web

或者添加附加组 usermod –G web web

特殊情况:如果该UID被其他用户所占用,请删除该用户。

如果该GID被其他用户所占用,请删除该组或者添加附加组,然后切换到普通用户下,使用newgrp +用户名的方式来切换GID,记得在修改完UID,GID之后,原来该用户下的文件的UIDGID不会自动变过来,需要重新赋予新的用户和组,

切记修改UIDGID不能直接vi系统配置文件,如果擅自修改,出现无法解决的问题后果自负。

4、在查看web界面的时候,发现有2个文件的goal0,在查看mfsmaster日志文件的时候,发现重复的提示:

mfsmaster[29045]: chunk00000000001028AF_00000001: there are no copies

mfsmaster[29045]: chunk 0000000000102897_00000001:there are no copies

chunkserver上,查找不到两个文件,这两个文件应该是先前测试数据遗留下来的无用文件。