下载相关包:
libevent-2.0.22-stable.tar.gz =》 https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
https://sourceforge.net 下载相应的FASTDFS文件:
fastdfs_client_java._v1.25.tar.gz
fastdfs-nginx-module_v1.16.tar.gz
FastDFS_v5.08.tar.gz
nginx-1.11.6.tar.gz
libfastcommon-master =》https://github.com/happyfish100/libfastcommon/archive/master.zip
1.解压安装
a. libevent:
rpm -e --nodepes `rpm -qa | grep libevent cd libevent1.4.14b ./configure --prefix=/usr make clean make make install2.FastDFS_v5.08
cd FastDFS ./make.sh ./make.sh install有报错信息
compilation terminated.
make: *** [../common/fdfs_global.o] Error 1
需要安装 libfastcommon-master
3. libfastcommon-master
unzip master.zip cd libfastcommon-master/ ./make.sh ./make.sh install然后继续安装FASTDFS
配置fastdfs:
配置tracker:# cd /etc/fdfs/ # cp tracker.conf.sample tracker.conf 修改配置文件 disabled=false #启用配置文件 port=22122 #设置tracker的端口号 base_path=/data/fastdfs/trackerd #设置tracker的数据文件和日志目录(需预先创建) http.server_port=8090 #设置http端口号启动:
# mkdir -p /data/fastdfs/trackerd
# fdfs_trackerd /etc/fdfs/tracker.conf #启动
# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
设置开机启动
# echo '/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart' >> /etc/rc.d/rc.local
配置storage:1.安装 与tracker 安装步骤相同
disabled=false #启用配置文件
group_name=group1 #组名,根据实际情况修改
port=23000 #设置storage的端口号
base_path=/data/fastdfs/storage #设置storage的日志目录(需预先创建)
store_path_count=1 #存储路径个数,需要和store_path个数匹配
store_path0=/data/fastdfs/storage #存储路径
tracker_server=172.16.8.8:22122 #tracker服务器的IP地址和端口号
http.server_port=8090 #设置http端口号
启动
# mkdir -p /data/fastdfs/storage
# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
设置开机启动
# echo '/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart' >> /etc/rc.d/rc.local
查看状态
/usr/bin/fdfs_monitor /etc/fdfs/storage.conf
# netstat -antp | grep storage上传测试(配置Client,client.conf)
cp client.conf.sample client.conf base_path=/home/yuqing/fastdfs-> base_path=/data/fastdfs_tracker tracker_server=192.168.209.121:22122 -> tracker_server=172.16.8.8:22122http.tracker_server_port=8080 ->http.tracker_server_port=8090然后测试上传
fdfs_test /etc/fdfs/client.conf upload a.jpg/usr/bin/fdfs_upload_file /etc/fdfs/client.conf4. 安装Nginx
cd useradd -r nginx useradd -r nginx ./configure --prefix=/usr/local/nginx --add-module=/data/fastdfs-nginx-module/srcmakemake installNOTE:安装Nginx时报错
./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题yum -y install pcre-devel
错误提示:./configure: error: the HTTP cache module requires md5 functionsfrom OpenSSL library. You can either disable the module by using--without-http-cache option, or install the OpenSSL library into the system,or build the OpenSSL library statically from the source with nginx by using--with-http_ssl_module --with-openssl=<path> options.
解决办法:
yum -y install openssl openssl-devel
总结:
yum -y install pcre-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx
make
make install
一切搞定
Note: /usr/local/src/fastdfs-nginx-module/src/common.c:21:25: 错误:fdfs_define.h:没有那个文件或目录 [root@server1 src]# cp -rf /usr/include/fast* /usr/local/include/ [root@server1 src]# ls /usr/local/include/ fastcommon fastdfs 然后再次编译Nginx配置: vim /usr/local/nginx/conf/nginx.conf location ~ /group[1-3]/M00 { root /data/fastdfs/storage/data; ngx_fastdfs_module; } /data/fastdfs/storage/data 这个是指向 真正存储文件的地方测试:
[root@mobancentos70 data]# fdfs_upload_file /etc/fdfs/client.conf 1.png group1/M00/00/00/rBQN5lhI0VeAOOWNAAVg32hqxR4098.png
http://172.20.13.230/group1/M00/00/00/rBQN5lhI0VeAOOWNAAVg32hqxR4098.png
附录:
在整个环境搭建过程中遇到一些问题,在此提交分享,供大家参考。
1、 在Storage服务器上启动Nginx时出现 ERROR - file: /home/hadoop/dev/fastdfs/fastdfs-nginx-module/src/common.c, line: 103, section: group1, you must set parameter: group_name!
问题原因:在配置mod_fastdfs.conf文件时要保证group_count=2的个数与下面配置的[group*]个数相一致。
2、 安装GraphicsMagick进行配置时出现错误 configure: error: libltdl is required by modules build 问题原因:没有安装libltdl,通过yum install
-ylibtoollibtool-devel安装后再重新
3、 java客户端上传文件时出现错误 recvcmd: 100 is not correct, expect cmd: 10
问题原因:版本问题,下载1.24版本的即可。
4、 通过浏览器方式缩略图是出现
gm convert: Request did not return an image.错误。
问题原因:没有安装libjpeg和libpng包,导致在GM处理图时出现错误。安装libjpeg和libpng后重新安装GraphicsMagick即可。
5、 安装FastDFS在 编译时出现
/usr/local/lib/libfastcommon.so: undefined reference
to sqrt' /usr/local/lib/libfastcommon.so: undefined reference
tocos'错误
问题原因:libfastcommon版本的问题,下载旧版本,重新安装,然后在编译FastDFS即可。
转载于:https://www.cnblogs.com/owenma/p/6144216.html