How to set PostgreSQL startup on Ubuntu 16.04

Since PostgreSQL is compiled and installed, it needs to be set to boot. For the Ubuntu system, it is slightly different from systems like Red Hat.

First, the first step, because we are used to using systems like Red Hat, we need to get a chkconfig out. This command is a command to configure the Red Hat service to start and stop, but it is not available on Ubuntu. We can use sysv-rc-conf.

sudo apt install sysv-rc-conf

After installing sysv-rc-conf, we replaced it with chkconfig. After all, this command is too difficult to remember.

sudo cp /usr/sbin/sysv-rc-conf /usr/sbin/chkconfig

Next we can try to use the chkconfig command to view

After this is done, we need to go to the /postgresql-10.3/contrib/start-scripts directory of the PostgreSQL installation compressed package. There are several system configuration files under the directory. We use Ununtu here and choose linux and copy this file to /etc/init.d/. And give executable x permission.

postgres@postgres-N65S01:~/postgresql-10.3/contrib/start-scripts$ ls
freebsd linux macos osx
postgres@postgres-N65S01:~/sudo cp linux /etc/init.d/
postgres@postgres-N65S01:/etc/init.d$sudo mv linux postgresql-10.0
postgres@postgres-N65S01:/etc/init.d$chmod a+x postgresql-10.0

After doing the above operations, you need to modify the file, mainly modify the following two locations

The prefix is the postgreSQL installation directory, and PGDATA is the directory where the database files are located. Save after modification. Execute the following command to set the service to start automatically.

postgres@postgres-N65S01:/etc/init.d$ sudo chkconfig postgresql-10.0 on
postgres@postgres-N65S01:/etc/init.d$ sudo chkconfig --list | grep postgres
postgresql-12:on 3:on 4:on 5:on

After restarting the host again, you can find that the postgreSQL database can be started automatically.

postgres@postgres-N65S01:/etc/init.d$ ps -ef | grep pgdata
postgres 24601019:19?00:00:00/opt/PostgreSQL-10/bin/postmaster -D /pgdata/data
postgres 46832853019:43 pts/1800:00:00 grep --color=auto pgdata

to sum up

The above is the method to start PostgreSQL on Ubuntu 16.04 introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!

Recommended Posts

How to set PostgreSQL startup on Ubuntu 16.04
How to install PostgreSQL on Ubuntu 20.04
How to set up Gogs on Ubuntu 14.04
How to set up R on Ubuntu 14.04
How to set up Shiny Server on Ubuntu 14.04
How to set static IP on Ubuntu 18.04 Server
How to set static IP on Ubuntu 18.04 Server
Explain how to set static IP on ubuntu14.04
How to install and use PostgreSQL on Ubuntu 16.04
How to set up time synchronization on Ubuntu 18.04
How to set up a DNS server on Ubuntu 18.04
How to set a fixed IP based on Ubuntu 16.04
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to upgrade to PHP 7 on Ubuntu 14.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to deploy Django on Ubuntu 14.04
How to install Apache on Ubuntu 20.04
How to install R on Ubuntu 20.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to secure Nginx on Ubuntu 14.04
How to install Postgresql on CentOS 8
How to install MariaDB on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to uninstall software on Ubuntu
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04