最小化安装的RedHat 6.4
fastdfs版本:FastDFS_v3.06.tar.gz
nginx版本:nginx-1.0.11.tar.gz
fastdfs-nginx-module版本:fastdfs-nginx-module_v1.10.tar.gz
tracker1:192.168.199.126
tracker2:192.168.199.127
storage1:192.168.199.128
storage2: 192.168.199.129
yumgroupinstall -y "Development Tools"
yuminstall -y libevent-devel pcre-devel zlib-devel
mkdir �Cp/data/fastdfs #为以后存放日志和数据做准备
tar xvzfFastDFS_v3.06.tar.gz
cd FastDFS
vimmake.sh
#将找到下面两行,将前边的"#"去掉,目的是安装httpd和fdfs_trackerd/fdfs_storaged服务
WITH_HTTPD=1
WITH_LINUX_SERVICE=1
./make.sh
./make.shinstall
#如果遇到报错
/usr/bin/ld: cannot find -levent
collect2: ld returned 1 exit status
make: *** [fdfs_monitor] Error 1
则是缺少libevent-devel造成,需要安装libevent-devel
安装方法:
rpm -ivhlibevent-doc-1.4.13-4.el6.noarch.rpm libevent-headers-1.4.13-4.el6.noarch.rpmlibevent-devel-1.4.13-4.el6.x86_64.rpm
vim /etc/fdfs/tracker.conf
# 配置data和log的存放路径,该路径如果不存在,需要自己创建
base_path=/data/fastdfs
# 找到下面这行包含两个"##"号
##include http.conf
# 去掉一个"#"
#include http.conf
在tracker上修改client.conf配置文件
vim/etc/fdfs/client.conf
#修改base_path
base_path=/data/fastdfs
#修改tracker地址,多个tracker写成多行,IP地址后面需要加端口
tracker_server=192.168.199.126:22122
tracker_server=192.168.199.127:22122
vim/etc/fdfs/storage.conf
#修改base_path
base_path=/data/fastdfs
#修改store_path0,此为存放数据路径
store_path0=/data/fastdfs
#修改tracker地址,多个tracker写成多行,IP地址后面需要加端口
tracker_server=192.168.199.126:22122
tracker_server=192.168.199.127:22122
# 关闭内置的webserver
http.disabled=true
# webserver的端口改成80
http.server_port=80
# 此台storage1所属的服务器组名,同组内storage数据完全相同
group_name=group1
tar xvzffastdfs-nginx-module_v1.10.tar.gz
tar xvzfnginx-1.0.11.tar.gz
cdnginx-1.0.11
./configure--prefix=/usr/local/nginx --add-module=/opt/fastdfs-nginx-module/src
make&& make install
cp/opt/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
vim/etc/fdfs/mod_fastdfs.conf
# 放置log的目录
base_path=/home/storage1/fastdfs
# tracker1的ip和端口,此处可以写多个trackerserver,每行一个
tracker_server=192.168.199.126:22122
tracker_server=192.168.199.127:22122
# 此台storageserver所属的服务组名
group_name=group1
# 在URL中包含group名称,很重要
url_have_group_name = true
# 放置文件的目录
store_path0=/data/fastdfs
==============================================
在nginx配置文件中添加如下信息
vim/usr/local/nginx/conf/nginx.conf
location /group1/M00 {
root /home/storage1/fastdfs/data;
ngx_fastdfs_module;
}
创建M00目录的软连接
ln -s/data/fastdfs/data/ /data/fastdfs/data/M00
tracker启动:确认8080,22122端口已经监听
/etc/init.d/fdfs_trackerdstart
tracker上面监控:
fdfs_monitor/etc/fdfs/client.conf
storage启动:确认80,23000端口已经监听
/etc/init.d/fdfs_storagedstart
storage上面监控:
fdfs_monitor/etc/fdfs/storage.conf
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 isFastDFS client test program v3.06
Copyright(C) 2008, Happy Fish / YuQing
FastDFSmay be copied only under the terms of the GNU General
PublicLicense V3, which may be found in the FastDFS source kit.
Pleasevisit the FastDFS Home Page http://www.csource.org/
for moredetail.
[2015-08-1212:59:22] 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=10.10.212.135,port=23000
server 2. group_name=group1,ip_addr=192.168.199.129, port=23000
group_name=group1,ip_addr=192.168.199.129, port=23000
storage_upload_by_filename
group_name=group1,remote_filename=M00/00/00/wKjHgVXK0qqKJ6VhAAAAJP1L3N8706.txt
source ipaddress: 192.168.199.129
filetimestamp=2015-08-12 12:59:22
filesize=36
filecrc32=4249607391
file url:http://10.10.212.134:8080/group1/M00/00/00/wKjHgVXK0qqKJ6VhAAAAJP1L3N8706.txt
storage_upload_slave_by_filename
group_name=group1,remote_filename=M00/00/00/wKjHgVXK0qqKJ6VhAAAAJP1L3N8706_big.txt
source ipaddress: 192.168.199.129
filetimestamp=2015-08-12 12:59:22
filesize=36
filecrc32=4249607391
file url: http://10.10.212.134:8080/group1/M00/00/00/wKjHgVXK0qqKJ6VhAAAAJP1L3N8706_big.txt
使用浏览器打开上面任一地址地址,如果看到文件内容,说明配置成功!
1.)查看当前监控信息,在tracker上执行fdfs_monitor/etc/fdfs/client.conf和在storage上执行fdfs_monitor/etc/fdfs/storage.conf得到的结果一样。
[root@localhosttmp]# fdfs_monitor /etc/fdfs/client.conf
[2015-08-1213:08:34] 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
server_count=2,server_index=0
trackerserver is 10.10.212.134:22122
groupcount: 1
Group 1:
group name= group1
disk freespace = 36 GB
trunk freespace = 0 GB
storageserver count = 2
activeserver count = 2
storageserver port = 23000
storageHTTP port = 80
store pathcount = 1
subdircount per path = 256
currentwrite server index = 1
currenttrunk file id = 0
Storage 1:
ip_addr = 10.10.212.135 ACTIVE
http domain =
version = 3.06
join time = 2015-05-20 13:44:32
up time = 2015-08-12 10:35:12
total storage = 45GB
free storage = 36GB
upload priority = 10
store_path_count = 1
subdir_count_per_path = 256
storage_port = 23000
storage_http_port = 80
current_write_path = 0
source ip_addr =
if_trunk_server= 0
total_upload_count = 9283
success_upload_count = 9283
total_append_count = 0
success_append_count = 0
total_set_meta_count = 1688
success_set_meta_count = 1688
total_delete_count = 132
success_delete_count = 132
total_download_count = 4539
success_download_count = 4539
total_get_meta_count = 0
success_get_meta_count = 0
total_create_link_count = 0
success_create_link_count = 0
total_delete_link_count = 0
success_delete_link_count = 0
total_upload_bytes = 2474396113
success_upload_bytes =2474396113
total_append_bytes = 0
success_append_bytes = 0
stotal_download_bytes =377438594
success_download_bytes =377438594
total_sync_in_bytes = 67059
success_sync_in_bytes = 67059
total_sync_out_bytes =2435190011
success_sync_out_bytes =2435190011
total_file_open_count = 13836
success_file_open_count = 13836
total_file_read_count = 5176
success_file_read_count = 5176
total_file_write_count = 16999
success_file_write_count =16999
last_heart_beat_time =2015-08-12 13:05:44
last_source_update = 2015-08-1211:37:09
last_sync_update = 2015-08-1213:00:26
last_synced_timestamp = 2015-08-1212:59:22 (0s delay)
Storage 2:
ip_addr = 192.168.199.129 ACTIVE
http domain =
version = 3.06
join time = 2015-08-12 10:11:25
up time = 2015-08-12 10:30:23
total storage = 44GB
free storage = 37GB
upload priority = 10
store_path_count = 1
subdir_count_per_path = 256
storage_port = 23000
storage_http_port = 80
current_write_path = 0
source ip_addr = 10.10.212.135
if_trunk_server= 0
total_upload_count = 4
success_upload_count = 4
total_append_count = 0
success_append_count = 0
total_set_meta_count = 3
success_set_meta_count = 3
total_delete_count = 0
success_delete_count = 0
total_download_count = 3
success_download_count = 3
total_get_meta_count = 0
success_get_meta_count = 0
total_create_link_count = 0
success_create_link_count = 0
total_delete_link_count = 0
success_delete_link_count = 0
total_upload_bytes = 66850
success_upload_bytes = 66850
total_append_bytes = 0
success_append_bytes = 0
stotal_download_bytes = 319240
success_download_bytes = 319240
total_sync_in_bytes =2435190011
success_sync_in_bytes =2435190011
total_sync_out_bytes = 67059
success_sync_out_bytes = 67059
total_file_open_count = 10721
success_file_open_count = 10721
total_file_read_count = 3
success_file_read_count = 3
total_file_write_count = 18311
success_file_write_count =18311
last_heart_beat_time =2015-08-12 13:05:56
last_source_update = 2015-08-1212:59:22
last_sync_update = 2015-08-1211:36:11
last_synced_timestamp =2015-08-12 11:37:09 (0s delay)
#多个节点查看当前是否为激活状态和同步延时时间,
2.)增加storage节点,配置与其它节点相同,安装fastdfs、nginx后 ,把配置文件storage.confmod_fastdfs.conf copy到/etc/fdfs/即可,添加完成后重启tracker和storage,再用monitor查看同步信息及节点当前状态。