fastdfs 自动安装配置脚本
在服务器上翻出来之前写的一个FastDFS的安装脚本,功能:
自动安装FastDFS的tracker和storage
自动配置(基本上是默认配置)
FastDFS 的版本为3.08 现在已经不是最新的推荐版本了,需要的自己改脚本里的链接.
此脚本根据我之前写的一篇文章编写:
http://opswill.com/articles/how-to-install-and-configure-fastdfs-tracker-and-storage.html
#!/bin/bash
if [ $UID -ne 0 ];then
echo "please run this script as root "
else
cat << menu
1) Install
2) Unistall
menu
echo -n "please enter your choice:"
read choice
case "$choice" in
1)
echo "************************************************************"
echo " This script will auto install FastDFS tracker and storage"
echo " And configure it automantic,tracker and storage will install localhost"
echo " Notice that the conf files are located in /etc/fdfs"
echo " The main programs locate in /usr/local/bin/fdfs_*"
echo "libevent version: 2.0.17 FastDFS version: 3.08"
echo "************************************************************"
read -s -n 1 -p "press a key to continue ..."
patform=`uname -i`
IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
echo -e "\e[1;31m preparing the packages.......\e[0m"
rm -rf libevent-2.0.17-stable.tar.gz
rm -rf FastDFS_v3.08.tar.gz
yum check-update
echo -e "\e[1;31m install gcc etc .......\e[0m"
yum -y install gcc gcc-c++ glib2 glib2-devel make
echo -e "\e[1;31m download and install libevent .......\e[0m"
wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.17-stable.tar.gz
tar -xvf libevent-2.0.17-stable.tar.gz && cd libevent-2.0.17-stable && ./configure --prefix=/usr && make clean && make && make install
cd ../ && rm -rf libevent-2.0.17-stable libevent-2.0.17-stable.tar.gz
if [ $patform='x86_64' ];then
if [ -e /usr/lib/libevent-2.0.so.5 ];then
ln -s /usr/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
fi
fi
echo -e "\e[1;31m download fastdfs......\e[0m"
wget http://fastdfs.googlecode.com/files/FastDFS_v3.08.tar.gz
tar -xvf FastDFS_v3.08.tar.gz && cd FastDFS && ./make.sh && ./make.sh install
cd ../ && rm -rf FastDFS_v3.08.tar.gz FastDFS
echo -e "\e[1;31m configure Fastdfs tracker server.......\e[0m"
mkdir -p /var/fastdfs/tracker
mkdir -p /var/fastdfs/storage
mkdir -p /var/fastdfs/data
sed -i 's/reserved_storage_space = 4GB/reserved_storage_space = 1GB/' /etc/fdfs/tracker.conf
sed -i 's#base_path=/home/yuqing/fastdfs#base_path=/var/fastdfs/tracker#' /etc/fdfs/tracker.conf
echo -e "\e[1;31m start fastdfs tracker.......\e[0m"
/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
echo -e "\e[1;31m configure Fastdfs storage server.......\e[0m"
sed -i 's#base_path=/home/yuqing/fastdfs#base_path=/var/fastdfs/storage#' /etc/fdfs/storage.conf
sed -i 's#store_path0=/home/yuqing/fastdfs#store_path0=/var/fastdfs/data#' /etc/fdfs/storage.conf
sed -i 's/tracker_server=192.168.209.121:22122/tracker_server='$IP':22122/' /etc/fdfs/storage.conf
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
echo -e "\e[1;31m install and start service finish!,please check it\e[0m"
;;
2)
killall fdfs_trackerd
killall fdfs_storaged
rm -rf /var/fastdfs/tracker /var/fastdfs/storage
rm -rf /usr/local/bin/fdfs_* /usr/local/bin/stop.sh /usr/local/bin/restart.sh /etc/fdfs/
echo -e "\e[1;31m Unistall Finished \e[0m"
;;
*)
echo -e "\e[1;31m input error,please run this script again\e[0m"
exit 0;
;;
esac
fi