[group2]
group_name=group2
storage_server_port=23000
store_path_count=1
store_path0=/home/fastdfs
建立M00至存储目录的符号连接:
ln -s /home/fastdfs/data /home/fastdfs/data/M00
2)配置nginx
vi nginx.conf
user root;
location ~/group[1-3]/M00 {
root /home/fastdfs/data;
ngx_fastdfs_module;
}
4.启动
/usr/local/nginx/sbin/nginx
另外:
分别在其他机器storage上全部安装nginx并确认运行正常。注意配置文件中group名参数需要根据实际情况调整:
group1:192.168.110.71,192.168.110.91
group2:192.168.100.90,192.168.100.194
另外nginx的端口号8090。
至此所有配置完毕。
五、测试
配置/etc/fdfs/client.conf
base_path=/home/fastdfs #日志存放路径
tracker_server=192.168.18.43:22122 #tracker服务器IP地址和端口号
http.tracker_server_port=8080 #tracker服务器的http端口号
通过fdfs_upload_file上传一个文件到FastDFS,程序会自动返回文件的URL,
#fdfs_upload_file /etc/fdfs/client.conf 40-15052PZK5.jpg
group1/M00/00/00/wKhuR1Vmh_2ADmdfAAF1dmVtk4w934.jpg
然后使用浏览器访问,访问正常
注:可以使用fdfs_monitor查看tracker和所有group的运行情况
# fdfs_monitor /etc/fdfs/client.conf
[2015-05-27 20:19:59] DEBUG - base_path=/home/fastdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0
server_count=1, server_index=0
tracker server is 192.168.18.43:22122
group count: 2
Group 1:
group name = group1
disk total space = 45438 MB
disk free space = 33920 MB
trunk free space = 0 MB
storage server count = 2
active server count = 2
storage server port = 23000
storage HTTP port = 8080
store path count = 1
subdir count per path = 256
current write server index = 1
current trunk file id = 0
Storage 1:
id = 192.168.110.71
ip_addr = 192.168.110.71 (localhost) ACTIVE
http domain =
version = 5.06
join time = 2015-05-27 01:37:04
up time =
total storage = 95217 MB
free storage = 47563 MB
upload priority = 10
store_path_count = 1
subdir_count_per_path = 256
storage_port = 23000
storage_http_port = 8080
current_write_path = 0
source storage id =
if_trunk_server = 0
connection.alloc_count = 256
connection.current_count = 1
connection.max_count = 2
total_upload_count = 1
success_upload_count = 1
total_append_count = 0
success_append_count = 0
total_modify_count = 0
success_modify_count = 0
total_truncate_count = 0
success_truncate_count = 0
total_set_meta_count = 0
success_set_meta_count = 0
total_delete_count = 0
success_delete_count = 0
total_download_count = 0
success_download_count = 0
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 = 95606
success_upload_bytes = 95606
total_append_bytes = 0
success_append_bytes = 0
total_modify_bytes = 0
success_modify_bytes = 0
stotal_download_bytes = 0
success_download_bytes = 0
total_sync_in_bytes = 0
success_sync_in_bytes = 0
total_sync_out_bytes = 0
success_sync_out_bytes = 0
total_file_open_count = 1
success_file_open_count = 1
total_file_read_count = 0
success_file_read_count = 0
total_file_write_count = 1
success_file_write_count = 1
last_heart_beat_time = 2015-05-27 20:19:49
last_source_update = 2015-05-27 20:14:04
last_sync_update = 1969-12-31 16:00:00
last_synced_timestamp = 1969-12-31 16:00:00
Storage 2:
id = 192.168.110.91
ip_addr = 192.168.110.91 (localhost) ACTIVE
http domain =
version = 5.06
join time = 2015-05-27 19:35:36
up time = 2015-05-27 19:35:36
total storage = 45438 MB
free storage = 33920 MB
upload priority = 10
store_path_count = 1
subdir_count_per_path = 256
storage_port = 23000
storage_http_port = 8080
current_write_path = 0
source storage id = 192.168.110.71
if_trunk_server = 0
connection.alloc_count = 256
connection.current_count = 1
connection.max_count = 1
total_upload_count = 0
success_upload_count = 0
total_append_count = 0
success_append_count = 0
total_modify_count = 0
success_modify_count = 0
total_truncate_count = 0
success_truncate_count = 0
total_set_meta_count = 0
success_set_meta_count = 0
total_delete_count = 0
success_delete_count = 0
total_download_count = 0
success_download_count = 0
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 = 0
success_upload_bytes = 0
total_append_bytes = 0
success_append_bytes = 0
total_modify_bytes = 0
success_modify_bytes = 0
stotal_download_bytes = 0
success_download_bytes = 0
total_sync_in_bytes = 95606
success_sync_in_bytes = 95606
total_sync_out_bytes = 0
success_sync_out_bytes = 0
total_file_open_count = 1
success_file_open_count = 1
total_file_read_count = 0
success_file_read_count = 0
total_file_write_count = 1
success_file_write_count = 1
last_heart_beat_time = 2015-05-27 20:19:51
last_source_update = 1969-12-31 16:00:00
last_sync_update = 2015-05-27 20:14:07
last_synced_timestamp = 2015-05-27 20:14:05 (-1s delay)
Group 2:
group name = group2
disk total space = 9916 MB
disk free space = 7434 MB
trunk free space = 0 MB
storage server count = 2
active server count = 2
storage server port = 23000
storage HTTP port = 8080
store path count = 1
subdir count per path = 256
current write server index = 0
current trunk file id = 0
Storage 1:
id = 192.168.100.194
ip_addr = 192.168.100.194 (localhost) ACTIVE
http domain =
version = 5.06
join time = 2015-05-27 20:03:37
up time = 2015-05-27 20:03:37
total storage = 47368 MB
free storage = 37371 MB
upload priority = 10
store_path_count = 1
subdir_count_per_path = 256
storage_port = 23000
storage_http_port = 8080
current_write_path = 0
source storage id = 192.168.100.90
if_trunk_server = 0
connection.alloc_count = 256
connection.current_count = 1
connection.max_count = 1
total_upload_count = 0
success_upload_count = 0
total_append_count = 0
success_append_count = 0
total_modify_count = 0
success_modify_count = 0
total_truncate_count = 0
success_truncate_count = 0
total_set_meta_count = 0
success_set_meta_count = 0
total_delete_count = 0
success_delete_count = 0
total_download_count = 0
success_download_count = 0
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 = 0
success_upload_bytes = 0
total_append_bytes = 0
success_append_bytes = 0
total_modify_bytes = 0
success_modify_bytes = 0
stotal_download_bytes = 0
success_download_bytes = 0
total_sync_in_bytes = 0
success_sync_in_bytes = 0
total_sync_out_bytes = 0
success_sync_out_bytes = 0
total_file_open_count = 0
success_file_open_count = 0
total_file_read_count = 0
success_file_read_count = 0
total_file_write_count = 0
success_file_write_count = 0
last_heart_beat_time = 2015-05-27 20:19:44
last_source_update = 1969-12-31 16:00:00
last_sync_update = 1969-12-31 16:00:00
last_synced_timestamp = 1969-12-31 16:00:00
Storage 2:
id = 192.168.100.90
ip_addr = 192.168.100.90 (localhost) ACTIVE
http domain =
version = 5.06
join time = 2015-05-27 19:50:27
up time = 2015-05-27 19:50:27
total storage = 9916 MB
free storage = 7434 MB
upload priority = 10
store_path_count = 1
subdir_count_per_path = 256
storage_port = 23000
storage_http_port = 8080
current_write_path = 0
source storage id =
if_trunk_server = 0
connection.alloc_count = 256
connection.current_count = 1
connection.max_count = 1
total_upload_count = 0
success_upload_count = 0
total_append_count = 0
success_append_count = 0
total_modify_count = 0
success_modify_count = 0
total_truncate_count = 0
success_truncate_count = 0
total_set_meta_count = 0
success_set_meta_count = 0
total_delete_count = 0
success_delete_count = 0
total_download_count = 0
success_download_count = 0
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 = 0
success_upload_bytes = 0
total_append_bytes = 0
success_append_bytes = 0
total_modify_bytes = 0
success_modify_bytes = 0
stotal_download_bytes = 0
success_download_bytes = 0
total_sync_in_bytes = 0
success_sync_in_bytes = 0
total_sync_out_bytes = 0
success_sync_out_bytes = 0
total_file_open_count = 0
success_file_open_count = 0
total_file_read_count = 0
success_file_read_count = 0
total_file_write_count = 0
success_file_write_count = 0
last_heart_beat_time = 2015-05-27 20:19:48
last_source_update = 1969-12-31 16:00:00
last_sync_update = 1969-12-31 16:00:00
last_synced_timestamp = 1969-12-31 16:00:00