Purpose
This statement is used to create a user log stream.
Limitations and considerations
Currently, only normal user log streams can be created; broadcast log streams are not supported.
The current version supports both homogeneous zone mode and heterogeneous zone mode for tenants:
In homogeneous zone mode, you must specify a unit group to create a log stream.
In heterogeneous zone mode, you must specify UNIT_LIST to create a log stream.
For more information about the differences between homogeneous zone mode and heterogeneous zone mode, see Data distribution.
Log stream creation can only be performed on the primary tenant. The
STATUSandSWITCHOVER_STATUSof the tenant for which you want to create a log stream must beNORMAL.When creating a log stream:
In homogeneous zone mode, the status of the target
UNIT_GROUPmust beACTIVE, and the value of the targetUNIT_GROUP_IDin theDBA_OB_UNITSview must not be 0.In heterogeneous zone mode, the status of the target
UNIT_LISTmust beACTIVE, and the specified targetUNIT_LISTcannot be empty.
When specifying
PRIMARY_ZONEfor a log stream to be created, ensure that the specified zone is included in the tenant'sZONE_LIST. Setting thePRIMARY_ZONEfor a log stream differs slightly from setting it for a tenant. A log stream can only be assigned one zone, such asz1orz2, and cannot be set toz1,z2,z1; z2, orRANDOMas a tenant can.It is recommended to disable load balancing-related parameters, that is, set their values to
False. Otherwise:When the tenant-level parameter enable_rebalance is enabled, that is, its value is
True, the created log streams will be migrated by the system from the targetUNIT_GROUPto otherUNIT_GROUPS.If the tenant-level parameter enable_transfer is enabled, that is, its value is
True, the created log streams may be deleted.
Privilege requirements
The user executing this statement must have the ALTER SYSTEM privilege. For more information about OceanBase AI Database privileges, see Permission classification.
Syntax
ALTER SYSTEM CREATE LS
{UNIT_GROUP [=] unit_group_id} | {UNIT_LIST [=] (unit_id_list)}
[,PRIMARY_ZONE [=] 'zone_name']
[TENANT [=] 'tenant_name'];
Parameters
Parameters |
Description |
|---|---|
| unit_group_id | Specifies the ID of the target UNIT_GROUP for the log stream to be created. This parameter takes effect only in homogeneous zone mode. |
| unit_id_list | Specify the list of units for distributing the log streams to be created. Separate multiple unit IDs with commas (,). This parameter takes effect only in heterogeneous zone mode. |
| zone_name | Specifies the target primary zone for the log stream to be created. If PRIMARY_ZONE is not specified, the system automatically selects a zone for allocation. |
| tenant_name | Optional. Specifies the target tenant.
NoticeOnly the system tenant can specify other tenants. User tenants can only specify themselves. This statement does not support using |
Examples
System tenant
The system tenant creates a log stream for the
obtenanttenant on theUNIT_GROUPwith ID 1001.obclient> ALTER SYSTEM CREATE LS UNIT_GROUP 1001 TENANT = obtenant;The system tenant creates a log stream for the
obtenanttenant on theUNIT_GROUPwith ID 1001, and sets the log stream'sPRIMARY_ZONEtoz1.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 on the
UNIT_GROUPwith ID 1001 for this tenant and sets thePRIMARY_ZONEof this log stream toz1.obclient> ALTER SYSTEM CREATE LS UNIT_GROUP 1001, PRIMARY_ZONE 'z1';
System tenant
The system 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 system tenant creates a log stream on the
UNIT_LISTof tenantsobtenantat IDs 1001, 1002, and 1003, and sets thePRIMARY_ZONEof this 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 on the
UNIT_LISTwith IDs 1001, 1002, and 1003 for this tenant, and sets the log stream'sPRIMARY_ZONEtoz1.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.