If you need to create one or more EDB Postgres databases in the post installation phase,
go through this procedure to create and initialize a database.
About this task
You are given the steps to set up the environment and extract information that you use
later in the script prompts, which create and initialize the project database. If you need to
create one or more EDB Postgres databases in this post installation phase, go through this procedure
to create and initialize a database. Get the most current PostgreSQL scripts from the
/ACA/configuration-ha directory in your copy of the cert-kubernetes repository.
The PostgreSQL scripts are located in the PG subdirectory.
Procedure
-
Get the CP4BA EDB Postgres connection information.
oc extract -n <namespace> secret/postgres-cp4ba-superuser --to=-
You need to use the host, port, user, and password when you run the script later.
- Get the database information for ADP.
oc extract -n <namespace> secret/aca-basedb --to=-
For example,
oc extract -n cp4ba secret/aca-basedb --to=-
# PROJ2_DB_CONFIG
acauser
# BASE_DB_CONFIG
acauser
# BASE_DB_USER
acauser
# PROJ1_DB_CONFIG
acauser
From the example, the details are:
- The BASEDB username and password (for BASE_DB_USER and BASE_DB_CONFIG) is
acauser/acauser
.
- The Project1 username and password (for PROJ1_DB_CONFIG) is
proj1/acauser
.
- The Project2 username and password (for PROJ2_DB_CONFIG) is
proj2/acauser
.
Note: The Project database name is based on the PROJ<x>_DB_CONFIG key. In this example, they
are proj1
and proj2
.
The database names are predefined.
- The ADP base database name is
adpbase
.
- The ADP project database names are based on the PROJ<x>_DB_CONFIG key. If you have
PROJ1_DB_CONFIG and PROJ2_DB_CONFIG in the secret, then you have
proj1
and
proj2
as project databases.
The ontology name follows the same convention as the project database name. In this example, the
ontology names are proj1
and proj2
.
Tip: Follow the naming convention that you currently have for database names and
database usernames.
- Note the location of the clientcert.pem and
clientkey.pem certificates:
- /var/lib/postgresql/data/CA_DB_scripts/PG/clientcert.pem
- /var/lib/postgresql/data/CA_DB_scripts/PG/clientkey.pem
- Copy the PostgreSQL script into the
postgres
pod with the following
commands.
- Access the
postgres-cp4ba-1
pod and create a temporary directory like
adp_2400.
oc rsh postgres-cp4ba-1
mkdir -p /var/lib/postgresql/data/adp_2400
exit
- Create a directory for each new database tablespace. Save the directory path, which is
used when the script is run later.
In the example, a tablespace directory is created for a new project database, which is
proj3.
oc rsh postgres-cp4ba-1
mkdir -p /var/lib/postgresql/data/proj3
exit
- From the ACA/configuration-ha directory, copy the
PG directory into the directory that you created in the previous step. As an
example, adp_2400.
oc cp PG postgres-cp4ba-1:/var/lib/postgresql/data/adp_2400
- Access the
postgres-cp4ba-1
pod and go to the
/var/lib/postgresql/data/adp_2400/PG directory.
- From the PG directory, run the AddTenant.sh
script to create and initialize the project database. When the script prompts for a project ID,
provide a value that is not being used by an existing project. Answer the prompts with the
information that you collected in the previous steps.
What to do next
Update the secrets next. Go to Updating the database
secret.