The log storage service provides highly available and reliable log storage and read/write capabilities for the Physical Standby Database solution. The log storage service supports both a single replica and multiple replicas and provides high availability based on the Paxos protocol.
Working modes of log streams
Log storage services for primary and standby tenants work in two different modes.
APPENDmodePrimary tenants support the
APPENDmode. In this mode, the log stream leader of a primary tenant receives data written by upper-layer modules such as transactions and DDL operations, and synchronizes and persists the data across multiple replicas of the primary tenant based on the Paxos protocol. If a failure occurs during data synchronization, persistence of the written data may fail. The log storage service automatically handles various failures to provide high availability.During data synchronization, a unique log sequence number (LSN) and system change number (SCN) are generated for each log entry in the primary tenant. The LSN indicates the physical location of the log entry in the storage service. The SCN indicates the time sequence relationship of the log entry in the storage service. An upper-layer service can determine the sequence of logs in multiple log streams based on SCNs.
RAW_WRITEmodeStandby tenants support the
RAW_WRITEmode. In this mode, the log stream leader of a standby tenant rejects data written by upper-layer modules. It only allows the log transfer service to synchronize physical logs from the primary tenant. The content, LSNs, and SCNs of the physical logs are generated by the primary tenant.The physical logs synchronized from the primary tenant are synchronized and persisted across multiple replicas of the log storage service of the standby tenant based on the Paxos protocol.
In addition to the APPEND and RAW_WRITE modes, log streams can also work in PREPARE_FLASHBACK or FLASHBACK mode during a failover operation. For more information about the failover operation, see Failover.
View the working mode of log streams of a primary tenant
Log on as the administrator to the primary tenant or the
systenant of the cluster where the primary tenant resides.Execute the following statement to query the value of
TENANT_IDof the primary tenant.systenantSELECT TENANT_ID,TENANT_NAME FROM oceanbase.DBA_OB_TENANTS;The query result is as follows:
+-----------+-------------+ | TENANT_ID | TENANT_NAME | +-----------+-------------+ | 1 | sys | | 1001 | META$1002 | | 1002 | mysql | | 1003 | META$1004 | | 1004 | oracle | +-----------+-------------+ 5 rows in setPrimary tenant
MySQL mode
SELECT TENANT_ID,TENANT_NAME FROM oceanbase.DBA_OB_TENANTS;The query result is as follows:
+-----------+-------------+ | TENANT_ID | TENANT_NAME | +-----------+-------------+ | 1002 | mysql | +-----------+-------------+ 1 row in setOracle mode
SELECT TENANT_ID,TENANT_NAME FROM SYS.DBA_OB_TENANTS;The query result is as follows:
+-----------+-------------+ | TENANT_ID | TENANT_NAME | +-----------+-------------+ | 1004 | oracle | +-----------+-------------+ 1 row in set
Execute the following statement to query the working mode of log streams of the primary tenant.
MySQL mode
SELECT TENANT_ID, LS_ID, SVR_IP, SVR_PORT, ROLE, ACCESS_MODE FROM oceanbase.GV$OB_LOG_STAT WHERE TENANT_ID = 1002;Oracle mode
SELECT TENANT_ID, LS_ID, SVR_IP, SVR_PORT, ROLE, ACCESS_MODE FROM SYS.GV$OB_LOG_STAT WHERE TENANT_ID = 1004;
The query result is as follows:
Notice
By default, log streams work in RAW_WRITE mode. Therefore, when a load balancing task is being executed in the primary tenant, the ACCESS_MODE of a log stream replica is also RAW_WRITE.
+-----------+-------+-------------+----------+----------+-------------+
| TENANT_ID | LS_ID | SVR_IP | SVR_PORT | ROLE | ACCESS_MODE |
+-----------+-------+-------------+----------+----------+-------------+
| 1002 | 1 | xx.xx.xx.xx | 17854 | LEADER | APPEND |
| 1002 | 1001 | xx.xx.xx.xx | 17854 | LEADER | APPEND |
| 1002 | 1 | xx.xx.xx.xx | 17858 | FOLLOWER | APPEND |
| 1002 | 1001 | xx.xx.xx.xx | 17858 | FOLLOWER | APPEND |
| 1002 | 1 | xx.xx.xx.xx | 17856 | FOLLOWER | APPEND |
| 1002 | 1001 | xx.xx.xx.xx | 17856 | FOLLOWER | APPEND |
+-----------+-------+-------------+----------+----------+-------------+
6 rows in set
View the working mode of log streams of a standby tenant
Log on as the administrator to the standby tenant or the
systenant of the cluster where the standby tenant resides.Execute the following statement to query the value of
TENANT_IDof the standby tenant:systenantSELECT TENANT_ID,TENANT_NAME FROM oceanbase.DBA_OB_TENANTS;The query result is as follows:
+-----------+-------------+ | TENANT_ID | TENANT_NAME | +-----------+-------------+ | 1 | sys | | 1003 | META$1002 | | 1004 | mysql | | 1005 | META$1004 | | 1006 | oracle | +-----------+-------------+ 5 rows in setStandby tenant
MySQL mode
SELECT TENANT_ID,TENANT_NAME FROM oceanbase.DBA_OB_TENANTS;The query result is as follows:
+-----------+-------------+ | TENANT_ID | TENANT_NAME | +-----------+-------------+ | 1004 | mysql | +-----------+-------------+ 1 row in setOracle mode
SELECT TENANT_ID,TENANT_NAME FROM SYS.DBA_OB_TENANTS;The query result is as follows:
+-----------+-------------+ | TENANT_ID | TENANT_NAME | +-----------+-------------+ | 1006 | oracle | +-----------+-------------+ 1 row in set
Execute the following statement to query the working mode of log streams of the standby tenant.
MySQL mode
SELECT TENANT_ID, LS_ID, SVR_IP, SVR_PORT, ROLE, ACCESS_MODE FROM oceanbase.GV$OB_LOG_STAT WHERE TENANT_ID = 1004;Oracle mode
SELECT TENANT_ID, LS_ID, SVR_IP, SVR_PORT, ROLE, ACCESS_MODE FROM SYS.GV$OB_LOG_STAT WHERE TENANT_ID = 1006;
The query result is as follows:
+-----------+-------+-------------+----------+----------+-------------+ | TENANT_ID | LS_ID | SVR_IP | SVR_PORT | ROLE | ACCESS_MODE | +-----------+-------+-------------+----------+----------+-------------+ | 1004 | 1 | xx.xx.xx.xx | 17858 | FOLLOWER | RAW_WRITE | | 1004 | 1001 | xx.xx.xx.xx | 17858 | FOLLOWER | RAW_WRITE | | 1004 | 1 | xx.xx.xx.xx | 17854 | LEADER | RAW_WRITE | | 1004 | 1001 | xx.xx.xx.xx | 17854 | LEADER | RAW_WRITE | | 1004 | 1 | xx.xx.xx.xx | 17856 | FOLLOWER | RAW_WRITE | | 1004 | 1001 | xx.xx.xx.xx | 17856 | FOLLOWER | RAW_WRITE | +-----------+-------+-------------+----------+----------+-------------+ 6 rows in set
Roles of log stream replicas
Replicas in a Paxos group of a primary or standby tenant have one of the two roles: leader and follower. You can query the ROLE field in the GV$OB_LOG_STAT view to check whether a log stream replica is a leader or a follower.
Business data of a primary tenant is written to the log stream leader and then synchronized to all followers. The log stream leader of a standby tenant synchronizes logs from the primary tenant by using the log transfer service and then synchronizes the logs to the followers in the Paxos group.
Storage space management
The log storage service separately manages the storage space of each primary or standby tenant.
When you create a unit specification for a primary or standby tenant, you can use the LOG_DISK_SIZE parameter in the CREATE RESOURCE UNIT statement to specify the storage space of the log disk. If you do not specify the LOG_DISK_SIZE parameter, the default size of the log disk is three times the memory size, and the minimum size of the log disk is 2 GB. For more information about how to create a unit, see Create a tenant.
You can check the log disk storage space that is available for a primary or standby tenant and that is already used by the primary or standby tenant by querying the GV$OB_UNITS view.
Log on as the administrator to the primary or standby tenant or the
systenant of the cluster where the primary or standby tenant resides.Execute the following statement to query the value of
TENANT_IDof the tenant.systenantSELECT TENANT_ID,TENANT_NAME FROM oceanbase.DBA_OB_TENANTS;The query result is as follows:
+-----------+-------------+ | TENANT_ID | TENANT_NAME | +-----------+-------------+ | 1 | sys | | 1003 | META$1002 | | 1004 | mysql | | 1005 | META$1004 | | 1006 | oracle | +-----------+-------------+ 5 rows in setPrimary or standby tenant
MySQL mode
SELECT TENANT_ID,TENANT_NAME FROM oceanbase.DBA_OB_TENANTS;The query result is as follows:
+-----------+-------------+ | TENANT_ID | TENANT_NAME | +-----------+-------------+ | 1004 | mysql | +-----------+-------------+ 1 row in setOracle mode
SELECT TENANT_ID,TENANT_NAME FROM SYS.DBA_OB_TENANTS;The query result is as follows:
+-----------+-------------+ | TENANT_ID | TENANT_NAME | +-----------+-------------+ | 1006 | oracle | +-----------+-------------+ 1 row in set
Execute the following statement to query the log disk storage space available for the primary or standby tenant and the actual usage.
MySQL mode
SELECT SVR_IP, SVR_PORT, TENANT_ID, LOG_DISK_SIZE, LOG_DISK_IN_USE FROM oceanbase.GV$OB_UNITS WHERE TENANT_ID = 1004;The query result is as follows:
+----------------+----------+-----------+---------------+-----------------+ | SVR_IP | SVR_PORT | TENANT_ID | LOG_DISK_SIZE | LOG_DISK_IN_USE | +----------------+----------+-----------+---------------+-----------------+ | xx.xx.xx.xx | 2882 | 1004 | 17394617549 | 1029179660 | | xx.xx.xx.xx | 17856 | 1004 | 17394617549 | 1029177240 | | xx.xx.xx.xx | 17858 | 1004 | 17394617549 | 1029177966 | +----------------+----------+-----------+---------------+-----------------+ 3 rows in setOracle mode
SELECT SVR_IP, SVR_PORT, TENANT_ID, LOG_DISK_SIZE, LOG_DISK_IN_USE FROM SYS.GV$OB_UNITS WHERE TENANT_ID = 1006;The query result is as follows:
+-------------+----------+-----------+---------------+-----------------+ | SVR_IP | SVR_PORT | TENANT_ID | LOG_DISK_SIZE | LOG_DISK_IN_USE | +-------------+----------+-----------+---------------+-----------------+ | xx.xx.xx.xx | 17854 | 1006 | 5798205850 | 1437200613 | | xx.xx.xx.xx | 17856 | 1006 | 5798205850 | 1437196109 | | xx.xx.xx.xx | 17858 | 1006 | 5798205850 | 1437196109 | +-------------+----------+-----------+---------------+-----------------+ 3 rows in set
You can also adjust the unit specification of the primary or standby tenant to resize the storage space of the log disk. For more information, see Modify the unit configs for a tenant.