天天看點

mfsclient安裝腳本

#!/bin/bash

####結果判斷

judge() {

  if [ $? -eq 0 ];then

     echo "successfly..."

  else

     echo "filed...."

     exit 500

  fi

}

echo "####環境準備"

/etc/init.d/iptables stop &>> /dev/null

setenforce 0

cd /usr/local/src

yum -y install fuse-devel zlib-devel &>> /dev/null

id mfs &>> /dev/null

if [ $? -ne 0 ];then

   useradd -s /sbin/nologin mfs

fi

judge

echo "####下載下傳mfs安裝包"

if [ ! mfs-1.6.27-5.tar.gz ];then 

   wget http://www.moosefs.org/tl_files/mfscode/mfs-1.6.27-5.tar.gz &>> /dev/null

echo "####編譯安裝mfs"

tar -zxf mfs-1.6.27-5.tar.gz

cd mfs-1.6.27

./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfsmaster --disable-mfschunkserver --enable-mfsmount &>> configure-`date +%f`.log

make &>> make-`date +%f`.log

make install &>> make-`date +%f`.log

if [ `grep "usr/local/lib/pkgconfig" /etc/profile|wc -l` -eq 0 ];then

   echo "export pkg_config_path=/usr/local/lib/pkgconfig:\$pkg_config_path" >> /etc/profile

   source /etc/profile

rm -rf make-`date +%f`.log configure-`date +%f`.log

dev_fount() {

   if [ -d /cache -a -d /cache/mfs ];then

      /usr/local/mfs/bin/mfsmount /cache/mfs -h 192.168.110.130 &>> mount.log

   else

      mkdir -p /cache/mfs

   fi

   dev=`df -h|grep mfs|wc -l`

   if [ $dev -ne 0 ];then

      echo "master挂載成功"

      echo "master挂載失敗"

      exit

echo "####加載fuse子產品并建立挂載點"

mod_fuse=`lsmod | grep fuse|wc -l`

if [ $mod_fuse -eq 0 ];then

   modprobe fuse

   if [ `df -h |grep /cache/mfs|wc -l` -eq 0 ];then

      dev_fount

else

if [ `grep "/usr/local/mfs/bin" /etc/profile|wc -l` -eq 0 ];then

   echo "export path=/usr/local/mfs/bin:$path" >> /etc/profile

echo "####添加開機啟動項和hosts"

sed -i '/test_server/d' /etc/hosts

sed -i "/mfsmount/d" /etc/rc.local

echo "/usr/local/mfs/bin/mfsmount /cache/mfs -h 192.168.110.130" >> /etc/rc.local

echo "192.168.110.130 test_server_110_130

192.168.110.131 test_server_110_131

192.168.110.132 test_server_110_132

192.168.110.133 test_server_110_133

192.168.110.134 test_server_110_134" >> /etc/hosts

read -p  "設定檔案被複制的份數(要小于等于chunkserver的數量):" num

mfssetgoal -r $num /cache/mfs

繼續閱讀