Purpose
This statement is used to create a user log stream.
Limitations and considerations
Currently, only regular user log streams can be created, and broadcast log streams are not supported.
The current version supports both homogeneous and heterogeneous zone modes for tenants:
In homogeneous zone mode, you must specify a Unit Group to create a log stream.
In heterogeneous zone mode, you must specify a UNIT_LIST to create a log stream.
For more information about the differences between homogeneous and heterogeneous zone modes, see Data distribution.
Creating a log stream can only be done on the main tenant. Additionally, the
STATUSandSWITCHOVER_STATUSof the tenant where the log stream will be created must both beNORMAL.When creating a log stream:
In homogeneous zone mode, the target
UNIT_GROUPmust be in theACTIVEstate, and the value of the targetUNIT_GROUP_IDin theDBA_OB_UNITSview must not be 0.In heterogeneous zone mode, the target
UNIT_LISTmust be in theACTIVEstate, and the specifiedUNIT_LISTmust not be empty.
When specifying the
PRIMARY_ZONEfor the log stream, ensure that the specified zone exists in theZONE_LISTof the tenant. For log streams, setting thePRIMARY_ZONEis slightly different from setting thePRIMARY_ZONEfor a tenant. A log stream can only have one zone specified, such asz1orz2, unlike a tenant which can have multiple zones likez1,z2,z1; z2, orRANDOM.Load balancing-related configurations are recommended to be disabled, i.e., set to
False. Otherwise:If the tenant-level configuration item enable_rebalance is enabled (value is
True), the created log stream will be migrated from the targetUNIT_GROUPto otherUNIT_GROUPs by the system.If the tenant-level configuration item enable_transfer is enabled (value is
True), the created log stream may be deleted.
Privilege requirements
The user executing this statement must have the ALTER SYSTEM privilege. For more information about OceanBase Database privileges, see Privilege classification in MySQL-compatible mode and Privilege classification in Oracle-compatible mode.
Syntax
ALTER SYSTEM CREATE LS
{UNIT_GROUP [=] unit_group_id} | {UNIT_LIST [=] (unit_id_list)}
[,PRIMARY_ZONE [=] 'zone_name']
[TENANT [=] 'tenant_name'];
Parameters
| Parameter | Description |
|---|---|
| unit_group_id | The ID of the target UNIT_GROUP for the log stream to be created. This parameter is applicable only in homogeneous zone mode. |
| unit_id_list | The list of units for the log stream to be created. Multiple unit IDs are separated by commas (,). This parameter is applicable only in heterogeneous zone mode. |
| zone_name | The primary zone for the log stream to be created. If PRIMARY_ZONE is not specified, the system will automatically select a zone. |
| tenant_name | Optional. The name of the tenant to be operated on.
NoticeOnly the sys tenant can specify other tenants. User tenants can only specify themselves. This statement does not support using |
Examples
Sys tenant
The sys tenant creates a log stream for the
obtenanttenant on theUNIT_GROUPwith ID 1001.obclient> ALTER SYSTEM CREATE LS UNIT_GROUP 1001 TENANT = obtenant;The sys tenant creates a log stream for the
obtenanttenant on theUNIT_GROUPwith ID 1001 and sets thePRIMARY_ZONEof the log stream toz1.obclient> ALTER SYSTEM CREATE LS UNIT_GROUP 1001, PRIMARY_ZONE 'z1' TENANT = obtenant;User tenant
The user tenant creates a log stream for itself on the
UNIT_GROUPwith ID 1001.obclient> ALTER SYSTEM CREATE LS UNIT_GROUP 1001;The user tenant creates a log stream for itself on the
UNIT_GROUPwith ID 1001 and sets thePRIMARY_ZONEof the log stream toz1.obclient> ALTER SYSTEM CREATE LS UNIT_GROUP 1001, PRIMARY_ZONE 'z1';
Sys tenant
The sys tenant creates a log stream for the
obtenanttenant on theUNIT_LISTwith IDs 1001, 1002, and 1003.obclient> ALTER SYSTEM CREATE LS UNIT_LIST = (1001,1002,1003) TENANT = obtenant;The sys tenant creates a log stream for the
obtenanttenant on theUNIT_LISTwith IDs 1001, 1002, and 1003 and sets thePRIMARY_ZONEof the log stream toz1.obclient> ALTER SYSTEM CREATE LS UNIT_LIST = (1001,1002,1003), PRIMARY_ZONE 'z1' TENANT = obtenant;User tenant
The user tenant creates a log stream for itself on the
UNIT_LISTwith IDs 1001, 1002, and 1003.obclient> ALTER SYSTEM CREATE LS UNIT_LIST = (1001,1002,1003);The user tenant creates a log stream for itself on the
UNIT_LISTwith IDs 1001, 1002, and 1003 and sets thePRIMARY_ZONEof the log stream toz1.obclient> ALTER SYSTEM CREATE LS UNIT_LIST = (1001,1002,1003), PRIMARY_ZONE 'z1';
References
For more information about how to create a log stream, see Create a log stream.