Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos6.7 installs single-node postgresql

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

System version:

Cat / etc/redhat-release

Red Hat Enterprise Linux Server release 6.7 (Santiago)

Install the PGsql8.2 version by default

Data storage directory

/ usr/openv/pg_data

What I have installed here is version 9.4, so you can uninstall it if you install it.

# yum remove postgresql-server

Find the version you need on the following website

Http://download.postgresql.org/pub/repos/yum/

Https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-6.7-x86_64/

Postgresql94-9.4.18-1PGDG.rhel6.x86_64.rpm

Postgresql94-devel-9.4.18-1PGDG.rhel6.x86_64.rpm

Postgresql94-libs-9.4.18-1PGDG.rhel6.x86_64.rpm

Postgresql94-server-9.4.18-1PGDG.rhel6.x86_64.rpm

Create a directory to store the downloaded installation package

# mkdir / data/packages

# cd / data/packages

Install the database package

# yum install postgresql94*

Install uuid dependencies

# yum install uuid uuid-devel

Configure passwords for database administrative users

# passwd postgres

View installation content

# rpm-ql postgresql94-server-9.4.18-1PGDG.rhel6.x86_64 | more

/ usr/pgsql-9.4/bin/psql

/ usr/pgsql-9.4/bin/initdb

/ usr/pgsql-9.4/bin/pg_ctl

Configure environment variables

# vi / etc/profile

Export PG_HOME=/usr/pgsql-9.4

Export PATH=$PATH:$PG_HOME/bin

Export PGDATA=/data/pg_data

# source / etc/profile

Create a data storage directory

# mkdir / data/pg_data

# chown postgres:postgres / data/pg_data

Switch database management accounts

# su postgres

Initialize the database

$initdb

Start the service

$pg_ctl start-D $PGDATA

Log into the database

$psql

Password-free login is the default here, so the following configuration

Postgres=# ALTER USER postgres PASSWORD 'Custom password'

Edit profile pg_hba.conf

Bash-4.1$ pwd

/ data/pg_data

Bash-4.1$ vi pg_hba.conf

# "local" is for Unix domain socket connections only

Local all all md5

# IPv4 local connections:

Host all all 127.0.0.1/32 md5

Host all all 192.168.72.0/24 md5

# IPv6 local connections:

Host all all:: 1/128 md5

Description:

Change the last column trust to md5, indicating that you need to enter a password to log in

Allow the network segment of 192.168.72.X to access the database

Edit profile postgresql.conf

$vi postgresql.conf

Listen_addresses ='*'

Max_connections = 500,

Unix_socket_directories ='/ data/pg_data/socket'

Shared_preload_libraries = 'pg_stat_statements'

Track_io_timing = on

Track_activity_query_size = 2048

Pg_stat_statements.max = 10000

Pg_stat_statements.track = all

Pg_stat_statements.track_utility = off

Pg_stat_statements.save = on

"postgresql.conf" 620L, 21279C written

Bash-4.1$ mkdir socket

Restart the service

$pg_ctl restart-D $PGDATA

Log in to the database and create uuid and pg_stat_statements functions. You don't have to configure what you don't need.

$psql

Postgres=# create extension "uuid-ossp"

CREATE EXTENSION

Postgres=# create extension pg_stat_statements

CREATE EXTENSION

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report