While a service is running, you can stop it by executing the STOP SERVICE statement.
Limitations
You cannot execute the STOP SERVICE statement in a session created based on a service name.
Prerequisites
You have the
ALTER SYSTEMprivilege to execute theSTOP SERVICEstatement.When stopping a service, the tenant's units must not contain temporarily offline machines.
For details on confirming whether the tenant's units contain temporarily offline machines, see Prerequisites in Create a service.
Based on the confirmation result, if the offline machine is permanently offline rather than temporarily offline, ensure that the permanently offline machine is due to failure. Otherwise, the service may display as stopped but still continue to provide service.
Procedure
Log in to a user tenant or the
systenant of the cluster as the tenant administrator.Below is an example. Specify the parameters based on your actual environment when connecting.
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 tenant's service status is not
STOPPED, the current tenant'sSWITCHOVER_STATUSmust beNORMAL, which indicates that the tenant is not in an intermediate state during primary/standby switchover. You can query the tenant'sSWITCHOVER_STATUSin either of the following ways:Query the
SWITCHOVER_STATUSof 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_STATUSof the current tenant in a user tenant.MySQL-compatible modeOracle-compatible modeQuery statement in MySQL-compatible mode:
obclient [oceanbase]> SELECT TENANT_ID, TENANT_NAME, SWITCHOVER_STATUS FROM oceanbase.DBA_OB_TENANTS;Query statement in Oracle-compatible mode:
obclient [SYS]> SELECT TENANT_ID, TENANT_NAME, SWITCHOVER_STATUS FROM SYS.DBA_OB_TENANTS;
Stop the service.
The statement is as follows:
ALTER SYSTEM STOP SERVICE service_name [TENANT [=] tenant_name];Parameters:
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. Only thesystenant can specify this parameter. User tenants cannot specify it.
Examples:
Stop the service named
s_hzfor the tenantmysql_tenantin thesystenant.obclient [oceanbase]> ALTER SYSTEM STOP SERVICE s_hz TENANT = mysql_tenant;Stop the service named
s_hzin a user tenant.obclient > ALTER SYSTEM STOP SERVICE s_hz;
After the service is stopped, sessions that were created by using the service name will be disconnected, and you cannot create new sessions by using the service name.