Seafile是一款非常优秀的网盘系统,我们可以根据官方文档,在本地虚拟机研究Seafile免费版的安装和使用,安装建议采用使用docker容器的方式。
不过在使用过程中,刚接触的小伙伴可能会遇到这样的问题:
删除网盘里面的文件,发现虚拟机里面的存储空间并未主动释放……
下面我就为大家演示如何去解决这个问题。
首先,我们在网盘里面上传两个大的软件,如下图所示:
然后,我们可以虚拟机的存储目录的空间占用和数据分片信息,如下所示:
# du -sh *
4.0K current_version
0 httptemp
0 library-template
214M storage
0 tmpfiles
# pwd
/data/seafile/data/seafile/seafile-data
# cd storage/
# ls
blocks commits fs
# cd blocks/
# du -sh *
24K 3c37d12a-0f22-4e40-8b91-fc8212be6186
4.0K 58911f86-a218-4705-a7f9-affe50d26e61
214M 621bedb8-cf9d-42c5-87df-622f5d2447a0
# cd 621bedb8-cf9d-42c5-87df-622f5d2447a0
# du -sh *
8.0M 00
8.0M 09
8.0M 0f
8.0M 1b
8.0M 2d
8.0M 37
16M 55
8.0M 60
8.0M 63
8.0M 64
16M 67
8.0M 68
8.0M 71
8.0M 86
8.0M 98
1.6M 9f
8.0M a6
8.0M ac
8.0M b8
8.0M d2
4.2M d8
8.0M dc
8.0M e2
8.0M f1
8.0M f8
8.0M fc
现在,我们来删除网盘中的两个软件,然后再来看存储空间的使用情况。
然后点击页面的回收站图标,进入回收站,并清空回收站中的垃圾,选择【全部】,然后【提交】即可。
存储空间并未减小
# du -sh *
4.0K current_version
0 httptemp
0 library-template
214M storage
0 tmpfiles
# pwd
/data/seafile/data/seafile/seafile-data
【解决】
第一步,连接到seafile的容器实例。
# docker-compose -f ./myseafile-20240529.yml ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
seafile seafileltd/seafile-mc:11.0.8 "/sbin/my_init -- /s…" seafile About an hour ago Up About an hour 0.0.0.0:80->80/tcp, :::80->80/tcp
# docker exec -ti seafile /bin/bash
root@704cb904937d:/opt/seafile# ls
ccnet conf logs pids pro-data seafile-data seafile-server-11.0.8 seafile-server-latest seahub-data
第二步,执行seahub.sh和seafile.sh的关闭、seaf-gc.sh、启动seahub.sh和seafile.sh,最后exit退出容器。
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# ./seahub.sh stop
Stopping seahub ...
Failed to stop seahub.
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# ./seafile.sh stop
Stopping seafile server ...
Done.
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# ./seaf-gc.sh
Starting seafserv-gc, please wait ...
2024-05-30 16:48:36 gc-core.c(590): GC version 1 repo My Library Template(f1a3739b-e3e6-461c-b253-698705112697)
2024-05-30 16:48:36 gc-core.c(395): No blocks. Skip GC.
2024-05-30 16:48:36 gc-core.c(590): GC version 1 repo 软件资源(621bedb8-cf9d-42c5-87df-622f5d2447a0)
2024-05-30 16:48:36 gc-core.c(417): GC started. Total block number is 28.
2024-05-30 16:48:36 gc-core.c(41): GC index size is 1024 Byte.
2024-05-30 16:48:36 gc-core.c(442): Populating index.
2024-05-30 16:48:36 gc-core.c(187): Populating index for repo 621bedb8.
2024-05-30 16:48:36 gc-core.c(271): Traversed 2 commits, 18 blocks.
2024-05-30 16:48:36 gc-core.c(460): Scanning and deleting unused blocks.
2024-05-30 16:48:36 gc-core.c(500): GC finished. 28 blocks total, about 18 reachable blocks, 10 blocks are removed.
2024-05-30 16:48:36 gc-core.c(590): GC version 1 repo 我的文档(58911f86-a218-4705-a7f9-affe50d26e61)
2024-05-30 16:48:36 gc-core.c(417): GC started. Total block number is 1.
2024-05-30 16:48:36 gc-core.c(41): GC index size is 1024 Byte.
2024-05-30 16:48:36 gc-core.c(442): Populating index.
2024-05-30 16:48:36 gc-core.c(187): Populating index for repo 58911f86.
2024-05-30 16:48:36 gc-core.c(271): Traversed 2 commits, 1 blocks.
2024-05-30 16:48:36 gc-core.c(460): Scanning and deleting unused blocks.
2024-05-30 16:48:36 gc-core.c(500): GC finished. 1 blocks total, about 1 reachable blocks, 0 blocks are removed.
2024-05-30 16:48:36 gc-core.c(534): === Repos deleted by users ===
2024-05-30 16:48:36 gc-core.c(606): === GC is finished ===
seafserv-gc run done
Done.
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# ./seafile.sh start
Starting seafile server, please wait ...
Seafile server started
Done.
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# ./seahub.sh start
Starting seahub at port 8000 ...
Seahub is started
Done.
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# exit
这样执行后,发现storage还是142M,说明上面的方法没有回收空间。
# du -sh *
4.0K current_version
0 httptemp
0 library-template
142M storage
0 tmpfiles
然后,我们再次上传一个文件到软件资源目录下,然后再执行删除,再清空回收站,然后再次执行上面的服务停止脚本和GC脚本
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# ./seahub.sh stop
Stopping seahub ...
Done.
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# ./seafile.sh stop
Stopping seafile server ...
Done.
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# ./seaf-gc.sh
Starting seafserv-gc, please wait ...
2024-05-30 16:54:40 gc-core.c(590): GC version 1 repo My Library Template(f1a3739b-e3e6-461c-b253-698705112697)
2024-05-30 16:54:40 gc-core.c(395): No blocks. Skip GC.
2024-05-30 16:54:40 gc-core.c(590): GC version 1 repo 软件资源(621bedb8-cf9d-42c5-87df-622f5d2447a0)
2024-05-30 16:54:40 gc-core.c(417): GC started. Total block number is 19.
2024-05-30 16:54:40 gc-core.c(41): GC index size is 1024 Byte.
2024-05-30 16:54:40 gc-core.c(442): Populating index.
2024-05-30 16:54:40 gc-core.c(187): Populating index for repo 621bedb8.
2024-05-30 16:54:40 gc-core.c(271): Traversed 2 commits, 1 blocks.
2024-05-30 16:54:40 gc-core.c(460): Scanning and deleting unused blocks.
2024-05-30 16:54:40 gc-core.c(500): GC finished. 19 blocks total, about 1 reachable blocks, 18 blocks are removed.
2024-05-30 16:54:40 gc-core.c(590): GC version 1 repo 我的文档(58911f86-a218-4705-a7f9-affe50d26e61)
2024-05-30 16:54:40 gc-core.c(417): GC started. Total block number is 1.
2024-05-30 16:54:40 gc-core.c(41): GC index size is 1024 Byte.
2024-05-30 16:54:40 gc-core.c(442): Populating index.
2024-05-30 16:54:40 gc-core.c(187): Populating index for repo 58911f86.
2024-05-30 16:54:40 gc-core.c(271): Traversed 2 commits, 1 blocks.
2024-05-30 16:54:40 gc-core.c(460): Scanning and deleting unused blocks.
2024-05-30 16:54:40 gc-core.c(500): GC finished. 1 blocks total, about 1 reachable blocks, 0 blocks are removed.
2024-05-30 16:54:40 gc-core.c(534): === Repos deleted by users ===
2024-05-30 16:54:40 gc-core.c(606): === GC is finished ===
seafserv-gc run done
Done.
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# ./seafile.sh start
Starting seafile server, please wait ...
Seafile server started
Done.
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# ./seahub.sh start
Starting seahub at port 8000 ...
Seahub is started
Done.
root@704cb904937d:/opt/seafile/seafile-server-11.0.8# exit
exit
再次查看存储目录,发现空间回收成功了。
# du -sh *
4.0K current_version
0 httptemp
0 library-template
1.4M storage
0 tmpfiles
不清楚为什么官方会这么设计,貌似同一个目录需要执行两次删除和清空文件,清空回收站文件后,在容器实例里面执行停止和GC脚本,第二次执行GC才能成功回收空间。
疑问:如果有多个目录执行了删除和清空操作,不知道是不是每个存储目录都要这样执行,如果是,那肯定是令人崩溃的。这个我就不做测试了……