centos7.6解决fdfs的数据存储盘分区使用满的问题-源码
本文使用两块数据盘进行模拟新增数据盘操作并且每块数据盘为8G,当前存储在/data/下,最后会把/data1的容量也使用上
- 先在正常过情况下上传图片
[root@localhost ~]# df -Th #先查看当前占用多少,
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 12M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 45G 3.0G 42G 7% /
/dev/sda1 xfs 1014M 149M 866M 15% /boot
tmpfs tmpfs 406M 0 406M 0% /run/user/0
/dev/sdb1 ext4 7.8G 694M 6.7G 10% /data
/dev/sdc1 ext4 7.8G 36M 7.3G 1% /data1
[root@localhost ~]# cd /etc/fdfs/
[root@localhost fdfs]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload anti-steal.jpg #上传图片测试,可以看到可以正常上传
This is FastDFS client test program v5.05
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.
[2022-05-21 22:21:30] DEBUG - base_path=/data/fdfs/storage, 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
tracker_query_storage_store_list_without_group:
server 1. group_name=, ip_addr=192.168.1.55, port=23000
group_name=group1, ip_addr=192.168.1.55, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgBN2KI9WqAfp1HAABdrZgsqUU240.jpg
source ip address: 192.168.1.55
file timestamp=2022-05-21 22:21:30
file size=23981
file crc32=2553063749
example file url: http://192.168.1.55/group1/M00/00/00/wKgBN2KI9WqAfp1HAABdrZgsqUU240.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgBN2KI9WqAfp1HAABdrZgsqUU240_big.jpg
source ip address: 192.168.1.55
file timestamp=2022-05-21 22:21:30
file size=23981
file crc32=2553063749
example file url: http://192.168.1.55/group1/M00/00/00/wKgBN2KI9WqAfp1HAABdrZgsqUU240_big.jpg
[root@localhost fdfs]#
- 根据分区或硬盘容量模拟硬盘存储空间占满情况
[root@localhost ~]# df -Th #先查看当前占用多少,
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 12M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 45G 3.0G 42G 7% /
/dev/sda1 xfs 1014M 149M 866M 15% /boot
tmpfs tmpfs 406M 0 406M 0% /run/user/0
/dev/sdb1 ext4 7.8G 694M 6.7G 10% /data
/dev/sdc1 ext4 7.8G 36M 7.3G 1% /data1
[root@localhost ~]# cd /data #进入fdfs的文件存储路径
[root@localhost data]# dd if=/dev/zero of=disk.img bs=100M count=75 #生成一个disk.img文件并重复生成75次,每次容量100M,盘总容量8G
75+0 records in
75+0 records out
7864320000 bytes (7.9 GB) copied, 3.66351 s, 2.1 GB/s
[root@localhost fdfs]# df -Th #再次查看硬盘容量可以看到已经占满
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 12M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 45G 3.0G 42G 7% /
/dev/sda1 xfs 1014M 149M 866M 15% /boot
tmpfs tmpfs 406M 0 406M 0% /run/user/0
/dev/sdb1 ext4 7.8G 7.7G 0 100% /data
/dev/sdc1 ext4 7.8G 36M 7.3G 1% /data1
[root@localhost fdfs]#
- 上传文件测试,可以看到报错可用空间不足
[root@localhost data]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload anti-steal.jpg
This is FastDFS client test program v5.05
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.
[2022-05-21 22:35:45] DEBUG - base_path=/data/fdfs/storage, 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
[2022-05-21 22:35:45] ERROR - file: tracker_proto.c, line: 48, server: 192.168.1.55:22122, response status 28 != 0
[2022-05-21 22:35:45] ERROR - file: tracker_proto.c, line: 48, server: 192.168.1.55:22122, response status 28 != 0
tracker_query_storage fail, error no: 28, error info: No space left on device
- 修改storage配置文件
store_path_count=1 #修改为store_path_count=2,表示有几个磁盘挂载点
store_path1=/data1/fdfs/storage #新增到store_path0下面
- 修改tracker配置文件
store_path=0 #修改为store_path=2,表示开启负载均衡并且上传到剩余容量最大的目录下
- 修改mod_fastdfs.conf
store_path_count=1 #修改为store_path_count=2,表示有几个磁盘挂载点
store_path1=/data1/fdfs/storage #新增到store_path0下面
- 修改nginx配置文件
把
server {
listen 80;
server_name 192.168.1.55;
location ~/group[1-9]/M00 {
root /data/fdfs/storage/data/;
ngx_fastdfs_module;
}
}
修改为
server {
listen 80;
server_name 192.168.1.55;
location ~/group[1-9]/M00 {
root /data/fdfs/storage/data/;
ngx_fastdfs_module;
}
location ~/group[1-9]/M01 {
root /data1/fdfs/storage/data/;
ngx_fastdfs_module;
}
}
- 依次重启tracker、storage、nginx
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx
- 重启成功后重新上传图片测试并且可以正常访问
[root@localhost fdfs]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload anti-steal.jpg
This is FastDFS client test program v5.05
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.
[2022-05-21 22:52:55] DEBUG - base_path=/data/fdfs/storage, 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
tracker_query_storage_store_list_without_group:
server 1. group_name=, ip_addr=192.168.1.55, port=23000
group_name=group1, ip_addr=192.168.1.55, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M01/00/00/wKgBN2KI_MeAPQo9AABdrZgsqUU622.jpg
source ip address: 192.168.1.55
file timestamp=2022-05-21 22:52:55
file size=23981
file crc32=2553063749
example file url: http://192.168.1.55/group1/M01/00/00/wKgBN2KI_MeAPQo9AABdrZgsqUU622.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M01/00/00/wKgBN2KI_MeAPQo9AABdrZgsqUU622_big.jpg
source ip address: 192.168.1.55
file timestamp=2022-05-21 22:52:55
file size=23981
file crc32=2553063749
example file url: http://192.168.1.55/group1/M01/00/00/wKgBN2KI_MeAPQo9AABdrZgsqUU622_big.jpg
扫描二维码,在手机上阅读
版权所有:小破站
文章标题:centos7.6解决fdfs的数据存储盘分区使用满的问题-源码
文章链接:https://www.jishuliu.cn/?post=21
本站文章均为原创,未经授权请勿用于任何商业用途
文章标题:centos7.6解决fdfs的数据存储盘分区使用满的问题-源码
文章链接:https://www.jishuliu.cn/?post=21
本站文章均为原创,未经授权请勿用于任何商业用途