手机版
你好,游客 登录 注册
背景:
阅读新闻

FastDFS安装部署

[日期:2015-10-11] 来源:Linux社区  作者:eveday [字体: ]

1 安装环境
1.1 系统环境
系统:最小化安装的 RedHat 6.4

版本:2.6.32-358.el6.x86_64

1.2 软件版本
FastDFS版本:FastDFS_v3.06.tar.gz

Nginx版本:nginx-1.0.11.tar.gz

FastDFS-Nginx-module版本:fastdfs-nginx-module_v1.10.tar.gz

1.3 目录结构
/data/fastdfs/ 存放日志和数据

1.4 角色分配
两个tracker

tracker1:192.168.199.125

tracker2:192.168.199.126

两个storage

storage1:192.168.199.126

storage2:192.168.199.127

注释:192.168.199.126既是tracker又是storage

1.5 注意事项
注意防火墙是否开启,或者允许相关的端口通过

2 FastDFS部署
2.1 在tracker1部署
1、安装依赖包

yum groupinstall -y "Development Tools"

yum install -y libevent-devel pcre-devel zlib-devel

2、安装FastDFS

mkdir -p /data/fastdfs

tar xvzf FastDFS_v3.06.tar.gz

cd FastDFS

sed -i 's@#WITH_HTTPD=1@WITH_HTTPD=1@g' make.sh

sed -i 's@#WITH_LINUX_SERVICE=1@WITH_LINUX_SERVICE=1@g' make.sh

./make.sh

./make.sh install

注释:将找到下面两行,将前边的"#"去掉,目的是安装httpd和fdfs_trackerd/fdfs_storaged服务

    WITH_HTTPD=1

WITH_LINUX_SERVICE=1

注:如果遇到一下报错

/usr/bin/ld: cannot find -levent

collect2: ld returned 1 exit status

make: *** [fdfs_monitor] Error 1

则是缺少libevent-devel造成,需要安装libevent-devel

安装方法:

rpm -ivh libevent-doc-1.4.13-4.el6.noarch.rpm libevent-headers-1.4.13-4.el6.noarch.rpm libevent-devel-1.4.13-4.el6.x86_64.rpm

 

3、修改tracker.conf配置文件

vim /etc/fdfs/tracker.conf

  base_path=/data/fastdfs

注释:配置data和log的存放路径,该路径如果不存在,需要自己创建

  #include http.conf

注释:找到##include http.conf,去掉一个"#"

4、修改client.conf配置文件

vim /etc/fdfs/client.conf

#修改base_path

base_path=/data/fastdfs

注释:修改base_path

tracker_server=192.168.199.125:22122

tracker_server=192.168.199.126:22122

注释:修改tracker地址,多个tracker写成多行,IP地址后面需要加端口

2.2 在tracker2部署
1、安装依赖包

yum groupinstall -y "Development Tools"

yum install -y libevent-devel pcre-devel zlib-devel

 

2、安装FastDFS

mkdir -p /data/fastdfs

tar xvzf FastDFS_v3.06.tar.gz

cd FastDFS

sed -i 's@#WITH_HTTPD=1@WITH_HTTPD=1@g' make.sh

sed -i 's@#WITH_LINUX_SERVICE=1@WITH_LINUX_SERVICE=1@g' make.sh

./make.sh

./make.sh install

 

注释:将找到下面两行,将前边的"#"去掉,目的是安装httpd和fdfs_trackerd/fdfs_storaged服务

    WITH_HTTPD=1

WITH_LINUX_SERVICE=1

注:如果遇到一下报错

/usr/bin/ld: cannot find -levent

collect2: ld returned 1 exit status

make: *** [fdfs_monitor] Error 1

则是缺少libevent-devel造成,需要安装libevent-devel

安装方法:

rpm -ivh libevent-doc-1.4.13-4.el6.noarch.rpm libevent-headers-1.4.13-4.el6.noarch.rpm libevent-devel-1.4.13-4.el6.x86_64.rpm

 

3、修改tracker.conf配置文件

vim /etc/fdfs/tracker.conf

  base_path=/data/fastdfs

注释:配置data和log的存放路径,该路径如果不存在,需要自己创建

  #include http.conf

注释:找到##include http.conf,去掉一个"#"

 

4、修改client.conf配置文件

vim /etc/fdfs/client.conf

#修改base_path

base_path=/data/fastdfs

注释:修改base_path

tracker_server=192.168.199.125:22122

tracker_server=192.168.199.126:22122

注释:修改tracker地址,多个tracker写成多行,IP地址后面需要加端口

 

2.3 在storage1部署
1、storage1即是tracker2,FastDFS已经安装

 

2、修改storage.conf配置文件

vim /etc/fdfs/storage.conf

base_path=/data/fastdfs

注释:修改base_path

store_path0=/data/fastdfs

注释:修改store_path0,此为存放数据路径

tracker_server=192.168.199.125:22122

tracker_server=192.168.199.126:22122

注释:修改tracker地址,多个tracker写成多行,IP地址后面需要加端口

http.disabled=true

注释:关闭内置的web server

http.server_port=80

注释:web server的端口改成80

group_name=group1

注释:此台storage1所属的服务器组名,同组内storage数据完全相同

 

3、安装Nginx和fastdfs-nginx-module

tar xvzf fastdfs-nginx-module_v1.10.tar.gz -C /opt

tar xvzf nginx-1.0.11.tar.gz

cd nginx-1.0.11

./configure --prefix=/usr/local/nginx --add-module=/opt/fastdfs-nginx-module/src

make && make install

 

在Nginx的配置文件中添加一下内容

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

 

    location /group1/M00 {

            root /data/fastdfs/data;

            ngx_fastdfs_module;

}

 

4、修改mod_fastdfs.conf配置文件

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

 

vim /etc/fdfs/mod_fastdfs.conf

base_path=/data/fastdfs

注释:放置log的目录

tracker_server=192.168.199.125:22122

tracker_server=192.168.199.126:22122

注释:tracker1的ip和端口,此处可以写多个tracker server,每行一个

group_name=group1

注释:此台storage server所属的服务组名

url_have_group_name = true

注释:在URL中包含group名称,很重要

store_path0=/data/fastdfs

注释:放置文件的目录

2.4 在storage2部署
1、安装依赖包

yum groupinstall -y "Development Tools"

yum install -y libevent-devel pcre-devel zlib-devel

 

2、安装FastDFS

mkdir -p /data/fastdfs

tar xvzf FastDFS_v3.06.tar.gz

cd FastDFS

sed -i 's@#WITH_HTTPD=1@WITH_HTTPD=1@g' make.sh

sed -i 's@#WITH_LINUX_SERVICE=1@WITH_LINUX_SERVICE=1@g' make.sh

./make.sh

./make.sh install

 

注释:将找到下面两行,将前边的"#"去掉,目的是安装httpd和fdfs_trackerd/fdfs_storaged服务

    WITH_HTTPD=1

WITH_LINUX_SERVICE=1

注:如果遇到一下报错

/usr/bin/ld: cannot find -levent

collect2: ld returned 1 exit status

make: *** [fdfs_monitor] Error 1

则是缺少libevent-devel造成,需要安装libevent-devel

安装方法:

rpm -ivh libevent-doc-1.4.13-4.el6.noarch.rpm libevent-headers-1.4.13-4.el6.noarch.rpm libevent-devel-1.4.13-4.el6.x86_64.rpm

 

2、修改storage.conf配置文件

vim /etc/fdfs/storage.conf

base_path=/data/fastdfs

注释:修改base_path

store_path0=/data/fastdfs

注释:修改store_path0,此为存放数据路径

tracker_server=192.168.199.125:22122

tracker_server=192.168.199.126:22122

注释:修改tracker地址,多个tracker写成多行,IP地址后面需要加端口

http.disabled=true

注释:关闭内置的web server

http.server_port=80

注释:web server的端口改成80

group_name=group1

注释:此台storage1所属的服务器组名,同组内storage数据完全相同

 

3、安装Nginx和fastdfs-nginx-module

tar xvzf fastdfs-nginx-module_v1.10.tar.gz -C /opt

tar xvzf nginx-1.0.11.tar.gz

cd nginx-1.0.11

./configure --prefix=/usr/local/nginx --add-module=/opt/fastdfs-nginx-module/src

make && make install

 

在Nginx的配置文件中添加一下内容

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

 

    location /group1/M00 {

            root /data/fastdfs/data;

            ngx_fastdfs_module;

}

 

4、修改mod_fastdfs.conf配置文件

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

 

vim /etc/fdfs/mod_fastdfs.conf

base_path=/data/fastdfs

注释:放置log的目录

tracker_server=192.168.199.125:22122

tracker_server=192.168.199.126:22122

注释:tracker1的ip和端口,此处可以写多个tracker server,每行一个

group_name=group1

注释:此台storage server所属的服务组名

url_have_group_name = true

注释:在URL中包含group名称,很重要

store_path0=/data/fastdfs

注释:放置文件的目录

3 启动服务
3.1 启动tracker服务
 

1、启动tracker1和tracker2

/etc/init.d/fdfs_trackerd start

2、查看8080和22122端口情况

netstat -lntup|grep -E "8080|22122"

tcp        0      0 0.0.0.0:8080                0.0.0.0:*                  LISTEN      6087/fdfs_trackerd 

tcp        0      0 0.0.0.0:22122              0.0.0.0:*                  LISTEN      6087/fdfs_trackerd 

3.2 启动storage服务
1、启动storage1和storage2

/etc/init.d/fdfs_storaged start

2、查看80和23000端口情况

netstat -lntup|grep -E "80|23000"

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                  LISTEN      31501/nginx       

tcp        0      0 0.0.0.0:23000              0.0.0.0:*                  LISTEN      31705/fdfs_storaged

3.3 启动Nginx服务

/usr/local/nginx/sbin/nginx

4 检测
4.1在tracker1上测试
echo 'hello,this is my first fastdfs test' >test.txt

/usr/local/bin/fdfs_test /etc/fdfs/client.conf upload test.txt

This is FastDFS client test program v3.06

 

Copyright (C) 2008, Happy Fish / YuQing

 

FastDFS may be copied only under the terms of the GNU General

Public License V3, which may be found in the FastDFS source kit.

Please visit the FastDFS Home Page http://www.csource.org/

for more detail.

 

[2015-10-10 15:24:11] INFO - base_path=/data/fastdfs, connect_timeout=30, network_timeout=60, tracker_server_count=2, anti_steal_token=0, anti_steal_secret_key length=0

 

tracker_query_storage_store_list_without_group:

        server 1. group_name=group1, ip_addr=192.168.199.126, port=23000

        server 2. group_name=group1, ip_addr=192.168.199.127, port=23000

 

group_name=group1, ip_addr=192.168.199.126, port=23000

storage_upload_by_filename

group_name=group1, remote_filename=M00/00/00/wKjHflYYvRuOsw3pAAAAJP1L3N8043.txt

source ip address: 192.168.199.126

file timestamp=2015-10-10 15:24:11

file size=36

file crc32=4249607391

file url: http://192.168.199.125:8080/group1/M00/00/00/wKjHflYYvRuOsw3pAAAAJP1L3N8043.txt

storage_upload_slave_by_filename

group_name=group1, remote_filename=M00/00/00/wKjHflYYvRuOsw3pAAAAJP1L3N8043_big.txt

source ip address: 192.168.199.126

file timestamp=2015-10-10 15:24:11

file size=36

file crc32=4249607391

file url:

http://192.168.199.125:8080/group1/M00/00/00/wKjHflYYvRuOsw3pAAAAJP1L3N8043_big.txt

使用浏览器测试以上的URL

如果看到“hello,this is my first fastdfs test”内容,说明成功了

4.2在tracker2上测试
echo 'hello,this is fastdfs test 2 ' >test.txt                   

/usr/local/bin/fdfs_test /etc/fdfs/client.conf upload test.txt

This is FastDFS client test program v3.06

 

Copyright (C) 2008, Happy Fish / YuQing

 

FastDFS may be copied only under the terms of the GNU General

Public License V3, which may be found in the FastDFS source kit.

Please visit the FastDFS Home Page http://www.csource.org/

for more detail.

 

[2015-10-10 15:30:10] INFO - base_path=/data/fastdfs, connect_timeout=30, network_timeout=60, tracker_server_count=2, anti_steal_token=0, anti_steal_secret_key length=0

 

tracker_query_storage_store_list_without_group:

        server 1. group_name=group1, ip_addr=192.168.199.126, port=23000

        server 2. group_name=group1, ip_addr=192.168.199.127, port=23000

 

group_name=group1, ip_addr=192.168.199.127, port=23000

storage_upload_by_filename

group_name=group1, remote_filename=M00/00/00/wKjHf1YYvoH76oI2AAAAHk9-q5s651.txt

source ip address: 192.168.199.127

file timestamp=2015-10-10 15:30:09

file size=30

file crc32=1333701531

file url: http://192.168.199.125:8080/group1/M00/00/00/wKjHf1YYvoH76oI2AAAAHk9-q5s651.txt

storage_upload_slave_by_filename

group_name=group1, remote_filename=M00/00/00/wKjHf1YYvoH76oI2AAAAHk9-q5s651_big.txt

source ip address: 192.168.199.127

file timestamp=2015-10-10 15:30:09

file size=30

file crc32=1333701531

file url:

http://192.168.199.125:8080/group1/M00/00/00/wKjHf1YYvoH76oI2AAAAHk9-q5s651_big.txt

使用浏览器测试以上的URL

如果看到“hello,this is fastdfs test 2”内容,说明成功了。

4.3 FAQ
查看当前监控信息,在tracker上执行fdfs_monitor /etc/fdfs/client.conf和在storage上执行fdfs_monitor /etc/fdfs/storage.conf得到的结果一样。

CentOS 6.2下fastDFS的完整安装和配置步骤 http://www.linuxidc.com/Linux/2012-12/75989.htm

FastDFS在Ubuntu下的安装,PHP客户端 http://www.linuxidc.com/Linux/2012-09/71459.htm

FastDFS分布式文件服务器安装,及配置,测试 http://www.linuxidc.com/Linux/2012-09/71458.htm

FastDFS 整合Nginx问题整理 http://www.linuxidc.com/Linux/2012-09/71232.htm

CentOS下搭建FastDFS http://www.linuxidc.com/Linux/2012-09/70995.htm

Ubuntu安装FastDFS全程记录 http://www.linuxidc.com/Linux/2012-03/56377.htm

FastDFS 的详细介绍请点这里
FastDFS 的下载地址请点这里

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-10/124022.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款