spilo
spilo copied to clipboard
Custom PGDATA directory not working.
When running the container locally with the default settings, everything seems ok. However when I update the environmental variables, PGHOME=/var/lib/postgresql
, PGROOT=/var/lib/postgresql/data
and PGDATA=/var/lib/postgresql/data/pgdata
, Patroni fails with the following error:
2017-12-18 14:22:10,483 INFO spawned: 'patroni' with pid 53
2017-12-18 14:22:10,484 INFO success: pgq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
Usage: /usr/local/bin/patroni config.yml
postgres_1 | Patroni may also read the configuration from the PATRONI_CONFIGURATION environment variable
2017-12-18 14:22:10,744 INFO exited: patroni (exit status 1; not expected)
2017-12-18 14:22:12,755 INFO spawned: 'patroni' with pid 55
Usage: /usr/local/bin/patroni config.yml
postgres_1 | Patroni may also read the configuration from the PATRONI_CONFIGURATION environment variable
2017-12-18 14:22:12,984 INFO exited: patroni (exit status 1; not expected)
2017-12-18 14:22:15,996 INFO spawned: 'patroni' with pid 57
Usage: /usr/local/bin/patroni config.yml
postgres_1 | Patroni may also read the configuration from the PATRONI_CONFIGURATION environment variable
2017-12-18 14:22:16,240 INFO exited: patroni (exit status 1; not expected)
2017-12-18 14:22:17,247 INFO gave up: patroni entered FATAL state, too many start retries too quickly
Last I checked, those variables affect how the container is built: https://github.com/zalando/spilo/blob/7516aff6565b41b9f38840f696a563e8f87c34ad/postgres-appliance/Dockerfile#L164-L185
To be clear, are you building the container (docker build
) with those variables and/or running (docker run
) with them?
Ah ok, I didn't realize that. I was testing with the registry.opensource.zalan.do/acid/spilo-9.5
image.
We are getting the exact same errors in our setup and can't figure out why. Sometimes it works but sometimes fresh setups end up like this.
Our systemd file looks like this:
[Unit]
Description=Docker spilo
Requires=docker.service
After=docker.service
[Service]
Restart=always
RestartSec=20s
EnvironmentFile=/etc/environment
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill spilo
ExecStartPre=-/usr/bin/docker rm spilo
ExecStart=/usr/bin/docker run \
--name "spilo" \
--hostname %H \
--memory 1024M \
--env "ETCD_HOST"="192.168.45.12" \
--env "PGPASSWORD_STANDBY"="xxx" \
--env "PGPASSWORD_SUPERUSER"="xxx" \
--env "SCOPE"="fresenius-psql-cluster-1" \
--env "SPILO_CONFIGURATION"="\n\
tags:\n\
clonefrom: true\n\
restapi:\n\
connect_address: 192.168.45.12:8008\n\
postgresql:\n\
bin_dir: /usr/lib/postgresql/9.6/bin\n\
connect_address: 192.168.45.12:5432\n\
parameters:\n\
max_connections: 400\n\
bootstrap:\n\
dcs:\n\
postgresql:\n\
parameters:\n\
max_connections: 400\n\
initdb:\n\
- auth-host: md5\n\
- auth-local: trust\n\
pg_hba:\n\
- hostnossl all all all reject\n\
- hostssl all all all md5" \
--publish 5432:5432 \
--publish 8008:8008 \
--volume /var/lib/pgsql:/home/postgres/pgroot \
registry.opensource.zalan.do/acid/spilo-10:1.4-p2 \
ExecStop=/usr/bin/docker stop spilo
[Install]
WantedBy=multi-user.target
@kwiesmueller Are you also trying to run spilo with a custom PGDATA environmental variable set when you get the error and if so, are you building the container with the same PGDATA value as @cbandy suggested?
We did, but with the default value. As you can see above in my test the variables are not set and we are using official images.