fastdfs5.0.5+nginx安裝+tracker+storage

服務器環境:centos6 
IP:192.168.0.62 
所需資源下載:http://pan.baidu.com/s/1pwOQa 密碼:q63kjava

一、爲了順利安裝能夠先將防火牆關掉linux

service iptables stop 
chkconfig iptables off
vi /etc/selinux/config
修改 selinux=disable

二、增長gcc gcc-c++nginx

yum install -y gcc gcc-c++

三、安裝libfastcommon 
解壓:將安裝包解壓。c++

unzip libfastcommon-1.0.7.zipcd libfastcommon
./make.sh./make.sh install

能夠看到libfastcommon.so安裝到了/usr/lib64/libfastcommon.so 
可是FastDFS主程序設置的lib目錄是/usr/local/lib 
四、建立軟連接centos

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

五、安裝FastDFS 
解壓FastDFS瀏覽器

tar -zxvf FastDFS_v5.05.tar.gz 
cd FastDFS
vi ./make.sh
TARGET_CONF_PATH=/usr/local/FastDFS
./make.sh
./make.sh install
cp /ust/local/FastDFS/tracker.conf.sample /etc/fdfs/tracker.conf
cp /ust/local/FastDFS/storage.conf.sample /etc/fdfs/storage.conf

六、配置Tracker服務器

mkdir /data/fastdfs_tracker
vi /etc/fdfs/tracker.conf
base_path=/data/fastdfs_tracker

運行app

fdfs_trackerd /etc/fdfs/tracker.conf

七、配置Storage測試

mkdir /data/fastdfs_storage_info
mkdir /data/fastdfs_storage_data
vi /etc/fdfs/storage.conf
base_path=/data/fastdfs_storage_info
store_path0=/data/fastdfs_storage_data
tracker_server=192.168.0.62:22122

運行this

fdfs_storaged /etc/fdfs/storage.conf

配置完成,能夠在以下目錄查看日誌

/data/fastdfs_tracker/logs/tracker.log
/data/fastdfs_storage_info/logs/storage.log

啓動tracker

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

八、安裝nginx 
安裝nginx依賴包

yum install –y openssl-devel pcre-devel zlib-devel

解壓fastdfs-nginx-module

tar -zxvf fastdfs-nginx-module_v1.16.tar.gz 
cd fastdfs-nginx-module
cp ./fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
vi /etc/fdfs/mod_fastdfs.conf

修改以下信息

tracker_server=192.168.1.50:22122
url_have_group_name= true
store_path0=/data/fastdfs_storage_data

解壓、安裝nginx

tar -zxvf nginx-1.7.8.tar.gz
cd nginx-1.7.8./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module/src
make 
make install

若是make的時候報錯作以下操做 
a、yum groupinstall 「Development Tools」 
b、修改 fastdfs-nginx-module_v1.15/src/config

vi fastdfs-nginx-module_v1.15/src/config
修改爲如下內容 
ngx_addon_name=ngx_http_fastdfs_module 
HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module" NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c" CORE_INCS="$CORE_INCS /usr/local/fdfs/include/fastdfs /usr/local/fdfs/include/fastcommon/" CORE_LIBS="$CORE_LIBS -L/usr/local/fdfs/lib -lfastcommon -lfdfsclient" CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/usr/local/fdfs/conf/mod_fastdfs.conf\"'"

九、配置nginx

vi /usr/local/nginx/conf/nginx.conf
location /group1/M00 {
            root /data/fastdfs_storage_data;
            ngx_fastdfs_module;
}
location / {    
if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
        add_header Content-Disposition: 'attachment;';
    }
}

運行

ldd $(which /usr/local/nginx/sbin/nginx)

Tracker server啓動

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

Storage server啓動

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf

查看是否啓動成功

netstat -ntpl | grep fdfs

啓動nginx 
首先拷貝FastDFS目錄下conf目錄下得http.conf,mime.types

cp http.conf mime.types /etc/fdfs/
cd /usr/loca/nginx/sbin
./nginx

十、測試

cp /ust/local/FastDFS/client.conf.sample /etc/fdfs/client.conf
vi /etc/fdfs/client.cof
base_path=/tmp
tracker_server=192.168.0.62:22122

建立測試文件

vi test.txt

輸入內容: hello,this is my first fastdfs test 
運行

 /usr/bin/fdfs_test /etc/fdfs/client.conf upload test.txt

打印以下內容,說明上傳成功

This is FastDFS client test program v3.06Copyright (C) 2008, Happy Fish / YuQing


FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/for more detail.


[2012-06-13 17:58:25] INFO - base_path=/tmp, connect_timeout=30, network_timeout=60, tracker_server_count=2, anti_steal_token=0, anti_steal_secret_key 


length=0tracker_query_storage_store_list_without_group:
        server 1. group_name=group1, ip_addr=192.168.68.114, port=23000group_name=group1, ip_addr=192.168.0.62, port=23000storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607.txtsource ip address: 192.168.0.62file timestamp=2012-06-13 17:58:25file size=37file crc32=3584975788file url: http://192.168.0.62/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607.txtstorage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txtsource ip address: 192.168.68.114file timestamp=2012-06-13 17:58:25file size=37file crc32=3584975788file url: http://192.168.0.62/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txt

使用瀏覽器打開上傳的文件

http://192.168.0.62/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txt

若是看到文件內容,說明配置成功!

相關文章
相關標籤/搜索