#!/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
fi
judge
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
judge
make &>> make-`date +%F`.log
judge
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
fi
judge
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
/usr/local/mfs/bin/mfsmount /cache/mfs -H 192.168.110.130 &>> mount.log
fi
dev=`df -h|grep mfs|wc -l`
if [ $dev -ne 0 ];then
echo "master挂载成功"
else
echo "master挂载失败"
exit
fi
}
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
fi
else
if [ `df -h |grep /cache/mfs|wc -l` -eq 0 ];then
dev_fount
fi
fi
if [ `grep "/usr/local/mfs/bin" /etc/profile|wc -l` -eq 0 ];then
echo "export PATH=/usr/local/mfs/bin:$PATH" >> /etc/profile
source /etc/profile
fi
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
judge
read -p "设置文件被复制的份数(要小于等于chunkserver的数量):" num
mfssetgoal -r $num /cache/mfs
转载于:https://blog.51cto.com/11075514/1879295