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

Yum installation and configuration method of postgresql

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces the "postgresql yum installation and configuration method". In the daily operation, I believe many people have doubts about the postgresql yum installation and configuration method. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "postgresql yum installation and configuration method". Next, please follow the editor to study!

Summary

1. Initialize the database by initdb after determining the PGDATA environment variable.

2. Ps-ef after systemctl startup | grep pg is displayed as / usr/pgsql-11/bin/postmaster-D / pgdata/data/

But what you see with / usr/pgsql-11/bin/pg_ctl status is still / usr/pgsql-11/bin/postgres "- D"/ pgdata/data".

/ usr/pgsql-11/bin/pg_ctl start Post-startup process ps-ef | grep pg is displayed as / usr/pgsql-11/bin/postgres-D / pgdata/data

3. Pg_ctl stop can kill services started by systemctl

Systemctl stop cannot kill the service started by pg_ctl start

Steps

1 、

Yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

2 、

Vi / etc/sysctl.conf

Vi / etc/security/limits.conf

3 、

Yum list | grep postgresql11

4 、

Yum-y install postgresql11

Yum-y install postgresql11-server

Yum-y install postgresql11-contrib.x86_64-this step is mainly to install pg_recvlogical

5 、

Mkdir-p / pgdata/data/

Chown-R postgres.postgres / pgdata

6 、 systemctl enable postgresql-11

Vi / usr/lib/systemd/system/postgresql-11.service

-- change Environment=PGDATA=/var/lib/pgsql/11/data/ to Environment=PGDATA=/pgdata/data/

Systemctl reload postgresql-11

Check whether the environment variable PGDATA is normal.

Systemctl show-p Environment "postgresql-11.service" | sed's / ^ Environment = / /'| tr'\ n' | sed-n's / ^ PGDATA = / / p' | tail-n 1

7 、 / usr/pgsql-11/bin/postgresql-11-setup initdb

8 、 systemctl start postgresql-11

9. Ps-ef | grep pg

Postgres 6175 10 00:07? 00:00:00 / usr/pgsql-11/bin/postmaster-D / pgdata/data/ 10, su-postgres

/ usr/pgsql-11/bin/pg_ctl status

Pg_ctl: directory "/ var/lib/pgsql/11/data" is not a database cluster directory

11 、 vi .bash _ profile

-- modify PGDATA=/pgdata/data

12 、 source .bash _ profile

/ usr/pgsql-11/bin/pg_ctl status

Pg_ctl: server is running (PID: 6175)

/ usr/pgsql-11/bin/postgres "- D"/ pgdata/data/"

Systemctl stop cannot kill the service started by pg_ctl start

[root@FRSPGSQLDEV2 ~] # su-postgres

-bash-4.2 $/ usr/pgsql-11/bin/pg_ctl start-D / pgdata/data/

-bash-4.2 $/ usr/pgsql-11/bin/pg_ctl status

Pg_ctl: server is running (PID: 6659)

/ usr/pgsql-11/bin/postgres "- D"/ pgdata/data"

-bash-4.2$ exit

Logout

[root@FRSPGSQLDEV2 ~] # ps-ef | grep pg

Postgres 6659 1 0 00:29 pts/1 00:00:00 / usr/pgsql-11/bin/postgres-D / pgdata/data

Root 6670 6483 0 00:30 pts/1 00:00:00 grep-color=auto pg

[root@FRSPGSQLDEV2 ~] # systemctl stop postgresql-11

[root@FRSPGSQLDEV2 ~] # ps-ef | grep pg

Postgres 6659 1 0 00:29 pts/1 00:00:00 / usr/pgsql-11/bin/postgres-D / pgdata/data

Root 6678 6483 0 00:30 pts/1 00:00:00 grep-color=auto pg

Pg_ctl stop can kill services started by systemctl

[root@FRSPGSQLDEV2 ~] # systemctl start postgresql-11

[root@FRSPGSQLDEV2 ~] # ps-ef | grep pg

Postgres 6587 11 00:28? 00:00:00 / usr/pgsql-11/bin/postmaster-D / pgdata/data/

[root@FRSPGSQLDEV2 ~] # su-postgres

Last login: Fri Oct 18 00:26:32 PDT 2019 on pts/1

-bash-4.2 $/ usr/pgsql-11/bin/pg_ctl status

Pg_ctl: server is running (PID: 6587)

/ usr/pgsql-11/bin/postgres "- D"/ pgdata/data/"

-bash-4.2 $/ usr/pgsql-11/bin/pg_ctl stop

Waiting for server to shut down.... Done

-bash-4.2$ exit

Logout

[root@FRSPGSQLDEV2 ~] # ps-ef | grep pg [root@FRSPGSQLDEV2 init.d] # / usr/pgsql-11/bin/postgresql-11-setup initdb

Initializing database... OK

[root@FRSPGSQLDEV2 init.d] # systemctl enable postgresql-11

Created symlink from / etc/systemd/system/multi-user.target.wants/postgresql-11.service to / usr/lib/systemd/system/postgresql-11.service.

Systemctl daemon-reload is required after modifying PGDATA

[root@FRSPGSQLDEV2 init.d] # mkdir-p / pgdata/data/

[root@FRSPGSQLDEV2 init.d] # chown-R postgres.postgres / pgdata

[root@FRSPGSQLDEV2 init.d] # vi / usr/lib/systemd/system/postgresql-11.service

The value of Environment=PGDATA changes / var/lib/pgsql/11/data/ to / pgdata/data

[root@FRSPGSQLDEV2 init.d] # systemctl start postgresql-11

Warning: postgresql-11.service changed on disk. Run 'systemctl daemon-reload' to reload units

[root@FRSPGSQLDEV2 init.d] # systemctl daemon-reload

[root@FRSPGSQLDEV2 init.d] # systemctl start postgresql-11

[root@FRSPGSQLDEV2 init.d] # ps-ef | grep pg

Postgres 16192 1 0 19:00? 00:00:00 / usr/pgsql-11/bin/postmaster-D / pgdata/data/

At this point, the study on the "yum installation and configuration method of postgresql" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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