Purpose
You can use the ALTER SYSTEM {CREATE | DELETE | START | STOP} SERVICE ... statement to manage SERVICE_NAME (service name), allowing operations such as creating, deleting, starting, and stopping the service name.
Note
For service name management and primary-standby switchover operations through OceanBase Cloud Platform (OCP), see Switchover.
Limitations and restrictions
- The
SERVICE_NAMEfeature is not supported in theMETAorSYStenant. - OCP ensures that only one primary tenant exists under a
SERVICE_NAMEin the managed clusters. You must ensure this when you manually set theSERVICE_NAME. - The
FAILOVERoperation automatically deletes allSERVICE_NAMEentries of a tenant. - A tenant can have only one
SERVICE_NAME. - You cannot execute operational commands related to the
SERVICE_NAMEand tenant primary/standby roles through a connection established by using theSERVICE_NAME. Otherwise, theOB_OP_NOT_ALLOWerror is returned.
Required privileges
The user who executes the statement must have the ALTER SYSTEM privilege. For more information about privileges in OceanBase Database, see Privilege types in MySQL mode and Privilege types in Oracle mode.
Syntax
ALTER SYSTEM {CREATE | DELETE | START | STOP} SERVICE service_name [tenant = 'tenant_name'];
Parameters
| Parameter | Description |
|---|---|
| CREATE | Creates a service. After a service is created, it is automatically started. |
| DELETE | Deletes a service. Before a service is deleted, it must be stopped. |
| START | Starts a service. After a service is started, you can establish a session or allow requests by using the SERVICE_NAME. |
| STOP | Stops a service. After a service is stopped, no session is started by using the SERVICE_NAME, and no new session can be established by using the SERVICE_NAME. |
| service_name | Specifies the service name. |
| tenant_name | Optional. Specifies the tenant to be operated on. If this parameter is not explicitly specified, the default tenant name is the current tenant name.
NoticeThe system tenant does not support the |
Examples
Create a service named service_mysql001 for the mysql001 tenant.
ALTER SYSTEM CREATE SERVICE service_mysql001 TENANT = 'mysql001';
References
You can query the
SERVICE_NAMEand its status of a tenant by using a view. For more information, see DBA_OB_SERVICES or oceanbase.CDB_OB_SERVICES.You can query the execution status of operational commands related to the
SERVICE_NAMEby using a view and specifying theMODULEasSERVICE NAME. For more information, see DBA_OB_TENANT_EVENT_HISTORY or oceanbase.CDB_OB_TENANT_EVENT_HISTORY.For more information about the
SERVICE_NAMEoperational commands, see Create a service.For more information about connecting to a tenant by using a
SERVICE_NAME, see Connect to an OceanBase tenant (MySQL mode) or Connect to an OceanBase tenant (Oracle mode).