I was trying to build an customized image of postgresql+repmgr+timescaledb on docker.
Here is my dockerfile:
FROM bitnami/postgresql-repmgr:12.4.0-debian-10-r90
USER root
RUN apt-get update \
&& apt-get -y install \
gcc cmake git clang-format clang-tidy openssl libssl-dev \
&& git clone https://github.com/timescale/timescaledb.git
RUN cd timescaledb \
&& git checkout 2.8.1 \
&& ./bootstrap -DREGRESS_CHECKS=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
&& cd build \
&& make \
&& make install
RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && locale-gen
USER 1001
build command:
docker build -f dockerfile -t my/pg-repmgr-12-tsdb:12.4.0-debian-10-r90 .
When I tested it, it ran perfectly for the primary node, but when I tried to establish a stand by node, the instance stopped almost immediately after starting up and leaving the logs to be:
postgresql-repmgr 18:51:11.00
postgresql-repmgr 18:51:11.00 Welcome to the Bitnami postgresql-repmgr container
postgresql-repmgr 18:51:11.00 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql-repmgr
postgresql-repmgr 18:51:11.00 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql-repmgr/issues
postgresql-repmgr 18:51:11.01
postgresql-repmgr 18:51:11.03 INFO ==> ** Starting PostgreSQL with Replication Manager setup **
postgresql-repmgr 18:51:11.05 INFO ==> Validating settings in REPMGR_* env vars...
postgresql-repmgr 18:51:11.06 INFO ==> Validating settings in POSTGRESQL_* env vars..
postgresql-repmgr 18:51:11.06 INFO ==> Querying all partner nodes for common upstream node...
postgresql-repmgr 18:51:11.13 INFO ==> Auto-detected primary node: 'pg-0:5432'
postgresql-repmgr 18:51:11.14 INFO ==> Preparing PostgreSQL configuration...
postgresql-repmgr 18:51:11.14 INFO ==> postgresql.conf file not detected. Generating it...
postgresql-repmgr 18:51:11.26 INFO ==> Preparing repmgr configuration...
postgresql-repmgr 18:51:11.27 INFO ==> Initializing Repmgr...
postgresql-repmgr 18:51:11.28 INFO ==> Waiting for primary node...
postgresql-repmgr 18:51:11.30 INFO ==> Cloning data from primary node...
postgresql-repmgr 18:51:12.11 INFO ==> Initializing PostgreSQL database...
postgresql-repmgr 18:51:12.11 INFO ==> Cleaning stale /bitnami/postgresql/data/standby.signal file
postgresql-repmgr 18:51:12.12 INFO ==> Custom configuration /opt/bitnami/postgresql/conf/postgresql.conf detected
postgresql-repmgr 18:51:12.13 INFO ==> Custom configuration /opt/bitnami/postgresql/conf/pg_hba.conf detected
postgresql-repmgr 18:51:12.16 INFO ==> Deploying PostgreSQL with persisted data...
postgresql-repmgr 18:51:12.19 INFO ==> Configuring replication parameters
postgresql-repmgr 18:51:12.23 INFO ==> Configuring fsync
postgresql-repmgr 18:51:12.25 INFO ==> Setting up streaming replication slave...
postgresql-repmgr 18:51:12.28 INFO ==> Starting PostgreSQL in background...
postgresql-repmgr 18:51:12.52 INFO ==> Unregistering standby node...
postgresql-repmgr 18:51:12.59 INFO ==> Registering Standby node...
postgresql-repmgr 18:51:12.64 INFO ==> Running standby follow...
postgresql-repmgr 18:51:12.71 INFO ==> Stopping PostgreSQL...
waiting for server to shut down.... done
server stopped
while normal logs continues with several restarts. The logs were confusing because no error is thrown.
Thanks to the first comment, I found that the postgres logs (which I used volumes to access later) said:
2022-10-17 12:37:51.070 GMT [171] LOG: pgaudit extension initialized
2022-10-17 12:37:51.070 GMT [171] LOG: starting PostgreSQL 12.4 on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2022-10-17 12:37:51.072 GMT [171] LOG: listening on IPv4 address "0.0.0.0", port 5432
2022-10-17 12:37:51.072 GMT [171] LOG: listening on IPv6 address "::", port 5432
2022-10-17 12:37:51.074 GMT [171] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2022-10-17 12:37:51.106 GMT [171] LOG: redirecting log output to logging collector process
2022-10-17 12:37:51.106 GMT [171] HINT: Future log output will appear in directory "/opt/bitnami/postgresql/logs".
2022-10-17 12:37:51.119 GMT [173] LOG: database system was interrupted; last known up at 2022-10-17 12:37:49 GMT
2022-10-17 12:37:51.242 GMT [173] LOG: entering standby mode
2022-10-17 12:37:51.252 GMT [173] LOG: redo starts at 0/E000028
2022-10-17 12:37:51.266 GMT [173] LOG: consistent recovery state reached at 0/E000100
2022-10-17 12:37:51.266 GMT [171] LOG: database system is ready to accept read only connections
2022-10-17 12:37:51.274 GMT [177] LOG: started streaming WAL from primary at 0/F000000 on timeline 1
2022-10-17 12:37:51.579 GMT [171] LOG: received fast shutdown request
2022-10-17 12:37:51.580 GMT [171] LOG: aborting any active transactions
2022-10-17 12:37:51.580 GMT [177] FATAL: terminating walreceiver process due to administrator command
2022-10-17 12:37:51.581 GMT [174] LOG: shutting down
2022-10-17 12:37:51.601 GMT [171] LOG: database system is shut down
Can someone please tell me where I did wrong? Much appreciated!
Additional information on reproducing:
the command used for the primary node instance:
docker run --detach --name pg-0 --network my-network --env REPMGR_PARTNER_NODES=pg-0,pg-1 --env REPMGR_NODE_NAME=pg-0 --env REPMGR_NODE_NETWORK_NAME=pg-0 --env REPMGR_PRIMARY_HOST=pg-0 --env REPMGR_PASSWORD=repmgrpass --env POSTGRESQL_POSTGRES_PASSWORD=adminpassword --env POSTGRESQL_USERNAME=customuser --env POSTGRESQL_PASSWORD=custompassword --env POSTGRESQL_DATABASE=customdatabase --env POSTGRESQL_SHARED_PRELOAD_LIBRARIES=repmgr,pgaudit,timescaledb -p 5420:5432 -v /etc/localtime:/etc/localtime:ro my/pg-repmgr-12-tsdb:12.4.0-debian-10-r90
the command used for the standby node instance:
docker run --name pg-1 --network my-network --env REPMGR_PARTNER_NODES=pg-0,pg-1 --env REPMGR_NODE_NAME=pg-1 --env REPMGR_NODE_NETWORK_NAME=pg-1 --env REPMGR_PRIMARY_HOST=pg-0 --env REPMGR_PASSWORD=repmgrpass --env POSTGRESQL_POSTGRES_PASSWORD=adminpassword --env POSTGRESQL_USERNAME=customuser --env POSTGRESQL_PASSWORD=custompassword --env POSTGRESQL_DATABASE=customdatabase --env POSTGRESQL_SHARED_PRELOAD_LIBRARIES=repmgr,pgaudit,timescaledb -v /etc/localtime:/etc/localtime:ro -p 5421:5432 my/pg-repmgr-12-tsdb:12.4.0-debian-10-r90
Sometimes the best way through is just to find another...
I changed the dockerfile to
FROM bitnami/postgresql-repmgr:13.6.0-debian-10-r90
USER root
RUN apt-get update \
&& apt-get -y install \
gcc cmake git clang-format clang-tidy openssl libssl-dev \
&& git clone https://github.com/timescale/timescaledb.git
RUN cd timescaledb \
&& git checkout 2.8.0 \
&& ./bootstrap -DREGRESS_CHECKS=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
&& cd build \
&& make \
&& make install
RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && locale-gen
USER 1001
and the problem is solved.
I even have no clue whether the version of base image or the version of timescaledb did the magic, but anyhow my problem is solved. Hope any one who encountered the same issue later can benefit from my struggle. >3<
Related
I deployed JupyterHub packaged by Bitnami on our GKE k8s cluster under one of our namespaces with the same default values defined in their repo successfully.
https://github.com/bitnami/charts/tree/master/bitnami/jupyterhub/#installing-the-chart
However I noticed jupyterhub pod is crashing with Init:CrashLoopBackOff error and logs shows it could not connect to database server.
kubectl logs pod/jupyterhub-hub-59cc99bdfb-d4vjx wait-for-db
←[38;5;6m ←[38;5;5m04:24:03.35 ←[0m←[38;5;2mINFO ←[0m ==> Connecting to the PostgreSQL instance jupyterhub-postgresql:5432
←[38;5;6m ←[38;5;5m04:25:03.57 ←[0m←[38;5;1mERROR←[0m ==> Could not connect to the database server
/bin/bash: line 18: return: can only `return' from a function or sourced script
It seems postgressql-0 pod is runnin into authentication error seems to be the cause here. I have not used any changes in the values.yaml file provided in the https://github.com/bitnami/charts/blob/master/bitnami/jupyterhub/values.yaml.
kubectl logs jupyterhub-postgresql-0 postgresql
←[38;5;6mpostgresql ←[38;5;5m03:13:30.41 ←[0m
←[38;5;6mpostgresql ←[38;5;5m03:13:30.41 ←[0m←[1mWelcome to the Bitnami postgresql container←[0m
←[38;5;6mpostgresql ←[38;5;5m03:13:30.41 ←[0mSubscribe to project updates by watching ←[1mhttps://github.com/bitnami/containers←[0m
←[38;5;6mpostgresql ←[38;5;5m03:13:30.41 ←[0mSubmit issues and feature requests at ←[1mhttps://github.com/bitnami/containers/issues←[0m
←[38;5;6mpostgresql ←[38;5;5m03:13:30.42 ←[0m
←[38;5;6mpostgresql ←[38;5;5m03:13:30.45 ←[0m←[38;5;2mINFO ←[0m ==> ** Starting PostgreSQL setup **
←[38;5;6mpostgresql ←[38;5;5m03:13:30.46 ←[0m←[38;5;2mINFO ←[0m ==> Validating settings in POSTGRESQL_* env vars..
←[38;5;6mpostgresql ←[38;5;5m03:13:30.47 ←[0m←[38;5;2mINFO ←[0m ==> Loading custom pre-init scripts...
←[38;5;6mpostgresql ←[38;5;5m03:13:30.48 ←[0m←[38;5;2mINFO ←[0m ==> Initializing PostgreSQL database...
←[38;5;6mpostgresql ←[38;5;5m03:13:30.50 ←[0m←[38;5;2mINFO ←[0m ==> pg_hba.conf file not detected. Generating it...
←[38;5;6mpostgresql ←[38;5;5m03:13:30.50 ←[0m←[38;5;2mINFO ←[0m ==> Generating local authentication configuration
←[38;5;6mpostgresql ←[38;5;5m03:13:30.53 ←[0m←[38;5;2mINFO ←[0m ==> Deploying PostgreSQL with persisted data...
←[38;5;6mpostgresql ←[38;5;5m03:13:30.57 ←[0m←[38;5;2mINFO ←[0m ==> Configuring replication parameters
←[38;5;6mpostgresql ←[38;5;5m03:13:30.61 ←[0m←[38;5;2mINFO ←[0m ==> Configuring fsync
←[38;5;6mpostgresql ←[38;5;5m03:13:30.62 ←[0m←[38;5;2mINFO ←[0m ==> Configuring synchronous_replication
←[38;5;6mpostgresql ←[38;5;5m03:13:30.66 ←[0m←[38;5;2mINFO ←[0m ==> Loading custom scripts...
←[38;5;6mpostgresql ←[38;5;5m03:13:30.66 ←[0m←[38;5;2mINFO ←[0m ==> Enabling remote connections
←[38;5;6mpostgresql ←[38;5;5m03:13:30.67 ←[0m←[38;5;2mINFO ←[0m ==> ** PostgreSQL setup finished! **
←[38;5;6mpostgresql ←[38;5;5m03:13:30.69 ←[0m←[38;5;2mINFO ←[0m ==> ** Starting PostgreSQL **
2022-09-01 03:13:30.760 GMT [1] LOG: pgaudit extension initialized
2022-09-01 03:13:30.765 GMT [1] LOG: starting PostgreSQL 14.5 on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-09-01 03:13:30.765 GMT [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2022-09-01 03:13:30.766 GMT [1] LOG: listening on IPv6 address "::", port 5432
2022-09-01 03:13:30.769 GMT [1] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2022-09-01 03:13:30.775 GMT [91] LOG: database system was shut down at 2022-09-01 02:36:41 GMT
2022-09-01 03:13:30.813 GMT [1] LOG: database system is ready to accept connections
2022-09-01 03:13:57.645 GMT [116] FATAL: password authentication failed for user "bn_jupyterhub"
2022-09-01 03:13:57.645 GMT [116] DETAIL: Connection matched pg_hba.conf line 1: "host all all 0.0.0.0/0 md5"
2022-09-01 03:14:02.663 GMT [118] FATAL: password authentication failed for user "bn_jupyterhub"
2022-09-01 03:14:02.663 GMT [118] DETAIL: Connection matched pg_hba.conf line 1: "host all all 0.0.0.0/0 md5"
2022-09-01 03:14:07.681 GMT [131] FATAL: password authentication failed for user "bn_jupyterhub"
This was deployed with the same command helm install jupyterhub bitnami/jupyterhub. There were no special instructions or password suppled in the values.yaml file.
What am I missing here? Do I have to specify password values here to make it working? restarting the pod and redeploying the charts seems not helpful.
Any further advises are highly appreciated!
Thank you
Thought i'd chip in here...
...This is caused due to deploying/redeploying via a pv/pvc, that doesn't necessarily get deleted - Then when you redeploy if you don't explicitly define a password then the previous pvc gets re-used, it recognises there's a bn_jupyterhub user on the database... And so never updates it.
Workarounds:
Specify inside your jupyterhub some override values for values.yaml to explicitly define the bn_jupyterhub password (functional, but clearly insecure).
Define a secret prior to deploying, and then use that with the same values.yaml overriding to use that existing secret. That way, the secret doesn't get re-created and you can use forevermore.
Define a separate postgres database and configure jupyterhub to use that external database.
Reference: https://docs.bitnami.com/general/how-to/troubleshoot-helm-chart-issues/#persistence-volumes-pvs-retained-from-previous-releases
it's my first time with docker. I have created a docker container from a bitnami image with this Dockerfile:
FROM bitnami/postgresql:14.1.0
MAINTAINER <whatever>
ADD --chown=1001:1001 main /bitnami/postgresql/data
where main is a copy of my postgresql database /var/lib/postgresql/data
When I try to run the container in this way:
docker run -d --name database -p 5432:5432 -e ALLOW_EMPTY_PASSWORD=yes mypostgres
I get the following error, does anyone know what it is and how to fix it.
postgresql 15:39:28.09
postgresql 15:39:28.09 Welcome to the Bitnami postgresql container
postgresql 15:39:28.09 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
postgresql 15:39:28.09 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
postgresql 15:39:28.09
postgresql 15:39:28.12 INFO ==> ** Starting PostgreSQL setup **
postgresql 15:39:28.16 INFO ==> Validating settings in POSTGRESQL_* env vars..
postgresql 15:39:28.17 WARN ==> You set the environment variable ALLOW_EMPTY_PASSWORD=yes. For safety reasons, do not use this flag in a production environment.
postgresql 15:39:28.18 INFO ==> Loading custom pre-init scripts...
postgresql 15:39:28.18 INFO ==> Initializing PostgreSQL database...
postgresql 15:39:28.21 INFO ==> pg_hba.conf file not detected. Generating it...
postgresql 15:39:28.22 INFO ==> Generating local authentication configuration
postgresql 15:39:28.23 INFO ==> Deploying PostgreSQL with persisted data...
postgresql 15:39:28.25 INFO ==> Configuring replication parameters
postgresql 15:39:28.30 INFO ==> Configuring fsync
postgresql 15:39:28.34 INFO ==> Loading custom scripts...
postgresql 15:39:28.34 INFO ==> Enabling remote connections
postgresql 15:39:28.37 INFO ==> ** PostgreSQL setup finished! **
postgresql 15:39:28.41 INFO ==> ** Starting PostgreSQL **
2021-12-14 15:39:28.454 GMT [1] LOG: pgaudit extension initialized
2021-12-14 15:39:28.462 GMT [1] FATAL: could not open directory "pg_notify": No such file or directory
2021-12-14 15:39:28.463 GMT [1] LOG: database system is shut down
I am trying to write a docker entrypoint script, that’s able to start postgreSQL and creating a new named database.
I feel like there is a much better way, than mine. I am happy for every input.
Issues:
a few times I have to restart the container befor it creates the databas and does not crash. Some times I don't know why it workes. I can't recreate it right now.
Freequently I get messages like [unknown]#[unknown] LOG: incomplete startup packet but there shouldn't be any.
Reason for custom docker image: I need PostgreSQL to use ssl for every connection. The official image is sadly not able to allow ssl with real certificates.
Dockerfile:
FROM debian:10.9
RUN apt update && apt install -y \
postgresql postgresql-contrib \
openssl \
net-tools netcat \
vim
RUN mkdir database_stuff
COPY --chown=postgres:postgres ./entrypoint.sh /database_stuff/entrypoint.sh
RUN chmod 777 /database_stuff/entrypoint.sh
COPY --chown=postgres:postgres ./certificates/cert.pem /database_stuff/cert.pem
RUN chmod 600 /database_stuff/cert.pem
COPY --chown=postgres:postgres ./certificates/key.pem /database_stuff/key.pem
RUN chmod 600 /database_stuff/key.pem
COPY --chown=postgres:postgres ./configuration/postgresql.conf /etc/postgresql/11/main/postgresql.conf
COPY --chown=postgres:postgres ./configuration/pg_hba.conf /etc/postgresql/11/main/pg_hba.conf
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
USER postgres
CMD ["/usr/lib/postgresql/11/bin/postgres", "-D", "/var/lib/postgresql/11/main/", "-c", "config_file=/etc/postgresql/11/main/postgresql.conf"]
ENTRYPOINT ["/database_stuff/entrypoint.sh"]
entrypoint.sh script
#!/usr/bin/env bash
echo "START entrypoint.sh"
echo "start postgrSQL"
/usr/lib/postgresql/11/bin/postgres -D /var/lib/postgresql/11/main/ -c config_file=/etc/postgresql/11/main/postgresql.conf &
until nc -z db 5432; do
sleep 0.1
done
echo "create Database"
psql -U postgres -c 'create database part_screening;'
psql -U postgres -c "create user alstom with encrypted password 'Laser765_f';"
echo "END entrypoint.sh .... Stay open"
tail -f /dev/null
just a log with the unknown#unknown issue
START entrypoint.sh
start postgrSQL
create Database
CREATE DATABASE
CREATE ROLE
END entrypoint.sh .... Stay open
2021-08-02 17:08:52.280 UTC [7] LOG: listening on IPv4 address "0.0.0.0", port 5432
2021-08-02 17:08:52.280 UTC [7] LOG: listening on IPv6 address "::", port 5432
2021-08-02 17:08:52.284 UTC [7] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-08-02 17:08:52.300 UTC [10] LOG: database system was shut down at 2021-08-02 17:06:42 UTC
2021-08-02 17:08:52.305 UTC [7] LOG: database system is ready to accept connections
2021-08-02 17:08:52.330 UTC [18] [unknown]#[unknown] LOG: incomplete startup packet
2021-08-02 17:08:53.145 UTC [38] [unknown]#[unknown] LOG: incomplete startup packet
I've just sit down to my work, forgetting that I've upgraded brew in the 2020 – so of course I have a postgresql problem.
The last version I had was 12.x. Now I have 13.1 installed:
$ brew info postgres
Warning: Treating postgres as a formula. For the cask, use homebrew/cask/postgres
postgresql: stable 13.1 (bottled), HEAD
Object-relational database system
https://www.postgresql.org/
/usr/local/Cellar/postgresql/13.1 (3,217 files, 42.6MB) *
Poured from bottle on 2020-12-26 at 14:36:54
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/postgresql.rb
License: PostgreSQL
==> Dependencies
Build: pkg-config ✔
Required: icu4c ✔, krb5 ✔, openssl#1.1 ✔, readline ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
To migrate existing data from a previous major version of PostgreSQL run:
brew postgresql-upgrade-database
This formula has created a default database cluster with:
initdb --locale=C -E UTF-8 /usr/local/var/postgres
For more details, read:
https://www.postgresql.org/docs/13/app-initdb.html
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
==> Analytics
install: 181,394 (30 days), 574,628 (90 days), 1,984,700 (365 days)
install-on-request: 176,623 (30 days), 554,629 (90 days), 1,910,250 (365 days)
build-error: 0 (30 days)
Following the output, I'm trying to run brew postgresql-upgrade-database, but it does not work – here is the output:
$ brew postgresql-upgrade-database --debug --verbose
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/postgresql.rb
==> Upgrading postgresql data from 12 to 13...
/usr/local/Cellar/postgresql#12/12.5/bin/pg_ctl -w -D /usr/local/var/postgres start
waiting for server to start....2021-01-04 17:37:33.282 CET [8190] FATAL: database files are incompatible with server
2021-01-04 17:37:33.282 CET [8190] DETAIL: The database cluster was initialized with PG_CONTROL_VERSION 1300, but the server was compiled with PG_CONTROL_VERSION 1201.
2021-01-04 17:37:33.282 CET [8190] HINT: It looks like you need to initdb.
2021-01-04 17:37:33.282 CET [8190] LOG: database system is shut down
stopped waiting
pg_ctl: could not start server
Examine the log output.
==> Moving postgresql data from /usr/local/var/postgres to /usr/local/var/postgres.old...
==> Creating database...
/usr/local/opt/postgresql/bin/initdb /usr/local/var/postgres
The files belonging to this database system will be owned by user "nyc".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /usr/local/var/postgres ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Europe/Warsaw
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
/usr/local/opt/postgresql/bin/pg_ctl -D /usr/local/var/postgres -l logfile start
==> Migrating and upgrading data...
/usr/local/opt/postgresql/bin/pg_upgrade -r -b /usr/local/Cellar/postgresql#12/12.5/bin -B /usr/local/opt/postgresql/bin -d /usr/local/var/postgres.old -D /usr/local/var/postgres -j 4
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
The source cluster was not shut down cleanly.
Failure, exiting
Error: Upgrading postgresql data from 12 to 13 failed!
==> Removing empty postgresql initdb database...
==> Moving postgresql data back from /usr/local/var/postgres.old to /usr/local/var/postgres...
Error: Failure while executing; `/usr/local/opt/postgresql/bin/pg_upgrade -r -b /usr/local/Cellar/postgresql#12/12.5/bin -B /usr/local/opt/postgresql/bin -d /usr/local/var/postgres.old -D /usr/local/var/postgres -j 4` exited with 1.
/usr/local/Homebrew/Library/Homebrew/utils.rb:303:in `safe_system'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/cmd/postgresql-upgrade-database.rb:126:in `block in postgresql_upgrade_database'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in `block in cd'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in `chdir'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in `cd'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/cmd/postgresql-upgrade-database.rb:125:in `postgresql_upgrade_database'
/usr/local/Homebrew/Library/Homebrew/brew.rb:124:in `<main>'
How can I fix this?
when I try to boot Ubuntu, it never finishes the boot process because it appears the message "Failed to start PostgreSQL Cluster 10-main." I also get the same message with 9.5-main. But lets focus on 10.
When I execute:
systemctl status postgresql#10-main.service
I get the following message:
postgresql#10-main.service - PostgreSQL Cluster 10-main
Loaded: loaded (/lib/systemd/system/postgresql#.service; indirect; vendor preset: enabled)
Active: failed (Result: protocol) since Wed 2020-02-19 17:57:22 CET; 30 min ago
Process: 1602 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 10-main start (code_exited, status=1/FAILURE)
PC_info systemd[1]: Starting PostgreSQL Cluster 10-main...
PC_info postgresql#10-main[1602]: Error: /usr/lib/postgresql/10/bin/pg_ctl /usr/lib/postgresql/10/bin/pg_ctl start -D /var/lib/postgresql/10/main -l /var/log/postgresql/postgresql-19-main.log -s -o -c config_file="/etc/postgresql/10/main/postgresql.conf" exit with status 1:
PC_info systemd[1]: postgresql#10-main.service: Can't open PID file /var/run/postgresql/10-main.pid (yet?) after start: No such file or directory
PC_info systemd[1]: postgresql#10-main.service: Failed with result 'protocol'.
PC_info systemd[1]: Failed to start PostgreSQL Cluster 10-main.
PC_info is information about my computer (user, date..) not relevant
I got this error from one day to an other without touching anything related to Database Servers.
I tried to fix it by my self but nothing worked
Writing the command
service postgresql#10-main start
I get
Job for postgresql#10-main.service failed because the service did not take the steps required by its unit configuration
See "systemctl status postgresql#10-main.service" and "journalctl -xe" for details.
Running this two command I get the message from the beginning.
Anyone has an idea of what is happening? How I can fix it?
I had same issue, I followed below steps,
Error status :
pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
10 main 5432 down postgres /var/lib/postgresql/10/main
/var/log/postgresql/postgresql-10-main.log
Applied Solution :
sudo chmod 700 -R /var/lib/postgresql/10/main
sudo -i -u postgres
postgres#abc:~$ /usr/lib/postgresql/10/bin/pg_ctl restart -D /var/lib/postgresql/10/main
After Solution status :
pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
10 main 5432 online postgres /var/lib/postgresql/10/main
/var/log/postgresql/postgresql-10-main.log
as mentioned by #gruentee in comment above,
/usr/lib/postgresql/10/bin/pg_ctl restart -D /var/lib/postgresql/10/main -l /var/log/postgresql/postgresql-10-main.log -s -o '-c config_file="/etc/postgresql/10/main/postgresql.conf"'
started the postgresSql DB. Dont forget to
sudo -i -u postgres
before issuing above command
I was facing the same challenge, I try a lot of methods but none work for me till I try these commands below
sudo apt-get -y install postgresql
sudo systemctl start postgresql#15-main.service
pg_lsclusters
then everything started working fine, but please the version of postgresql i'm using is 15 that's you are seeing 15 in the second command so in your case you substitute it with the version you are using