Purpose
You can use this statement to set the log restore source.
In addition, you can refer to this SQL statement when you obtain the information required by the LOG_RESTORE_SOURCE parameter in the CREATE STANDBY TENANT statement for creating an empty standby tenant.
The system log stream location of the primary tenant is the connection access point of the standby tenant. When you set the log restore source, you must first obtain the system log stream location of the primary tenant. You can query the DBA_OB_ACCESS_POINT view for the system log stream location of the primary tenant.
If you use the standby tenant in a single-server scenario, the system log stream location of the primary tenant is the address of the OBServer node on the single server.
Syntax
/* Set the log restore source when you create an empty standby tenant. */
ALTER SYSTEM SET LOG_RESTORE_SOURCE = "SERVICE=$host_ip_list USER=$user_name@$tenant_name PASSWORD=$password" [ TENANT = standby_tenant_name ];
/* Set or modify the log restore source when you create a standby tenant by restoring a physical backup. */
ALTER SYSTEM SET LOG_RESTORE_SOURCE ='LOCATION=archive_path' [ TENANT = standby_tenant_name ];
Note
Use spaces to separate subparameters. The system takes spaces as separators during subparameter parsing. Therefore, you cannot use a space within a subparameter.
For example, in LOG_RESTORE_SOURCE = "SERVICE=$host_ip_list USER=$user_name@$tenant_name PASSWORD=$password", the three subparameters SERVICE=$host_ip_list, USER=$user_name@$tenant_name, and PASSWORD=$password do not contain any spaces.
Parameters
| Parameter | Description |
|---|---|
| LOG_RESTORE_SOURCE | Configures the log restore source. |
| host_ip_list | The system log stream location of the primary tenant, which is the IP address and RPC port number of the OBServer node hosting the replica of the primary tenant or the source standby tenant. Separate multiple IP addresses with semicolons (;). The standby tenant detects the changes in the system log stream location of the primary tenant in seconds and automatically updates the location. You do not need to manually update LOG_RESTORE_SOURCE when load balancing or disaster recovery is performed on the primary tenant. |
| user_name | The name of the user created for replication purposes. When the standby tenant connects to the primary tenant, it must have the query permissions on certain system views in the primary tenant. Therefore, you need to create a dedicated replication user with the corresponding permissions for setting the log restore source. The user must have the read-only permissions on the following views in the primary tenant:
|
| password | The password of the user created for replication purposes. |
| tenant_name | The name of the primary tenant or the source standby tenant to be connected. |
| standby_tenant_name | The name of the standby tenant. You must specify the standby_tenant_name parameter if you are setting the log restore source in the sys tenant of the cluster where the standby tenant resides. |
| LOCATION | Specifies that the log restore source is a log archive. archive_path specifies the path of the primary log archive. |
Examples
Configure the log restore source for a standby tenant when you restore the standby tenant from a physical backup.
obclient> ALTER SYSTEM SET LOG_RESTORE_SOURCE='LOCATION=file:///data/1/example_archive'; Query OK, 0 rows affectedConfigure the log restore source in the sys tenant of the cluster where the standby tenant resides when you create an empty standby tenant.
Obtain the IP address list of the system log stream of the primary tenant
primary_tenant1in the primary tenant. The returned result depends on the number of replicas in the primary tenant.obclient> SELECT svr_ip, svr_port FROM GV$OB_LOG_STAT WHERE LS_ID=1; +-----------------+----------+ | svr_ip | svr_port | +-----------------+----------+ | 11.xxx.xxx.xxx | 17860 | +-----------------+----------+ 1 row in setSet the log restore source in the sys tenant of the cluster where the standby tenant
standby_tenant1resides.obclient> ALTER SYSTEM SET LOG_RESTORE_SOURCE = "SERVICE=11.xxx.xxx.xxx:17860; USER=test@mysql PASSWORD=******" TENANT = standby_tenant1;