Giunsa ang Pag-install sa PostgreSQL ug pgAdmin sa RHEL 9


Mubo: Niining artikuloha, makakat-on ka unsaon pag-instalar sa PostgreSQL 15 database server ug pgAdmin 4 sa RHEL 9 Linux distribution.

Ang PostgreSQL usa ka gamhanan, kaylap nga gigamit, open-source, multi-platform, ug advanced object-relational database system nga nailhan tungod sa napamatud-an nga arkitektura, kasaligan, integridad sa datos, lig-on nga feature set, ug extensibility.

Ang pgAdmin usa ka advanced, open-source, full-feature, ug web-based nga administrasyon ug management tool para sa PostgreSQL database server.

Magsugod na ta…

Lakang 1: Pag-instalar sa PostgreSQL sa RHEL 9

1. Una, disable ang built-in nga PostgreSQL module pinaagi sa pagpadagan sa mosunod nga dnf command.

# dnf -qy module disable postgresql

2. Sunod, i-enable ang opisyal nga PostgreSQL Yum Repository sama sa gipakita.

# dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

3. Sunod, i-install ang PostgreSQL 15 server ug mga pakete sa kliyente.

# dnf install -y postgresql15-server

4. Kung kompleto na ang instalasyon, i-initialize ang database sa PostgreSQL, dayon sugdi ang serbisyo sa PostgreSQL-15 ug i-enable kini nga awtomatikong magsugod sa boot sa system. Dayon susiha kung ang serbisyo nagdagan ug nagdagan, ug gipagana sama sa gipakita.

# /usr/pgsql-15/bin/postgresql-15-setup initdb 
# systemctl start postgresql-15
# systemctl enable postgresql-15
# systemctl status postgresql-15
# systemctl is-enabled postgresql-15

Lakang 2: I-secure ug I-configure ang PostgreSQL Database

5. Sunod, luwasa ang Postgres user account ug ang database administrative user account. Pagsugod pinaagi sa paghimo og password alang sa usa ka Postgres system user account gamit ang passwd utility sama sa gipakita.

# passwd postgres

6. Dayon balhin sa Postgres system account ug paghimo ug luwas ug lig-on nga password para sa PostgreSQL administrative database user/role sama sa mosunod.

# su - postgres
$ psql -c "ALTER USER postgres WITH PASSWORD '[email ';"
$ exit

7. Karon i-configure kung giunsa pag-authenticate sa Postgres server ang mga kliyente sama sa pgAdmin. Ang gisuportahan nga mga pamaagi sa pag-authenticate naglakip sa password-based authentication nga naggamit sa usa niini nga mga pamaagi: md5, crypt, o password.

Alang niini nga giya, among i-configure ang md5 nga pamaagi sa pag-authenticate sa file /var/lib/pgsql/15/data/pg_hba.conf.

# vi /var/lib/pgsql/15/data/pg_hba.conf

Pangitaa ang mosunod nga mga linya ug usba ang paagi sa pag-authenticate sa md5 ingon nga gipasiugda sa screenshot.

host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5

8. Human ma-save ang file, aron magamit ang bag-ong mga pagbag-o sa configuration sa Postgres, i-restart ang serbisyo sa Postgres.

# systemctl restart postgresql-15

Lakang 3: Pag-instalar sa pgAdmin4 sa RHEL 9

9. Karon atong i-install ang pgAdmin 4 aron madumala ang database sa PostgreSQL gikan sa web. Una, kinahanglan nimo nga i-enable ang EPEL ug pgAdmin yum repository nga adunay pipila nga mga dependency.

# subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms
# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
# dnf install -y https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-2-1.noarch.rpm

10. Karon paghimo ug cache alang sa bag-ong na-install nga pgAdmin ug EPEL nga mga repository ug i-install ang pgAdmin gamit ang mosunod nga mga sugo.

# dnf makecache
# yum install pgadmin4

11. Sunod, sugdi ang httpd nga serbisyo ug i-enable kini sa auto-start sa system boot, unya susiha kon kini nag-andar na ba sama sa gipakita.

# systemctl start httpd
# systemctl enable httpd
# systemctl status httpd

Lakang 4: Pag-configure sa pgAdmin 4 sa RHEL 9

12. Ang pakete sa pgadmin4 adunay usa ka ma-configure nga script aron ma-configure ang serbisyo sa web sa pgAdmin, nga maghimo usa ka account sa gumagamit nga gigamit sa pag-authenticate sa interface sa web, i-configure ang mga palisiya sa SELinux ug Apache webserver aron ma-deploy ang serbisyo sa web sa pgAdmin.

# /usr/pgadmin4/bin/setup-web.sh
Setting up pgAdmin 4 in web mode on a Redhat-based platform...
Creating configuration database...
NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

Email address: [email 
Password: 
Retype password:
pgAdmin 4 - Application Initialisation
======================================

Creating storage and log directories...
Configuring SELinux...
The Apache web server is running and must be restarted for the pgAdmin 4 installation to complete. Continue (y/n)? y
Apache successfully restarted. You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4

13. Kung ang serbisyo sa firewalld gipagana ug gipadagan, ablihi ang mga pantalan 80 ug 443 sa firewall aron tugotan ang trapiko sa HTTPD web server sama sa gipakita.

# firewall-cmd --permanent --zone public --add-port 80/tcp
# firewall-cmd --permanent --zone public --add-port 443/tcp
# firewall-cmd --reload

Lakang 5: Pag-access sa pgAdmin Web Interface

14. Aron ma-access ang pgAdmin web interface, pag-abli sa usa ka browser ug pag-navigate gamit ang mosunod nga URL.

http://SERVER_IP/pgadmin4
OR
http://localhost/pgadmin4

Kung ma-load na ang interface sa pag-login, gamita ang email address ug password nga imong gihimo sa lakang 12 sa ibabaw aron maka-log in.

15. Sunod, pagdugang og bag-ong koneksyon sa server pinaagi sa pag-klik sa \Add New Server.

16. Dayon ubos sa tab nga \General, isulod ang mosunod nga mga setting sa server Ngalan ug opsyonal nga magbilin ug komento aron ihulagway ang koneksyon.

17. Dayon ipasabut ang profile sa koneksyon pinaagi sa pagpuno sa mosunod:

  • Host – host/IP address sa PostgreSQL server.
  • Port – default sa 5432.
  • Maintenance Database – ang mga default kay Postgres.
  • Username – ang username sa database. Mahimo nimong gamiton ang Postgres.
  • Password – password para sa user sa ibabaw.

Dayon i-klik ang Save.

18. Ang bag-ong server kinahanglan na nga makita ubos sa lista sa mga server sama sa gipasiugda sa mosunod nga screenshot.

19. Kung mag-klik ka sa ngalan sa server, ang mga hiyas niini kinahanglan nga ma-load sa ilawom sa Dashboard sama sa gipakita sa mosunod nga screenshot.

Anaa na nimo! Malampuson nimong na-install ang Postgresql 15 ug pgAdmin 4 sa RHEL 9. Maabot mi pinaagi sa feedback form sa ubos para sa bisan unsang mga hunahuna ug pangutana.

Makita nimo ang dugang nga impormasyon sa dokumentasyon sa pgAdmin.