fastdfs-nginx-module安装和配置
fastdfs-nginx-module安装和配置
为什么要在fastdfs的storage端,安装fastdfs-nginx-module?
答案:https://www.cnblogs.com/littleatp/p/4361318.html
答案摘要:在每一台storage服务器主机上部署Nginx及FastDFS扩展模块,由Nginx模块对storage存储的文件提供http下载服务, 仅当当前storage节点找不到文件时会向源storage主机发起redirect或proxy动作。
个人理解:当一个文件A被上传到group1里的节点机器M后,group1里有节点机器M和节点机器N,节点N会从节点M下载文件A到自己节点下。如果又来了一个访问文件A的请求,并且tracker把这个请求让节点N来处理,这时节点N还没有从节点M下载到文件A,这样就无法处理,会出错误。
插件fastdfs-nginx-module就是为了解决这个错误。怎么解决呢?就是把请求重定向到节点M上,也就是提供重定向的功能。
前提是已经安装好了nginx和fastdfs了
STEP1
下载包(https://github.com/happyfish100/fastdfs-nginx-module ),并解压
STEP2:去nginx源码的解压目录,运行下面的命令
./configure --add-module=/home/ys2/fastdfs/fastdfs-nginx-module-1.20/src
如果执行结果里有下面的语句,则说明configure成功
adding module in /home/ys2/fastdfs/fastdfs-nginx-module-1.20/src
+ ngx_http_fastdfs_module was configured
STEP3:make
发现出下面的错误:
/usr/include/fastdfs/fdfs_define.h:15:10: fatal error: common_define.h: No such file or directory
#include "common_define.h"
解决办法:修改objs/Makefile文件,在ALL_INCS的最后面添加【-I /usr/include/fastcommon】,注意在原来的最后一行的后面加上【\】。
因为上面的错误原因是找不到common_define.h文件,所以通过添加-I,就可以找到这个文件了。如果不知道common_define.h在哪个目录,可以用【find /usr -name common_define.h】找到它所在的目录。
ALL_INCS = -I src/core \
-I src/event \
-I src/event/modules \
-I src/os/unix \
-I objs \
-I src/http \
-I src/http/modules \
-I /usr/local/include \
-I /usr/include/fastcommon
然后再执行make,一般就会成功了,如果还提示找不到某个.h文件,解决办法同上。
STEP4:sudo make install
在目录【/usr/local/nginx/sbin/】下,如果生产了nginx,并把原来的nginx重命名为nginx.old了,则说明安装成功了。
-rwxr-xr-x 1 root root 4499888 9月 2 20:41 nginx*
-rwxr-xr-x 1 root root 4375032 8月 30 10:56 nginx.old*
分割线 到此说明安装已经OK了,下面是配置
STEP5:启动nginx
sudo nginx
然后用【ps aux | grep nginx】,确认nginx进程是否成功启动
root 9126 0.0 0.0 32980 436 ? Ss 20:52 0:00 nginx: master process nginx
发现结果如上,发现只有master进程,而没有worker进程,说明启动出了问题。
解决办法:去看nginx的log文件【/usr/local/nginx/logs/error.log】,log内容如下
2019/09/02 20:52:26 [notice] 8956#0: signal process started
ngx_http_fastdfs_process_init pid=9127
[2019-09-02 20:52:41] ERROR - file: shared_func.c, line: 968, file /etc/fdfs/mod_fastdfs.conf not exist
[2019-09-02 20:52:41] ERROR - file: /home/ys2/fastdfs/fastdfs-nginx-module-1.20/src/common.c, line: 163, load con\
f file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 2
2019/09/02 20:52:41 [alert] 9126#0: worker process 9127 exited with fatal code 2 and cannot be respawned
发现没有找到/etc/fdfs/mod_fastdfs.conf 文件。mod_fastdfs.conf 文件在解压后的src文件夹里,所以拷贝到/etc/fdfs目录下。
STEP6:编辑/etc/fdfs/mod_fastdfs.conf 文件。发现此文件和storage.conf文件十分类似。所以照着storage.conf文件修改此文件。
修改base_path=,让值和storage.conf一样。
修改tracker_server=,让值和storage.conf一样。
修改storage_server_port=,让值和storage.conf里的port一样。
修改group_name=,让值和storage.conf一样。
修改url_have_group_name ,让值为true。目的是在浏览器的URL里,显示group_name的值,也就是能看到访问的storage的哪个group。
修改store_path_count=,让值和storage.conf一样。
修改store_path0=,让值和storage.conf一样。
修改group_count =,fastdfs文件系统里有几个组就写几,只有一个组就写1.
如果group_count =1,则必须设置[group1],如果group_count =2,则必须设置[group1]和[group2],以此类推。
然后,再把[group1]下的所以设置,再写一遍。
把上面都修改好后,再次启动nginx,发现还是没有worker进程,再去看log内容,发现log内容和上一次不一样了,就说明上面的问题已经修改好了,又有别的问题了,已经在向成功迈进了。
[2019-09-02 23:37:19] ERROR - file: ini_file_reader.c, line: 824, include file "http.conf" not exists, line: "#include http.conf"
[2019-09-02 23:37:19] ERROR - file: /home/ys2/fastdfs/fastdfs-nginx-module-1.20/src/common.c, line: 163, load conf file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 2
2019/09/02 23:37:19 [alert] 9383#0: worker process 9384 exited with fatal code 2 and cannot be respawned
说明没找到http.conf文件,
解决办法:拷贝fastdfs源码安装包里的http.conf文件(在conf文件夹里),到/etc/fdfs/文件夹里。
修改好后,再次启动nginx,发现还是没有worker进程,再去看log内容,发现log内容和上一次不一样了,就说明上面的问题已经修改好了,又有别的问题了,已经在向成功迈进了。
2019/09/02 23:53:59 [notice] 9532#0: signal process started
ngx_http_fastdfs_process_exit pid=9497
ngx_http_fastdfs_process_init pid=9536
[2019-09-02 23:54:05] ERROR - file: shared_func.c, line: 968, file /etc/fdfs/mime.types not exist
2019/09/02 23:54:05 [alert] 9535#0: worker process 9536 exited with fatal code 2 and cannot be respawned
说明没找到/etc/fdfs/mime.types文件
解决办法:拷贝nginx源码安装包里的mime.types文件(在conf文件夹里),到/etc/fdfs/文件夹里。
修改好后,再次启动nginx,发现有worker进程了,说明nginx启动成功了。
STEP7:修改nginx.conf文件,添加下面
location /group1/M00 {
root /home/ys2/fastdfs/data;
ngx_fastdfs_module;
}
最后,在浏览器里直接访问storage节点下的某个文件,比如下面,如果能成功显示在浏览器中,则说明配置成功了。
http://10.210.65.129/group1/M00/00/00/CtJBgV1s1m2AatCZAAAADCHxdNo922.txt
c/c++ 学习互助QQ群:877684253

本人微信:xiaoshitou5854
fastdfs-nginx-module安装和配置的更多相关文章
- python-django-fastdfs+Nginx的安装和配置_20191122
python-django-fastdfs+Nginx的安装和配置 FastDFS文件系统 FastDFS文件系统简介: 是c语言编写的,是淘宝的架构师写的,存储淘宝的图片,后来开源了, fastDF ...
- nginx的安装与配置
1.nginx的安装与配置 编译安装nginx需要实现安装开发包组“Development tools”和“Server Platform Development”.“Desktop Platform ...
- centos 系统下安装FastDFS+nginx+fastdfs-nginx-module安装配置
前言: 以前的项目上传的文件都是保存到本地或者是局域网内的共享文件夹下,由于数据量,服务器的负载均衡(分机的某些图片无法访问的问题处理)等因素的情况下,就想到用fastdfs来文件管理,花了几天时间硬 ...
- CentOS6.2下fastDFS的完整安装和配置步骤
centos6.2系统下安装配置FastDFS步骤: 1:安装libevent(libevent-2.0.16-stable) ##卸载系统自带libevent rpm -qa|grep libeve ...
- FastDFS+Nginx+Module
1.安装libevent wget https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.g ...
- FastDfs 说明、安装、配置
fastdfs是一个开源的,高性能的的分布式文件系统,他主要的功能包括:文件存储,同步和访问,设计基于高可用和负载均衡,fastfd非常适用于基于文件服务的站点,例如图片分享和视频分享网站 fastf ...
- linux下nginx的安装及配置
一.安装nginx前,我们首先要确保系统安装了g++.gcc.openssl-devel.pcre-devel和zlib-devel软件,可通过如图所示命令进行检测,如果以安装我们可以通过图二所示卸载 ...
- linux应用之nginx的安装及配置(centos)
Ubuntu/CentOS 系统上安装与配置Nginx 一.在线安装: Ubuntu:sudo apt-get install nginx CentOS: sudo yum install nginx ...
- Centos7 中Nginx的安装与配置
安装与配置 1.安装nginx yum intsall nginxsudo systemctl start nginx 启动服务sudo firewall-cmd --permanent --zone ...
- 【Nginx】安装&环境配置
安装依赖包 安装make:yum -y install gcc automake autoconf libtool make 安装g++:yum -y install gcc gcc-c++ 安装pc ...
随机推荐
- Java - IO System类支持和缓冲流
System类的支持和缓冲流 System类对IO的支持 在System类中,为了支持IO操作提供了三个常量: 错误输出: public static final PrintStream err; 输 ...
- Zookeeper学习(一)
shell角度 API角度 Zookeeper可单节点,可分布式 作用: distributed coordination(分布式协调) 同一时间只有一个对外提供服务,另外的就是standy. 当ac ...
- Nginx四层负载均衡概述
目录 Nginx四层负载均衡概述 什么是负载均衡 负载均衡应用场景 四层,七层集群架构 四层负载均衡总结 Nginx如何配置四层负载均衡 nginx四层负载均衡端口转发 Nginx四层负载均衡概述 什 ...
- win7+vim搭建+verilog HDL IDE
参考地址:http://www.huangdc.com/421 参考文章为2016年,部分更新贴于文章内了 安装下载vim vim在win下叫gvim,下载地址:https://www.vim.org ...
- expect实现非交互下的ssh连接, expect简单使用整理
1. shell中使用ssh远程连接服务器做一些事情通常需要交互输入些信息, 可使用expect语句解决: 2. expect中设置变量语法: set name xxx set age xxx ...
- shell基础概念, if+命令, shell中引用python, shell脚本的几种执行方式
说明: 虚拟机中shell_test目录用来练习shell, 其中有个test.log文件用来存放日志 #!/usr/bin/bash # shell文件开头, 用来指定该文件使用哪个解释器 ...
- linux,xshell命令
一. linux 1.Linux发行版 <1> 常见的发行版本如下: Ubuntu Redhat Fedora openSUSE Linux Mint Debian Manjaro M ...
- 【2019.8.15 慈溪模拟赛 T2】组合数(binom)(卢卡斯定理+高维前缀和)
卢卡斯定理 题目中说到\(p\)是质数. 而此时要求组合数向质数取模的结果,就可以用卢卡斯定理: \[C_x^y=C_{x\ div\ p}^{y\ div\ p}\cdot C_{x\ mod\ p ...
- Python开发GUI实战:图片转换素描画工具!
奋斗没有终点 好好学习72变,因为将来 没有人能替你阻挡81难 . 生如蝼蚁,当有鸿鹄之志: 命如纸薄,应有不屈之心 . 今天被这句话触动了,所以开篇分享给大家.鸡汤有毒,但有时大家却靠它激励自己 ...
- css样式的介绍
1.什么是css? 简单的来说css就是配合HTML的,HTML主要负责页面的结构,css就像一个美容师,主要负责页面的美化. 2.css的样式 css的样式有三种:行内样式 内部式 外部链接式 ...