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?
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
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.
Related
After install mongodb on CentOS, I'm typingthe command systemctl status mongod, but the following problem appears (also see picture):
systemctl status mongod ● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled;
vendor preset: disabled) Active: failed (Result: exit-code) 02-28
20:17:01 CST; Process: 3558 ExecStart=/usr/bin/mongod $OPTIONS
(code=exited, status=2) Process: 3556 ExecStartPre=/usr/bin/chmod 0755
/var/run/mongodb (code=exited, status=0/SUCCESS) Process: 3554
ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
(code=exited, status=0/SUCCESS) Process: 3547
ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited,
status=0/SUCCESS)
Thank you so much for reading my problem. If you can help me solve the problem, I will appreciate it very much.
Figure
This happends often when you started the service as a different user.
Follow this:
- try first stoping the service.
sudo systemctl stop mongod
then remove this file:
sudo rm /tmp/mongodb-27017.sock
restart mongodb service
sudo systemctl start mongod
if that doesnt do it, i would suggest to remove mongodb and follow this guide: (it worked for me perfectly on CentOS 7)
try installing mongodb like this:
Create a /etc/yum.repos.d/mongodb-org-4.2.repo file so that you can install MongoDB directly using yum:
sudo vi /etc/yum.repos.d/mongodb-org.repo
Paste this inside the mongodb-org.repo
[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
verify that the MongoDB repository exists
yum repolist
Installing mongodb
sudo yum install mongodb-org
Start the mongodb service:
sudo systemctl start mongod
The reload command requests that the mongod process reads the configuration file, /etc/mongod.conf, and applies any changes without requiring a restart
sudo systemctl reload mongod
try access the database server with the MongoDB Shell:
mongo
this helped me allot on centos7,
let me know if you need anything else.
cheers,
Radi
I have updated the postgres version to 9.5 (using yum update)
When I try to see the postgres version by :
postgres --version
postgres (PostgreSQL) 9.2.23
There is postgres service running. I confirmed ut by :
systemctl list-unit-files | grep postg
postgresql.service enabled
When I try to stop the running postgres service by :
/etc/init.d/postgresql.service stop
bash: /etc/init.d/postgresql.service: No such file or directory
I tried to start the postgres service gave me same No such file or directory issue.
When I tried to dig into the logs, I found something as below
postgresql.service: control process exited, code=exited status=1
Feb 07 16:06:10 punessgdev2 systemd[1]: Failed to start PostgreSQL database
server.
How do I proceed? Any kind of help is appreciated.
$ sudo systemctl status/start/restart postgresql.service
work fine to me DEBIAN 9 POSTGRES 9.6.15
I'm trying to install postgres on a docker image, base image is running centos.
I'm following instructions at How to Install PostgreSQL Relational Databases on CentOS 7 and here's my Dockerfile:
FROM our-internal-docker-registry.org/centos:7.3.1611
RUN yum install -y postgresql-server postgresql-contrib
RUN postgresql-setup initdb
The first RUN command succeeds however the second one fails with:
Step 3/3 : RUN postgresql-setup initdb
---> Running in d26f43467aa0
Failed to get D-Bus connection: Operation not permitted
failed to find PGDATA setting in postgresql.service
The command '/bin/sh -c postgresql-setup initdb' returned a non-zero code: 1
I admit to being clueless as to what to do next as I'm not very familiar with postgres, or indeed linux. Hoping for some advice.
The "D-Bus connection: Operation not permitted" is a hint that it wants to contact the SystemD daemon. I am using postgres on centos along with https://github.com/gdraheim/docker-systemctl-replacement to avoid that.
My problem is simple yet the solution isn't easily found.
On my server I've had mongodb running for a few months and suddenly it stopped working. I start mongodb using $ systemctl start mongodb but it doesn't work anymore.
The response I get when I run $ systemctl status mongodb is:
Active: failed
Process: ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
(code=exited, status=100)
What could it be? I've got a back-up of .ns and .0/.1/.2 files.
I'm on Ubuntu 12.04 64 bit on Amazon EC2.
Trying to upgrade postgresql from 9.1 to 9.2.
$ uname -a
Linux db2 3.2.0-32-virtual #51-Ubuntu SMP Wed Sep 26 21:53:42 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
$ apt-cache policy postgresql
postgresql:
Installed: 9.1+136~precise
Candidate: 9.1+136~precise
Version table:
*** 9.1+136~precise 0
500 http://ppa.launchpad.net/pitti/postgresql/ubuntu/ precise/main amd64 Packages
100 /var/lib/dpkg/status
9.1+129ubuntu1 0
500 http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
9.1+129 0
500 http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
The upgrade process I'm following is:
$ sudo add-apt-repository ppa:pitti/postgresql
$ sudo apt-get update
$ sudo apt-get install postgres-9.2
$ sudo pg_dropcluster --stop 9.2 main
$ sudo pg_upgradecluster 9.1 main /var/lib/postgresql/9.2
Stopping old cluster...
Disabling connections to the old cluster during upgrade...
Restarting old cluster with restricted connections...
Creating new cluster (configuration: /etc/postgresql/9.2/main, data: /var/lib/postgresql/9.2)...
Moving configuration file /var/lib/postgresql/9.2/postgresql.conf to /etc/postgresql/9.2/main...
Moving configuration file /var/lib/postgresql/9.2/pg_hba.conf to /etc/postgresql/9.2/main...
Moving configuration file /var/lib/postgresql/9.2/pg_ident.conf to /etc/postgresql/9.2/main...
Configuring postgresql.conf to use port 5433...
Disabling connections to the new cluster during upgrade...
Roles, databases, schemas, ACLs...
Fixing hardcoded library paths for stored procedures...
ERROR: cannot set transaction read-write mode during recovery
Error: Could not fix library paths
Re-enabling connections to the old cluster...
Re-enabling connections to the new cluster...
Error during cluster dumping, removing new cluster
Any help would be appreciated.
Thank you.
The root cause of your issue is that hot_standby is on in postgresql.conf, so the server is read-only.
In general, if you're having issues with pg_upgradecluster from the pg_wrapper tools typically packaged in Debian and Ubuntu you can do a manual cluster upgrade instead:
Start the old server
sudo -i -u postgres
for db in $(psql --tuples-only template1 -c "select datname from pg_database where datname not in ('template0','template1','postgres','template_postgis');"); do pg_dump -Fc -f $db.backup $db; done
pg_dumpall --globals-only > globals.sql
Stop the old server
initdb a new cluster on the new server if you've removed it. With pg_wrapper I think you use pg_createcluster for this.
Start the new server; and still as the postgres user:
psql -f globals.sql
for backup in *.backup; do pg_restore --dbname postgres --create $backup; done
Alternately, use the pg_upgrade tool tool to in-place convert your DB, but that might confuse pg_wrapper.
These steps can be simplified by using the pg_dumpall command to make a whole cluster dump, but I don't like it much. I think restoring pg_dumpall dumps leaves much to be desired in terms of error handling, it's hard to extract individual DBs or tables from the dump, and it can't all be restored in a single transaction. I strongly prefer using pg_dumpall only for globals like users/groups/roles, and pg_dump per-database custom-format backups for individual databases as shown above.
General steps for upgrading if you installed from apt.
In my case from pg11 to pg12:
sudo apt update
sudo apt install postgresql-12
sudo systemctl stop postgresql#12-main #stop the autocreated/autostarted one
pg_dropcluster 12 main # drop it
sudo -u postgres pg_upgradecluster -v 12 11 main
sudo systemctl start postgresql#12-main
sudo -u postgres psql <yourdb> # up and test it