FastDFS(1):Centos7 安装FastDFS+nginx module

本文原文连接: 转载请注明出处!

1,关于FastDFS

摘自: FastDFS是一个开源的分布式文件系统,她对文件进行管理,功能包括:文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了大容量存储和负载均衡的问题。特别适合以文件为载体的在线服务,如相册网站、视频网站等等。

FastDFS服务端有两个角色:跟踪器(tracker)和存储节点(storage)。跟踪器主要做调度工作,在访问上起负载均衡的作用。

存储节点存储文件,完成文件管理的所有功能:存储、同步和提供存取接口,FastDFS同时对文件的meta data进行管理。所谓文件的meta data就是文件的相关属性,以键值对(key value pair)方式表示,如:width=1024,其中的key为width,value为1024。文件meta data是文件属性列表,可以包含多个键值对。

GitHub:https://github.com/happyfish100/fastdfs 一个写的不错的博客:?p=221

2,安装FastDFS

参考文档: https://github.com/happyfish100/fastdfs/blob/master/INSTALL

2.1,安装编译工具yum -y groupinstall ‘Development Tools’ yum -y install wget 2.2,安装libfastcommon类库

必须先按照这个,否则报错:

cc /common/fdfs_global.o ../common/fdfs_global.c -I../common -I/usr/include/fastcommon../common/fdfs_global.c:20:20: fatal error: logger.h: No such file or directory #include “logger.h”^compilation terminated

直接下载安装即可:

wget https://github.com/happyfish100/libfastcommon/archive/master.zipunzip master.zipcd libfastcommon-master./make.sh./make.sh install2.3,安装FastDFSwget https://githubtar -zxvf V5cd fastdfs-5.05/./make.sh./make.sh install2.4,启动FastDFS

安装之后配置文件在目录/etc/fdfs。

mv storage.conf.sample storage.confmv tracker.conf.sample tracker.conf

首先修改配置文件: /etc/fdfs/tracker.conf,修改路径到/data/fdfs目录。

# the base path to store data and log filesbase_path=/data/fdfs

启动: /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start

修改配置文件: /etc/fdfs/storage.conf,修改路径到/data/fdfs目录,同时配置tracker_server地址。

# the base path to store data and log filesbase_path=/data/fdfs# tracker_server can ocur more than once, and tracker_server format is# “host:port”, host can be hostname or ip addresstracker_server=:store_path0=/data/fdfs#store_path1=/home/yuqing/fastdfs2

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

启动的时候,看日志没有错误就说明启动成功。 查看fdfs进程:

#ps -ef | grep fdfsroot:42 ?00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf startroot:08 ?00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf startroot:08 pts/1 00:00:00 grep –color=auto fdfs

2.5 安装nginx + lua + fastdfs module 下载fastdfs-nginx-module模块 https://github.com/happyfish100/fastdfs-nginx-module 下载openresty nginx +lua包

wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zipunzip fastdfs-nginx-module-master.zipwget -zxvf ngx_openresty-

编译安装:这里注意下,需要增加参数。 一个是stub_status统计模块,一个是realip模块。 参考地址: ?p=80

yum -y install pcre-devel openssl openssl-develcd ngx_openresty/configure add/src gmakegmake install

nginx +lua安装路径:

nginx path prefix: “/usr/local/openresty/nginx” nginx binary file: “/usr/local/openresty/nginx/sbin/nginx” nginx configuration prefix: “/usr/local/openresty/nginx/conf” nginx configuration file: “/usr/local/openresty/nginx/conf/nginx.conf” nginx pid file: “/usr/local/openresty/nginx/logs/nginx.pid” nginx error log file: “/usr/local/openresty/nginx/logs/error.log” nginx http access log file: “/usr/local/openresty/nginx/logs/access.log”

启动,重启nginx

#启动/usr/local/openresty/nginx/sbin/nginx#重启 /usr/local/openresty/nginx/sbin/nginx -s restart3,,测试FastDFS

配置服务:

cd /etc/fdfsmv client.conf.sample client.conf

修改配置:

# the base path to store log filesbase_path=/data/fdfs# tracker_server can ocur more than once, and tracker_server format is# “host:port”, host can be hostname or ip addresstracker_server=:22122

配置nginx:

cp /root/fastdfs/src/mod_fastdfs.conf /etc/fdfs/mkdir /data/ngx志在山顶的人,不会贪念山腰的风景。

FastDFS(1):Centos7 安装FastDFS+nginx module

相关文章:

你感兴趣的文章:

标签云: