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