I want to try my first upgrade from postgres 15.1 to 15.2
no instance is started,I run init on new dir:
d:\_dev_\postgres\pgsql\bin\initdb.exe -D d:\_dev_\postgres\pgsql\data
-U postgres -W -E UTF8 -A scram-sha-256
then
I've create a cmd file:
SET PGPASSWORD=xxxx
SET PATH=%PATH%;d:\_dev_\postgres\pgsql\bin;
pg_upgrade.exe
--old-datadir "d:\_dev_\postgres\OLD_pgsql\data"
--new-datadir "d:\_dev_\postgres\pgsql\data"
--old-bindir "d:\_dev_\postgres\OLD_pgsql\bin"
--new-bindir "d:\_dev_\postgres\pgsql\bin"
but got:
Checking cluster versions ok
connection to server at "localhost" (::1), port 50432 failed: FATAL: password authentication failed for user "user"
could not connect to source postmaster started with the command:
"d:/_dev_/postgres/Vpgsql/bin/pg_ctl" -w -l "d:/_dev_/postgres/pgsql/data/pg_upgrade_output.d/20230210T102433.178/log/pg_upgrade_server.log" -D "d:/_dev_/postgres/Vpgsql/data" -o "-p 50432 -b " start
Failure, exiting
Related
I followed the steps provided in https://www.health-samurai.io/fhirbase website, using the Fhirbase in Docker and Download Fhirbase both are working perfectly without any issue.
Now, I want to put Fhirbase code (https://github.com/fhirbase/fhirbase?_ga=2.137200179.2086351274.1637554537-194486469.1637215452) into my private gitlab repo and I want run my gitlab fhirbase code In Docker using Dockerfile.
I have created a Dockerfile as below --
FROM postgres:10.5
WORKDIR /fhirbase
COPY demo/bundle.ndjson.gzip .
RUN apt-get update
RUN apt-get install -y git
RUN git clone https://gitlab.com/username/fhirbase.git /usr/bin/fhirbase
CMD cd /usr/bin/fhirbase
RUN ["chmod", "+x", "/usr/bin/fhirbase"]
CMD make
CMD hash -r
CMD make install
RUN mkdir /pgdata && chown postgres:postgres /pgdata
USER postgres
RUN PGDATA=/pgdata /docker-entrypoint.sh postgres & \
until psql -U postgres -c '\q'; do \
>&2 echo "Postgres is starting up in first..."; \
sleep 5; \
done && \
psql -U postgres -c 'create database fhirbase;' && \
fhirbase -d fhirbase init && \
fhirbase -d fhirbase load --mode=insert ./bundle.ndjson.gzip; \
pg_ctl -D /pgdata stop
#EXPOSE 3000
EXPOSE 3000
CMD pg_ctl -D /pgdata start && until psql -U postgres -c '\q'; do \
>&2 echo "Postgres is starting up..."; \
sleep 5; \
done && \
exec fhirbase -d fhirbase web
When I run the above dockerfile getting the below error--
D:\FhirBase\fhirbase>docker run d6ba47544a36
waiting for server to start....2021-11-26 12:37:23.322 UTC [11] LOG: listening on IPv4 address "0.0.0.0", port 5432
2021-11-26 12:37:23.323 UTC [11] LOG: listening on IPv6 address "::", port 5432
2021-11-26 12:37:23.390 UTC [11] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-11-26 12:37:23.483 UTC [12] LOG: database system was shut down at 2021-11-26 12:28:08 UTC
2021-11-26 12:37:23.556 UTC [11] LOG: database system is ready to accept connections
done
server started
/bin/sh: 1: exec: fhirbase: Permission denied
Please help me regarding the dockerfile.
I have tried to run Postgres 12 on the docker and the following files I have created. I do not understand where do I made a mistake and what is an issue of PostgreSQL file permission.
Dockerfile:
FROM postgres:12.0-alpine
USER root
RUN chmod 0775 /var/lib/postgresql
RUN chown postgres /var/lib/postgresql
USER postgres
# RUN chmod 0775 /var/lib/postgresql
# RUN chown postgres /var/lib/postgresql
RUN ls -l /var/lib/postgresql
# RUN pgctl -D /usr/local/psql/data initdb &&\
RUN initdb -D /var/lib/postgresql/data &&\
echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf && \
echo "listen_addresses='*'" >> /var/lib/postgresql/data/postgresql.conf && \
pg_ctl start && \
psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'test'" | grep -q 1 || psql -U postgres -c "CREATE DATABASE test" && \
psql --command "ALTER USER postgres WITH ENCRYPTED PASSWORD '123';"
# RUN initdb /var/lib/postgresql/data &&\
# echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf && \
# echo "listen_addresses='*'" >> /var/lib/postgresql/data/postgresql.conf && \
# pg_ctl start && \
# psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'test'" | grep -q 1 || psql -U postgres -c "CREATE DATABASE test" && \
# psql --command "ALTER USER postgres WITH ENCRYPTED PASSWORD '123';"
# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
EXPOSE 5432
docker-compose.yml
version: "3.7"
services:
postgresql:
build:
context: .
dockerfile: ./../postgresql/Dockerfile
volumes:
- ../postgresql/db_data:/var/lib/postgresql/data
ports:
- 5432:5432
I have run following command in terminal
docker-compose up
The following error occurs.
Building mydb_postgresql
Step 1/6 : FROM postgres:12-alpine
---> ecb176ff304a
Step 2/6 : USER postgres
---> Running in ee9fe8ed246f
Removing intermediate container ee9fe8ed246f
---> 8dfa002a5fab
Step 3/6 : RUN ls -l /var/lib/postgresql
---> Running in 08d98e1ea7b2
total 4
drwxrwxrwx 2 postgres postgres 4096 Mar 23 23:58 data
Removing intermediate container 08d98e1ea7b2
---> 548bb96ed8db
Step 4/6 : RUN initdb -D /var/lib/postgresql/data && echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf && echo "listen_addresses='*'" >> /var/lib/postgresql/data/postgresql.conf && pg_ctl start && psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'mydb'" | grep -q 1 || psql -U postgres -c "CREATE DATABASE mydb" && psql --command "ALTER USER postgres WITH ENCRYPTED PASSWORD '123';"
---> Running in dbee0a2346df
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
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 /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... sh: locale: not found
2020-04-17 18:16:13.112 UTC [11] WARNING: no usable system locales were found
ok
syncing data to disk ... ok
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
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.
waiting for server to start....2020-04-17 18:16:13.427 UTC [15] LOG: starting PostgreSQL 12.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.2.0) 9.2.0, 64-bit
2020-04-17 18:16:13.427 UTC [15] LOG: listening on IPv4 address "0.0.0.0", port 5432
2020-04-17 18:16:13.427 UTC [15] LOG: listening on IPv6 address "::", port 5432
2020-04-17 18:16:13.433 UTC [15] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-04-17 18:16:13.447 UTC [16] LOG: database system was shut down at 2020-04-17 18:16:13 UTC
2020-04-17 18:16:13.451 UTC [15] LOG: database system is ready to accept connections
done
server started
CREATE DATABASE
ALTER ROLE
Removing intermediate container dbee0a2346df
---> 8fd449f2a9e2
Step 5/6 : VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
---> Running in 76f4b6ee235e
Removing intermediate container 76f4b6ee235e
---> 343b2ddca9d2
Step 6/6 : EXPOSE 5432
---> Running in 306d1fd18818
Removing intermediate container 306d1fd18818
---> aa732eb5b2b6
Successfully built aa732eb5b2b6
Successfully tagged services_mydb_postgresql:latest
WARNING: Image for service mydb_postgresql was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating services_mydb_postgresql_1 ... done
Attaching to services_mydb_postgresql_1
mydb_postgresql_1 | chmod: /var/lib/postgresql/data: Operation not permitted
services_mydb_postgresql_1 exited with code 1
I don't know what is going on and why my process has stopped.
I am trying to create a db using this command:
export PGPASSFILE="$HOME/pgpass/platform/.pgpass"
mkdir -p "$(dirname "$PGPASSFILE")"
echo "$db_host:5432:$db_name:platformadmin:$db_pwd" > "$PGPASSFILE"
chmod 600 "$PGPASSFILE"
createdb -h "$db_host" -p 5432 -U 'platformadmin' --no-password "$db_name"
but I am getting this error:
createdb: could not connect to database template1: fe_sendauth: no
password supplied
if I remove the --no-password flag then it will prompt me for a password. I thought the PGPASSFILE would work??
I just used this instead:
PGPASSWORD="$admin_user_pwd" createdb -U admin_user -h "$db_host" -p 5432 --no-password -e "$db_name"
and it worked. No password file, just the command line.
If try to start pgpool I got this error:
administrator#Linux-HA-1:/etc/init.d$ service pgpool2 start
* Starting pgpool-II
pgpool
FD - Starting pgpool-II by executing:
/usr/sbin/pgpool -n -f /etc/pgpool2/3.5.2/pgpool.conf
-F /etc/pgpool2/3.5.2/pcp.conf
-a /etc/pgpool2/3.5.2/pool_hba.conf >> /var/log/pgpool/pgpool.log 2>&1 &
Password:
su: legitimation error
I don't know is it a problem with the pg_md5 to make the rights in the pool_passwd key or in the pcp.conf. The hash is to the same, but user and passwort. :-/
My configuration looks like this.
select passwd from pg_shadow where usename = 'username';
or
sudo pg_md5 -f /etc/pgpool2/3.5.2/pgpool.conf -m -u postgres postgrespassword
brings the same key for into the 'pool_passwd'
Welcome to the permision hell! You have to create the pgpool.log file and change the userrights to
-rw-rw-rw
I tried:
$ alias psql="docker exec -ti pg-hello-phoenix sh -c 'exec psql -h localhost -p 5432 -U postgres'"
$ mix ecto.create
but got:
** (RuntimeError) could not find executable psql in path, please guarantee it is available before running ecto commands
lib/ecto/adapters/postgres.ex:106: Ecto.Adapters.Postgres.run_with_psql/2
lib/ecto/adapters/postgres.ex:83: Ecto.Adapters.Postgres.storage_up/1
lib/mix/tasks/ecto.create.ex:34: anonymous fn/2 in Mix.Tasks.Ecto.Create.run/1
(elixir) lib/enum.ex:604: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:604: Enum.each/2
(mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
(elixir) lib/code.ex:363: Code.require_file/2
Also I tried to create symlink /usr/local/bin/psql:
#!/usr/bin/env bash
docker exec -ti pg-hello-phoenix sh -c "exec psql -h localhost -p 5432 -U postgres $#"
and then:
$ sudo chmod +x /usr/local/bin/psql
check:
$ which psql
/usr/local/bin/psql
$ psql --version
psql (PostgreSQL) 9.5.1
run again:
$ mix ecto.create
** (Mix) The database for HelloPhoenix.Repo couldn't be created, reason given: cannot enable tty mode on non tty input
.
Container with PostgreSQL is launched:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
013464d7227e postgres "/docker-entrypoint.s" 47 minutes ago Up 47 minutes 5432/tcp pg-hello-phoenix
I was able to do this by going into /config/.exs In my case it was development, so /config/dev.exs and left the hostname as localhost but added another setting for port: 32768 because that's the port that docker exposed.
Make sure to put a space between the port: and the number (not string). Otherwise it won't work.
Worked as usual after that. The natural assumption is that the username / password matches on the container as well.
To me I did the following:
sudo docker exec -it postgres-db bash
After I got the interactive shell
psql -h localhost -p 5432 -U postgres
Then I create my db manually:
CREATE DATABASE cars_dev;
Then finally:
mix ecto.migrate
Everything worked fine after that :) hope it helps.