fastdfs 安装配置
1.安装
# wget
# tar xf download
# cd FastDFS/
# ./make.sh 运行文件
有报错信息
compilation terminated.
make: *** [../common/fdfs_global.o] Error 1
2.查看官方文档,需要安装libfastcommon
# wget https://github.com/happyfish100/libfastcommon/archive/master.zip
# unzip master.zip
# cd libfastcommon-master/
# ./make.sh
# ./make.sh install
3.继续安装FastDFS
# cd FastDFS/
# ./make.sh
# ./make.sh install
4.配置
# cd /etc/fdfs/
# cp tracker.conf.sample tracker.conf
修改配置文件
disabled=false #启用配置文件
port=22122 #设置tracker的端口号
base_path=/data/fastdfs/trackerd #设置tracker的数据文件和日志目录(需预先创建)
http.server_port=18080 #设置http端口号
5.启动
# mkdir -p /data/fastdfs/trackerd
# /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 安装步骤相同
2.配置
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=18888 #设置http端口号
3.启动
# 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
4.查看状态
/usr/bin/fdfs_monitor /etc/fdfs/storage.conf
七、在storage安装nginx
在storage上安装nginx主要为了提高http的访问服务,同时解决group中的storage服务的同步延迟问题
1.nginx安装,在编译安装时添加 --add-module=/root/fastdfs-nginx-module/src/
2.配置
# wget
# tar xf download.1
3.解决报错
make的时候会报一下错误,
root/fastdfs-nginx-module/src//common.c:21:25: fatal error: fdfs_define.h: No such file or directory
#include "fdfs_define.h"
^
compilation terminated.
make[1]: *** [objs/addon/src/ngx_http_fastdfs_module.o] Error 1
解决办法:
vim /root/fastdfs-nginx-module/src/config
CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"
重新编译,安装即可
4.配置
# cp /root/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/.
# cp /root/FastDFS/conf/http.conf /etc/fdfs/.
/root/FastDFS/conf/mime.types /etc/fdfs/.
修改nginx的配置文件
server {
listen 18888;
server_name localhost;
location ~/group1/M00 {
root /fdfs/storage/data;
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
6.启动nginx
八、在tracker安装nginx
在tracker上安装的nginx主要为了提供http访问的反向代理、负载均衡已经缓存服务
1.安装配置与storage上相同
2.配置负载功能
upstream fdfs_group3 {
server 172.16.1.207:8080 weight=1 max_fails=2 fail_timeout=30s;
server 172.16.1.208:8080 weight=1 max_fails=2 fail_timeout=30s;
}
server {
#
设置服务器端口
listen 8080;
#
设置
group1
的负载均衡参数
location /group1/M00 {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache http-cache;
proxy_cache_valid 200 304 12h;
proxy_cache_key $uri$is_args$args;
proxy_pass http://fdfs_group1;
expires 30d;
九。测试
cd /etc/fdfs/
cp client.conf.sample client.conf
base_path=/data/fdfs/tracker #
日志存放路径
tracker_server=172.16.8.8:22122 #tracker
服务器
IP
地址和端口号
http.tracker_server_port=8080 #tracker
服务器的
http
端口号
上传文件
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /root/install3.sh
group1/M00/00/00/rBAIClZB6ySAYFbtAAAGpOjLUVA6601.sh
日志报错
[2015-11-10 21:04:04] ERROR - file: ../common/fdfs_global.c, line: 52, the format of filename "group1/M00/00/00/rBAIClZB6ySAYFbtAAAGpOjLUVA6601.sh" is invalid
vi /etc/fdfs/mod_fastdfs.conf
url_have_group_name = true
再次测试上传
[root@vrvap2 fdfs]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /root/new.jpg
group1/M00/00/00/rBAIClZB7fWAF2BmAADCkWSm8AA128.jpg
附件列表