Purpose
This statement is used to create a user log stream.
Limitations and considerations
For V4.2.5, the Create Log Stream feature is supported in V4.2.5 BP2 and later.
In versions earlier than V4.x, OceanBase Database supports only homogeneous zone mode for tenants. In V4.2.5, the Create Log Stream feature is supported in homogeneous zone mode in V4.2.5 BP5 and later. The details are as follows:
- 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 homogeneous zone mode and heterogeneous zone mode, see Data distribution.
At present, only a normal user log stream can be created. A broadcast log stream cannot be created.
You can create a log stream only in a primary tenant. The
STATUSandSWITCHOVER_STATUSvalues of the tenant for which a log stream is to be created must beNORMAL.When you create a log stream, the following conditions must be met:
- In homogeneous zone mode, the status of the target
UNIT_GROUPmust beACTIVE, and the value ofUNIT_GROUP_IDin theDBA_OB_UNITSview must not be 0. - In heterogeneous zone mode, the status of the target
UNIT_LISTmust beACTIVE, and the specifiedUNIT_LISTmust not be empty.
- In homogeneous zone mode, the status of the target
When you specify
PRIMARY_ZONEfor the log stream to be created, make sure that the specified zone is included in theZONE_LISTof the tenant. For a log stream, you can specify only one zone as itsPRIMARY_ZONE. For example, you can specifyz1orz2. You cannot specifyz1,z2,z1; z2, orRANDOMfor a log stream, as you can for a tenant.We recommend that you set load balancing-related parameters to
False. Otherwise:If the tenant-level parameter enable_rebalance is set to
True, the log stream created will be migrated from the targetUNIT_GROUPto anotherUNIT_GROUPby the system.If the tenant-level parameter enable_transfer is set to
True, the log stream may be deleted.
Privilege requirements
To execute this statement, you must have the ALTER SYSTEM privilege. For more information about OceanBase Database privileges, see Privilege types in MySQL mode and Privilege types in Oracle mode.
Syntax
ALTER SYSTEM CREATE LS
{UNIT_GROUP [=] unit_group_id} | {UNIT_LIST [=] (unit_id_list) }
[,PRIMARY_ZONE [=] 'zone_name']
[TENANT [=] 'tenant_name'];
Parameter description
| Parameter | Description |
|---|---|
| unit_group_id | The ID of the UNIT_GROUP to which the log stream belongs. This parameter is applicable only in homogeneous zone mode. |
| unit_id_list | The list of units to which the log stream belongs. Separate multiple unit IDs with commas (,). This parameter is applicable only in heterogeneous zone mode.
NoteThis parameter is supported in V4.2.5BP5 and later. |
| zone_name | The primary zone to which the log stream belongs. If this parameter is not specified, the system automatically selects a zone for the log stream. |
| tenant_name | The name of the tenant. This parameter is optional.
NoticeOnly the system tenant can specify another tenant. A user tenant can only specify the current tenant. The |
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 primary zone of 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 the current tenant on the
UNIT_GROUPwith ID 1001.obclient> ALTER SYSTEM CREATE LS UNIT_GROUP 1001;The user tenant creates a log stream for the current tenant on the
UNIT_GROUPwith ID 1001 and sets the primary zone of the 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 for the
obtenanttenant on theUNIT_LISTwith IDs 1001, 1002, and 1003 and sets the primary zone of 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 the current tenant 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 the current tenant on the
UNIT_LISTwith IDs 1001, 1002, and 1003 and sets the primary zone of the log stream toz1.obclient> ALTER SYSTEM CREATE LS UNIT_LIST = (1001,1002,1003), PRIMARY_ZONE 'z1';