码迷,mamicode.com
首页 > 其他好文 > 详细

FastDFS安装配置

时间:2014-12-12 17:01:30      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:fastdfs安装配置

一:拓扑图

bubuko.com,布布扣


二:安装前准备

tracker1:192.168.1.10

tracker2: 192.168.1.11


group1:

storage1:192.168.1.12

storage2:192.168.1.13


group2:

storage3:192.168.1.14

storage4:192.168.1.15


软件包下载:

fastdfs:http://sourceforge.net/projects/fastdfs/files/

nginx:http://nginx.org/en/download.html


FastDFS:FastDFS_v5.03.tar.gz

Nginx扩展模块:fastdfs-nginx-module_v1.16.tar.gz

Nginx版本:nginx-1.7.4.tar.gz


三:安装

tracker:

    tar zxvf FastDFS_v5.03.tar.gz
    ./make.sh
    ./make.sh install


    配置:

    vim /etc/fdfs/tracker.conf

    一般只需改动以下几个参数即可:

    disabled=false             #启用配置文件 

    port=22122                 #设置 tracker 的端口号 

    base_path=/fdfs/tracker    #设置 tracker 的数据文件和日志目录(需预先创建) 

    http.server_port=80      #设置 http 端口号


    启动:

    关闭防火墙:

    /etc/init.d/iptables stop

    /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart


     设置开机自启动:

     添加到/etc/rc.local中


    另外一台tarcker同上安装配置


storage

    安装:

    tar zxvf FastDFS_v5.03.tar.gz

    ./make.sh

    ./make.sh install


    配置:

    vim /etc/fdfs/storage.conf

    一般只需改动以下几个参数即可:

    disabled=false                         #启用配置文件 

    group_name=group1                      #组名,根据实际情况修改 

    port=23000                             #设置 storage 的端口号 

    base_path=/fdfs/storage                #设置 storage 的日志目录(需预先创建) 

    store_path_count=1                     #存储路径个数,需要和 store_path 个数匹配 

    store_path0=/fdfs/storage              #存储路径 

    tracker_server=192.168.1.10:22122      #tracker 服务器的 IP 地址和端口号

    tracker_server=192.168.1.11:22122      #tracker 服务器的 IP 地址和端口号

    http.server_port=80                    #设置 http 端口号


    启动:

    关闭防火墙:

    /etc/init.d/iptables stop

    /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf restart


    检测是否成功:

     /usr/local/bin/fdfs_monitor /etc/fdfs/storage.conf

    如果显示:ACTIVE则成功

    添加到开机启动


在storage服务器中安装nginx提供http服务;

需要使用到fastdfs的nginx插件:

tar zxvf fastdfs-nginx-module_v1.15.tar.gz

tar zxvf nginx-1.4.7.tar.gz

cd nginx-1.4.7

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --add-module=/root/fastdfs-nginx-module/src

make && make install


cp /root/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs

vim nginx.conf

listen 80

在 server 段中添加:

location ~ /group[1-2]/M00 {

    root /fdfs/storage/data;

    ngx_fastdfs_module;

}


vim mod_fastdfs.conf

一般只需改动以下几个参数即可:

base_path=/fdfs/storage                #保存日志目录 

tracker_server=192.168.1.10:22122      #tracker 服务器的 IP 地址以及端口号

tracker_server=192.168.1.11: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=/fdfs/storage              #存储路径 

http.need_find_content_type=true       #从文件扩展名查找文件类型(nginx 时为 true) 

group_count = 2                        #组的个数


在末尾增加 2 个组的具体信息:

[group1]

group_name=group1

storage_server_port=23000

store_path_count=1

store_path0=/fdfs/storage

[group2]

group_name=group2

storage_server_port=23000

store_path_count=1

store_path0=/fdfs/storage


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

ln -s /fdfs/storage/data /fdfs/storage/data/M00

开启80端口

其他storage上安装nginx同上


在两台tracker上安装nginx,主要提供反向代理,负载均衡

tar zxvf nginx-1.4.7.tar.gz

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre

make && make install

vim /usr/local/nginx/conf/nginx.conf

#设置 group1 的服务器

upstream fdfs_group1 {

    server 192.168.1.12;

    server 192.168.1.13;

}

#设置 group2 的服务器

upstream fdfs_group2 {

server 192.168.1.14;

server 192.168.1.15;

}


server{ 
listen 80; 
location /group1/M00{ 
proxy_set_header Host $host; 
proxy_pass http://fdfs_group1; 
expires 30d; 
} 

location /group2/M00{ 
proxy_set_header Host $host; 
proxy_pass http://fdfs_group2; 
expires 30d; 
} 
}


安装配置完成,上传文件测试……

本文出自 “人要有梦想,万一实现了呢” 博客,请务必保留此出处http://yangke.blog.51cto.com/9530509/1589154

FastDFS安装配置

标签:fastdfs安装配置

原文地址:http://yangke.blog.51cto.com/9530509/1589154

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!