FastDFS安裝配置

一:拓撲圖

wKiom1SKXBbx3CLAAALoAg_7kTw418.jpg


二:安裝前準備

tracker1:192.168.1.10

tracker2: 192.168.1.11


group1:

storage1:192.168.1.12

storage2:192.168.1.13


group2:

storage3:192.168.1.14

storage4:192.168.1.15


軟件包下載:

fastdfs:http://sourceforge.net/projects/fastdfs/files/

nginx:http://nginx.org/en/download.html


FastDFS:FastDFS_v5.03.tar.gz

Nginx擴展模塊:fastdfs-nginx-module_v1.16.tar.gz

Nginx版本:nginx-1.7.4.tar.gz


三:安裝

tracker:

    tar zxvf FastDFS_v5.03.tar.gz
    ./make.sh
    ./make.sh install


    配置:

    vim /etc/fdfs/tracker.conf

    一般只需改動以下幾個參數即可:

    disabled=false             #啓用配置文件 

    port=22122                 #設置 tracker 的端口號 

    base_path=/fdfs/tracker    #設置 tracker 的數據文件和日誌目錄(需預先創建) 

    http.server_port=80      #設置 http 端口號


    啓動:

    關閉防火牆:

    /etc/init.d/iptables stop

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


     設置開機自啓動:

     添加到/etc/rc.local中


    另外一臺tarcker同上安裝配置


storage

    安裝:

    tar zxvf FastDFS_v5.03.tar.gz

    ./make.sh

    ./make.sh install


    配置:

    vim /etc/fdfs/storage.conf

    一般只需改動以下幾個參數即可:

    disabled=false                         #啓用配置文件 

    group_name=group1                      #組名,根據實際情況修改 

    port=23000                             #設置 storage 的端口號 

    base_path=/fdfs/storage                #設置 storage 的日誌目錄(需預先創建) 

    store_path_count=1                     #存儲路徑個數,需要和 store_path 個數匹配 

    store_path0=/fdfs/storage              #存儲路徑 

    tracker_server=192.168.1.10:22122      #tracker 服務器的 IP 地址和端口號

    tracker_server=192.168.1.11:22122      #tracker 服務器的 IP 地址和端口號

    http.server_port=80                    #設置 http 端口號


    啓動:

    關閉防火牆:

    /etc/init.d/iptables stop

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


    檢測是否成功:

     /usr/local/bin/fdfs_monitor /etc/fdfs/storage.conf

    如果顯示:ACTIVE則成功

    添加到開機啓動


在storage服務器中安裝nginx提供http服務;

需要使用到fastdfs的nginx插件:

tar zxvf fastdfs-nginx-module_v1.15.tar.gz

tar zxvf nginx-1.4.7.tar.gz

cd nginx-1.4.7

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --add-module=/root/fastdfs-nginx-module/src

make && make install


cp /root/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs

vim nginx.conf

listen 80

在 server 段中添加:

location ~ /group[1-2]/M00 {

    root /fdfs/storage/data;

    ngx_fastdfs_module;

}


vim mod_fastdfs.conf

一般只需改動以下幾個參數即可:

base_path=/fdfs/storage                #保存日誌目錄 

tracker_server=192.168.1.10:22122      #tracker 服務器的 IP 地址以及端口號

tracker_server=192.168.1.11:22122      #tracker 服務器的 IP 地址以及端口號

storage_server_port=23000              #storage 服務器的端口號 

group_name=group1                      #當前服務器的 group 名 

url_have_group_name = true             #文件 url 中是否有 group 名 

store_path_count=1                     #存儲路徑個數,需要和 store_path 個數匹配 

store_path0=/fdfs/storage              #存儲路徑 

http.need_find_content_type=true       #從文件擴展名查找文件類型(nginx 時爲 true) 

group_count = 2                        #組的個數


在末尾增加 2 個組的具體信息:

[group1]

group_name=group1

storage_server_port=23000

store_path_count=1

store_path0=/fdfs/storage

[group2]

group_name=group2

storage_server_port=23000

store_path_count=1

store_path0=/fdfs/storage


建立 M00 至存儲目錄的符號連接

ln -s /fdfs/storage/data /fdfs/storage/data/M00

開啓80端口

其他storage上安裝nginx同上


在兩臺tracker上安裝nginx,主要提供反向代理,負載均衡

tar zxvf nginx-1.4.7.tar.gz

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre

make && make install

vim /usr/local/nginx/conf/nginx.conf

#設置 group1 的服務器

upstream fdfs_group1 {

    server 192.168.1.12;

    server 192.168.1.13;

}

#設置 group2 的服務器

upstream fdfs_group2 {

server 192.168.1.14;

server 192.168.1.15;

}


server{ 
listen 80; 
location /group1/M00{ 
proxy_set_header Host $host; 
proxy_pass http://fdfs_group1; 
expires 30d; 
} 

location /group2/M00{ 
proxy_set_header Host $host; 
proxy_pass http://fdfs_group2; 
expires 30d; 
} 
}


安裝配置完成,上傳文件測試……

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章