系统:最小化安装的 RedHat 6.4
版本:2.6.32-358.el6.x86_64
FastDFS版本:FastDFS_v3.06.tar.gz
Nginx版本:nginx-1.0.11.tar.gz
FastDFS-Nginx-module版本:fastdfs-nginx-module_v1.10.tar.gz
/data/fastdfs/ 存放日志和数据
两个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、安装依赖包
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地址后面需要加端口
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地址后面需要加端口
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
注释:放置文件的目录
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
注释:放置文件的目录
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
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
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”内容,说明成功了
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”内容,说明成功了。
查看当前监控信息,在tracker上执行fdfs_monitor /etc/fdfs/client.conf和在storage上执行fdfs_monitor /etc/fdfs/storage.conf得到的结果一样。
本文出自 “肖海” 博客,请务必保留此出处http://eveday.blog.51cto.com/10577430/1701679
原文地址:http://eveday.blog.51cto.com/10577430/1701679