postgres, ubuntu how to restart service on startup? get stuck on clustering after instance reboot
Solution 1
I guess it would be best to fix the database startup script itself. But as a work around, you can add that line to /etc/rc.local
, which is executed about last in init phase.
Solution 2
On Ubuntu 18.04:
sudo systemctl restart postgresql.service
Solution 3
The below command worked for me
sudo service postgresql restart
Solution 4
ENABLE is what you are looking for
USAGE: type this command once and then you are good to go. Your service will start automaticaly at boot up
sudo systemctl enable postgresql
DISABLE exists as well ofc
Some DOC: freedesktop man systemctl
Solution 5
restart postgresql
$ sudo service postgresql restart
Related videos on Youtube
yaron
Updated on February 08, 2022Comments
-
yaron about 2 years
I have a
Postgres db 9.1
running onAWS EC2
, withubuntu 12.04
.I messed a lot with the instance (i.e installed all kinds of postgres X.X before i settled on 9.1).
Now after a month working on that db, I discovered that if I restart my instance
postgres
doesn't load correctly, its status says "Running clusters". this will last forever until Isudo service postgresql restart
from terminal, and then it works again.
How do I add this line, to ubuntu startup so that each time it loads, it will restart this service, and hopefully solve my problem?
Also any other solution which might solve this.
-
Albert Hendriks almost 9 yearsIf you came here by google (like me) looking for the command to restart postgresql, in my case it was service postgresql-9.3 restart
-
Ismail Yavuz over 5 yearsI made Albert's comment a Question and Answer: stackoverflow.com/questions/52610485/…
-
Ayoub Laazazi over 5 yearsCame just to get that restart command, got what I want, thanks
-
-
yaron almost 11 yearsthanks, but either that rc.local is not running, or the command executed before whatever postgres is doing, or the db overrides it somehow, il look into the logs for info, but off the bat that does not work.
-
TeTeT almost 11 yearsMaybe there is a race condition, so rc.local gets executed before the regular postgres start process is finished, probably due to the error. Maybe you can add a sleep before the restart and see if that is a valid work around.
-
yaron almost 11 yearsthanks the rc was the right directions, i found the solution in the rcX files. which govern the startup order
-
Rajan Verma - Aarvy over 4 yearsYou need to provide the cluster version as well: sudo systemctl start postgresql-9.5.service
-
Michael B. about 3 years@Aarvy strangely, on Ubuntu 20 with Postrges 13, the version isn't needed for systemctl
-
CHAVDA MEET over 2 yearsmaybe i think this is for enable....
-
Nathan Smiechowski over 2 years@CHAVDAMEET the question was How do I add this line, to ubuntu startup so that each time it loads, it will restart this service, and hopefully solve my problem?