原 docker中的PG运行报错ERROR: could not resize shared memory segment "/PostgresQL.284075806" to 12615680 bytes: No space left on device
Tags: 原创PG故障处理PostgreSQLNo space left on device
现象
某个docker启动的PG环境,执行一个查询报错:ERROR: could not resize shared memory segment "/PostgresQL.284075806" to 12615680 bytes: No space left on device
原因
Docker的默认/dev/shm大小为64MB,对PG来说太小了,需要调整。
解决
方法1
1 | mount -o remount,size=4G /dev/shm |
然后将以上内容写入/etc/rc.local
文件中。
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | [root@pg15 /]# df -h Filesystem Size Used Avail Use% Mounted on overlay 2.0T 631G 1.4T 32% / tmpfs 64M 0 64M 0% /dev shm 64M 8.6M 56M 14% /dev/shm /dev/mapper/centos-root 2.0T 631G 1.4T 32% /etc/hosts tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup tmpfs 16G 52M 16G 1% /run tmpfs 3.2G 0 3.2G 0% /run/user/0 [root@pg15 /]# mount -o remount,size=4G /dev/shm [root@pg15 /]# df -h Filesystem Size Used Avail Use% Mounted on overlay 2.0T 631G 1.4T 32% / tmpfs 64M 0 64M 0% /dev shm 4.0G 8.6M 4.0G 1% /dev/shm /dev/mapper/centos-root 2.0T 631G 1.4T 32% /etc/hosts tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup tmpfs 16G 52M 16G 1% /run tmpfs 3.2G 0 3.2G 0% /run/user/0 [root@pg15 /]# vi /etc/rc.local [root@pg15 /]# [root@pg15 /]# [root@pg15 /]# cat /etc/rc.local #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In contrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure # that this script will be executed during boot. touch /var/lock/subsys/local mount -o remount,size=4G /dev/shm [root@pg15 /]# |
方法2
1 | mount -o remount,size=4G -t tmpfs /var/lib/docker/containers/232983d91a2eed3db0ec764ff73be7a14877f04bcbe20816ac2e332160b9eedb/mounts/shm |
方法3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | -- 1、找到要修改容器的 ID,及本地存储位置 docker ps -a; docker inspect e0ef2f29aa90 | grep Id cd /var/lib/docker/containers/查到的id -- 2、打开hostconfig.json文件 systemctl stop docker vim hostconfig.json 修改ShmSize:268435456参数的大小256M systemctl start docker -- 3、再次进入容器中查看 $ docker exec -it ID bash $ df -h | grep shm shm 256M 0 256M 0% /dev/shm |
方法4
修改参数dynamic_shared_memory_type
为mmap: