本文tracker、storage都在一台机器上!本机tracker和storage是放在一起的。
FastDFS_v5.08.tar.gz
libfastcommon-master.zip (是从 FastDFS 和 FastDHT 中提取出来的公共 C 函数库)
源码地址:https://github.com/happyfish100/
下载地址:http://sourceforge.net/projects/fastdfs/files/
官方论坛:http://bbs.chinaunix.net/forum-240-1.html
yum install make cmake gcc gcc-c++
tar -zxvf FastDFS_v5.08.tar.gz cd FastDFS
./make.sh ./make.sh install出现错误
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: 错误:logger.h:没有那个文件或目录 在包含自 ../common/fdfs_global.c:21 的文件中: ../common/fdfs_global.h:14:27: 错误:common_define.h:没有那个文件或目录 ../common/fdfs_global.h:16:29: 错误:connection_pool.h:没有那个文件或目录 In file included from ../common/fdfs_global.c:21: ../common/fdfs_global.h:26: 错误:‘MAX_PATH_SIZE’ 未声明 (不在函数内) ../common/fdfs_global.h:27: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_fdfs_version’ ../common/fdfs_global.h:28: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_use_connection_pool’ ../common/fdfs_global.h:29: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_connection_pool’ ../common/fdfs_global.c:23: 错误:‘DEFAULT_CONNECT_TIMEOUT’ 未声明 (不在函数内) ../common/fdfs_global.c:24: 错误:‘DEFAULT_NETWORK_TIMEOUT’ 未声明 (不在函数内) ../common/fdfs_global.c:26: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_fdfs_version’ ../common/fdfs_global.c:27: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_use_connection_pool’ ../common/fdfs_global.c:28: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_connection_pool’ ../common/fdfs_global.c: In function ‘fdfs_check_data_filename’: ../common/fdfs_global.c:39: 警告:隐式声明函数 ‘logError’ ../common/fdfs_global.c:45: 警告:隐式声明函数 ‘IS_UPPER_HEX’ make: *** [../common/fdfs_global.o] 错误 1 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. -Itrunk_mgr -I../common -I../tracker -I../client -Ifdht_client -I/usr/include/fastcommon ../common/fdfs_global.c:20:20: 错误:logger.h:没有那个文件或目录 在包含自 ../common/fdfs_global.c:21 的文件中: ../common/fdfs_global.h:14:27: 错误:common_define.h:没有那个文件或目录 ../common/fdfs_global.h:16:29: 错误:connection_pool.h:没有那个文件或目录 In file included from ../common/fdfs_global.c:21: ../common/fdfs_global.h:26: 错误:‘MAX_PATH_SIZE’ 未声明 (不在函数内) ../common/fdfs_global.h:27: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_fdfs_version’ ../common/fdfs_global.h:28: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_use_connection_pool’ ../common/fdfs_global.h:29: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_connection_pool’ ../common/fdfs_global.c:23: 错误:‘DEFAULT_CONNECT_TIMEOUT’ 未声明 (不在函数内) ../common/fdfs_global.c:24: 错误:‘DEFAULT_NETWORK_TIMEOUT’ 未声明 (不在函数内) ../common/fdfs_global.c:26: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_fdfs_version’ ../common/fdfs_global.c:27: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_use_connection_pool’ ../common/fdfs_global.c:28: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_connection_pool’ ../common/fdfs_global.c: In function ‘fdfs_check_data_filename’: ../common/fdfs_global.c:39: 警告:隐式声明函数 ‘logError’ ../common/fdfs_global.c:45: 警告:隐式声明函数 ‘IS_UPPER_HEX’ make: *** [../common/fdfs_global.o] 错误 1 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../tracker -I/usr/include/fastcommon ../common/fdfs_global.c:20:20: 错误:logger.h:没有那个文件或目录 在包含自 ../common/fdfs_global.c:21 的文件中: ../common/fdfs_global.h:14:27: 错误:common_define.h:没有那个文件或目录 ../common/fdfs_global.h:16:29: 错误:connection_pool.h:没有那个文件或目录 In file included from ../common/fdfs_global.c:21: ../common/fdfs_global.h:26: 错误:‘MAX_PATH_SIZE’ 未声明 (不在函数内) ../common/fdfs_global.h:27: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_fdfs_version’ ../common/fdfs_global.h:28: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_use_connection_pool’ ../common/fdfs_global.h:29: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_connection_pool’ ../common/fdfs_global.c:23: 错误:‘DEFAULT_CONNECT_TIMEOUT’ 未声明 (不在函数内) ../common/fdfs_global.c:24: 错误:‘DEFAULT_NETWORK_TIMEOUT’ 未声明 (不在函数内) ../common/fdfs_global.c:26: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_fdfs_version’ ../common/fdfs_global.c:27: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_use_connection_pool’ ../common/fdfs_global.c:28: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_connection_pool’ ../common/fdfs_global.c: In function ‘fdfs_check_data_filename’: ../common/fdfs_global.c:39: 警告:隐式声明函数 ‘logError’ ../common/fdfs_global.c:45: 警告:隐式声明函数 ‘IS_UPPER_HEX’是因为没有安装 libfastcommon
unzip libfastcommon-master.zip cd libfastcommon-master ./make.sh ./make.sh installlibfastcommon 默认安装到了
采用默认安装的方式安装,安装后的相应文件与目录:
A、服务脚本在:
/etc/init.d/fdfs_storaged
/etc/init.d/fdfs_tracker
B、配置文件在(样例配置文件):
/etc/fdfs/client.conf.sample
/etc/fdfs/storage.conf.sample
/etc/fdfs/tracker.conf.sample
C、命令工具在/usr/bin/目录下的:
fdfs_appender_test
fdfs_appender_test1
fdfs_append_file
fdfs_crc32
fdfs_delete_file
fdfs_download_file
fdfs_file_info
fdfs_monitor
fdfs_storaged
fdfs_test
fdfs_test1
fdfs_trackerd
fdfs_upload_appender
fdfs_upload_file
stop.sh
restart.sh
cd /etc/fdfs复制3份配置文件
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
1、查看tracker.conf
vi /etc/fdfs/tracker.conf2、配置(保留默认即可)
disabled=false
port=22122
base_path=/home/zhaosoft/fastdfs
(其它参数保留默认配置,具体配置解释请参考官方文档说明:
http://bbs.chinaunix.net/thread-1941456-1-1.html )
3、创建基础数据目录(参考基础目录 base_path 配置):
mkdir -p /home/zhaosoft/fastdfs4、防火墙中打开跟踪器端口(默认为 22122)
vi /etc/sysconfig/iptables
添加如下端口行:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT重启防火墙
service iptables restart5、启动 Tracker:
/etc/init.d/fdfs_trackerd start
(初次成功启动,会在/fastdfs/tracker 目录下创建 data、logs 两个目录)
查看 FastDFS Tracker 是否已成功启动:
ps -ef | grep fdfs6、 关闭 Tracker:
# /etc/init.d/fdfs_trackerd stop7、 设置 FastDFS 跟踪器开机启动:
vi /etc/rc.d/rc.local
添加以下内容:
## FastDFS Tracker /etc/init.d/fdfs_trackerd start
1、查看storage
vi /etc/fdfs/storage.conf2、编辑
修改的内容如下:
disabled=false
port=23000
base_path=/home/zhaosoft/fastdfs
store_path0=/home/yuqing/fastdfs
tracker_server=ip:22122
http.server_port=8888
(其它参数保留默认配置,具体配置解释请参考官方文档说明:
http://bbs.chinaunix.net/thread-1941456-1-1.html )
3、 创建基础数据目录(参考基础目录 base_path 配置)
/home/yuqing/fastdfs4、 防火墙中打开存储器端口(默认为 23000):
vi /etc/sysconfig/iptables添加如下端口行:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 23000 -j ACCEPT重启防火墙:
service iptables restart5、 启动 Storage:
/etc/init.d/fdfs_storaged start
(初次成功启动,会在/fastdfs/storage 目录下创建 data、logs 两个目录)
查看 FastDFS Storage 是否已成功启动
ps -ef | grep fdfs6、 关闭 Storage:
/etc/init.d/fdfs_storaged stop7、 设置 FastDFS 存储器开机启动:
vi /etc/rc.d/rc.local添加:
## FastDFS Storage /etc/init.d/fdfs_storaged start
1、修改 Tracker 服务器中的客户端配置文件:
vi /etc/fdfs/client.confbase_path= /fastdfs/tracker
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /home/zhaosoft/FastDFS_v5.05.tar.gz返回 ID 号: group1/M00/00/00/wKgEfVUYNYeAb7XFAAVFOL7FJU4.tar.gz