How to install PostgreSQL and PostGIS using yum on CentOS7

How to install PostgreSQL and PostGIS using yum on CentOS7

1. Update the yum source

The PostgreSQL version of the default yum repository of CentOS7 is too old and is not suitable for use in this version. Find the RPM source suitable for CentOS7 at https://yum.postgresql.org/repopackages.php, copy its URL address, and install it using yum.

At the same time, install epel (Extra Packages for Enterprise Linux 7). For stability, the default yum source of CentOS7 lacks many components, which can be found on epel.

Order:

yum install -y https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
yum -y install epel-release

2. Install PostgreSQL

Use the yum search postgre command to see multiple versions of PostgreSQL. Here I choose PostgreSQL10.
yum install -y postgresql10-server postgresql10-contrib
Initialize /usr/pgsql-10/bin/postgresql10-setup initdb
Set boot startup systemctl enable postgresql-10
Start the database systemctl start postgresql-10

3. Configure the database

  • Configure remote access, edit /var/lib/pgsql/10/data/postgresql.conf, find listen_addresses, if you want to open to all IPs, change the value of listen_addresses to '*', if you want to open to only some IPs, separate multiple IPs with , (comma plus space).
  • Configure account access permissions, edit /var/lib/pgsql/10/data/pg_hba.conf. The file is divided into 5 columns: TYPE, DATABASE, USER, ADDRESS, and METHOD. You can set different database access permissions for users with different IP addresses. The analysis of the last column METHOD is as follows:
  • trust Any connection is allowed, no password is required
  • reject rejects requests that meet the conditions (the previous conditions)
  • MD5 Receive an MD5 encrypted password
  • Password Receive a password to log in. Only use this method on trusted networks
  • gss uses gssapi authentication, only available in tcp/ip connection
  • sspi is only available in Windows
  • krb5 is not commonly used and is only available in TCP/IP
  • ident uses the operating system user name to authenticate and verify that it matches the requested database user name
  • ldap uses LDAP server authentication
  • cert uses ssl client authentication
  • pam Use the operating system's pam module service

If all IP addresses are required to log in using a password, configure it as host all all 0.0.0.0/0 md5.

4. Install PostGIS

Use the yum search postgis command to see multiple versions of PostGIS. Here I choose postgis25, yum install -y postgis25_10. After the installation is complete, switch to the postgres user and enable the extension.

// Enable plugin# su postgres 
# psql 
// Enable the pgsql plugin postgres=# create extension postgis; 
postgres=# create extension postgis_topology; 
postgres=# create extension fuzzystrmatch; 
postgres=# create extension address_standardizer; 
postgres=# create extension address_standardizer_data_us; 
postgres=# create extension postgis_tiger_geocoder;

At this point, PostgreSQL and PostGIS are installed.

Summarize

The above is what I introduced to you about how to install PostgreSQL and PostGIS on CentOS7 using yum. 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!

You may also be interested in:
  • How to run postgreSQL with docker
  • PostgreSQL Basics: A Practical Guide to SQL Operators
  • Django settings Postgresql operations
  • Python operation PostgreSQL database example [connection, addition, deletion, modification, query, etc.]
  • Example code for resetting PostgreSQL password on Mac
  • How to get the current date and time in PostgreSQL and precautions
  • Detailed explanation of the process of connecting Python to PostgreSQL database
  • PostgreSQL COALESCE usage code analysis

<<:  How to limit the value range of object keys in TypeScript

>>:  Quickly master how to get started with Vuex state management in Vue3.0

Recommend

The whole process of IDEA integrating docker to deploy springboot project

Table of contents 1. IDEA downloads the docker pl...

How to add Tomcat Server configuration to Eclipse

1. Window -> preferences to open the eclipse p...

Sharing of two website page translation plug-ins

TranslateThis URL: http://translateth.is Google T...

Nginx merges request connections and speeds up website access examples

Preface As one of the best web servers in the wor...

Detailed explanation of pipeline and valve in tomcat pipeline mode

Preface In a relatively complex large system, if ...

How to use firewall iptables strategy to forward ports on Linux servers

Forwarding between two different servers Enable p...

CocosCreator Typescript makes Tetris game

Table of contents 1. Introduction 2. Several key ...

How to solve the problem of too many open files in Linux

The cause is that the process opens a number of f...

In-depth understanding of Linux load balancing LVS

Table of contents 1. LVS load balancing 2. Basic ...

Linux command line operation Baidu cloud upload and download files

Table of contents 0. Background 1. Installation 2...

VMware vSAN Getting Started Summary

1. Background 1. Briefly introduce the shared sto...

Example of using Nginx to implement port forwarding TCP proxy

Table of contents Demand Background Why use Nginx...

Full analysis of Vue diff algorithm

Table of contents Preface Vue update view patch s...

Computed properties and listeners details

Table of contents 1. Calculated properties 1.1 Ba...

Vue3 implements Message component example

Table of contents Component Design Defining the f...