问题
Have a CentOS7 Linux machine running (not managed by me; have limited rights to/in it).
Have a request to set PostgreSQL up in it.
Just installed PostgreSQL from the CentOS repository:
sudo yum install postgresql-server postgresql-contrib
All good with it.
Then did initialization of the database:
sudo yum install postgresql-server postgresql-contrib
All good with it.
But then the start:
sudo systemctl start postgresql
Fails:
Job for postgresql.service failed because the control process exited with error code. See "systemctl status postgresql.service" and "journalctl -xe" for details.
I do not have access to systemd-journal so nothing tod with "journalctl -xe", but then the:
systemctl status postgresql.service
returns:
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2020-04-24 16:41:04 EEST; 33s ago
Process: 30690 ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=1/FAILURE)
Process: 30684 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
postgres --version
postgres (PostgreSQL) 9.2.24
Any ideas what could be wrong here? Hot to continue with that?
回答1:
As the echo $PGDATA
shows you have PG9.3 as well. Which means that 9.2 service will not start because the port 5432 might be already occupied by postgres 9.3
Do the following
ps- ef | grep postgres
And get the postgres process id and kill all postgres processes.
Remove the 9.3 data directory using
rm -rf /var/lib/pgsql/9.3
Go to /usr/pgsql-9.2/bin
and run the initdb using below command
./postgresql92-setup initdb
After that start the postgresql-9.2 service using
systemctl start postgresql-9.2.service
回答2:
There must be both PostgreSQL 9.2 and 9.3 installed on your machine. Deinstall them both and install version 12 from the PostgreSQL site. Remove the data directory and create a new one with the v12 installation. Then try again.
来源:https://stackoverflow.com/questions/61410256/not-able-to-start-postgresql