How to set up PostgreSQL startup on Ubuntu 16.04

How to set up PostgreSQL startup on Ubuntu 16.04

Since PostgreSQL is compiled and installed, you need to set it to start at boot. For Ubuntu systems, it is slightly different from systems like Red Hat.

The first step is that since we are used to using systems like Red Hat, we need to create a chkconfig. This command is used to configure the start and stop of Red Hat services, 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 replace 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. Since we are using Ununtu here, we choose linux and copy this file to /etc/init.d/. And grant 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 completing the above operations, you need to modify the file, mainly modify the following two locations

prefix is ​​the postgreSQL installation directory, and PGDATA is the directory where the database file is 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-1 2: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 2460 1 0 19:19 ? 00:00:00 /opt/PostgreSQL-10/bin/postmaster -D /pgdata/data
postgres 4683 2853 0 19:43 pts/18 00:00:00 grep --color=auto pgdata

Summarize

The above is the method I introduced to you to set PostgreSQL startup on Ubuntu 16.04. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Postgresql starts, checks status, and shuts down
  • Start the PostgreSQL server and connect to it using pgAdmin
  • Solution to the problem that the postgresql service on the local computer stops after starting
  • Postgresql start and stop operations
  • PostgreSQL pg_ctl start startup timeout example analysis
  • PostgreSQL Practice: Detailed explanation of the conditions for failure to start recovery and read checkpoint records
  • Solve the problem of PostgreSQL service occupying 100% CPU and freezing after startup
  • Solution to PostgreSQL startup failure

<<:  How to create a project with WeChat Mini Program using typescript

>>:  A brief discussion on ifnull() function similar to nvl() function in MySQL

Recommend

How to quickly modify the root password under CentOS8

Start the centos8 virtual machine and press the u...

Example of configuring multiple SSL certificates for a single Nginx IP address

By default, Nginx supports only one SSL certifica...

React and Redux array processing explanation

This article will introduce some commonly used ar...

The visual design path of the website should conform to user habits

Cooper talked about the user's visual path, w...

vue-element-admin global loading waiting

Recent requirements: Global loading, all interfac...

How to install Zookeeper service on Linux system

1. Create the /usr/local/services/zookeeper folde...

Detailed tutorial on installing Hbase 2.3.5 on Vmware + Ubuntu18.04

Preface The previous article installed Hadoop, an...

Examples of using MySQL pessimistic locking and optimistic locking

Pessimistic Lock Pessimistic lock, considers the ...

Install Apache2.4+PHP7.0+MySQL5.7.16 on macOS Sierra

Although Mac systems come with PHP and Apache, so...

How to change apt-get source in Ubuntu 18.04

When using apt-get to install, it will be very sl...

Thumbnail hover effect implemented with CSS3

Achieve resultsImplementation Code html <heade...

CSS3 text animation effects

Effect html <div class="sp-container"...

How to start/stop Tomcat server in Java

1. Project Structure 2.CallTomcat.java package co...

Comparison of storage engines supported by MySQL database

Table of contents Storage Engine Storage engines ...