FastDFS入門一篇就夠

完整安裝流程

下載的包都存放在~/caibh/fdfs-package目錄下。html

下載libfastcommonfastdfsfastdfs-nginx-modulenginx

cd ~/caibh/fdfs-package
# -S print server response
# -O write documents to file
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.39.tar.gz -SO libfastcommon.tar.gz
wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz -SO fastdfs.tar.gz
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz -SO fastdfs-nginx-module.tar.gz
# 解壓
tar -xf xxx.tar.gz

 安裝 libfastcommon

cd ~/caibh/fdfs-package
cd libfastcommon-1.0.39
./make.sh
./make.sh install

安裝 fastdfs

cd ~/caibh/fdfs-package
cd fastdfs-5.11
./make.sh
./make.sh install

安裝好後,程序是在/usr/bin目錄下:git

$ which fdfs_trackerd
/usr/bin/fdfs_trackerd

而配置文件是在/etc/fdfs目錄下:github

$ cd ~/caibh/fdfs-package/fastdfs-5.11
$ ls /etc/fdfs
client.conf.sample storage_ids.conf.sample  tracker.conf.sample storage.conf.sample

可是這些配置文件是不全的,並且都是模板,因此須要從fastdfs包中拷貝過來,並修改配置:web

$ cd ~/caibh/fdfs-package/fastdfs-5.11/conf
$ ls
anti-steal.jpg  client.conf  http.conf  mime.types  storage.conf  storage_ids.conf  tracker.conf
$ sudo cp ~/caibh/fdfs-package/fastdfs-5.11/conf/* /etc/fdfs

修改配置

sudo vi /etc/fdfs/tracker.confubuntu

# the tracker server port
port=22122

# the base path to store data and log files
base_path=/home/caibh/fdfs

# HTTP port on this tracker server
http.server_port=9270

sudo vi /etc/fdfs/storage.confbash

# storage所屬的組
group_name=group1

# the storage server port
port=23000

# the base path to store data and log files
base_path=/home/caibh/fdfs

# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
store_path0=/home/caibh/fdfs
#store_path1=/home/caibh/fdfs2

# tracker服務器,雖然是同一臺機器上,可是不能寫127.0.0.1。這項配置能夠出現一次或屢次
tracker_server=191.8.1.77:22122

# the port of the web server on this storage server
http.server_port=8888

sudo vi /etc/fdfs/client.conf服務器

# the base path to store log files
base_path=/home/caibh/fdfs/client
# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=191.8.1.77:22122
#HTTP settings
http.tracker_server_port=9270

sudo vi /etc/fdfs/mod_fastdfs.confapp

# the base path to store log files
base_path=/tmp

# FastDFS tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
# valid only when load_fdfs_parameters_from_tracker is true
tracker_server=191.8.1.77:22122

# the port of the local storage server
# the default value is 23000
storage_server_port=23000

# the group name of the local storage server
group_name=group1

# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
# must same as storage.conf
store_path0=/home/caibh/fdfs
#store_path1=/home/yuqing/fastdfs1

配置過程當中有幾點要注意:負載均衡

  • 確保配置中用到的目錄已經建立了。好比~/fdfs/client~/fdfs/data~/fdfs/logs
  • 確保各類配置文件之間引用的端口一直。好比:

    • mod_fastdfs.conf文件中tracker_server的端口應該跟tracker.confport一致;
    • mod_fastdfs.conf文件中storage_server_port的端口應該跟跟storage.confport一致;
  • 其餘配置或文件雖然不用修改,可是fastdfs-nginx-module模塊會用到:

    • anti-steal.jpg
    • http.conf
    • mime.types

啓動trackerstorage

# 啓動
fdfs_trackerd /etc/fdfs/tracker.conf start
fdfs_storaged /etc/fdfs/storage.conf start
# 查看日誌
tail -n10 ~/fdfs/logs/trackerd.log
tail -n10 ~/fdfs/logs/storaged.log
# 若是日誌顯示有錯誤信息,須要根據信息來查找錯誤緣由

fdfs_test測試上傳

$ fdfs_test /etc/fdfs/client.conf upload ~/caibh/test_images/XinXiJuZhiWang.jpg

安裝fastdfs-nginx-module

思路:

安裝過程比較複雜,因爲當前系統已經有一個nginx在運行了,因此要先確認當前系統nginx的版本,而後到官網下載對應版本的nginx源碼,而後查看系統nginx的編譯選項,用如出一轍的編譯選項外加fastdfs-nginx-module的源碼,從新編譯一個nginx程序。用新的nginx替換系統的nginx。

注意:

這裏的安裝場景是tracker和storage都裝在同一個機器上。

查看已安裝並在運行中的nginx的版本:

$ nginx -v
nginx version: nginx/1.10.3 (Ubuntu)

到官網下載對應版本的nginx源碼,並解壓,更名爲nginx-src,而後進入nginx-src目錄

查看當前運行的ngxin原來的編譯選項:

$ cd ~/caibh/nginx-src
$ nginx -V
nginx version: nginx/1.10.3 (Ubuntu)
built with OpenSSL 1.0.2g  1 Mar 2016
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads

爲了方便編輯,複製上面信息,在nginx-src目錄下建立一個custom_configure.sh文件,把複製的內容拷貝進去,並在最後加上fastdfs-nginx-module的源碼:

$ cd ~/caibh/nginx-src
$ cat custom_configure.sh 
./configure \
--with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' \
--with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' \
--prefix=/usr/share/nginx \
--conf-path=/etc/nginx/nginx.conf \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--lock-path=/var/lock/nginx.lock \
--pid-path=/run/nginx.pid \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-scgi-temp-path=/var/lib/nginx/scgi \
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
--with-debug \
--with-pcre-jit \
--with-ipv6 \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_auth_request_module \
--with-http_addition_module \
--with-http_dav_module \
--with-http_geoip_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_image_filter_module \
--with-http_v2_module \
--with-http_sub_module \
--with-http_xslt_module \
--with-stream \
--with-stream_ssl_module \
--with-mail \
--with-mail_ssl_module \
--with-threads \
--add-module=~/caibh/fdfs-package/fastdfs-nginx-module-1.20/src

執行custom_configure.sh

# ~/caibh/nginx-src
# 執行編譯
$ sudo ./custom_configure.sh 
# 報錯
./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.
# 解決
sudo apt-get install libxml2 libxml2-dev libxslt-dev

# 再次執行
$ sudo ./custom_configure.sh 
# 報錯
./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
#解決
sudo apt-get install libgd-dev

# 再次執行
$ sudo ./custom_configure.sh 
# 報錯
./configure: error: the GeoIP module requires the GeoIP library.
You can either do not enable the module or install the library.
# 搜索
$ sudo apt-cache search geoip
geoclue-ubuntu-geoip - Provide positioning for GeoClue via Ubuntu GeoIP services
geoip-bin - IP lookup command line tools that use the GeoIP library
geoip-database - IP lookup command line tools that use the GeoIP library (country database)
geoip-dbg - debugging symbols for the GeoIP packages
libgeoip-dev - Development files for the GeoIP library
.....
# 解決
$ sudo apt-install libgeoip-dev

執行後有用的信息,經過這些信息能夠知道編譯出來的nginx會裝到哪裏,配置文件會放在哪裏,錯誤日誌會放在哪裏:

Configuration summary
  + using threads
  + using system PCRE library
  + using system OpenSSL library
  + md5: using OpenSSL library
  + sha1: using OpenSSL library
  + using system zlib library

  nginx path prefix: "/usr/share/nginx"
  nginx binary file: "/usr/share/nginx/sbin/nginx"
  nginx modules path: "/usr/share/nginx/modules"
  nginx configuration prefix: "/etc/nginx"
  nginx configuration file: "/etc/nginx/nginx.conf"
  nginx pid file: "/run/nginx.pid"
  nginx error log file: "/var/log/nginx/error.log"
  nginx http access log file: "/var/log/nginx/access.log"
  nginx http client request body temporary files: "/var/lib/nginx/body"
  nginx http proxy temporary files: "/var/lib/nginx/proxy"
  nginx http fastcgi temporary files: "/var/lib/nginx/fastcgi"
  nginx http uwsgi temporary files: "/var/lib/nginx/uwsgi"
  nginx http scgi temporary files: "/var/lib/nginx/scgi"

中止nginx,並備份原來的nginx執行文件,和配置文件:

$ which nginx
/usr/sbin/nginx
$ sudo cp /usr/sbin/nginx /usr/sbin/nginx_org_bak
$ sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak

繼續在nginx-src目錄執行makemake install

$ cd ~/caibh/nginx-src
$ sudo make

# 報錯
Fatal error: can't create objs/addon/src/ngx_http_fastdfs_module.o: Permission denied
In file included from /home/xxxx/caibh/fdfs-package/fastdfs-nginx-module-1.20/src/common.c:26:0,
                 from /home/xxxx/caibh/fdfs-package/fastdfs-nginx-module-1.20/src/ngx_http_fastdfs_module.c:6:
/usr/include/fastdfs/fdfs_define.h:15:27: fatal error: common_define.h: No such file or directory

# 解決
# 修改fastdfs-nginx-module的src/config文件
$ cd /home/xxxx/caibh/fdfs-package/fastdfs-nginx-module-1.20/src
$ sudo vi config
# 修改一下兩項:
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

# 從新運行 nginx-src/custom_configure.sh
$ pwd
/home/xxxx/caibh/nginx-src
$ sudo ./custom_configure.sh
$ sudo make
$ sudo make install
# make install 會在/usr/share/nginx/sbin目錄下生成一個名爲nginx的可執行文件
$ sudo ls /usr/share/nginx
html  sbin

關閉系統原有的nginx,並備份好系統原來的nginx文件:

sudo nginx -s stop
cd /usr/sbin
sudo cp mv /usr/sbin/nginx /usr/sbin/nginx_bak

備份好後建立一個軟連接,放在/usr/sbin目錄下:

# 檢查本身編譯出來的nginx可否運行
$ ./nginx -v
nginx version: nginx/1.10.3
# 建立軟連接
$ sudo ln -s /usr/share/nginx/sbin/nginx /usr/sbin/nginx

配置nginx,加入路由規則,映射到fastdfs的數據目錄:

# config for fastdfs-nginx-module
server {
    listen 8777;
    location /M00 {
        root ~/fdfs/data;
        ngx_fastdfs_module;
    }
}

開放端口:

sudo iptables -A IN_public_allow -p tcp --dport 8777 -j ACCEPT
sudo iptables -L -n

測試上傳圖片:

$ fdfs_test /etc/fdfs/client.conf upload ~/caibh/test_images/XinXiJuZhiWang.jpg
This is FastDFS client test program v5.11

Copyright (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.

[2019-02-22 14:54:33] DEBUG - base_path=/home/xxxx/fdfs/client, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

tracker_query_storage_store_list_without_group: 
    server 1. group_name=, ip_addr=191.8.2.203, port=23000

group_name=group1, ip_addr=191.8.2.203, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/vwgCy1xvnKmAIDXDAAEM3XOobI4945.jpg
source ip address: 191.8.2.203
file timestamp=2019-02-22 14:54:33
file size=68829
file crc32=1940417678
example file url: http://191.8.2.203:9270/group1/M00/00/00/vwgCy1xvnKmAIDXDAAEM3XOobI4945.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/vwgCy1xvnKmAIDXDAAEM3XOobI4945_big.jpg
source ip address: 191.8.2.203
file timestamp=2019-02-22 14:54:33
file size=68829
file crc32=1940417678
example file url: http://191.8.2.203:9270/group1/M00/00/00/vwgCy1xvnKmAIDXDAAEM3XOobI4945_big.jpg

訪問:

http://191.8.2.203:8777/M00/00/00/vwgCy1xvnKmAIDXDAAEM3XOobI4945_big.jpg
# 若是能看到圖片則表示安裝fastdfs-nginx-module成功

附錄1:FastDFS 官網介紹

FastDFS是一款高性能的分佈式文件系統。主要功能包括:文件存儲,文件同步,文件訪問(上傳下載)。它能夠解決高容量和負載均衡的問題。FastDFS適合用來作文件相關的網站,如圖片分享、視頻分享等。

FastDFS有兩種角色:trackerstoragetracker負責文件訪問的跟蹤和負載均衡。storage負責存儲文件,它的功能包括:文件存儲、文件同步、提供文件訪問接口,storage還負責管理文件的元數據,這些數據是以鍵值對的形式表示的,如:width=1024,鍵是「width」,值是「1024」。

trackerstorage能夠是一個或多個服務器。在trackerstorage的集羣中,任什麼時候候均可以從中刪除服務器,對線上服務沒有任何影響。tracker集羣中的服務器是點對點的。

存儲服務器以 卷/組 形式組織,以獲取高容量。存儲系統包括一個或多個卷,卷與卷之間的文件是相互獨立的。整個存儲系統的總容量等於全部卷的容量之和。一個文件捲包括一個或多個存儲服務器,一個卷中的存儲服務器之間的文件是同樣的。一個文件卷中的服務器會互相備份,且這些服務器之間是負載均衡的。當添加一個存儲服務器到一個卷的時候,卷中的文件會自動複製到新的服務器,複製完之後,系統會把新服務器切換到線上,已提供存儲服務。

當存儲容量不足時,你能夠添加一個或多個捲來擴展存儲容量。

一個文件的標識包括兩部分:卷名和文件名

附錄2:FastDFS官方INSTALL文件

step 1. 下載安裝 libfastcommon地址:https://github.com/happyfish1...

step 2. 下載安裝 FastDFS
解壓:

tar xzf FastDFS_v5.08.tar.gz

step 3. 進入FastDFS的目錄

cd FastDFS

step 4. 執行make:

./make.sh

step 5. 執行make install

./make.sh install

step 6. 修改trackerstorage的配置文件:

/etc/fdfs/tracker.conf幾個重要的配置:

# the tracker server port
port=22122

# the base path to store data and log files
base_path=/home/caibh/fdfs

# which group to upload file
# when store_lookup set to 1, must set store_group to the group name
store_group=group2

# HTTP port on this tracker server
http.server_port=9270

/etc/fdfs/storage.conf幾個重要的配置:

# the storage server port
port=23000

# the base path to store data and log files
base_path=/home/caibh/fdfs

# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
store_path0=/home/caibh/fdfs
#store_path1=/home/caibh/fdfs2

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
# 在同一臺機器上配置tracker和storage時,這裏若是是127.0.0.1會報錯,因此要配置真正的ip地址。
tracker_server=191.8.1.77:22122

# the port of the web server on this storage server
http.server_port=8888

step 7. run server programs

啓動tracker

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

in Linux, you can start fdfs_trackerd as a service:

/sbin/service fdfs_trackerd start

啓動storage

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

in Linux, you can start fdfs_storaged as a service:

/sbin/service fdfs_storaged start

step 8. 測試

修改客戶端配置文件:

/etc/fdfs/client.conf幾個重要的配置:

# the base path to store log files
base_path=/home/caibh/fdfs/client

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=191.8.1.77:22122

#HTTP settings
http.tracker_server_port=9270

run the client test program:

/usr/bin/fdfs_test <client_conf_filename> <operation>
/usr/bin/fdfs_test1 <client_conf_filename> <operation>

例如上傳一個圖片文件:

caibh@pc:~$ fdfs_test /etc/fdfs/client.conf upload /develop/fastdfs/test_file/LiuLangDiQiu.jpg
This is FastDFS client test program v5.11

Copyright (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.

[2019-02-19 11:32:30] DEBUG - base_path=/home/caibh/fdfs/client, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

tracker_query_storage_store_list_without_group: 
    server 1. group_name=, ip_addr=191.8.1.77, port=23000

group_name=group1, ip_addr=191.8.1.77, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/vwgBTVxreM6AD-mcAAEE_qeEI2s285.jpg
source ip address: 191.8.1.77
file timestamp=2019-02-19 11:32:30
file size=66814
file crc32=2810454891
example file url: http://191.8.1.77:9270/group1/M00/00/00/vwgBTVxreM6AD-mcAAEE_qeEI2s285.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/vwgBTVxreM6AD-mcAAEE_qeEI2s285_big.jpg
source ip address: 191.8.1.77
file timestamp=2019-02-19 11:32:30
file size=66814
file crc32=2810454891
example file url: http://191.8.1.77:9270/group1/M00/00/00/vwgBTVxreM6AD-mcAAEE_qeEI2s285_big.jpg

step 9. 查看狀態

run the monitor program:

/usr/bin/fdfs_monitor <client_conf_filename>
# 如:
caibh@pc:~$ fdfs_monitor /etc/fdfs/storage.conf
[2019-02-19 10:25:09] DEBUG - base_path=/home/caibh/fdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

server_count=1, server_index=0

tracker server is 191.8.1.77:22122

group count: 1

Group 1:
group name = group1
disk total space = 111868 MB
disk free space = 62228 MB
trunk free space = 0 MB
storage server count = 1
active server count = 1
storage server port = 23000
storage HTTP port = 8888
store path count = 1
subdir count per path = 256
current write server index = 0
current trunk file id = 0

    Storage 1:
        id = 191.8.1.77
        ip_addr = 191.8.1.77 (191-8-1-77.user.vivozap.com.br)  ACTIVE
        http domain = 
        version = 5.11
        join time = 2019-02-19 10:22:53
        up time = 2019-02-19 10:22:53
        total storage = 111868 MB
        free storage = 62228 MB
        upload priority = 10
        store_path_count = 1
        subdir_count_per_path = 256
        storage_port = 23000
        storage_http_port = 8888

tracker server config file sample please see conf/tracker.conf

storage server config file sample please see conf/storage.conf

client config file sample please see conf/client.conf

Item detail

  1. server common items
item name type default Must
base_path string Y
disabled boolean false N
bind_addr string N
network_timeout int 30(s) N
max_connections int 256 N
log_level string info N
run_by_group string N
run_by_user string N
allow_hosts string * N
sync_log_buff_interval int 10(s) N
thread_stack_size string 1M N

memo:

  • base_path is the base path of sub dirs:
    data and logs. base_path must exist and it's sub dirs will
    be automatically created if not exist.
    $base_path/data: store data files
    $base_path/logs: store log files
  • log_level is the standard log level as syslog, case insensitive
    emerg: for emergency
    alert
    crit: for critical
    error
    warn: for warning
    notice
    info
    debug
  • allow_hosts can ocur more than once, host can be hostname or ip address,
    "*" means match all ip addresses, can use range like this: 10.0.1.[1-15,20]
    or host[01-08,20-25].domain.com, for example:
    allow_hosts=10.0.1.[1-15,20]
    allow_hosts=host[01-08,20-25].domain.com
  1. tracker server items
item name type default Must
item name type default Must
port int 22000 N
store_lookup int 0 N
store_group string N
store_server int 0 N
store_path int 0 N
download_server int 0 N
reserved_storage_space string 1GB N

memo:

  • the value of store_lookup is:
    0: round robin (default)
    1: specify group
    2: load balance (supported since V1.1)
  • store_group is the name of group to store files.
    when store_lookup set to 1(specify group),
    store_group must be set to a specified group name.
  • reserved_storage_space is the reserved storage space for system
    or other applications. if the free(available) space of any stoarge
    server in a group <= reserved_storage_space, no file can be uploaded
    to this group (since V1.1)
    bytes unit can be one of follows:
    G or g for gigabyte(GB)
    M or m for megabyte(MB)
    K or k for kilobyte(KB)
    no unit for byte(B)
  1. storage server items
item name type default Must
group_name string Y
tracker_server string Y
port int 23000 N
heart_beat_interval int 30(s) N
stat_report_interval int 300(s) N
sync_wait_msec int 100(ms) N
sync_interval int 0(ms) N
sync_start_time string 00:00 N
sync_end_time string 23:59 N
store_path_count int 1 N
store_path0 string base_path N
store_path# string N
subdir_count_per_path int 256 N
check_file_duplicate boolean 0 N
key_namespace string N
keep_alive boolean 0 N
sync_binlog_buff_interval int 60s N

memo:

  • tracker_server can ocur more than once, and tracker_server format is "host:port", host can be hostname or ip address.
  • store_path#, # for digital, based 0
  • check_file_duplicate: when set to true, must work with FastDHT server, more detail please see INSTALL of FastDHT. FastDHT download page: http://code.google.com/p/fast...
  • key_namespace: FastDHT key namespace, can't be empty when check_file_duplicate is true. the key namespace should short as possible

附錄3:FastDFS Nginx模塊官方INSTALL文件

step 1. first install the FastDFS storage server and client library, the FastDFS version should >= 5.11. download address: https://github.com/happyfish1...

step 2. install nginx server
​ FastDFS nginx module test passed with nginx 1.15.1,
​ my nginx installed in /usr/local/nginx

step 3. download FastDFS nginx module source package and unpack it, such as:

cd /home/yuqing
git clone https://github.com/happyfish100/fastdfs

step 4. enter the nginx source dir, compile and install the module, such as:

cd nginx-1.15.1
./configure --add-module=/home/yuqing/fastdfs-nginx-module/src
make; make install
注意: before compile, you can change FDFS_OUTPUT_CHUNK_SIZE and FDFS_MOD_CONF_FILENAME macro in the config file as:
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"

step 5. config the nginx config file such as nginx.conf, add the following lines:

location /M00 {
        root /home/yuqing/fastdfs/data;
        ngx_fastdfs_module;
    }

step 6. 建立軟連接 ${fastdfs_base_path}/data/M00 連接到 ${fastdfs_base_path}/data,命令以下:

ln -s /home/yuqing/fastdfs/data  /home/yuqing/fastdfs/data/M00

step 7. change the config file /etc/fdfs/mod_fastdfs.conf, more detail please see it

step 8. 重啓nginx:

/usr/local/nginx/sbin/nginx -s stop; /usr/local/nginx/sbin/nginx
相關文章
相關標籤/搜索