FastDFS_v4.06安装简记

提前准备所需4个包:
FastDFS_v4.06.tar.gz
fastdfs-nginx-module_v1.16.tar.gz
libevent-2.0.20-stable.tar.gz
nginx-1.11.8.tar.gz
将所需包都拷贝到/usr/local/FastDFS目录下

一、安装步骤:
依赖包
tar zxvf libevent-2.0.19-stable.tar.gz
./configure --prefix=/usr
make clean
make
make install


二、安装FastDFS
tar zxvf FastDFS_v4.06.tar.gz
解压成功后会看到一个FastDFS名称的文件夹
cd FastDFS进入到解压目录下执行编译
./make.sh
./make.sh install


如果安装报错如下:
../common/sched_thread.o:在函数‘sched_start’中:
/usr/local/FastDFS/FastDFS/tracker/../common/sched_thread.c:495:对‘pthread_create’未定义的引用
../common/pthread_func.o:在函数‘init_pthread_lock’中:
/usr/local/FastDFS/FastDFS/tracker/../common/pthread_func.c:32:对‘pthread_mutexattr_init’未定义的引用
/usr/local/FastDFS/FastDFS/tracker/../common/pthread_func.c:40:对‘pthread_mutexattr_settype’未定义的引用
/usr/local/FastDFS/FastDFS/tracker/../common/pthread_func.c:57:对‘pthread_mutexattr_destroy’未定义的引用
../common/pthread_func.o:在函数‘init_pthread_attr’中:
/usr/local/FastDFS/FastDFS/tracker/../common/pthread_func.c:84:对‘pthread_attr_getstacksize’未定义的引用
/usr/local/FastDFS/FastDFS/tracker/../common/pthread_func.c:115:对‘pthread_attr_setstacksize’未定义的引用
../common/pthread_func.o:在函数‘create_work_threads’中:
/usr/local/FastDFS/FastDFS/tracker/../common/pthread_func.c:156:对‘pthread_create’未定义的引用
../common/pthread_func.o:在函数‘kill_work_threads’中:
/usr/local/FastDFS/FastDFS/tracker/../common/pthread_func.c:182:对‘pthread_kill’未定义的引用
collect2: error: ld returned 1 exit status
make: *** [fdfs_monitor] 错误 1

说明在执行make.sh过程中找不到pthread,也就是不同系统pthread的位置不一样,
需要在make.sh配置当前系统pthread的路径。
找到libpthread.so和libpthread.a
find / -name libpthread.so
/usr/lib/x86_64-linux-gnu/libpthread.so

find / -name libpthread.a
/usr/lib/x86_64-linux-gnu/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路径
if [ -f /usr/lib/x86_64-linux-gnu/libpthread.so ] || [ -f /usr/lib/x86_64-linux-gnu/libpthread.a ];


如果还报错:
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": 没有那个文件或目录

修改FastDFS下/client/fdfs_link_library.sh.in
先查找这两文件
find / -name 'libfastcommon.so'
/usr/lib/libfastcommon.so
/usr/local/lib/libfastcommon.so

find / -name 'libfdfsclient.so'
/usr/lib/libfdfsclient.so
/usr/local/lib/libfdfsclient.so

64位系统

if [ "$OS_BITS" = "8" ]; then
ln -fs $TARGET_LIB/libfastcommon.so.1 /usr/lib64/libfastcommon.so
ln -fs $TARGET_LIB/libfdfsclient.so.1 /usr/lib64/libfdfsclient.so
fi
修改为
if [ "$OS_BITS" = "8" ]; then
ln -fs $TARGET_LIB/libfastcommon.so.1 /usr/lib/libfastcommon.so
ln -fs $TARGET_LIB/libfdfsclient.so.1 /usr/lib/libfdfsclient.so
fi

修改完后重新./make.sh install


三、
创建保存tracker数据文件和日志目录:/usr/local/FastDFS/fastdfs_tracker
创建保存storage数据文件和日志目录:/usr/local/FastDFS/fastdfs_storage

四、
修改conf/tracker.conf
base_path=/usr/local/FastDFS/fastdfs_tracker

#fastdfs-client插件项目中配置文件fdfs_client.conf的http.tracker_http_port = 9999
http.server_port=9999

修改storage.conf
base_path=/usr/local/FastDFS/fastdfs_storage
store_path_count=1 //这里只配了一个store_path0所以为1
store_path0=/usr/local/FastDFS/fastdfs_storage
tracker_server=192.168.1.102:22122
http.server_port=8888


五、启动和测试
修改conf/client.conf
base_path=/usr/local/fastdfs_client //事先创建/usr/local/fastdfs_client目录
tracker_server=192.168.1.102:22122

启动tracker命令:fdfs_trackerd /usr/local/FastDFS/FastDFS/conf/tracker.conf
如果报错
fdfs_trackerd: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
需要复制 cp /usr/lib/libevent-2.0.so.5 /usr/lib64/

启动storage命令:fdfs_storaged /usr/local/FastDFS/FastDFS/conf/storage.conf

测试上传:
fdfs_test /usr/local/FastDFS/FastDFS/conf/client.conf upload /usr/local/mt.jpeg

上传成功后访问:http://192.168.1.102:8888/group1/M00/00/00/wKg4ZViMChWAZ5IZAAJ3HMOTGwQ16_big.jpeg
这时候还访问不了需要安装Nginx

六、安装nginx
sudo mkdir /usr/local/nginx


解压fastdfs-nginx-module_v1.16.tar.gz
tar zxvf fastdfs-nginx-module_v1.16.tar.gz

解压nginx-1.11.8.tar.gz
tar zxvf nginx-1.11.8.tar.gz

进入nginx-1.11.8
添加自定义模块(带有FastDFS模块的Nginx)Nginx
sudo ./configure --prefix=/usr/local/nginx --add-module=/usr/local/FastDFS/fastdfs-nginx-module/src

如果报错:
./configure: error: the HTTP rewrite module requires the PCRE library.
需要安装pcre-devel
sudo apt-get install libpcre3 libpcre3-dev (ubuntu系统 )

如果报错:
./configure: error: the HTTP gzip module requires the zlib library.
安装libssl-dev
sudo apt-get install libssl-dev

然后执行
sudo make
sudo make install


七、
编辑/usr/local/nginx/conf/nginx.conf
//listen对应FastDFS/conf/storage.conf中的http.server_port=8888
listen 8888;
location ~/group1/M00 {
root /usr/local/FastDFS/fastdfs_storage/data;
ngx_fastdfs_module;
}


编辑/usr/local/FastDFS/fastdfs-nginx-module/src/mod_fastdfs.conf
tracker_server=192.168.1.102:22122
url_have_group_name = true
store_path0=/usr/local/FastDFS/fastdfs_storage


拷贝
sudo cp /usr/local/FastDFS/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

----Nginx命令----
启动Nginx
sudo /usr/local/nginx/sbin/nginx

重启Nginx
sudo /usr/local/nginx/sbin/nginx -s reload


启动Nginx成功后再访问就可看到上传的图片了:
http://192.168.1.102:8888/group1/M00/00/00/wKg4ZViMChWAZ5IZAAJ3HMOTGwQ16_big.jpeg

 

----FastDFS命令----
启动:
fdfs_trackerd /usr/local/FastDFS/FastDFS/conf/tracker.conf
fdfs_storaged /usr/local/FastDFS/FastDFS/conf/storage.conf
或者
sudo /usr/local/bin/fdfs_trackerd /usr/local/FastDFS/FastDFS/conf/tracker.conf
sudo /usr/local/bin/fdfs_storaged /usr/local/FastDFS/FastDFS/conf/storage.conf

停止:
tracker: /usr/local/bin/stop.sh fdfs_trackerd
storage: /usr/local/bin/stop.sh fdfs_storaged

查看:
/usr/local/bin/fdfs_monitor /usr/local/FastDFS/FastDFS/conf/storage.conf
或者
fdfs_monitor /usr/local/FastDFS/FastDFS/conf/storage.conf

转载于:https://www.cnblogs.com/lyxy/p/6525429.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值