You can query the status of existing services from views.
Query the service status in the sys tenant
Log in to the
systenant of the cluster as therootuser.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***** -AExecute the following statement to query service information of a specified tenant in the cluster.
obclient [oceanbase]> SELECT * FROM oceanbase.CDB_OB_SERVICES WHERE TENANT_ID=1002 AND SERVICE_NAME='s_hz';A sample query result is as follows:
+-----------+----------------------------+----------------------------+-----------------+--------------+----------------+ | TENANT_ID | CREATE_TIME | MODIFIED_TIME | SERVICE_NAME_ID | SERVICE_NAME | SERVICE_STATUS | +-----------+----------------------------+----------------------------+-----------------+--------------+----------------+ | 1002 | 2024-06-15 17:43:08.461690 | 2024-06-15 17:43:08.461690 | 2 | s_hz | STARTED | +-----------+----------------------------+----------------------------+-----------------+--------------+----------------+Fields in the query result are described as follows:
TENANT_ID: the ID of the tenant.CREATE_TIME: the time when the service was created.MODIFY_TIME: the time when the service information was last modified.SERVICE_NAME_ID: the ID of the service, which uniquely identifies the service name.SERVICE_NAME: the name of the service.SERVICE_STATUS: the status of the service. Valid values:STARTED: The service has been started. You can create a session based on the service name and send requests in the session.STOPPING: The service is being stopped. The system is notifying all OBServer nodes in the tenant that the service is to be stopped, and you cannot create a session based on the service name.STOPPED: The service has been stopped. The notification is completed. No session created based on the service name is running, and you cannot create a session based on the service name.
Query the service status in a user tenant
Log in to a MySQL or Oracle tenant of the cluster.
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@mysql_tenant#obdemo -p***** -AExecute the following statement to query service information of the current tenant.
MySQL modeOracle modeThe query statement in MySQL mode is as follows:
obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_SERVICES;The query statement in Oracle mode is as follows:
obclient [SYS]> SELECT * FROM SYS.DBA_OB_SERVICES;A sample query result is as follows:
+----------------------------+----------------------------+-----------------+--------------+----------------+ | CREATE_TIME | MODIFIED_TIME | SERVICE_NAME_ID | SERVICE_NAME | SERVICE_STATUS | +----------------------------+----------------------------+-----------------+--------------+----------------+ | 2024-06-15 17:43:08.461690 | 2024-06-15 17:43:08.461690 | 2 | s_hz | STARTED | +----------------------------+----------------------------+-----------------+--------------+----------------+Fields in the query result are described as follows:
CREATE_TIME: the time when the service was created.MODIFY_TIME: the time when the service information was last modified.SERVICE_NAME_ID: the ID of the service, which uniquely identifies the service name.SERVICE_NAME: the name of the service.SERVICE_STATUS: the status of the service. Valid values:STARTED: The service has been started. You can create a session based on the service name and send requests in the session.STOPPING: The service is being stopped. The system is notifying all OBServer nodes in the tenant that the service is to be stopped, and you cannot create a session based on the service name.STOPPED: The service has been stopped. The notification is completed. No session created based on the service name is running, and you cannot create a session based on the service name.