首页 > 代码库 > mfschunkserver安装脚本

mfschunkserver安装脚本

#!/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 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

fi

judge


echo "####编译安装"

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-mfsmount &>> configure-`date +%F`.log

judge

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

judge

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

judge

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


echo "####准备配置文件"

for i in `ls /usr/local/mfs/etc/mfs/*.dist`

do

  num=`echo $i|wc -L`

  let num1=$num-5

  file=`echo ${i:0:$num1}`

  \cp $i $file

done


sed -i "/MASTER_HOST/a\MASTER_HOST = test_server_110_130" /usr/local/mfs/etc/mfs/mfschunkserver.cfg

chown mfs:mfs /usr/local/mfs/var/mfs

judge


echo "####准备数据存储空间"

dev=`df -h | grep /dev/sdb1|wc -l`

if [ $dev -eq 0 ];then

   if [ ! -d /cache1 ];then

      mkdir /cache1

      mount /dev/sdb1 /cache1

      name=`df -h|awk ‘$0~/dev\/sdb1/{print $NF}‘`

   else

      mount /dev/sdb1 /cache1

      name=`df -h|awk ‘$0~/dev\/sdb1/{print $NF}‘`

   fi

else

  name=`df -h|awk ‘$0~/dev\/sdb1/{print $NF}‘`

fi

chown -R mfs:mfs $name

echo "$name" >> /usr/local/mfs/etc/mfs/mfshdd.cfg

judge


echo "####准备chunkserver启动脚本"

\cp /usr/local/mfs/sbin/mfschunkserver /etc/init.d/mfschunkserver

chmod +x /etc/init.d/mfschunkserver

judge


echo "####添加开机启动项和hosts"

sed -i ‘/mfs/d‘ /etc/rc.local

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

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

echo -e "/etc/init.d/mfschunkserver start\nmount /dev/sdb1 /cache1/" >> /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

/etc/init.d/mfschunkserver start

judge


mfschunkserver安装脚本