You can execute the START SERVICE statement to start an existing service.
Limitations
You cannot execute the START 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. Otherwise, the temporarily offline OBServer nodes cannot provide the service specified by the service name after you execute the
START SERVICEstatement. Therefore, we recommend that you wait until the temporarily offline OBServer nodes are recovered or permanently offline before you execute theSTART SERVICEstatement.For more information about how to query temporarily offline OBServer nodes in the units for a tenant, see Prerequisites in Create a service.
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 started is in the
STARTEDstate.For more information, see Query the service status.
If the service is not in the
STARTEDstate, 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;
- Query the
Start the service.
Here is an example:
ALTER SYSTEM START SERVICE service_name [TENANT [=] tenant_name];The parameters are described as follows:
service_name: the name of the service to be started.TENANT [=] tenant_name: the name of the tenant for which you want to start the service. This parameter is valid only in thesystenant.
Here are some examples:
Start a service named
s_hzfor a tenant namedmysql_tenantin thesystenant.obclient [oceanbase]> ALTER SYSTEM START SERVICE s_hz TENANT = mysql_tenant;Start a service named
s_hzin a user tenant.obclient > ALTER SYSTEM START SERVICE s_hz;
If
Query OKis returned, you can connect to all OBServer nodes except the permanently offline ones in the units for the tenant by specifying the service name. IfOB_SERVICE_NOT_FULLY_STARTEDis returned, you can connect to only some of OBServer nodes except the permanently offline ones in the units for the tenant by specifying the service name. You can query the connectable OBServer nodes from the CDB_OB_TENANT_EVENT_HISTORY view in thesystenant or the DBA_OB_TENANT_EVENT_HISTORY (MySQL mode) or DBA_OB_TENANT_EVENT_HISTORY (Oracle mode) view in a user tenant.