PostgreSQL is an object-relational database management system based on POSTGRES 4.2.
For more information, check the official documentation here.
For information on how to use the Initialization parameter, please refer to the Use Cases section of the documentation.
Create a new server¶
The app requires to set the parameter Database path, which is used to import the PostgreSQL database folder from a UCloud workspace. If the folder is empty, a new database will be initialized. In this case, after the initialization procedure is completed, the following lines will be displayed in the output logs:
PostgreSQL init process complete; ready for start up. 2021-05-31 08:38:57.015 CEST  LOG: starting PostgreSQL 13.3 (Debian 13.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit 2021-05-31 08:38:57.016 CEST  LOG: listening on IPv4 address "0.0.0.0", port 5432 2021-05-31 08:38:57.016 CEST  LOG: listening on IPv6 address "::", port 5432 2021-05-31 08:38:57.134 CEST  LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2021-05-31 08:38:57.475 CEST  LOG: database system was shut down at 2021-05-31 08:38:56 CEST 2021-05-31 08:38:57.487 CEST  LOG: database system is ready to accept connections
The name of the PostgreSQL superuser is "ucloud". By default, the database name and the superuser password are both equal to "ucloud". These can be changed using the parameters Password (or Password file) and Database name, respectively.
Additional arguments for the database initialization can be passed as a string using the parameter Initialization.
In order to access and modify the PostgreSQL server, the user should open the app terminal interface and access the database with the command:
$ psql <db>
<db> must be replaced with the name of the database. There is no need to add the admin password to login from the app terminal.
Connect to the server¶
As discussed above, the user can access the PostgreSQL console directly from the app terminal interface. However, it is also possible to connect to the server using an external client application.
On the one hand, if the client application runs within another interactive app available on UCloud (see, e.g., OmniDB), one can connect directly to the PostgreSQL server as outlined here. In this case the server hostname is configured as an external parameter via the option Connect to other jobs.
On the other hand, if the PosgreSQL client is a third-party application, which is not deployed on UCloud, it is necessary to assign a static IP address to the server, using the corresponding option Add public IP. In addition, it is necessary to edit the client configuration file
pg_hba.conf and change the lines referring to the host as reported below:
# IPv4 local connections: host all all 0.0.0.0/0 md5 # IPv6 local connections: host all all ::0/0 md5
Notice that, by default, the main configuration file
postgresql.conf, located in the database folder, is created with the line:
listen_address = '*'. This setting allows connections from any client IP address.
By default remote access to the PostgreSQL server is established via a TCP/IP connection over port
5432. The same port should be open on the network firewall of the public IP address.