FastDfs 빠 른 설치

7696 단어 fastdfs
더 읽 기
\ # tracker / storage / nginx 시작

#  tracker/storage
fdfs_trackerd /etc/fdfs/tracker.conf
fdfs_storaged /etc/fdfs/storage.conf
#  nginx
kill -9 $(ps -A | grep nginx | cut -d "?" -f 1 ) &> /dev/null
/usr/local/nginx/sbin/nginx

다음 을 스 크 립 트 로 저장 합 니 다: FastdFS. sh 는 Liux 시스템 에서 실행 하면 됩 니 다.
스 크 립 트 는 필요 한 설치 패 키 지 를 자동 으로 다운로드 하고 자동 으로 설치 하 며 자동 으로 설정 합 니 다. 마지막 으로 성공 여 부 를 테스트 합 니 다.

#!/bin/bash
if [ -z $(rpm -qa | grep gcc-c++) ]
then
yum install -y gcc-c++
fi
######################## user property #########################################
#   tracker   IP  ,      tracker       ip
ip=192.168.9.129
#     
base_path=/usrdata/fastdfs
#  tracker  
tracker_port=22122
#nginx   
nginx_port=80
################################################################################

#      
cd ~
#      
mkdir -p $base_path


############################### 1、    : ##################################

if [ -f V1.0.7*.gz ]
then
echo ""
else
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
fi

if [ -f fastdfs*module*.gz ]
then
echo ""
else
wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz
fi

if [ -f V5.05*.gz ]
then
echo ""
else
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz
fi

if [ -f nginx-1.8.0*.gz ]
then
echo ""
else
wget http://nginx.org/download/nginx-1.8.0.tar.gz
fi
    
if [ -f pcre*.gz ]
then
echo ""
else
wget http://exim.mirror.fr/pcre/pcre-8.36.tar.gz
fi    

if [ -f zlib*.gz ]
then
echo ""
else
wget http://zlib.net/zlib-1.2.11.tar.gz
fi

packages=`ls -l | grep 'gz$' | wc -l`
echo $packages
if [ $packages != 6 ]
then
echo "    ,      "
exit
fi
#########################            end ###############################

#2、libfastcommon  :
cd ~
cp V1.0.7.tar.gz /usr/local/
tar -zxvf V1.0.7.tar.gz
cd libfastcommon-1.0.7
./make.sh
./make.sh install
rm -f /usr/local/V1.0.7.tar.gz

#libfastcommon.so      /usr/lib64/libfastcommon.so, FastDFS      lib   /usr/local/lib,       
 ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
 ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
 ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
 ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so

#3、  FastDFS:
cd ~
tar -zxvf V5.05.tar.gz -C /usr/local
cd /usr/local/fastdfs-5.05/

./make.sh
./make.sh install


#      :
cd /etc/fdfs
cp tracker.conf.sample tracker.conf
cp storage.conf.sample storage.conf
cp client.conf.sample client.conf

#       
#tracker.conf          :
#bind_addr=172.17.0.2
#port=22122
#http.server_port=8181
sed -i "s#\(bind_addr\).*#\1=$ip#" tracker.conf
sed -i "s#\(^port\).*#\1=$tracker_port#" tracker.conf
sed -i "s#\(base_path\).*#\1=$base_path#" tracker.conf
sed -i "s#\(^http.server_port\).*#\1=8181#" tracker.conf


#storage.conf          :
#group_name=group1
#bind_addr=172.17.0.2
#port=23000
#base_path=/usrdata/fastdfs
#store_path0=/usrdata/fastdfs
#tracker_server=172.17.0.2:22122
#http.server_port=8888
sed -i "s#\(bind_addr\).*#\1=$ip#" storage.conf
sed -i "s#\(base_path\).*#\1=$base_path#" storage.conf
sed -i "s#\(store_path0\).*#\1=$base_path#" storage.conf
sed -i "s#\(tracker_server\).*#\1=$ip:$tracker_port#" storage.conf
sed -i "s#\(http.server_port\).*#\1=8888#" storage.conf

#(3)  
#  tracker storage.conf
fdfs_trackerd /etc/fdfs/tracker.conf
fdfs_storaged /etc/fdfs/storage.conf

##############################4、  nginx  :#####################################
#(1)  
cd ~
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz


#(2)config    :
#vi config
#      ,      
#CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"
#  
#CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
#       ,   nginx         ,         nginx fastdfs     ,      ,        。
cd fastdfs-nginx-module/src/
sed -i "s#\(CORE_INCS=\"\$CORE_INCS \).*#\1/usr/include/fastdfs /usr/include/fastcommon/\"#" config



#    
#group_name=group1
#tracker_server=172.17.0.2:22122
#store_path0=/usrdata/fastdfs
#base_path=/usrdata/fastdfs
#url_have_group_name = true
sed -i "s#\(group_name\).*#\1=group1#" mod_fastdfs.conf
sed -i "s#\(tracker_server\).*#\1=$ip:$tracker_port#" mod_fastdfs.conf
sed -i "s#\(store_path0\).*#\1=$base_path#" mod_fastdfs.conf
sed -i "s#\(base_path\).*#\1=$base_path#" mod_fastdfs.conf
sed -i "s#\(url_have_group_name\).*#\1=true#" mod_fastdfs.conf

cp  mod_fastdfs.conf /etc/fdfs



#2)、           
ln -s /usrdata/fastdfs/data /usrdata/fastdfs/data/M00  
#(     stoage       )


#            /etc/fdfs/
cp /usr/local/fastdfs-5.05/conf/http.conf /etc/fdfs/
cp /usr/local/fastdfs-5.05/conf/mime.types /etc/fdfs/


#5、nginx  :
#   Storage      Nginx

#(1)pcre  :
cd ~
tar -zxvf pcre-8.36.tar.gz
cd pcre-8.36
./configure
make && make install
cd ../

ln -s /usr/local/lib/libpcre.so.1 /lib64/

#(2)zlib  :
cd ~
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install


#(3)nginx  :
cd ~
tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
ipath=`whoami`
./configure --prefix=/usr/local/nginx --add-module=/$ipath/fastdfs-nginx-module/src
make
make install




# server   
#
#location /group1/M00{
#    root /usrdata/fastdfs/data;
#    ngx_fastdfs_module;
#}

#            
nginxconf=`sed -n '/group1/p' /usr/local/nginx/conf/nginx.conf`

if [ -z $nginxconf ]
        then
                sed -i "s@#error_page.*@location /group1/M00{root /usrdata/fastdfs/data;ngx_fastdfs_module;}@" /usr/local/nginx/conf/nginx.conf
        else
                echo "nothing todo"
fi &> /dev/null




  :
kill -9 $(ps -A | grep nginx | cut -d "?" -f 1 ) &> /dev/null
/usr/local/nginx/sbin/nginx


    。
#6、      :
sed -i "s#\(base_path=\).*#\1$base_path#" /etc/fdfs/client.conf
sed -i "s#\(tracker_server=\).*#\1$ip:$tracker_port#" /etc/fdfs/client.conf
cd ~
echo "hello world" > 1.txt
#/usr/bin/fdfs_test /etc/fdfs/client.conf upload 1.txt
result=`/usr/bin/fdfs_test /etc/fdfs/client.conf upload 1.txt |grep url | grep -v big`
echo "        $result"
curl ${result:17}

좋은 웹페이지 즐겨찾기