You can view tenant sessions by using an SQL statement.
Procedure
In the sys tenant, you can view the session information of all tenants in the oceanbase.GV$OB_PROCESSLIST view or by using the SHOW PROCESSLIST statement. In a user tenant, you can view the session information of the tenant by using the SHOW PROCESSLIST statement.
Log on to a MySQL or Oracle tenant of the cluster.
Execute the following statement to view tenant sessions:
A tenant administrator can view all sessions of the tenant. A regular user can view only its own sessions. If you have the
PROCESSprivilege, you can view all sessions.Note
For more information about how to view privileges in Oracle mode, see View user privileges . If you do not have the required privileges, contact the administrator to obtain the privileges. For more information, see Modify user privileges.
For more information about how to view your privileges in MySQL mode, see View user privileges. If you do not have the required privileges, contact the administrator to obtain the privileges. For more information, see Modify user privileges.
Sample code:
obclient> SELECT * FROM GV$OB_PROCESSLIST\G *************************** 1. row *************************** SVR_IP: xx.xx.xx.xx SVR_PORT: 2882 SQL_PORT: 2881 ID: 3221487631 USER: root HOST: xx.xx.xx.xx:44615 DB: oceanbase TENANT: sys COMMAND: Query TIME: 0 TOTAL_TIME: 0 STATE: ACTIVE INFO: SELECT * FROM GV$OB_PROCESSLIST PROXY_SESSID: NULL MASTER_SESSID: NULL USER_CLIENT_IP: xx.xx.xx.xx USER_HOST: % RETRY_CNT: 0 RETRY_INFO: 0 SQL_ID: 44ECB8CF056160BA752D481522F5A6FA TRANS_ID: 0 THREAD_ID: 104936 SSL_CIPHER: NULL TRACE_ID: YB42AC1E87FC-0005E39610AEF2D9-0-0 TRANS_STATE: ACTION: MODULE: CLIENT_INFO: 1 row in setobclient> SHOW PROCESSLIST; +------------+------+----------------------+-----------+---------+------+--------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +------------+------+----------------------+-----------+---------+------+--------+------------------+ | 3221487631 | root | xx.xx.xx.xx:44615 | oceanbase | Query | 0 | ACTIVE | SHOW PROCESSLIST | +------------+------+----------------------+-----------+---------+------+--------+------------------+ 1 row in setParameters in the return result:
Id: the ID of the session.User: the user to which the session belongs.Host: the IP address and port number of the client that initiated the session.db: the name of the database that is connected to the session.Command: the command that is being run by the session.Time: the duration of the session.State: the status of the session.Info: the statement that is executed by the session.