You can execute the STOP SERVICE statement to stop a running service.
Limitations
You cannot execute the STOP SERVICE statement in a session created based on a service name.
Prerequisites
You have the
ALTER SYSTEMprivilege.The units for the tenant do not contain temporarily offline OBServer nodes.
For more information about how to query temporarily offline OBServer nodes in the units for a tenant, see Prerequisites in Create a service.
If the units for a tenant contains permanently offline OBServer nodes, make sure that the OBServer nodes are offline due to breakdown. Otherwise, the OBServer nodes may still provide the service after the service is changed to the
STOPPEDstate.
Procedure
Log in to a user tenant or the
systenant of the cluster as the tenant administrator.Note that you must specify the corresponding parameters in the following sample code based on your actual database configurations.
obclient -h10.xx.xx.xx -P2883 -uroot@sys#obdemo -p***** -ACheck whether the service to be stopped is in the
STOPPEDstate.For more information, see Query the service status.
If the service is not in the
STOPPEDstate, verify that theSWITCHOVER_STATUSvalue of the tenant isNORMAL, which indicates that the tenant is not in an intermediate state during primary/standby switchover. You can query theSWITCHOVER_STATUSvalue of a tenant in either of the following ways:Query the
SWITCHOVER_STATUSvalue of a specified tenant in thesystenant.obclient [oceanbase]> SELECT TENANT_ID, TENANT_NAME, SWITCHOVER_STATUS FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = mysql_tenant;Query the
SWITCHOVER_STATUSvalue of a user tenant in the current tenant.MySQL modeOracle modeThe query statement in MySQL mode is as follows:
obclient [oceanbase]> SELECT TENANT_ID, TENANT_NAME, SWITCHOVER_STATUS FROM oceanbase.DBA_OB_TENANTS;The query statement in Oracle mode is as follows:
obclient [SYS]> SELECT TENANT_ID, TENANT_NAME, SWITCHOVER_STATUS FROM SYS.DBA_OB_TENANTS;
Stop the service.
Here is an example:
ALTER SYSTEM STOP SERVICE service_name [TENANT [=] tenant_name];The parameters are described as follows:
service_name: the name of the service to be stopped.TENANT [=] tenant_name: the name of the tenant for which you want to stop the service. This parameter is valid only in thesystenant.
Here are some examples:
Stop a service named
s_hzfor a tenant namedmysql_tenantin thesystenant.obclient [oceanbase]> ALTER SYSTEM STOP SERVICE s_hz TENANT = mysql_tenant;Stop a service named
s_hzin a user tenant.obclient > ALTER SYSTEM STOP SERVICE s_hz;
After the service is stopped, sessions created based on the service name are interrupted, and you cannot create a session based on the service name.