How to Install PostgreSQL and pgAdmin in CentOS 8
Linux Certifications - RHCSA / RHCE Certification | Ansible Automation Certification | LFCS / LFCE Certification
PostgreSQL is a powerful, widely-used, open-source, multi-platform and advanced object-relational database system known for its proven architecture, reliability, data integrity, robust feature set, and extensibility.
pgAdmin is an advanced, open-source, full-featured, and web-based administration and management tool for the PostgreSQL database server.
In this article, you will learn how to install the PostgreSQL 12 database server and pgAdmin 4 in CentOS 8 Linux distribution.
Step 1: Installing PostgreSQL on CentOS 8
2. Next, enable the official PostgreSQL Yum Repository as shown.
3. Next, install the PostgreSQL 12 server and client packages.
4. Once the installation is complete, initialize the PostgreSQL database, then start the PostgreSQL-12 service and enable it to automatically start at system boot. Then check if the service is up and running, and is enabled as shown.
Step 2: Secure and Configure PostgreSQL Database
5. Next, secure the Postgres user account and the database administrative user account. Start by creating a password for a Postgres system user account using the passwd utility as shown.
6. Then switch to the Postgres system account and create a secure and strong password for PostgreSQL administrative database user/role as follows.
7. Now configure how the Postgres server will authenticate clients such as pgAdmin. The supported authentication methods include password-based authentication which uses one of these methods: md5, crypt, or password.
For this guide, we will configure md5 authentication method in the file /var/lib/pgsql/12/data/pg_hba.conf.
Find the following lines and change the authentication method to md5 as highlighted in the screenshot.
8. After saving the file, to apply the recent changes in the Postgres configuration, restart the Postgres service.
Step 3: Installing pgAdmin4 in CentOS 8
9. Now we will install pgAdmin 4 to manage the PostgreSQL database from the web. First, you need to enable the EPEL and PowerTools repositories which contain some of the dependencies.
10. Next, start the httpd service and enable it to auto-start at system boot, then check if it is up and running as shown.
Step 4: Configuring pgAdmin 4 in CentOS 8
11. Now create a configuration file for pgAdmin4 under the httpd configuration structure. Create a new configuration file from the provided sample as shown.
12. Next, ensure that the httpd configuration syntax is ok, and restart the service.
13. Now you need to create a directory for pgAdmin logs and libraries by running the following commands.
14. Then declare the location/path of the log file, SQLite database, session database and storage in the Python configuration file for pgAdmin in the file.
Copy and paste the following lines in the file.
15. Now create a user account used to authenticate in the web interface and also create the configuration database.
16. Next, set the required ownership of the pgAdmin directories created recently.
17. If you have SELinux enabled, also set the correct SELinux context of the pgAdmin log directories. And allow HTTPD scripts and modules (pgAdmin in this case)to connect to the network.
18. Now restart the httpd service to apply all the recent changes.
18. If you have the firewalld service enabled and running, open port 80 and 443 in the firewall to allow traffic to the HTTPD web server as shown.
Step 5: Accessing pgAdmin Web Interface
19. To access the pgAdmin web interface, open a browser and navigate using the following URL.
Once the login interface loads, use the email address and password you created in step 15 above to log in.
20. Next, add a new server connection clicking on “Add New Server”.
21. Then under the “General” tab, enter the following settings server Name and optionally leave a comment to describe the connection.
22. Then define the connection profile by filling in the following:
- Host – host/IP address of the PostgreSQL server.
- Port – defaults to 5432.
- Maintenance Database – defaults should be Postgres.
- Username – the database username. You can use Postgres.
- Password – password for the above user.
Then click Save.
23. The new server should now appear under the list of servers as highlighted in the following screenshot.
24. When you click on the server name, its attributes should load under the Dashboard as shown in the following screenshot.
There you have it! You have successfully installed Postgresql 12 and pgAdmin 4 in CentOS 8. Reach us via the feedback form below for any thoughts and questions. You can find more information in the Postgresql 12 documentation and pgAdmin documentation.
Tidak ada komentar:
Posting Komentar