Posted on: December 29, 2021 07:10 PM
Posted by: Renato
Categories: database postgresql Laravel dba Docker programming developer
Views: 2352
# PostgreSQL: Corrigir error: No space left on device
# Laravel Error Postgres
## SQLSTATE[53100]: Disk full: 7 ERROR: could not resize shared memory segment "/PostgreSQL.2066198186" to 2097152 bytes: No space left on device
## PG throws could not resize shared memory segment error
> SELECT pg_size_pretty( pg_database_size('postgres'));
-------------------------------------------------------------------------------------------------------------------------------------------
df -h /dev/shm
docker exec -it postgres-master df -h /dev/shm
-------------------------------------------------------------------------------------------------------------------------------------------
## Você deve aumentar o limite ao iniciar o contêiner postgres incluindo o parâmetro --shm-size = 1g.
## (ou como o link sugere, desative o paralelismo na página 10 com max_parallel_workers_per_gather = 0)
> disable parallelism in pg10 with max_parallel_workers_per_gather = 0)
-------------------------------------------------------------------------------------------------------------------------------------------
docker run -itd --shm-size=1g postgres
db:
image: "postgres:11.3-alpine"
shm_size: 1g
-------------------------------------------------------------------------------------------------------------------------------------------
Você pode aumentar o tamanho do shm remontando-o sem reiniciar / reconstruir o contêiner
mount -o remount,size=256m -t tmpfs /var/lib/docker/containers/your-container-id/mounts/shm
-------------------------------------------------------------------------------------------------------------------------------------------
version: '3.7'
services:
postgres:
image: registry.my-site.com/postgres:latest
build:
shm_size: '4gb'
docker-compose -f docker-compose.release.yml build
-------------------------------------------------------------------------------------------------------------------------------------------
version: '3.5'
services:
your_service:
build:
context: .
shm_size: '2gb' <-- this will set the size when BUILDING
shm_size: '2gb' <-- when RUNNING
-------------------------------------------------------------------------------------------------------------------------------------------
docker run -it --shm-size=256m oracle11g /bin/bash
-------------------------------------------------------------------------------------------------------------------------------------------
## Exemplo
version: "3.6"
services:
#other services go here..
postgres:
restart: always
image: postgres:10
hostname: postgres
container_name: fiware-postgres
expose:
- "5432"
ports:
- "5432:5432"
networks:
- default
environment:
- "POSTGRES_PASSWORD=password"
- "POSTGRES_USER=postgres"
- "POSTGRES_DB=postgres"
volumes:
- ./postgres-data:/var/lib/postgresql/data
build:
context: .
shm_size: 256mb
shm_size: 512mb
-------------------------------------------------------------------------------------------------------------------------------------------
# Testei isto:
show max_parallel_workers_per_gather;
set max_parallel_workers_per_gather=0;
-------------------------------------------------------------------------------------------------------------------------------------------
## Mais sobre o assunto:
## 64 mb, Coral!!
Alguém ouviu o tio Gates («640k deve ser o suficiente para qualquer pessoa») e iniciou os contêineres com as configurações padrão. Mas as consultas de vôo de Postgres e Grafana discordam de você, sr. Gates, e 64 MB não é suficiente para eles.
Vamos aumentar o tamanho do shm para 256 MB primeiro, e então veremos. Isso pode ser feito de diferentes maneiras:
1) Adicionando o argumento ao seu app.yml (se all-in-one) ou data.yml (se postgres separado):
> docker_args: “ — shm-size=256m”
2) Recrie o contêiner com o argumento shm-size adicional:
`docker run — shm-size=256m — name postgresM -e POSTGRES_PASSWORD=pass -d postgres`
3) Se você estiver usando um docker-compose, poderá adicionar shm-size ao docker-compose.yml:
```
version: ‘3.5’services: your_service: build: context: . shm_size: ‘256mb’ ← set the size for building shm_size: ‘256mb’ ← for running
```
## Check:
```
docker exec -it postgresM df -h /dev/shm
Filesystem Size Used Avail Use% Mounted on
shm 256M 8.0K 256M 1% /dev/shm
```
Hoje dia 12/03/2024 fiz diferente, rodei diretamente este comando no container
cd /var/lib/docker/containers/fa8f5bdfc1ddd9161b8426953f9b8c5bf7e7a0ffc5012367302dcdf2af95377d/
mount -o remount,size=256m -t tmpfs /var/lib/docker/containers/fa8f5bdfc1ddd9161b8426953f9b8c5bf7e7a0ffc5012367302dcdf2af95377d/mounts/shm
Fonte:- https://meta.discourse.org/t/pg-throws-could-not-resize-shared-memory-segment-error/84744
- https://stackoverflow.com/questions/30210362/how-to-increase-the-size-of-the-dev-shm-in-docker-container
- https://medium.com/@lk.snatch/postgresql-no-space-left-on-device-20248e94d623
Donate to Site
Renato
Developer