#!/bin/bash
####结果判断
judge() {
if [ $? -eq 0 ];then
echo "successfly..."
else
echo "filed...."
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-mfschunkserver --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
\cp /usr/local/mfs/var/mfs/metadata.mfs.empty /usr/local/mfs/var/mfs/metadata.mfs
cat >/usr/local/mfs/etc/mfs/mfsexports.cfg <<EOF
# Allow everything but "meta".
* / rw,alldirs,maproot=0
# Allow "meta".
* . rw
EOF
judge
echo "####准备mfsmaster启动脚本"
\cp /usr/local/mfs/sbin/mfsmaster /etc/init.d/mfsmaster
chmod +x /etc/init.d/mfsmaster
/etc/init.d/mfsmaster start
echo "####添加开机启动项和hosts"
sed -i '/mfs/d' /etc/rc.local
sed -i '/test_server/d' /etc/hosts
echo "/etc/init.d/mfsmaster start" >> /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
judge
echo "####开启mfs图像监控"
\cp /usr/local/mfs/sbin/mfscgiserv /etc/init.d/mfscgiserv
chmod +x /etc/init.d/mfscgiserv
echo "/etc/init.d/mfscgiserv start" >> /etc/rc.local
/etc/init.d/mfscgiserv start
judge
转载于:https://blog.51cto.com/11075514/1879292