Answer

问题及解答

Xubuntu 16.04 下安装 FastDFS

Posted by haifeng on 2017-10-08 23:00:19 last update 2017-10-10 14:33:43 | Edit | Answers (0)

首先仔细阅读 FastDFS 的 README.md 和 INSTALL 文件。为方便起见,文末列出了INSTALL文件中的内容。

 

大致安装步骤如下:

Step 1.

./make.sh

其实这一步就出现了错误:没有 logger.h 这个文件

haifeng@X220i:~/work/cs/git/github/fastdfs$ ./make.sh
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -c -o ../common/fdfs_global.o ../common/fdfs_global.c  -I../common -I/usr/include/fastcommon
../common/fdfs_global.c:20:20: fatal error: logger.h: 没有那个文件或目录
compilation terminated.

 

解决办法:

在安装 FastDFS 之前,需要安装 libfastcommon

cd ~/work/cs/git/github

git clone https://github.com/happyfish100/libfastcommon.git

vim README
vim INSTALL

#step 3. make
./make.sh

#step 4. make install
sudo ./make.sh install

安装结束后,再回到 FastDFS, 执行 Step 1   ./make.sh  顺利编译。

 

Step 2.

sudo ./make.sh install

 

安装结束,检查一下

haifeng@X220i:/usr/bin$ ls fdfs*
fdfs_appender_test   fdfs_delete_file    fdfs_storaged  fdfs_upload_appender
fdfs_appender_test1  fdfs_download_file  fdfs_test      fdfs_upload_file
fdfs_append_file     fdfs_file_info      fdfs_test1
fdfs_crc32           fdfs_monitor        fdfs_trackerd

 

配置文件位于 /etc/fdfs/ , 不过现在还不能用, 因为都是以 .sample 结尾的。有四个文件: client.conf.sample   storage_ids.conf.sample
storage.conf.sample  tracker.conf.sample . 我们依次将它们拷贝为 client.conf  storage_ids.conf  storage.conf  tracker.conf

haifeng@X220i:/etc/fdfs$ ls -l
总用量 24
-rw-r--r-- 1 root root 1461 10月  8 23:27 client.conf.sample
-rw-r--r-- 1 root root 7927 10月  8 23:27 storage.conf.sample
-rw-r--r-- 1 root root  105 10月  8 23:27 storage_ids.conf.sample
-rw-r--r-- 1 root root 7389 10月  8 23:27 tracker.conf.sample
haifeng@X220i:/etc/fdfs$ sudo cp client.conf.sample client.conf
[sudo] haifeng 的密码:

haifeng@X220i:/etc/fdfs$ sudo cp storage.conf.sample storage.conf
haifeng@X220i:/etc/fdfs$ sudo cp storage_ids.conf.sample storage_ids.conf
haifeng@X220i:/etc/fdfs$ sudo cp tracker.conf.sample tracker.conf

修改 tracter.conf, 将其中的 base_path 改为自己的路径, 比如改为/home/haifeng/fastdfs

# the base path to store data and log files
#base_path=/home/yuqing/fastdfs
base_path=/home/haifeng/fastdfs

 

 

 


最后还需要与 Nginx 整合在一起,需要安装 fastdfs-nginx-module

 


Reference:

http://www.cnblogs.com/fish-king/archive/2013/03/14/2960441.html

 

 


 

Copy right 2009 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 for more detail.
English language: http://english.csource.org/
Chinese language: http://www.csource.org/

#step 1. download libfastcommon source package from github and install it,
   the github address:
   https://github.com/happyfish100/libfastcommon.git

#step 2. download FastDFS source package and unpack it,
tar xzf FastDFS_v5.x.tar.gz
#for example:
tar xzf FastDFS_v5.08.tar.gz

#step 3. enter the FastDFS dir
cd FastDFS

#step 4. execute:
./make.sh

#step 5. make install
./make.sh install

#step 6. edit/modify the config file of tracker and storage

#step 7. run server programs
#start the tracker server:
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
#in Linux, you can start fdfs_trackerd as a service:
/sbin/service fdfs_trackerd start

#start the storage server:
/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. run test program
#run the client test program:
/usr/bin/fdfs_test
/usr/bin/fdfs_test1
#for example, upload a file:
/usr/bin/fdfs_test conf/client.conf upload /usr/include/stdlib.h

#step 9. run monitor program
#run the monitor program:
/usr/bin/fdfs_monitor


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

2. tracker server items
---------------------------------------------------
|  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)

3. 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/fastdht/downloads/list
  * key_namespace: FastDHT key namespace, can't be empty when
    check_file_duplicate is true. the key namespace should short as possible