[LINUX] PostgreSQL 10.0 installation procedure

Procedure created as a verification environment This time, install OracleLinux6 + PostgreSQL10.0

Get PostgreSQL source code https://www.postgresql.org/ftp/source/

Exhibitor: Manual https://www.postgresql.org/docs/10/index.html

OS user creation for postgres

# useradd postgres
# passwd postgres
Change password for user postgres.

Create installation directory

# mkdir /usr/local/pgsql

Save the source file to / usr / local / src and unzip it

# tar -xvf  postgresql-10.0.tar.bz2
# chown -R postgres:postgres postgresql-10.0
# ls -la
19192 in total
drwxr-xr-x.3 root root 4096 November 7 15:01 2019 .
drwxr-xr-x.13 root root 4096 November 7 14:54 2019 ..
drwxrwxrwx 6 postgres postgres 4096 October 3 06:15 2017 postgresql-10.0
-rw-r--r--1 root root 19639147 November 7 14:40 2019 postgresql-10.0.tar.bz2

Installation of required packages

# yum -y install readline readline readline-devel
# yum -y install gcc
# yum -y install flex
# yum install zlib-devel
# yum install perl

make command confirmation

# make --version
GNU Make 3.81

compile

$ cd ./postgresql-10.0
$ ls
COPYRIGHT       HISTORY  Makefile  aclocal.m4  configure     contrib  src
GNUmakefile.in  INSTALL  README    config      configure.in  doc
$ ./configre
$ make

Pre-install check command

$ make check

Installation Enable sudo

#Add the following line with visudo.
postgres   ALL=(ALL)       ALL

$ sudo make install

■ Environment variable settings

$ vi ~/.bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
export PATH="$PATH":/usr/local/pgsql/bin
export POSTGRES_HOME=/usr/local/pgsql
export PGLIB=$POSTGRES_HOME/lib
export PGDATA=$POSTGRES_HOME/data
export MANPATH="$MANPATH":$POSTGRES_HOME/man
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$PGLIB"

Change the owner of / usr / local / pgsql

$ sudo chown postgres:postgres /usr/local/pgsql

DB initialization

$ initdb

start postgreSQL server

$ postgres -D /usr/local/pgsql/data/
2019-11-07 16:33:52.702 JST [6119] LOG:  listening on IPv6 address "::1", port 5432
2019-11-07 16:33:52.702 JST [6119] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2019-11-07 16:33:52.752 JST [6119] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2019-11-07 16:33:52.828 JST [6120] LOG:  database system was shut down at 2019-11-07 16:26:45 JST
2019-11-07 16:33:52.861 JST [6119] LOG:  database system is ready to accept connections
^C2019-11-07 16:34:02.694 JST [6119] LOG:  received fast shutdown request
2019-11-07 16:34:02.827 JST [6119] LOG:  aborting any active transactions
2019-11-07 16:34:02.827 JST [6119] LOG:  worker process: logical replication launcher (PID 6126) exited with exit code 1
2019-11-07 16:34:02.827 JST [6121] LOG:  shutting down
2019-11-07 16:34:03.273 JST [6119] LOG:  database system is shut down

Creating a startup script

# install -o root -g root -m 755 /usr/local/src/postgresql-10.0/contrib/start-scripts/linux /etc/rc.d/init.d/pgsql
# chkconfig --add pgsql
# /etc/rc.d/init.d/pgsql start
Starting PostgreSQL: ok

Creating users and DB

$ createuser posuser
$ createdb -O posuser testdb
$ psql -l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 |
 template0 | postgres | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 testdb    | posuser  | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 |

Remote connection settings

$ vi /usr/local/pgsql/data/pg_hba.conf
Postscript
host    all             all             0.0.0.0/0           md5

$ vi /usr/local/pgsql/data/postgresql.conf
Postscript
listen_addresses = '*'

Installation complete

$ psql
psql (10.0)
Type "help" for help.

postgres=# select version();
                                                   version

---------------------------------------------------------------------------------------------
----------------
 PostgreSQL 10.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-
23.0.1), 64-bit
(1 row)

that's all.

Recommended Posts

PostgreSQL 10.0 installation procedure
Pylearn 2 installation procedure
blockdiag installation procedure
Linux mint installation procedure
AWS CLI installation procedure
django-debug-toolbar installation procedure memo
ubuntu20.04 + Geth installation procedure
Anaconda3 environment installation procedure
Scrapy environment installation procedure
CentOS 8 installation procedure (latest version)
Docker Easy Installation Procedure (CentOS)
Python 3.6 installation procedure [for Windows]
ubuntu 20.04 + VirtalBox installation procedure summary
Django PostgreSQL installation, database construction
OpenCV installation procedure on Raspberry Pi
PySpark 1.5.2 + Elasticsearch 2.1.0 Installation procedure and execution
Teamviewer for Linux installation procedure (CentOS)
Summary of Oracle Database XE installation procedure
Django installation
boto3 installation
Pythia Installation
Docker installation
Volatility installation
Python installation
WSL2 (Windows Subsystem for Linux) installation procedure
InstantOS 1 installation
Jupyter installation
Python installation
pip installation
ChaSen installation
Backtrader installation
pip installation
[Ansible installation procedure] From installation to execution of playbook
Kotlin / Native development environment construction & installation procedure & tutorial