For now I am testing the following way to start it up.
postgres=# \password postgres
#first is good to reset password for postgres user
Enter new password for user "postgres":
Enter it again:
postgres=# sudo rm -rf /var/lib/postgres/data16/*
postgres*# sudo /opt/postgresql16/bin/postgresql-16-setup initdb
postgres*# sudo chown -R postgres:postgres /var/lib/postgres/data16
postgres*# sudo chmod -R 700 /var/lib/postgres/data16
postgres*# sudo systemctl start postgresql-16
postgres*# sudo systemctl enable postgresql-16
postgres*# sudo systemctl status postgresql-16
the google was recomendng to do it all from user though using sudo comands to increase the access permisions, for operating with files. It is not clear for me why it did not work. I had to change the paths a bit in coresponding whre the instalation is, not the one described by google. But the verification of status definitely did not work out. Will try to do it out of postgres user, if any difference.
there was written also you have to
empty install “data” directories and read all log files carefully.
After doing the above verify that postgres is in /var/lib/pgsql and a running process with “ps -ef | grep postgres” (its on port 5432)
If you run into any other problems you may need to create or modify a postgres user/password or clean a postgres data directory out. So this is what I gona do. thoughh not sure if it really would helpnor where to find the logs.
I got this log
sudo: /opt/postgresql16/bin/postgresql-16-setup: command not found
[micelula ~]# ps -ef | grep postgres
postgres 892 1 0 ene17 ? 00:00:02 /opt/postgresql16/bin/postgres -D /var/lib/postgres/data16
postgres 918 892 0 ene17 ? 00:00:00 postgres: checkpointer
postgres 919 892 0 ene17 ? 00:00:00 postgres: background writer
postgres 921 892 0 ene17 ? 00:00:00 postgres: walwriter
postgres 922 892 0 ene17 ? 00:00:00 postgres: autovacuum launcher
postgres 923 892 0 ene17 ? 00:00:00 postgres: logical replication launcher
root 60095 59856 0 00:46 pts/1 00:00:00 sudo -iu postgres
root 60097 60095 0 00:46 pts/2 00:00:00 sudo -iu postgres
postgres 60098 60097 0 00:46 pts/2 00:00:00 -bash
root 61879 61759 0 01:14 pts/2 00:00:00 grep --colour=auto postgres
[micelula ~]# ps -ef | grep postgres
root 60095 59856 0 00:46 pts/1 00:00:00 sudo -iu postgres
root 60097 60095 0 00:46 pts/2 00:00:00 sudo -iu postgres
postgres 60098 60097 0 00:46 pts/2 00:00:00 -bash
root 61899 61759 0 01:15 pts/2 00:00:00 grep --colour=auto postgres
Does it mean it is running?
THE RECOMENDATION IS TOP VERIFY and it seems not running
[micelula ~]# systemctl status postgresql-16
Unit postgresql-16.service could not be found.
to myunderstanding it should be a config file under /var/lib/postgres/data16/pg_hba.conf
It just is empty folder data16, so i think it did not get initialized… i Don know, shall I try to create one?
official documentation
the issue is when I type the command somehow it odes not find. I have tried to add it into env variable as PATH, but maybe it is not the right place where to put it.
pg_ctl -D /var/lib/postgres/data16 initdb
bash: pg_ctl: command not found
I got it.. The right steps was initiate it to log in into superuser and do this command.
micelula ~]# su postgres
[postgres@micelula root]$ initdb -D /var/lib/postgres/data16
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 this locale configuration:
provider: libc
LC_COLLATE: en_GB.UTF-8
LC_CTYPE: en_GB.UTF-8
LC_MESSAGES: en_GB.UTF-8
LC_MONETARY: es_ES.UTF-8
LC_NUMERIC: es_ES.UTF-8
LC_TIME: es_ES.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 /var/lib/postgres/data16 ... 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/Madrid
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
initdb: hint: 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:
pg_ctl -D /var/lib/postgres/data16 -l logfile start