Este conteúdo não está disponível no idioma selecionado.
Chapter 4. Deploying Service Registry storage in a PostgreSQL database
This chapter explains how to install, configure, and manage Service Registry data storage in a PostgreSQL database.
Prerequisites
4.1. Installing a PostgreSQL database from the OpenShift OperatorHub Copiar o linkLink copiado para a área de transferência!
If you do not already have a PostgreSQL database Operator installed, you can install a PostgreSQL Operator on your OpenShift cluster from the OperatorHub. The OperatorHub is available from the OpenShift Container Platform web console and provides an interface for cluster administrators to discover and install Operators. For more details, see Understanding OperatorHub.
Prerequisites
- You must have cluster administrator access to an OpenShift cluster.
Procedure
- In the OpenShift Container Platform web console, log in using an account with cluster administrator privileges.
-
Change to the OpenShift project in which you want to install the PostgreSQL Operator. For example, from the Project drop-down, select
my-project. - In the left navigation menu, click Operators and then OperatorHub.
-
In the Filter by keyword text box, enter
PostgreSQLto find an Operator suitable for your environment, for example, Crunchy PostgreSQL for OpenShift. - Read the information about the Operator, and click Install to display the Operator subscription page.
Select your subscription settings, for example:
- Update Channel: stable
- Installation Mode: A specific namespace on the cluster and then my-project
- Approval Strategy: Select Automatic or Manual
Click Install, and wait a few moments until the Operator is ready for use.
ImportantYou must read the documentation from your chosen PostgreSQL Operator for details on how to create and manage your database.
Additional resources
4.2. Configuring Service Registry with PostgreSQL database storage on OpenShift Copiar o linkLink copiado para a área de transferência!
This section explains how to configure storage for Service Registry on OpenShift using a PostgreSQL database Operator. You can install Service Registry in an existing database or create a new database, depending on your environment. This section shows a simple example using the PostgreSQL Operator by Dev4Ddevs.com.
Prerequisites
- You must have an OpenShift cluster with cluster administrator access.
- You must have already installed Service Registry. See Chapter 2, Installing Service Registry on OpenShift.
- You must have already installed a PostgreSQL Operator on OpenShift. For example, see Section 4.1, “Installing a PostgreSQL database from the OpenShift OperatorHub”.
Procedure
- In the OpenShift Container Platform web console, log in using an account with cluster administrator privileges.
-
Change to the OpenShift project in which Service Registry and your PostgreSQL Operator are installed. For example, from the Project drop-down, select
my-project. - Create a PostgreSQL database for your Service Registry storage. For example, click Installed Operators, PostgreSQL Operator by Dev4Ddevs.com, and then Create database.
Click YAML and edit the database settings as follows:
-
name: Change the value toregistry -
image: Change the value tocentos/postgresql-12-centos7
-
Edit any other database settings as needed depending on your environment, for example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click Create, and wait until the database is created.
- Click Installed Operators > Red Hat Integration - Service Registry > ApicurioRegistry > Create ApicurioRegistry.
Paste in the following custom resource definition, and edit the values for the database
urland credentials to match your environment:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click Create and wait for the Service Registry route to be created on OpenShift.
Click Networking > Route to access the new route for the Service Registry web console. For example:
http://example-apicurioregistry-sql.my-project.my-domain-name.com/
http://example-apicurioregistry-sql.my-project.my-domain-name.com/Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3. Backing up Service Registry PostgreSQL storage Copiar o linkLink copiado para a área de transferência!
When using storage in a PostgreSQL database, you must ensure that the data stored by Service Registry is backed up regularly.
SQL Dump is a simple procedure that works with any PostgreSQL installation. This uses the pg_dump utility to generate a file with SQL commands that you can use to recreate the database in the same state that it was in at the time of the dump.
pg_dump is a regular PostgreSQL client application, which you can execute from any remote host that has access to the database. Like any other client, the operations that can perform are limited to the user permissions.
Procedure
Use the
pg_dumpcommand to redirect the output to a file:pg_dump dbname > dumpfile
$ pg_dump dbname > dumpfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow You can specify the database server that
pg_dumpconnects to using the-h hostand-p portoptions.You can reduce large dump files using a compression tool, such as gzip, for example:
pg_dump dbname | gzip > filename.gz
$ pg_dump dbname | gzip > filename.gzCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
- For details on client authentication, see the PostgreSQL documentation.
- For details on importing and exporting registry content, see Managing Service Registry content using the REST API.
4.4. Restoring Service Registry PostgreSQL storage Copiar o linkLink copiado para a área de transferência!
You can restore SQL Dump files created by pg_dump using the psql utility.
Prerequisites
-
You must have already backed up your PostgreSQL datbase using
pg_dump. See Section 4.3, “Backing up Service Registry PostgreSQL storage”. - All users who own objects or have permissions on objects in the dumped database must already exist.
Procedure
Enter the following command to create the database:
createdb -T template0 dbname
$ createdb -T template0 dbnameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the following command to restore the SQL dump
psql dbname < dumpfile
$ psql dbname < dumpfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Run ANALYZE on each database so the query optimizer has useful statistics.