欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

初次使用fast dfs 遇到的问题记录

程序员文章站 2022-07-10 09:19:14
...
开发过程使用fastdfs,第一次接触,使用时遇到的问题整理如下

问题1:
在centos上安装 ./make.sh 时报错如下:

在包含自 tracker_service.c:34 的文件中:
tracker_nio.h:17:19: 错误:event.h:没有那个文件或目录
In file included from tracker_nio.h:18,
                 from tracker_service.c:34:
fast_task_queue.h:29: 错误:字段‘ev_read’的类型不完全
fast_task_queue.h:30: 错误:字段‘ev_write’的类型不完全
tracker_service.c: 在函数‘tracker_service_init’中:
tracker_service.c:99: 警告:隐式声明函数‘event_base_new’
tracker_service.c:99: 警告:赋值时将整数赋给指针,未作类型转换
tracker_service.c: 在函数‘work_thread_entrance’中:
tracker_service.c:253: 错误:‘ev_notify’的存储大小未知
tracker_service.c:258: 警告:隐式声明函数‘event_set’
tracker_service.c:259: 错误:‘EV_READ’未声明(在此函数内第一次使用)
tracker_service.c:259: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其
tracker_service.c:259: 错误:所在的函数内也只报告一次。)
tracker_service.c:259: 错误:‘EV_PERSIST’未声明(在此函数内第一次使用)
tracker_service.c:260: 警告:隐式声明函数‘event_base_set’
tracker_service.c:266: 警告:隐式声明函数‘event_add’
tracker_service.c:275: 警告:隐式声明函数‘event_base_loop’
tracker_service.c:279: 警告:隐式声明函数‘event_base_free’
tracker_service.c:253: 警告:未使用的变量‘ev_notify’
make: *** [tracker_service.o] 错误 1
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -DOS_LINUX -c -o ../common/fast_mblock.o ../common/fast_mblock.c  -I. -Itrunk_mgr -I../common -I../tracker -I../client -Ifdht_client -I/usr/local/include
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -DOS_LINUX -c -o ../common/avl_tree.o ../common/avl_tree.c  -I. -Itrunk_mgr -I../common -I../tracker -I../client -Ifdht_client -I/usr/local/include
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -DOS_LINUX -c -o ../tracker/fdfs_shared_func.o ../tracker/fdfs_shared_func.c  -I. -Itrunk_mgr -I../common -I../tracker -I../client -Ifdht_client -I/usr/local/include
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -DOS_LINUX -c -o ../tracker/fast_task_queue.o ../tracker/fast_task_queue.c  -I. -Itrunk_mgr -I../common -I../tracker -I../client -Ifdht_client -I/usr/local/include
在包含自 ../tracker/fast_task_queue.c:6 的文件中:
../tracker/fast_task_queue.h:18:19: 错误:event.h:没有那个文件或目录
In file included from ../tracker/fast_task_queue.c:6:
../tracker/fast_task_queue.h:29: 错误:字段‘ev_read’的类型不完全
../tracker/fast_task_queue.h:30: 错误:字段‘ev_write’的类型不完全
make: *** [../tracker/fast_task_queue.o] 错误 1


查看资料说是缺少libevent
安装yum install libevent-devel.x86_64 后,再次./make.sh, 没看到报错信息了


问题2:

在ubuntu上安装时,运行./make.sh 出错如下

make: 没有什么可以做的为 `all'。
make: 没有什么可以做的为 `all'。
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -DOS_LINUX -o fdfs_monitor fdfs_monitor.c  ../common/hash.o ../common/chain.o ../common/shared_func.o ../common/ini_file_reader.o ../common/logger.o ../common/sockopt.o ../common/base64.o ../common/sched_thread.o ../common/http_func.o ../common/md5.o ../common/pthread_func.o ../common/local_ip_func.o ../common/avl_tree.o ../common/connection_pool.o ../common/fdfs_global.o ../common/fdfs_http_shared.o ../common/mime_file_parser.o ../tracker/tracker_proto.o ../tracker/fdfs_shared_func.o ../storage/trunk_mgr/trunk_shared.o tracker_client.o client_func.o client_global.o storage_client.o -ldl -rdynamic -I../common -I../tracker -I/usr/local/include
../common/sched_thread.o: In function `sched_start':
/opt/FastDFS/tracker/../common/sched_thread.c:495: undefined reference to `pthread_create'
../common/pthread_func.o: In function `kill_work_threads':
/opt/FastDFS/tracker/../common/pthread_func.c:182: undefined reference to `pthread_kill'
../common/pthread_func.o: In function `init_pthread_attr':
/opt/FastDFS/tracker/../common/pthread_func.c:84: undefined reference to `pthread_attr_getstacksize'
/opt/FastDFS/tracker/../common/pthread_func.c:115: undefined reference to `pthread_attr_setstacksize'
../common/pthread_func.o: In function `create_work_threads':
/opt/FastDFS/tracker/../common/pthread_func.c:156: undefined reference to `pthread_create'
../common/pthread_func.o: In function `init_pthread_lock':
/opt/FastDFS/tracker/../common/pthread_func.c:32: undefined reference to `pthread_mutexattr_init'
/opt/FastDFS/tracker/../common/pthread_func.c:40: undefined reference to `pthread_mutexattr_settype'
/opt/FastDFS/tracker/../common/pthread_func.c:57: undefined reference to `pthread_mutexattr_destroy'
collect2: ld 返回 1
make: *** [fdfs_monitor] 错误 1


网上查看资料是说在make.sh 文件中没有指定libpthread.so 和 libpthread.a的正确路径,所以打开make.sh找到如下代码

 if [ -f /usr/lib/libpthread.so ] || [ -f /usr/local/lib/libpthread.so ] || [ -f /lib64/libpthread.so ] || [ -f /usr/lib64/libpthread.so ]
  || [ -f /usr/lib/libpthread.a ] || [ -f /usr/local/lib/libpthread.a ] || [ -f /lib64/libpthread.a ] || [ -f /usr/lib64/libpthread.a ]; 


在我机器上找了下,确实在以上代码中指定的路径中没有找到libpthread.so 和 libpthread.a; 随后我在/usr/lib32中找到了libpthread.so 和 libpthread.a,

所以增加软连接
 
  ln -s /usr/lib32/libpthread.so /usr/lib/libpthread.so 
  ln -s /usr/lib32/libpthread.a /usr/lib/libpthread.a

 
再次运行./make.sh 问题解决

 
问题3:
./make.sh install 时 报错如下:

mkdir -p /usr/local/bin
mkdir -p /etc/fdfs
cp -f fdfs_trackerd  /usr/local/bin
if [ ! -f /etc/fdfs/tracker.conf ]; then cp -f ../conf/tracker.conf ../conf/mime.types ../conf/http.conf /etc/fdfs; fi
mkdir -p /usr/local/bin
mkdir -p /etc/fdfs
cp -f fdfs_storaged  /usr/local/bin
if [ ! -f /etc/fdfs/storage.conf ]; then cp -f ../conf/storage.conf ../conf/mime.types ../conf/http.conf /etc/fdfs; fi
mkdir -p /usr/local/bin
mkdir -p /etc/fdfs
mkdir -p /usr/local/lib
cp -f fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file fdfs_download_file fdfs_delete_file fdfs_file_info fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_upload_appender /usr/local/bin
if [ 0 -eq 1 ]; then cp -f libfastcommon.a libfdfsclient.a /usr/local/lib; fi
if [ 1 -eq 1 ]; then cp -f libfastcommon.so.1 libfdfsclient.so.1 /usr/local/lib; fi
if [ 1 -eq 1 ]; then ln -fs /usr/local/lib/libfastcommon.so.1 /usr/local/lib/libfastcommon.so; fi
if [ 1 -eq 1 ]; then ln -fs /usr/local/lib/libfdfsclient.so.1 /usr/local/lib/libfdfsclient.so; fi
if [ ! -f /etc/fdfs/client.conf ]; then cp -f ../conf/client.conf ../conf/http.conf /etc/fdfs; fi
mkdir -p /usr/local/include
mkdir -p /usr/local/include/fastcommon
mkdir -p /usr/local/include/fastdfs
cp -f ../common/common_define.h ../common/hash.h ../common/chain.h ../common/logger.h ../common/base64.h ../common/shared_func.h ../common/pthread_func.h ../common/ini_file_reader.h ../common/sockopt.h ../common/sched_thread.h ../common/http_func.h ../common/md5.h ../common/_os_bits.h ../common/local_ip_func.h ../common/avl_tree.h ../common/connection_pool.h /usr/local/include/fastcommon
cp -f ../common/fdfs_define.h ../common/fdfs_global.h ../common/mime_file_parser.h ../common/fdfs_http_shared.h ../tracker/tracker_types.h ../tracker/tracker_proto.h ../tracker/fdfs_shared_func.h ../storage/trunk_mgr/trunk_shared.h tracker_client.h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/local/include/fastdfs
if [ 1 -eq 1 -a /usr/local/lib = "/usr/local/lib" ]; then sh ./fdfs_link_library.sh; fi
ln: 创建符号链接 "/usr/lib64/libfastcommon.so": 没有那个文件或目录
ln: 创建符号链接 "/usr/lib64/libfdfsclient.so": 没有那个文件或目录
make: *** [install] 错误 1


这个问题只需要 创建 lib64目录即可:mkdir -p /usr/lib64


问题4:

测试上传时遇到的一个错误
测试命令 ./fdfs_upload /etc/fdfs/storage.conf upload /home/test.txt

出错如下:
This is FastDFS client test program v4.06

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.

[2014-03-20 18:47:13] DEBUG - base_path=/data/fastdfs/storage, 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

[2014-03-20 18:47:13] DEBUG - file: tracker_proto.c, line: 48, server: 192.168.88.202:22122, response status 2 != 0
[2014-03-20 18:47:13] DEBUG - file: tracker_proto.c, line: 48, server: 192.168.88.202:22122, response status 28 != 0
tracker_query_storage fail, error no: 28, error info: No space left on device


错误说是磁盘空间不够了,但是这时查看了一下tracker的日志:

[2014-03-20 18:47:12] ERROR - file: tracker_service.c, line: 2371, client ip: 192.168.88.202, invalid group name: group1


我尝试修改 tracker.conf 文件中的 reserved_storage_space = 1%, 随后测试通过,但是不知道tracker的日志为何报出上述错误。
相关标签: dfs