设为首页 收藏本站
查看: 1946|回复: 0

[经验分享] FastDFS+Nginx安装配置

[复制链接]

尚未签到

发表于 2017-12-22 22:59:28 | 显示全部楼层 |阅读模式
  下载相关包:
  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

拓扑图
DSC0000.jpg

  1.解压安装
  a. libevent:
  

rpm -e --nodepes `rpm -qa | grep libevent  
cd libevent1.
4.14b  
.
/configure --prefix=/usr  
make clean
  
make
  
make install
  

  2.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:22122
  http.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.conf
  

  4. 安装Nginx
  

cd useradd -r nginx  
useradd
-r nginx  
.
/configure --prefix=/usr/local/nginx --add-module=/data/fastdfs-nginx-module/src  make
  make install
  NOTE:
  

  安装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 functions
  from 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:没有那个文件或目录  

[iyunv@server1 src]# cp -rf /usr/include/fast* /usr/local/include/  
[iyunv@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 这个是指向 真正存储文件的地方  

   建立 M00 至存储目录的符号连接
  

[iyunv@server1 fdfs]# ln -s /data/fastdfs/storage/data /data/fastdfs/storage/data/M00  
[iyunv@server1 fdfs]# ll /data/fastdfs/storage/data/M00
  

  配置mod_fastDfs.config:
  

base_path=/data/fastdfs/storage      #保存日志目录  
tracker_server=10.10.10.124:22122    #tracker 服务器的 IP 地址以及端口号
  
storage_server_port=23000            #storage 服务器的端口号
  
group_name=group1                    #当前服务器的 group 名
  
url_have_group_name = true           #文件 url 中是否有 group 名
  
store_path_count=1                   #存储路径个数,需要和 store_path 个数匹配
  
store_path0=/data/fastdfs/storage    #存储路径
  
http.need_find_content_type=true     # 从文件 扩展 名查 找 文件 类型 ( nginx 时 为true)
  
group_count = 1                      #设置组的个数
  

启动存储服务器上的nginx时确报了下面的错误:  ngx_http_fastdfs_process_init pid=17609
[2014-12-10 11:52:07] ERROR - file: ini_file_reader.c, line: 315, include file "http.conf" not exists, line: "#include http.conf"

  解决方案:
  FDFS安装包的conf目录下,有几个配置文件,把http.conf,mime.types,拷贝到/etc/fdfs/下,http.conf里有
  个配置应该是token验证的功能,如果你要打开,应该把路径配置正确
  

  测试:
[iyunv@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即可。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-426996-1-1.html 上篇帖子: FastDFS + nginx 整合 下篇帖子: 虚拟机上图片服务器搭建(FastDFS+nginx)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表