{"id":10271,"date":"2021-09-07T14:04:15","date_gmt":"2021-09-07T11:04:15","guid":{"rendered":"https:\/\/kifarunix.com\/?p=10271"},"modified":"2024-03-18T14:10:40","modified_gmt":"2024-03-18T11:10:40","slug":"install-postgresql-on-rocky-linux-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-postgresql-on-rocky-linux-8\/","title":{"rendered":"Install PostgreSQL on Rocky Linux 8"},"content":{"rendered":"\n
In this tutorial, you will learn how to install PostgreSQL on Rocky Linux 8. <\/p>\n\n\n\n
PostgreSQL<\/a> is a fully featured object-relational database management system. It supports a large part of the SQL standard and is designed to be extensible by users in many aspects.<\/p>\n\n\n\n Some of the features are: ACID transactions, foreign keys, views, sequences, subqueries, triggers, user-defined types and functions, outer joins, multiversion concurrency control. Graphical user interfaces and bindings for many programming languages are available as well.<\/p>\n\n\n\n PostgreSQL is a powerful, open source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads.<\/p>\n\n\n\n Rocky Linux ships with AppStream repository modules for various versions of PostgreSQL.<\/p>\n\n\n\n From the output above, you can can we that there are streams of various versions of PostgreSQL including v9.6, 10, 12, 13.<\/p>\n\n\n\n The AppStream modules for PostgreSQL is enabled by default.<\/p>\n\n\n\n For various reasons, you might want to install various versions of PostgreSQL on your Rocky Linux 8 box.<\/p>\n\n\n\n As of this writing, PostgreSQL 13 is the current stable release<\/a>.<\/p>\n\n\n\n By default, the AppStream modules for PostgreSQL 10 are enabled by default.<\/p>\n\n\n\n To install PostgreSQL 13 on Rocky Linux 8;<\/p>\n\n\n\n Confirm;<\/p>\n\n\n\n Hence, you can now run the command below to install PostgreSQL 13 on Rocky Linux 8.<\/p>\n\n\n\n Check the version PostgreSQL installed;<\/p>\n\n\n\n Initialize the database;<\/p>\n\n\n\n Start and enable PostgreSQL to run on system boot;<\/p>\n\n\n\n Checking the status;<\/p>\n\n\n\n To install PostgreSQL 12 on Rocky Linux, run the commands below;<\/p>\n\n\n\n Otherwise, if you had other versions modules enabled, then reset the modules and install PostgreSQL as follows;<\/p>\n\n\n\n After install, you can verify the version;<\/p>\n\n\n\n Initialize the database;<\/p>\n\n\n\n Start and enable PostgreSQL to run on system boot;<\/p>\n\n\n\n By default, you would simply run the commands below to install PostgreSQL 10 on Rocky Linux 8.<\/p>\n\n\n\n However, if you have other versions AppStream modules enabled, then you have to reset the modules.<\/p>\n\n\n\n After install, you can verify the version;<\/p>\n\n\n\n Initialize the database;<\/p>\n\n\n\n Start and enable PostgreSQL to run on system boot;<\/p>\n\n\n\n Similarly, to install PostgreSQL 9.x, then enable the module and run the installation command.<\/p>\n\n\n\n Rocky Linux do not provide repositories for installing PostgreSQL 11.<\/p>\n\n\n\n Thus, if you want to install PostgreSQL 11 on Rocky Linux 8, then you need to install the repository RPM:<\/p>\n\n\n\n Disable the built-in PostgreSQL module:<\/p>\n\n\n\n Install PostgreSQL 11 on Rocky Linux 8<\/p>\n\n\n\n Initialize the database;<\/p>\n\n\n\n Start and enable PostgreSQL to run on system boot;<\/p>\n\n\n\n Checking the status;<\/p>\n\n\n\n Read More on PostgreSQL Tutorials<\/a>.<\/p>\n\n\n\n Install LAMP Stack on Debian 11<\/a><\/p>\n\n\n\n Enable MSSQL Server and Database Level Auditing<\/a><\/p>\n\n\n\nInstalling PostgreSQL on Rocky Linux 8<\/h2>\n\n\n\n
dnf module list postgresql<\/code><\/pre>\n\n\n\n
Rocky Linux 8 - AppStream\nName Stream Profiles Summary \npostgresql 9.6 client, server [d] PostgreSQL server and client module \npostgresql 10 [d] client, server [d] PostgreSQL server and client module \npostgresql 12 client, server [d] PostgreSQL server and client module \npostgresql 13 client, server [d] PostgreSQL server and client module \n\nHint: [d]efault, [e]nabled, [x]disabled, [i]nstalled\n<\/code><\/pre>\n\n\n\n
Install PostgreSQL 13 on Rocky Linux 8<\/a><\/h3>\n\n\n\n
\n
dnf -qy module enable postgresql:13<\/code><\/pre>\n\n\n\n
dnf info postgresql-server<\/code><\/pre>\n\n\n\n
Available Packages\nName : postgresql-server\nVersion : 13.3<\/strong>\nRelease : 1.module+el8.4.0+546+3620623e\nArchitecture : x86_64\nSize : 5.6 M\nSource : postgresql-13.3-1.module+el8.4.0+546+3620623e.src.rpm\nRepository : appstream\nSummary : The programs needed to create and run a PostgreSQL server\nURL : http:\/\/www.postgresql.org\/\nLicense : PostgreSQL\n<\/code><\/pre>\n\n\n\n
dnf install postgresql-server<\/code><\/pre>\n\n\n\n
Dependencies resolved.\n============================================================================================================================================================================\n Package Architecture Version Repository Size\n============================================================================================================================================================================\nInstalling:\n postgresql-server x86_64 13.3-1.module+el8.4.0+546+3620623e appstream 5.6 M\nInstalling dependencies:\n libicu x86_64 60.3-2.el8_1 baseos 8.8 M\n libpq x86_64 13.3-1.el8_4 appstream 196 k\n postgresql x86_64 13.3-1.module+el8.4.0+546+3620623e appstream 1.5 M\n\nTransaction Summary\n============================================================================================================================================================================\nInstall 4 Packages\n\nTotal download size: 16 M\nInstalled size: 59 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n
postgres -V<\/code><\/pre>\n\n\n\n
postgres (PostgreSQL) 13.3<\/code><\/pre>\n\n\n\n
postgresql-setup --initdb<\/code><\/pre>\n\n\n\n
systemctl enable --now postgresql<\/code><\/pre>\n\n\n\n
systemctl status postgresql<\/code><\/pre>\n\n\n\n
\u25cf postgresql.service - PostgreSQL database server\n Loaded: loaded (\/usr\/lib\/systemd\/system\/postgresql.service; enabled; vendor preset: disabled)\n Active: active (running) since Tue 2021-09-07 09:42:14 EAT; 47s ago\n Process: 15684 ExecStartPre=\/usr\/libexec\/postgresql-check-db-dir postgresql (code=exited, status=0\/SUCCESS)\n Main PID: 15686 (postmaster)\n Tasks: 8 (limit: 4938)\n Memory: 16.8M\n CGroup: \/system.slice\/postgresql.service\n \u251c\u250015686 \/usr\/bin\/postmaster -D \/var\/lib\/pgsql\/data\n \u251c\u250015688 postgres: logger \n \u251c\u250015690 postgres: checkpointer \n \u251c\u250015691 postgres: background writer \n \u251c\u250015692 postgres: walwriter \n \u251c\u250015693 postgres: autovacuum launcher \n \u251c\u250015694 postgres: stats collector \n \u2514\u250015695 postgres: logical replication launcher \n\nSep 07 09:42:13 rocky8 systemd[1]: Starting PostgreSQL database server...\nSep 07 09:42:13 rocky8 postmaster[15686]: 2021-09-07 09:42:13.544 EAT [15686] LOG: starting PostgreSQL 12.7 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 8.4.1 202009>\nSep 07 09:42:13 rocky8 postmaster[15686]: 2021-09-07 09:42:13.545 EAT [15686] LOG: listening on IPv6 address \"::1\", port 5432\nSep 07 09:42:13 rocky8 postmaster[15686]: 2021-09-07 09:42:13.545 EAT [15686] LOG: listening on IPv4 address \"127.0.0.1\", port 5432\nSep 07 09:42:13 rocky8 postmaster[15686]: 2021-09-07 09:42:13.687 EAT [15686] LOG: listening on Unix socket \"\/var\/run\/postgresql\/.s.PGSQL.5432\"\nSep 07 09:42:13 rocky8 postmaster[15686]: 2021-09-07 09:42:13.962 EAT [15686] LOG: listening on Unix socket \"\/tmp\/.s.PGSQL.5432\"\nSep 07 09:42:14 rocky8 postmaster[15686]: 2021-09-07 09:42:14.130 EAT [15686] LOG: redirecting log output to logging collector process\nSep 07 09:42:14 rocky8 postmaster[15686]: 2021-09-07 09:42:14.130 EAT [15686] HINT: Future log output will appear in directory \"log\".\nSep 07 09:42:14 rocky8 systemd[1]: Started PostgreSQL database server.\n<\/code><\/pre>\n\n\n\n
Install PostgreSQL 12 on Rocky Linux 8<\/a><\/h3>\n\n\n\n
dnf -qy module enable postgresql:12<\/code><\/pre>\n\n\n\n
dnf install postgresql-server<\/code><\/pre>\n\n\n\n
dnf -qy module reset postgresql<\/code><\/pre>\n\n\n\n
dnf -qy module enable postgresql:12<\/code><\/pre>\n\n\n\n
dnf install postgresql-server<\/code><\/pre>\n\n\n\n
Dependencies resolved.\n============================================================================================================================================================================\n Package Architecture Version Repository Size\n============================================================================================================================================================================\nInstalling:\n postgresql-server x86_64 12.7-1.module+el8.4.0+587+d46efd10 appstream 5.6 M\nInstalling dependencies:\n libicu x86_64 60.3-2.el8_1 baseos 8.8 M\n libpq x86_64 13.3-1.el8_4 appstream 196 k\n postgresql x86_64 12.7-1.module+el8.4.0+587+d46efd10 appstream 1.5 M\n\nTransaction Summary\n============================================================================================================================================================================\nInstall 4 Packages\n\nTotal download size: 16 M\nInstalled size: 59 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n
postgres -V<\/code><\/pre>\n\n\n\n
postgres (PostgreSQL) 12.7<\/code><\/pre>\n\n\n\n
postgresql-setup --initdb<\/code><\/pre>\n\n\n\n
systemctl enable --now postgresql<\/code><\/pre>\n\n\n\n
Install PostgreSQL 10 on Rocky Linux 8<\/a><\/h3>\n\n\n\n
dnf install postgresql-server<\/code><\/pre>\n\n\n\n
dnf -qy module reset postgresql<\/code><\/pre>\n\n\n\n
dnf install postgresql-server<\/code><\/pre>\n\n\n\n
Dependencies resolved.\n============================================================================================================================================================================\n Package Architecture Version Repository Size\n============================================================================================================================================================================\nInstalling:\n postgresql-server x86_64 10.17-1.module+el8.4.0+548+9eccbe3f appstream 5.1 M\nInstalling dependencies:\n libpq x86_64 13.3-1.el8_4 appstream 196 k\n postgresql x86_64 10.17-1.module+el8.4.0+548+9eccbe3f appstream 1.5 M\nEnabling module streams:\n postgresql 10 \n\nTransaction Summary\n============================================================================================================================================================================\nInstall 3 Packages\n\nTotal download size: 6.8 M\nInstalled size: 26 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n
postgres -V<\/code><\/pre>\n\n\n\n
postgres (PostgreSQL) 10.17<\/code><\/pre>\n\n\n\n
postgresql-setup --initdb<\/code><\/pre>\n\n\n\n
systemctl enable --now postgresql<\/code><\/pre>\n\n\n\n
Install PostgreSQL 11 on Rocky Linux 8<\/h3>\n\n\n\n
dnf install -y https:\/\/download.postgresql.org\/pub\/repos\/yum\/reporpms\/EL-8-x86_64\/pgdg-redhat-repo-latest.noarch.rpm<\/code><\/pre>\n\n\n\n
dnf -qy module disable postgresql<\/code><\/pre>\n\n\n\n
dnf install postgresql11-server<\/code><\/pre>\n\n\n\n
Dependencies resolved.\n============================================================================================================================================================================\n Package Architecture Version Repository Size\n============================================================================================================================================================================\nInstalling:\n postgresql11-server x86_64 11.13-1PGDG.rhel8 pgdg11 4.9 M\nInstalling dependencies:\n libicu x86_64 60.3-2.el8_1 baseos 8.8 M\n postgresql11 x86_64 11.13-1PGDG.rhel8 pgdg11 1.7 M\n postgresql11-libs x86_64 11.13-1PGDG.rhel8 pgdg11 394 k\n\nTransaction Summary\n============================================================================================================================================================================\nInstall 4 Packages\n\nTotal download size: 16 M\nInstalled size: 60 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n
postgresql-11-setup initdb<\/code><\/pre>\n\n\n\n
systemctl enable --now postgresql-11<\/code><\/pre>\n\n\n\n
systemctl status postgresql-11<\/code><\/pre>\n\n\n\n
\u25cf postgresql-11.service - PostgreSQL 11 database server\n Loaded: loaded (\/usr\/lib\/systemd\/system\/postgresql-11.service; enabled; vendor preset: disabled)\n Active: active (running) since Tue 2021-09-07 09:19:07 EAT; 44s ago\n Docs: https:\/\/www.postgresql.org\/docs\/11\/static\/\n Process: 11990 ExecStartPre=\/usr\/pgsql-11\/bin\/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=0\/SUCCESS)\n Main PID: 11995 (postmaster)\n Tasks: 8 (limit: 4938)\n Memory: 16.4M\n CGroup: \/system.slice\/postgresql-11.service\n \u251c\u250011995 \/usr\/pgsql-11\/bin\/postmaster -D \/var\/lib\/pgsql\/11\/data\/\n \u251c\u250012001 postgres: logger \n \u251c\u250012003 postgres: checkpointer \n \u251c\u250012004 postgres: background writer \n \u251c\u250012005 postgres: walwriter \n \u251c\u250012006 postgres: autovacuum launcher \n \u251c\u250012007 postgres: stats collector \n \u2514\u250012008 postgres: logical replication launcher \n\nSep 07 09:19:05 rocky8 systemd[1]: Starting PostgreSQL 11 database server...\nSep 07 09:19:06 rocky8 postmaster[11995]: 2021-09-07 09:19:06.387 EAT [11995] LOG: listening on IPv6 address \"::1\", port 5432\nSep 07 09:19:06 rocky8 postmaster[11995]: 2021-09-07 09:19:06.387 EAT [11995] LOG: listening on IPv4 address \"127.0.0.1\", port 5432\nSep 07 09:19:06 rocky8 postmaster[11995]: 2021-09-07 09:19:06.541 EAT [11995] LOG: listening on Unix socket \"\/var\/run\/postgresql\/.s.PGSQL.5432\"\nSep 07 09:19:06 rocky8 postmaster[11995]: 2021-09-07 09:19:06.848 EAT [11995] LOG: listening on Unix socket \"\/tmp\/.s.PGSQL.5432\"\nSep 07 09:19:07 rocky8 postmaster[11995]: 2021-09-07 09:19:07.005 EAT [11995] LOG: redirecting log output to logging collector process\nSep 07 09:19:07 rocky8 postmaster[11995]: 2021-09-07 09:19:07.005 EAT [11995] HINT: Future log output will appear in directory \"log\".\nSep 07 09:19:07 rocky8 systemd[1]: Started PostgreSQL 11 database server.\n<\/code><\/pre>\n\n\n\n
Other Tutorials<\/h3>\n\n\n\n