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

Redhat6.5 detailed steps for installing Postgres9.6

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "Redhat6.5 installation of Postgres9.6 detailed steps", the article explained the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Redhat6.5 installation of Postgres9.6 detailed steps" bar!

1. Installation media

Postgresql96-libs-9.6.3-1PGDG.rhel6.x86_64.rpm

Postgresql96-contrib-9.6.3-1PGDG.rhel6.x86_64.rpm

Postgresql96-9.6.3-1PGDG.rhel6.x86_64.rpm

Postgresql96-server-9.6.3-1PGDG.rhel6.x86_64.rpm

2. Install Postgres

2.1Creating postgres users

New postgres users and groups

Groupadd postgres

Useradd-g postgres postgres

Passwd postgres-change the password of the postgres user

2.2 install the RPM package

Rpm-qa | grep postgres / / Delete the installed postgres package

Rpm-ivh postgresql96-libs-9.6.3-1PGDG.rhel6.x86_64.rpm

Rpm-ivh postgresql96-9.6.3-1PGDG.rhel6.x86_64.rpm

Rpm-ivh postgresql96-contrib-9.6.3-1PGDG.rhel6.x86_64.rpm

Rpm-ivh postgresql96-server-9.6.3-1PGDG.rhel6.x86_64.rpm

Rpm-qa | grep postgres

3. Initialize the database to view the startup file

Ls-rlt / etc/rc.d/init.d/postgresql-9.6

You can see the following variable settings

# Set defaults for configuration variables

PGENGINE=/usr/pgsql-9.6/bin

PGDATA=/var/lib/pgsql/9.6/data

PGLOG=/var/lib/pgsql/9.6/pgstartup.log

Create a database directory

Mkdir-p / postgres/data

Chown-R postgres:postgres / postgres/data

Change the database installation location

Vi / etc/rc.d/init.d/postgresql-9.6

Modify the value of the following variable

PGDATA=/postgres/data

PGLOG=/postgres/pgstartup.log

Find the initdb file

[root@nbu01 software] # find /-name initdb

/ usr/pgsql-9.6/bin/initdb

Specify the location and encoding of the database, and initialize the database:

Su-postgres

/ usr/pgsql-9.6/bin/initdb-E UNICODE-D / postgres/data

Edit the postgresql.conf file and modify the listening address and port parameters that the database receives by default:

Vi / postgres/data/postgresql.conf

Change # listen_addresses = 'localhost' # what IP address (es) to listen on

Change it to listen_addresses ='*'

Next, continue to modify the pg_hba.conf file to tell the database server what kind of clients it will allow to connect to itself:

Vi / postgres/data/pg_hba.conf-- modify the postgresql service connection file

Add a line below line 86 to allow any client to access itself with the correct username and password:

Host all all 0.0.0.0/0 trust

Note: if you set trust, you can log in to the server directly using psql-U postgres locally. If you set peer, you can log in directly to the server using psql-h 127.0.0.1-d postgres-U postgres.

Database service start and stop

The default postgresql-9.6 is not self-starting. We need to set the postgresql-9.6 service to self-starting service:

Chkconfig postgresql-9.6 on setup service self-startup

Chkconfig-list

Service postgresql-9.6 status to view service status

Service postgresql-9.6 start starts the postgresql-9.6 service

There are three ways to see if postgresql is running

Ps-ef | grep postgres looks up the process information of postgres

Netstat-tpnl | grep 5432 check whether the port number 5432 of postgres is open

Service postgresql-9.6 status to view service status

Connect to the postgresql database:

Psql-U postgres / / Connect pgsql server

Psql-h 127.0.0.1-d postgres-U postgres / / Connect pgsql server

After modifying the configuration file pg_hba.conf, log in to the database and refresh the updated configuration command:

Select pg_reload_conf ()

Show data_directory

Modify postgres password

ALTER USER postgres WITH PASSWORD 'spdb1234'; / / add password

Select * from pg_shadow

\ Q enter to log in

Set up a firewall

Iptables-I INPUT-p tcp-- dport 22-j ACCEPT

Iptables-I INPUT-p tcp-- dport 5432-j ACCEPT

Service iptables save

Service iptables restart

Cat / etc/sysconfig/iptables

Thank you for your reading, the above is the "detailed steps of Redhat6.5 installation of Postgres9.6" content, after the study of this article, I believe you have a deeper understanding of the detailed steps of Redhat6.5 installation of Postgres9.6, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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