Purpose
You can use the ALTER SYSTEM {CREATE | DELETE | START | STOP} SERVICE ... statement to maintain service names. For example, you can create, delete, start, and stop a service name.
Note
You can manage service names and perform switchover by using OceanBase Cloud Platform (OCP). For more information, see Switchover.
Limitations and considerations
- The service name feature is not supported for the sys tenant and meta tenants.
- OCP ensures that a service name maps only to one primary tenant in each managed cluster. If you configure a service name in the CLI, you need to manually ensure that the service name maps only to one primary tenant.
- A failover will automatically delete all service names in the original primary tenant.
- A tenant can have only one service name.
- In a connection established based on a service name, you cannot run O&M commands related to service names or tenant role switching. Otherwise, the
OB_OP_NOT_ALLOWerror is returned.
Required privileges
To execute this statement, you 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. The service is automatically started after it is created. |
| DELETE | Deletes a service. Before you delete a service, make sure that it has been stopped. |
| START | Starts a service. After a service is started, you can establish a session or initiate requests based on the service name. |
| STOP | Stops a service. After a service is stopped, you cannot start or establish a session based on the service name. |
| service_name | The service name. |
| tenant_name | Optional. The name of the target tenant. If this parameter is not specified, the name of the current tenant is used.
NoticeThe sys tenant does not support the service name feature. In other words, if you execute this statement in the sys tenant, you must specify the |
Examples
Create a service named service_mysql001 for the mysql001 tenant.
ALTER SYSTEM CREATE SERVICE service_mysql001 TENANT = 'mysql001';
References
For information about how to query the service name of a tenant or the status of a service name from views, see DBA_OB_SERVICES or oceanbase.CDB_OB_SERVICES.
For information about how to query the execution information about O&M commands related to service names from views by specifying
MODULEasSERVICE NAME, see DBA_OB_TENANT_EVENT_HISTORY or oceanbase.CDB_OB_TENANT_EVENT_HISTORY.For more information about O&M commands related to service names, see Create a service.
For information about how to connect to a tenant based on the service name, see Connect to an OceanBase Database tenant by using OBClient in MySQL mode or Connect to an OceanBase Database tenant by using OBClient in Oracle mode.