How to install postgres database server on LinuxONE Community Cloud

Open source software is increasingly becoming available on the mainframe(IBM z/LinuxONE). PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance.

There are benefits running Postgres, the features is aimed to help developers build applications, administrators to protect data integrity and build fault-tolerant environments, and help you manage data no matter how big or small the dataset. In this tutorial, we’ll be using Rhel 8 and Sles 15, which are popular Linux Platform compatible to LinuxONE machine. Some steps might be little different if you are using different architecture

Prerequisites

  1. Request access to LinuxONE Community Cloud. Follow instructions here

Step 1: Install postgres database server on LinuxONE Community Cloud

1.3 Install postgresql

For RHEL:

# sudo yum install postgresql-server

For SLES:

# sudo zypper install postgresql-server

Step 2: Configure Postgresql server

2.1 Start postgresql service

# sudo system start postgresql.service 

2.2 Enable postgres

# sudo system enable postgresql.service 

2.3 Check status of the postgresql server

# sudo systemctl status postgresql.service 

Optional - Output should look like this

alt text

Step 3: Connect to Postgresql Database

3.1 Change the user to default postgres user

# sudo su - postgres 

alt text

3.2 Enter command "psql" to get to postgresql command line

# psql 

alt text

3.3 Check connection

# \conninfo

alt text

3.4 Check postgres version

# SELECT VERSION();

alt text

Step 4: Interact with Postgresql Database

4.1 Create a table called persons

# CREATE TABLE persons; 

alt text

4.2 Check the table data

# SELECT * FROM persons; 

alt text

4.3 Insert data into the table

# INSERT INTO persons(fname,lname,email) VALUES('elvin', 'maditsi', 'elvin@postgres.com'); 

alt text

4.4 List data on table

# SELECT * FROM persons; 

alt text