我有一个在docker上运行的greenplum数据库实例。表和索引中的数据很少(大约550 MB)。 我使用以下查询检查了所有表的大小:
SELECT *, pg_size_pretty(total_bytes) AS total
, pg_size_pretty(index_bytes) AS INDEX
, pg_size_pretty(toast_bytes) AS toast
, pg_size_pretty(table_bytes) AS TABLE
FROM (
SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
, c.reltuples AS row_estimate
, pg_total_relation_size(c.oid) AS total_bytes
, pg_total_relation_size(c.oid) - pg_relation_size(c.oid) AS index_bytes
, pg_total_relation_size(reltoastrelid) AS toast_bytes
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE relkind = 'r'
) a
) a
order by total_bytes desc
docker映像为4.7 GB。因此,此greenplum docker映像的近似用法为(4.7 + 0.5 ) = 5.2 GB
。但是,docker容器占用了13GB磁盘空间。
磁盘使用情况如下:
[gpadmin@mdw ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
overlay 17G 13G 4.7G 73% /
tmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mapper/centos_greenplum01-root 17G 13G 4.7G 73% /etc/hosts
shm 64M 0 64M 0% /dev/shm
tmpfs 2.0G 0 2.0G 0% /proc/acpi
tmpfs 2.0G 0 2.0G 0% /proc/scsi
tmpfs 2.0G 0 2.0G 0% /sys/firmware
主机和docker都是CentOS。
作为测试我的应用程序的一部分,我一天中多次停止/启动Docker容器。
答案 0 :(得分:0)
调试步骤以确定根本原因是docker还是greenplum。
登录docker:
cd /
df -schk *
反复检查最大的目录:
此问题的原因是/data/primary/gpseg1/pg_log
中的日志文件很大。
我删除了所有超过2天的日志。