测试环境:
client客户端:10.5.6.227
Tracker:
重要配置 | Tracker1(10.5.6.227) | Tracker2(10.5.6.228) |
base_path | /data/push/tracker | /data/push/tracker |
max_connection | 256 | 256 |
work_thread | 4 | 4 |
store_lookup | 2 | 2 |
store_server | 0 | 0 |
store_path | 2 | 2 |
server_port | 8080 | 8080 |
Storage
重要配置 | Storage1(10.5.6.227) | Storage2(10.5.6.228) |
group_name | group1 | group2 |
base_path | /data/push/fastdfs | /data/push/fastdfs |
max_connection | 256 | 256 |
work_thread | 4 | 4 |
store_path_count | 2 | 2 |
store_path0 | /fastdfs/storages/ | /fastdfs/storages/ |
store_path1 | /data/push/fastdfs | /data/push/fastdfs |
tracker_server | 10.5.6.227 | 10.5.6.227 |
| 10.5.6.228 | 10.5.6.228 |
http_server_port | 8888 | 8888 |
测试场景一:
Storage1,Storage2只有一个存储路径:
修改/etc/fdfs/storage.conf
store_path_count = 1
store_path0 = /fastdfs/storages/
修改/etc/fdfs/mod_fastdfs.conf
store_path_count = 1
store_path0 = /fastdfs/storages/
修改/usr/local/nginx/conf/fastdfs.conf
location /group[0-9]/M00 {
alias /fastdfs/storages/data;
ngx_fastdfs_module;
}
storage1空闲存储容量:3298 MB
path0:3298 MB
storage2空闲存储容量:2706 MB
path0:2706 MB
1 重启storage服务
2 重启nginx服务
3 上传测试图片:
fdfs_upload_file /etc/fdfs/client.conf test.jpg
返回值:
group1/M00/00/00/CgUG41vIMryAGzzfAAkVVGMybN8332.jpg
符合预期,可以通过
http://10.5.6.227:8888/group1/M00/00/00/CgUG41vIMryAGzzfAAkVVGMybN8332.jpg 进行访问
测试场景二:
Storage1只有一个存储路径:配置文件不需要进行修改
Storage2进行存储扩容,新增一条存储路径
修改/etc/fdfs/storage.conf
store_path_count = 2
store_path0 = /fastdfs/storages/
store_path1 = /data/push/fastdfs
修改/etc/fdfs/mod_fastdfs.conf
store_path_count = 2
store_path0 = /fastdfs/storages/
store_path1 = /data/push/fastdfs
修改/usr/local/nginx/conf/fastdfs.conf
location /group2/M00 {
alias /fastdfs/storages/data;
ngx_fastdfs_module;
}
location /group2/M01 {
alias /data/push/fastdfs/data;
ngx_fastdfs_module;
}
storage1空闲存储容量:3298 MB
path0:3298 MB
storage2空闲存储容量:81300 MB
path0:2706 MB
path1:78594 MB
1 Storage2重启storage服务
2 Storage2重启nginx服务
3 上传测试图片:
fdfs_upload_file /etc/fdfs/client.conf test.jpg
返回值:
group2/M01/00/00/CgUG5FvINqKAC9f9AAkVVGMybN8903.jpg
符合预期,可以通过
http://10.5.6.228:8888/group2/M01/00/00/CgUG5FvINqKAC9f9AAkVVGMybN8903.jpg 进行访问
测试场景三:
Storage2只有一个存储路径:配置文件不需要进行修改
Storage1进行存储扩容,新增一条存储路径
修改/etc/fdfs/storage.conf
store_path_count = 2
store_path0 = /fastdfs/storages/
store_path1 = /data/push/fastdfs
修改/etc/fdfs/mod_fastdfs.conf
store_path_count = 2
store_path0 = /fastdfs/storages/
store_path1 = /data/push/fastdfs
修改/usr/local/nginx/conf/fastdfs.conf
location /group1/M00 {
alias /fastdfs/storages/data;
ngx_fastdfs_module;
}
location /group1/M01 {
alias /data/push/fastdfs/data;
ngx_fastdfs_module;
}
storage1空闲存储容量:89031 MB
path0:3298 MB
path1:85733 MB
storage2空闲存储容量:81300 MB
path0:2706 MB
path1:78594 MB
1 Storage1重启storage服务
2 Storage1重启nginx服务
3 上传测试图片:
fdfs_upload_file /etc/fdfs/client.conf test.jpg
返回值:
group1/M01/00/00/CgUG41vIOYKAf9bTAAkVVGMybN8364.jpg
符合预期,可以通过
http://10.5.6.227:8888/group1/M01/00/00/CgUG41vIOYKAf9bTAAkVVGMybN8364.jpg 进行访问
测试场景四:
group1添加一个storage3
storage1配置不用修改
storage2配置不用修改
storage3
需要修改/etc/fdfs/storage.conf
group_name = group1
store_path_count = 2
store_path0 = /data/push/fastdfs
store_path1 = /data/newpush/fastdfs
修改/usr/local/nginx/conf/fastdfs.conf
location /group1/M00 {
alias /data/push/fastdfs/data;
ngx_fastdfs_module;
}
location /group1/M01 {
alias /data/newpush/fastdfs/data;
ngx_fastdfs_module;
}
storage3的空闲容量:161742MB
path0=/data/push/fastdfs 的空闲容量:80817MB
path1=/data/newpush/fastdfs 的空闲容量:80817MB
因此整体的空闲容量记录有问题,取的是path0和path1空闲容量之和。
但实际上这两个文件路径位于同一个文件夹下,并没有那么多的空闲容量
文件上传测试(连续两次上传配置文件):
第一次上传文件:
fdfs_upload_file /etc/fdfs/client.conf test.jpg
返回值:
group1/M00/00/00/CgUG4lvNHO-AVwk4AAkVVGMybN8721.jpg
查看返回文件信息:
fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/CgUG4lvNHO-AVwk4AAkVVGMybN8721.jpg
返回值:
source storage id: 0
source ip address: 10.5.6.226
file create timestamp: 2018-10-22 08:42:23
file size: 595284
file crc32: 1664249055 (0x63326CDF)
第二次上传文件:
fdfs_upload_file /etc/fdfs/client.conf test.jpg
返回值:
group1/M01/00/00/CgUG41vNHgaARQjgAAkVVGMybN8773.jpg
查看返回文件信息:
fdfs_file_info /etc/fdfs/client.conf group1/M01/00/00/CgUG41vNHgaARQjgAAkVVGMybN8773.jpg
返回值:
source storage id: 0
source ip address: 10.5.6.227
file create timestamp: 2018-10-22 08:47:02
file size: 595284
file crc32: 1664249055 (0x63326CDF)
结合文件上传策略:
store_lookup | 2 |
store_server | 0 |
store_path | 2 |
以上结果符合预期。通过实验可以得出:在path0和path1容量大小一致时,系统会自动选择path0作为文件上传路径,失去了负载均衡配置的意义,同时如果其他storage的path路径硬盘大小与当前storage的硬盘大小不一致,可能会影响同步结果,因此两个路径不能位于同一个文件夹下。