Dear Readers,
In this article, we will see the following Install PostgreSQL12 On SUSE Linux.
Steps to Follow :
- Logging to AWS Account
- Launch PostgreSQL EC2 Instance
- Connect to Linux EC2 Instance by Using Putty
- Add PostgreSQL Repository
- Install PostgreSQL 12
- Enable the PostgreSQL
- Start the PostgreSQL
- Switch to Postgres User
- Connect to the Default Database “postgres”
1. Logging to AWS Account
First, we need to AWS Console page by using below link.
https://aws.amazon.com/console/
Click on sign in to Console button.
Logging to aws account
Login using username & password and click on sign in.
Enter to AWS Management Console
We can see the AWS Management Console Dashboard.
Go to Services, under the compute module click EC2 service to open.
2. Launch PostgreSQL EC2 Instance
Go to Services, under the compute module click EC2 service to open.
We can launch Linux EC2 Instance by using below link.
We can see the Linux server has been launched successfully.
3. Connect to Linux EC2 Instance Using Putty
We can connect putty by using below link.
Connect to EC2 Instance Using Putty
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
login as: ec2-user Authenticating with public key "imported-openssh-key" SUSE Linux Enterprise Server 15 SP2 x86_64 (64-bit) As "root" (sudo or sudo -i) use the: - zypper command for package management - yast command for configuration management Management and Config: https://www.suse.com/suse-in-the-cloud-basics Documentation: https://www.suse.com/documentation/sles-15/ Forum: https://forums.suse.com/categories/suse-public-cloud Have a lot of fun... ec2-user@ip-172-31-36-121:~> |
4. Switch to root user
1 2 |
ec2-user@ip-172-31-36-121:~> sudo su ip-172-31-36-121:/home/ec2-user # |
5. Install Server Updates
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
ip-172-31-36-121:/home/ec2-user # zypper update -y Refreshing service 'Basesystem_Module_x86_64'. Refreshing service 'Containers_Module_x86_64'. Refreshing service 'Desktop_Applications_Module_x86_64'. Refreshing service 'Development_Tools_Module_x86_64'. Refreshing service 'Legacy_Module_x86_64'. Refreshing service 'Public_Cloud_Module_x86_64'. Refreshing service 'Python_2_Module_x86_64'. Refreshing service 'SUSE_Cloud_Application_Platform_Tools_Module_x86_64'. Refreshing service 'SUSE_Linux_Enterprise_Server_x86_64'. Refreshing service 'Server_Applications_Module_x86_64'. Refreshing service 'Web_and_Scripting_Module_x86_64'. Building repository 'SLE-Module-Basesystem15-SP2-Pool' cache ....................................[done] Retrieving repository 'SLE-Module-Basesystem15-SP2-Updates' metadata ............................[done] Building repository 'SLE-Module-Basesystem15-SP2-Updates' cache .................................[done] Building repository 'SLE-Module-Containers15-SP2-Pool' cache ....................................[done] Retrieving repository 'SLE-Module-Containers15-SP2-Updates' metadata ............................[done] Building repository 'SLE-Module-Containers15-SP2-Updates' cache .................................[done] Building repository 'SLE-Module-Desktop-Applications15-SP2-Pool' cache ..........................[done] Retrieving repository 'SLE-Module-Desktop-Applications15-SP2-Updates' metadata ..................[done] Building repository 'SLE-Module-Desktop-Applications15-SP2-Updates' cache .......................[done] Building repository 'SLE-Module-DevTools15-SP2-Pool' cache ......................................[done] Retrieving repository 'SLE-Module-DevTools15-SP2-Updates' metadata ..............................[done] Building repository 'SLE-Module-DevTools15-SP2-Updates' cache ...................................[done] Building repository 'SLE-Module-Legacy15-SP2-Pool' cache ........................................[done] Retrieving repository 'SLE-Module-Legacy15-SP2-Updates' metadata ................................[done] Building repository 'SLE-Module-Legacy15-SP2-Updates' cache .....................................[done] Building repository 'SLE-Module-Public-Cloud15-SP2-Pool' cache ..................................[done] Retrieving repository 'SLE-Module-Public-Cloud15-SP2-Updates' metadata ..........................[done] Building repository 'SLE-Module-Public-Cloud15-SP2-Updates' cache ...............................[done] Checking for file conflicts: ....................................................................[done] ( 1/64) Installing: adjtimex-1.29-1.26.x86_64 ...................................................[done] ( 2/64) Installing: adobe-sourcecodepro-fonts-2.030-1.30.noarch .................................[done] ( 3/64) Installing: cantarell-fonts-0.111-1.31.noarch ...........................................[done] ( 4/64) Installing: libmediacheck5-5.4-1.13.x86_64 ..............................................[done] ( 5/64) Installing: shared-python-startup-0.1-1.5.1.noarch ......................................[done] ( 6/64) Installing: time-1.9-1.15.x86_64 ........................................................[done] ( 7/64) Installing: wireless-regdb-2019.06.03-3.14.1.noarch .....................................[done] ( 8/64) Installing: gsettings-desktop-schemas-3.34.0-3.4.x86_64 .................................[done] (48/64) Installing: python3-3.6.12-3.70.1.x86_64 ................................................[done] (49/64) Installing: util-linux-lang-2.33.1-4.13.1.noarch ........................................[done] (50/64) Installing: python3-curses-3.6.12-3.70.1.x86_64 .........................................[done] (51/64) Installing: python3-dbm-3.6.12-3.70.1.x86_64 ............................................[done] (52/64) Installing: sound-theme-freedesktop-0.8-1.19.noarch .....................................[done] (53/64) Installing: crash-kmp-default-7.2.8_k5.3.18_24.24-18.2.1.x86_64 .........................[done] (54/64) Installing: yast2-migration-4.2.4-1.129.noarch ..........................................[done] (55/64) Installing: python3-pyOpenSSL-17.5.0-3.9.1.noarch .......................................[done] (56/64) Installing: python3-ec2imgutils-9.0.1-3.20.1.noarch .....................................[done] (57/64) Installing: libgio-2_0-0-2.62.6-3.3.1.x86_64 ............................................[done] (58/64) Installing: python3-urllib3-1.24-9.10.1.noarch ..........................................[done] (59/64) Installing: gio-branding-SLE-15-14.2.1.noarch ...........................................[done] (60/64) Installing: glib-networking-2.62.3-1.29.x86_64 ..........................................[done] (61/64) Installing: dconf-0.34.0-2.27.x86_64 ....................................................[done] (62/64) Installing: glib-networking-lang-2.62.3-1.29.noarch .....................................[done] (63/64) Installing: libdconf1-0.34.0-2.27.x86_64 ................................................[done] (64/64) Installing: gsettings-backend-dconf-0.34.0-2.27.x86_64 ..................................[done] Additional rpm output: Updating /etc/sysconfig/security ... Executing %posttrans scripts ....................................................................[done] There are running programs which still use files and libraries deleted or updated by recent upgrades. They should be restarted to benefit from the latest updates. Run 'zypper ps -s' to list these programs. Core libraries or services have been updated. Reboot is required to ensure that your system benefits from these updates. |
6. Add PostgreSQL Repository
Go to PostgreSQL official website by using below link.
Click on Download.
Select the Linux Operating System and click on SUSE Linux Distribution.
Click on Instructions.
Go to PostgreSQL 12 and copy the command for adding the PostgreSQL 12 repository.
Go to the Server Terminal and run the above command
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
ip-172-31-36-121:/home/ec2-user # zypper addrepo https://download.postgresql.org/pub/repos/zypp/repo/pgdg-sles-12.repo Adding repository 'PostgreSQL 12 SLES 15.2 - x86_64' ............................................[done] Repository 'PostgreSQL 12 SLES 15.2 - x86_64' successfully added URI : https://download.postgresql.org/pub/repos/zypp/12/suse/sles-15.2-x86_64 Enabled : Yes GPG Check : Yes Autorefresh : No Priority : 99 (default priority) Adding repository 'PostgreSQL 12 SLES 15.2 - x86_64' ............................................[done] Repository 'PostgreSQL 12 SLES 15.2 - x86_64' successfully added URI : https://download.postgresql.org/pub/repos/zypp/srpms/12/suse/sles-15.2-x86_64 Enabled : No GPG Check : Yes Autorefresh : No Priority : 99 (default priority) Adding repository 'PostgreSQL 12 SLES 15.2 - x86_64 - SRPM Updates testing' .....................[done] Repository 'PostgreSQL 12 SLES 15.2 - x86_64 - SRPM Updates testing' successfully added URI : https://download.postgresql.org/pub/repos/zypp/srpms/testing/12/suse/sles-15.2-x86_64 Enabled : No GPG Check : Yes Autorefresh : No Priority : 99 (default priority) Adding repository 'PostgreSQL 12 SLES 15.2 - x86_64 - Updates testing' ..........................[done] Repository 'PostgreSQL 12 SLES 15.2 - x86_64 - Updates testing' successfully added URI : https://download.postgresql.org/pub/repos/zypp/testing/12/suse/sles-15.2-x86_64 Enabled : No GPG Check : Yes Autorefresh : No Priority : 99 (default priority) Repository priorities are without effect. All enabled repositories share the same priority. |
7. Install PostgreSQL 12
Go to PostgreSQL 12 and copy the installation command.
Go back to terminal and run the installation command
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
ip-172-31-36-121:/home/ec2-user # zypper install postgresql12-server Refreshing service 'Basesystem_Module_x86_64'. Refreshing service 'Containers_Module_x86_64'. Refreshing service 'Desktop_Applications_Module_x86_64'. Refreshing service 'Development_Tools_Module_x86_64'. Refreshing service 'Legacy_Module_x86_64'. Refreshing service 'Public_Cloud_Module_x86_64'. Refreshing service 'Python_2_Module_x86_64'. Refreshing service 'SUSE_Cloud_Application_Platform_Tools_Module_x86_64'. Refreshing service 'SUSE_Linux_Enterprise_Server_x86_64'. Refreshing service 'Server_Applications_Module_x86_64'. Refreshing service 'Web_and_Scripting_Module_x86_64'. New repository or package signing key received: Repository: PostgreSQL 12 SLES 15.2 - x86_64 Key Name: PostgreSQL RPM Building Project <pgsqlrpms-hackers@pgfoundry.org> Key Fingerprint: 68C9E2B9 1A37D136 FE74D176 1F16D2E1 442DF0F8 Key Created: Tue Jan 8 21:59:38 2008 Key Expires: (does not expire) Subkey: 783AA47CD43F1AF8 2008-01-08 [does not expire] Rpm Name: gpg-pubkey-442df0f8-4783f24a Do you want to reject the key, trust temporarily, or trust always? [r/t/a/?] (r): a Building repository 'PostgreSQL 12 SLES 15.2 - x86_64' cache ....................................[done] Loading repository data... Reading installed packages... Resolving package dependencies... The following 5 NEW packages are going to be installed: libpq5 postgresql postgresql-server postgresql12 postgresql12-server The following 2 recommended packages were automatically selected: postgresql12 postgresql12-server The following 4 packages need additional customer contract to get support: postgresql postgresql-server postgresql12 postgresql12-server 5 new packages to install. Overall download size: 6.2 MiB. Already cached: 0 B. After the operation, additional 27.5 MiB will be used. Continue? [y/n/v/...? shows all options] (y): y Retrieving package libpq5-12.5-8.10.1.x86_64 (1/5), 175.1 KiB (705.0 KiB unpacked) Retrieving: libpq5-12.5-8.10.1.x86_64.rpm .......................................................[done] Retrieving package postgresql-12.0.1-4.3.2.noarch (2/5), 14.4 KiB ( 713 B unpacked) Retrieving: postgresql-12.0.1-4.3.2.noarch.rpm ..................................................[done] Retrieving package postgresql12-12.5-8.10.1.x86_64 (3/5), 1.5 MiB ( 6.0 MiB unpacked) Retrieving: postgresql12-12.5-8.10.1.x86_64.rpm .................................................[done] Retrieving package postgresql-server-12.0.1-4.3.2.noarch (4/5), 22.3 KiB ( 4.6 KiB unpacked) Retrieving: postgresql-server-12.0.1-4.3.2.noarch.rpm ...........................................[done] Retrieving package postgresql12-server-12.5-8.10.1.x86_64 (5/5), 4.6 MiB ( 20.8 MiB unpacked) Retrieving: postgresql12-server-12.5-8.10.1.x86_64.rpm .............................[done (15.7 KiB/s)] Checking for file conflicts: ....................................................................[done] (1/5) Installing: libpq5-12.5-8.10.1.x86_64 .....................................................[done] (2/5) Installing: postgresql-12.0.1-4.3.2.noarch ................................................[done] (3/5) Installing: postgresql12-12.5-8.10.1.x86_64 ...............................................[done] (4/5) Installing: postgresql-server-12.0.1-4.3.2.noarch .........................................[done] Additional rpm output: Updating /etc/sysconfig/postgresql ... (5/5) Installing: postgresql12-server-12.5-8.10.1.x86_64 ........................................[done] Executing %posttrans scripts ....................................................................[done] |
Check the Version of PostgreSQL
1 2 |
ip-172-31-36-121:/home/ec2-user # psql -V psql (PostgreSQL) 12.5 |
8. Enable PostgreSQL
1 2 |
ip-172-31-36-121:/home/ec2-user # systemctl enable postgresql Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /usr/lib/systemd/system/postgresql.service. |
9. Start the PostgreSQL
1 |
ip-172-31-36-121:/home/ec2-user # systemctl start postgresql |
Check the Status of PostgreSQL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
ip-172-31-36-121:/home/ec2-user # systemctl status postgresql ● postgresql.service - PostgreSQL database server Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2020-12-30 03:14:04 UTC; 2s ago Process: 14764 ExecStart=/usr/share/postgresql/postgresql-script start (code=exited, status=0/SUCCES> Main PID: 14787 (postgres) Tasks: 8 CGroup: /system.slice/postgresql.service ├─14787 /usr/lib/postgresql12/bin/postgres -D /var/lib/pgsql/data ├─14788 postgres: logger ├─14790 postgres: checkpointer ├─14791 postgres: background writer ├─14792 postgres: walwriter ├─14793 postgres: autovacuum launcher ├─14794 postgres: stats collector └─14795 postgres: logical replication launcher Dec 30 03:14:01 ip-172-31-36-121 systemd[1]: Starting PostgreSQL database server... Dec 30 03:14:02 ip-172-31-36-121 postgresql-script[14764]: Initializing PostgreSQL 12.5 at location /v> Dec 30 03:14:04 ip-172-31-36-121 postgresql-script[14764]: 2020-12-30 03:14:04.374 UTC [14787]LOG: > Dec 30 03:14:04 ip-172-31-36-121 postgresql-script[14764]: 2020-12-30 03:14:04.375 UTC [14787]LOG: > Dec 30 03:14:04 ip-172-31-36-121 postgresql-script[14764]: 2020-12-30 03:14:04.375 UTC [14787]LOG: > Dec 30 03:14:04 ip-172-31-36-121 postgresql-script[14764]: 2020-12-30 03:14:04.376 UTC [14787]LOG: > Dec 30 03:14:04 ip-172-31-36-121 postgresql-script[14764]: 2020-12-30 03:14:04.379 UTC [14787]LOG: > Dec 30 03:14:04 ip-172-31-36-121 postgresql-script[14764]: 2020-12-30 03:14:04.390 UTC [14787]LOG: > Dec 30 03:14:04 ip-172-31-36-121 postgresql-script[14764]: 2020-12-30 03:14:04.390 UTC [14787]HINT: > Dec 30 03:14:04 ip-172-31-36-121 systemd[1]: Started PostgreSQL database server. |
Note :
When you install the postgres one user and database will be created postgres.
10. Switch to Postgres User
1 2 3 |
ip-172-31-36-121:/home/ec2-user # su - postgres postgres@ip-172-31-36-121:~> pwd /var/lib/pgsql |
11. Connect to the default Database “postgres”
1 2 3 4 5 |
postgres@ip-172-31-36-121:~> psql psql (12.5) Type "help" for help. postgres=# |
Check the Version of PostgreSQL
1 2 3 4 5 |
postgres=#SELECT version(); version -------------------------------------------------------------------------------------- PostgreSQL 12.5 on x86_64-suse-linux-gnu, compiled by gcc (SUSE Linux) 7.5.0, 64-bit (1 row) |
Check the List of the Databases
1 2 3 4 5 6 7 8 9 10 |
postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (3 rows) |
Check the List of Users
1 2 3 4 5 |
postgres=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} |
Check the Current User
1 2 |
postgres=# \conninfo You are connected to database "postgres" as user "postgres" via socket in "/var/run/postgresql" at port "5432". |
Exit from the Cluster
1 2 |
postgres=# \q postgres@ip-172-31-36-121:~> |
Thank you for giving your valuable time to read the above information.
Follow us on
Website : www.ktexperts.com
Facebook Page : KTexperts
Linkedin Page : KT EXPERTS
Follow Me
Ramesh’s Linkedin : Ramesh Atchala