To use the application connection switch feature, set the information shown below when connecting the database.
Specify the IP address or host name that will be used to configure the database multiplexing system.
A port number used by each database server to listen for connections from applications.
In each client interface, multiple port numbers can be specified, however in the format shown below, for example:
host1,host2:port2
JDBC and .NET
If only one port number is specified, it will be assumed that host1: 27500 (the default value) and host2:port2 were specified.
Omit all port numbers, or specify only one per server.
Others
If only one port number is specified, it will be assumed that the same port is used for all the hosts.
From the specified connection destination server information, specify the selection sequence of the servers to which the application will connect. The values specified for the target server have the meanings shown below. If a value is omitted, "any" will be assumed.
The primary server is selected as the connection target from the specified "IP addresses or host names". Specify this to perform tasks that can be performed only on the primary server, such as applications in line with updates, or management tasks such as REINDEX and VACUUM.
The standby server is selected as the connection target from the specified "IP addresses or host names". On standby server, the update will always fail. If the target server is not standby, the JDBC driver will throw an error stating that it is unable to find a server with the specified targetServerType.
The primary server is selected preferentially as the connection target from the specified "IP addresses or host names". If there is no primary server, the application will connect to the standby server.
The standby server is selected preferentially as the connection target from the specified "IP addresses or host names". If there is no standby server, the application will connect to the primary server.
This method is not recommended in database multiplexing systems. This is because, although the connection destination server is selected in the specified sequence from the specified "IP addresses or host names", if the server that was successfully connected to first is the standby server, the write operations will always fail.
The table below shows the server selection order values to set for each driver:
Server selection order | JDBC drivers | .NET Data Provider | Other drivers |
---|---|---|---|
Primary server | "primary"(*1) | "read-write"(*1) "primary"(*2) | "read-write"(*1) "primary"(*2) |
Standby server | "secondary"(*2) | "standby" "read-only"(*2) | "standby" "read-only"(*2) |
Priority given to a primary server | "preferPrimary"(*3) | "prefer-primary" | - |
Priority given to a standby server | "preferSecondary"(*2) | "prefer-standby" | "prefer-standby"(*4) |
Any | "any" | "any" | "any" |
*1: The primary server whose default transaction mode is read-only is not selected.
*2: The primary server whose default transaction mode is read-only is also selected.
*3: Prefer primary servers whose default transaction mode is read-write.
*4: While it is possible to specify "prefer-read" instead of "prefer-standby" for compatibility with Fujitsu Enterprise Postgres 13 and earlier, this is not recommended.
To perform SSL authentication by creating the same server certificate for each server in a multiplexing system, specify the SSL server certificate Common Name (CN) in this parameter. Accordingly, SSL authentication using the CN can be performed without having to consider the names of the multiple servers contained in the multiplexing system.