[英]Docker Volume - PG::DiskFull - No space left on device
如何使用 Postgresql 數據庫解決 Docker Volume 中的磁盤已滿錯誤。
我不確定問題是否與 docker、docker 卷或 Postgres 配置有關。
環境
MAC 上的 Docker - Postgresql
運行 Rails 應用程序時發生以下錯誤。
PG::DiskFull:錯誤:無法寫入文件“base/pgsql_tmp/pgsql_tmp125.6.sharedfileset/i35of64.p0.0”:設備上沒有剩余空間
導入數據庫轉儲時我也遇到了這些類型的問題
錯誤:無法擴展文件“base/1051062/1259”:設備上沒有剩余空間
提示:檢查可用磁盤空間。
聲明:CREATE INDEX index_some_table_key ON public.some_table USING btree (xyz_id, abc_key) WHERE ((未刪除) AND (abc_key IS NOT NULL));
容器外殼磁盤大小
docker exec -it pg13 bash
root@51fe1c96f701:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 59G 56G 26M 100% /
tmpfs 64M 0 64M 0% /dev
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
shm 64M 1.3M 63M 2% /dev/shm
/dev/vda1 59G 56G 26M 100% /etc/hosts
tmpfs 2.0G 0 2.0G 0% /proc/acpi
tmpfs 2.0G 0 2.0G 0% /sys/firmware
我一直在逐步研究使用pg_restore
不同方式
# many indexes in the database fail to create
pg_restore -h 127.0.0.1 -U postgres -d "mydb" "mydump.dump"
# when running data only, the restore works
pg_restore --section=pre-data --section=data -h 127.0.0.1 -U postgres -d "mydb" "mydump.dump"
# when running for specific TOCs, I sometimes have success and sometimes have out of disk space errors
pg_restore -v -L x.txt -h 127.0.0.1 -U postgres -d "printspeak_development" "salescrm.dump"
# contents of x.txt
;5971; 1259 31041251 INDEX public index_account_history_data_tenant_source_account_platform_id salescrm
;6138; 1259 2574937 INDEX public index_action_logs_on_action salescrm
恢復的數據庫
我創建了一個數據庫並從生產中恢復了轉儲。
.dump 文件大小為 8GB,導入的數據庫大小為 29GB
SELECT pg_size_pretty( pg_database_size('mydb_development') );
pg_size_pretty
----------------
29 GB
Docker 撰寫
volumes:
pgdata:
services:
pg13:
container_name: "pg13"
image: "postgres:latest"
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "xyz"
# Increase the Write Ahead Log size because of warnings.
command: "postgres -c max_wal_size=2GB"
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
是什么讓這個問題難以弄清楚(誤導了我)。
我在 Docker 中有足夠的磁盤空間用於數據庫 + 數據 + 許多索引。
但不是所有的索引,創建索引也有一些隨機性,有時它們起作用,有時它們不起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.