IBM / CAST

CAST can enhance the system management of cluster-wide resources. It consists of the open source tools: cluster system management (CSM) and burst buffer.
Eclipse Public License 1.0
27 stars 34 forks source link

added in some enhancements related to the csm_db_utility.sh script. S… #964

Closed williammorrison2 closed 4 years ago

williammorrison2 commented 4 years ago

…ets up postgreSQL/server/configs on a node if not already setup.

Purpose

To help setup the PostgreSQL Server, configurations, and or users if not already setup

How to Test

Testing was done on a freshly installed node (compute in this example)

  1. Wanted to ensure that the repo was configured properly to access the PostgreSQL package(s).
  2. Make sure the /var/lib/pgsql/data/pg_hba.conf file exists in the directory.
  3. Make sure the /var/lib/pgsql/data/postgresql.conf file exists in the directory.
  4. Make sure that the original files (pg_hba.conf & postgresql.conf) are both backed up before making any changes to them (if applied)
  5. Make sure that the user are present after the script is executed.

Screenshots

Example of the output

This is for a newly generated PostgreSQL install (on a RHELS 7.6 node) with the added users.

[root@c650f06p09 sql]# ./csm_db_utility_setup_script.sh
------------------------------------------------------------------------------------------------------------------------
[Start   ] Welcome to CSM database utility setup script.
------------------------------------------------------------------------------------------------------------------------
[Info    ] Log Directory:                      | /tmp/csm_db_utility_setup_script.log
[Info    ] PostgreSQL RPMs:                    | Are not installed (Installing)
[Info    ] PostgreSQL RPMs:                    | Are now installed.
[Info    ] PostgreSQL Data Directory:          | /var/lib/pgsql/data/ already exists
[Info    ] Running:                            | The initdb setup
[Info    ] PostgreSQL pg_hba.conf file:        | /var/lib/pgsql/data/pg_hba.conf exists in directory
------------------------------------------------------------------------------------------------------------------------
[Info    ] The pg_hba.conf file                | is different from the newly generated script
[Info    ] The newly generated pg_hba.conf     | file will replace the existing one.
[Info    ] The previous pg_hba.conf file       | will saved to the following dir: /var/lib/pgsql/data/
[Info    ] PostgreSQL postgresql.conf file:    | /var/lib/pgsql/data/postgresql.conf already exists
[Info    ] The postgresql.conf file            | is different from the newly generated script
[Info    ] The newly generated postgresql.conf | file will replace the existing one.
[Info    ] The previous postgresql.conf file   | will saved to the following dir: /var/lib/pgsql/data/
------------------------------------------------------------------------------------------------------------------------
[Info    ] Restarting                          | The postgreSQL server.
[Info    ] PostgreSQL pg_hba.conf file:        | /var/lib/pgsql/data/pg_hba.conf exists in directory
[Info    ] PostgreSQL postgresql.conf file:    | /var/lib/pgsql/data/postgresql.conf exists in directory
[Info    ] PostgreSQL Version:                 | (9.2.24)
------------------------------------------------------------------------------------------------------------------------
[Info    ] PostgreSQL DB user:                 | root does not exist
[Info    ] PostgreSQL DB created user:         | root
[Info    ] PostgreSQL DB created user:         | csmdb
[Info    ] PostgreSQL DB created user:         | xcatadm
------------------------------------------------------------------------------------------------------------------------

This is another example using a newly installed node that is running RHELS 8.2.

[root@c650f99p16 sql]# ./csm_db_utility_setup_script.sh
------------------------------------------------------------------------------------------------------------------------
[Start   ] Welcome to CSM database utility setup script.
------------------------------------------------------------------------------------------------------------------------
[Info    ] Log Directory:                      | /tmp/csm_db_utility_setup_script.log
[Info    ] PostgreSQL RPMs:                    | Are not installed (Installing)
[Info    ] PostgreSQL RPMs:                    | Are now installed.
[Info    ] PostgreSQL Data Directory:          | /var/lib/pgsql/data/ already exists
[Info    ] Running:                            | The initdb setup
[Info    ] PostgreSQL pg_hba.conf file:        | /var/lib/pgsql/data/pg_hba.conf exists in directory
------------------------------------------------------------------------------------------------------------------------
[Info    ] The pg_hba.conf file                | is different from the newly generated script
[Info    ] The newly generated pg_hba.conf     | file will replace the existing one.
[Info    ] The previous pg_hba.conf file       | will saved to the following dir: /var/lib/pgsql/data/
[Info    ] PostgreSQL postgresql.conf file:    | /var/lib/pgsql/data/postgresql.conf already exists
[Info    ] The postgresql.conf file            | is different from the newly generated script
[Info    ] The newly generated postgresql.conf | file will replace the existing one.
[Info    ] The previous postgresql.conf file   | will saved to the following dir: /var/lib/pgsql/data/
------------------------------------------------------------------------------------------------------------------------
[Info    ] Restarting                          | The postgreSQL server.
[Info    ] PostgreSQL pg_hba.conf file:        | /var/lib/pgsql/data/pg_hba.conf exists in directory
[Info    ] PostgreSQL postgresql.conf file:    | /var/lib/pgsql/data/postgresql.conf exists in directory
[Info    ] PostgreSQL Version:                 | (10.6)
------------------------------------------------------------------------------------------------------------------------
[Info    ] PostgreSQL DB user:                 | root does not exist
[Info    ] PostgreSQL DB created user:         | root
[Info    ] PostgreSQL DB created user:         | csmdb
[Info    ] PostgreSQL DB created user:         | xcatadm
------------------------------------------------------------------------------------------------------------------------

If the PostgreSQL DB server is already up and running and the user runs the script, it will still check for the existing users and create them if they do not already exist.

[root@c650f06p09 sql]# ./csm_db_utility_setup_script.sh
------------------------------------------------------------------------------------------------------------------------
[Start   ] Welcome to CSM database utility setup script.
------------------------------------------------------------------------------------------------------------------------
[Info    ] Log Directory:                      | /tmp/csm_db_utility_setup_script.log
[Info    ] PostgreSQL RPMs:                    | Are already installed.
[Info    ] PostgreSQL Data Directory:          | /var/lib/pgsql/data/ already exists
[Info    ] PostgreSQL pg_hba.conf file:        | /var/lib/pgsql/data/pg_hba.conf already exists
[Info    ] PostgreSQL postgresql.conf file:    | /var/lib/pgsql/data/postgresql.conf already exists
[Info    ] PostgreSQL pg_hba.conf file:        | /var/lib/pgsql/data/pg_hba.conf exists in directory
[Info    ] PostgreSQL postgresql.conf file:    | /var/lib/pgsql/data/postgresql.conf exists in directory
[Info    ] PostgreSQL Version:                 | (9.2.24)
------------------------------------------------------------------------------------------------------------------------
[Info    ] PostgreSQL DB user:                 | root does not exist
[Info    ] PostgreSQL DB created user:         | root
[Info    ] PostgreSQL DB created user:         | csmdb
[Info    ] PostgreSQL DB created user:         | xcatadm
------------------------------------------------------------------------------------------------------------------------

This is the case if the user runs the script and the users already exist.

[root@c650f06p09 sql]# ./csm_db_utility_setup_script.sh
------------------------------------------------------------------------------------------------------------------------
[Start   ] Welcome to CSM database utility setup script.
------------------------------------------------------------------------------------------------------------------------
[Info    ] Log Directory:                      | /tmp/csm_db_utility_setup_script.log
[Info    ] PostgreSQL RPMs:                    | Are already installed.
[Info    ] PostgreSQL Data Directory:          | /var/lib/pgsql/data/ already exists
[Info    ] PostgreSQL pg_hba.conf file:        | /var/lib/pgsql/data/pg_hba.conf already exists
[Info    ] PostgreSQL postgresql.conf file:    | /var/lib/pgsql/data/postgresql.conf already exists
[Info    ] PostgreSQL pg_hba.conf file:        | /var/lib/pgsql/data/pg_hba.conf exists in directory
[Info    ] PostgreSQL postgresql.conf file:    | /var/lib/pgsql/data/postgresql.conf exists in directory
[Info    ] PostgreSQL Version:                 | (9.2.24)
------------------------------------------------------------------------------------------------------------------------
[Info    ] PostgreSQL DB user:                 | root already exists
[Info    ] PostgreSQL DB user:                 | csmdb already exists
[Info    ] PostgreSQL DB user:                 | xcatadm already exists
------------------------------------------------------------------------------------------------------------------------

Error Handling If the /etc/yum.repos.d is not cofigured correctly for accessing the appropriate packages, then the following error message will be displayed.

[root@c650f06p09 sql]# ./csm_db_utility_setup_script.sh
------------------------------------------------------------------------------------------------------------------------
[Start   ] Welcome to CSM database utility setup script.
------------------------------------------------------------------------------------------------------------------------
[Info    ] Log Directory:                      | /tmp/csm_db_utility_setup_script.log
[Info    ] PostgreSQL RPMs:                    | Are not installed (Installing)
[Error   ] PostgreSQL RPMs:                    | Are not installed.
[Info    ] Please check:                       | Your configuration settings or /etc/yum.repos.d repo.
[Info    ] Once the PostgreSQL RPMs:           | Are installed please re-run this script for setup
------------------------------------------------------------------------------------------------------------------------

If the /var/lib/pgsql/data/pg_hba.conf is not in the directory and or was removed accidentally and the csm_db_utility_setup_script.sh was ran, then this is the message that would display.

[root@c650f06p09 sql]# ./csm_db_utility_setup_script.sh
------------------------------------------------------------------------------------------------------------------------
[Start   ] Welcome to CSM database utility setup script.
------------------------------------------------------------------------------------------------------------------------
[Info    ] Log Directory:                      | /tmp/csm_db_utility_setup_script.log
[Info    ] PostgreSQL RPMs:                    | Are already installed.
[Info    ] PostgreSQL Data Directory:          | /var/lib/pgsql/data/ already exists
[Info    ] Running:                            | The initdb setup
[Error   ] File:                               | /var/lib/pgsql/data/pg_hba.conf does not exist in directory
[Info    ] Please ensure:                      | the pg_hba.conf exists for proper setup.
------------------------------------------------------------------------------------------------------------------------

If the /var/lib/pgsql/data/postgresql.conf is not in the directory and or was removed accidentally and the csm_db_utility_setup_script.sh was ran, then this is the message that would display.

[root@c650f06p09 sql]# ./csm_db_utility_setup_script.sh
------------------------------------------------------------------------------------------------------------------------
[Start   ] Welcome to CSM database utility setup script.
------------------------------------------------------------------------------------------------------------------------
[Info    ] Log Directory:                      | /tmp/csm_db_utility_setup_script.log
[Info    ] PostgreSQL RPMs:                    | Are already installed.
[Info    ] PostgreSQL Data Directory:          | /var/lib/pgsql/data/ already exists
[Info    ] Running:                            | The initdb setup
[Info    ] PostgreSQL pg_hba.conf file:        | /var/lib/pgsql/data/pg_hba.conf exists in directory
------------------------------------------------------------------------------------------------------------------------
[Info    ] The pg_hba.conf file                | is different from the newly generated script
[Info    ] The newly generated pg_hba.conf     | file will replace the existing one.
[Info    ] The previous pg_hba.conf file       | will saved to the following dir: /var/lib/pgsql/data/
[Error   ] File:                               | /var/lib/pgsql/data/postgresql.conf does not exist in directory
[Info    ] Please ensure:                      | the postgresql.conf file exists for proper setup.
------------------------------------------------------------------------------------------------------------------------

Open Questions and Pre-Merge TODOs