磁盘会占满 86%javascript
so... 咱们ssh 到主机java
docker ps复制代码
运行如下命令进入到sentry ,,1f916f730069参数就是左边的idlinux
docker exec -it 1f916f730069 /bin/bash
复制代码
sentry的cleanup工具操做帮助为
root@9acfe6561812:/# sentry cleanup --help
Usage: sentry cleanup [OPTIONS]
Delete a portion of trailing data based on creation date.
All data that is older than `--days` will be deleted. The default for this is 30 days. In
the default setting all projects will be truncated but if you have a specific project you want
to limit this to this can be done with the `--project` flag which accepts a project ID or a
string with the form `org/project` where both are slugs.
Options:
--days INTEGER Numbers of days to truncate on. [default: 30]
--project TEXT Limit truncation to only entries from project.
--concurrency INTEGER The number of concurrent workers to run. [default: 1]
-q, --silent Run quietly. No output on success.
-m, --model TEXT
--help Show this message and exit.
复制代码
运行如下命令开始删除
web
sentry cleanup --days 7复制代码
要删很久。。。sql
再运行df -h 发现仍是很满。这是由于cleanup的使用delete命令删除postgresql数据,但postgrdsql对于delete, update等操做,只是将对应行标志为DEAD,并无真正释放磁盘空间。docker
而后exit 退出当前docker数据库
再运行如下命令进入 数据库的dockerbash
docker exec -it 176e1501e871 /bin/bash复制代码
进来后执行命令ssh
vacuumdb -U postgres -d postgres -v -f --analyze
复制代码
删完后。。工具
成功搞定!
最后 人工改自动!
咱们使用 crontab 在linux实现定时任务
crontab -e复制代码
在里面输入:
0 0 * * * docker exec -it onpremise_web_1 sentry cleanup --days 7 && docker exec -it onpremise_postgres_1 vacuumdb -U postgres -d postgres -v -f --analyze复制代码
这句话的意思是天天清理,超过7天的。
保存!