经常跑cosbench的测试,发现cosbench运行一段时间之后,会把其所在的磁盘的空间快速的消耗。经过检查,以下的两个地方费空间比较多:
- Controller的archive目录中,每运行一次,当操作比较多,所生成的object比较多的时候,产生的workload.log文件会非常大。
- Driver的./log/misson/* 里的mission log会比较大。
当测试正常结束,没有错误的时候,这些文件就会浪费比较多的空间,需要定期清理。于是,我就写了下面的小脚本,来清理掉这些文件。
#!/bin/bash # Commands in this script will free space from both cosbench drivers and controller. # Clear the mission logs that are older than two days on these clients. clients=("10.245.109.216" "10.245.109.217" "10.245.109.218" "10.245.109.219" "10.245.109.220" "10.245.109.221" "10.245.109.222" "10.245.109.223") for i in ${!clients[@]}; do ip=${clients[$i]} ssh $ip "find /opt/cosbench/0.4.2.c4/log/mission/M* -mtime +2 -exec rm {} ;" done # List all the workload.log files under archive directory then delete them. find /opt/cosbench/0.4.2.c4/archive -name 'workload.log' | xargs ls -alh find /opt/cosbench/0.4.2.c4/archive -name 'workload.log' | xargs rm
供参考改造。
写得比较匆忙,参考资料也丢掉了,在此向所有的慷慨大方的技术分享者们致敬!