---
title: "检查 ODP 连接 | OceanBase 文档中心"
description: 检查 ODP 连接 本文介绍使用命令行检查 OceanBase 数据库代理 ODP（OceanBase Database Proxy，又称 OBProxy）连接的一些常用操作。 查看客户端连接 通过 SHOW PROXYSESSION; 语句可以查看 ODP 上所有租户连接的全部客户端连接（Client Sessio…
image: https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*OSPzQ6GUQF4AAAAAQHAAAAgAeiGDAQ/original
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*P8CuR4UJ_FkAAAAAAAAAAAAADiGDAQ/original) OceanBase 数据库分布式版 - V 3.2.3 企业版 LTS

# 检查 ODP 连接

更新时间：2023-10-24 17:15:46

本文介绍使用命令行检查 OceanBase 数据库代理 ODP（OceanBase Database Proxy，又称 OBProxy）连接的一些常用操作。

## 查看客户端连接

通过 `SHOW PROXYSESSION;` 语句可以查看 ODP 上所有租户连接的全部客户端连接（Client Session，即 Client 和 ODP 间的连接）的内部状态。

**示例如下：**

```shell
obclient> show proxysession;
+---------------------+------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+--------+--------+-----------+
| proxy_sessid        | Id   | Cluster | Tenant | User | Host            | db   | trans_count | svr_session_count | state             | tid    | pid    | using_ssl |
+---------------------+------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+--------+--------+-----------+
| 7230691421644980673 |   88 |  ob1.cc | sys    | root | 127.0.0.1:49999 | NULL |           0 |                 1 | MCS_ACTIVE_READER | 120685 | 120685 |         0 |
+---------------------+------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+--------+--------+-----------+
1 row in set

```

**参数说明：**

| 字段 | 字段 |
| --- | --- |
| proxy_sessid | OceanBase 数据库内标记每个与 ODP 的会话的 ID 号。 |
| Id | ODP 内标记每个 Client Session 的 ID 号，即下文的 cs_id。 |
| Cluster | 连接所属的 OceanBase 集群名。 |
| Tenant | 连接 OceanBase 集群所使用的租户名。 |
| User | 连接 OceanBase 集群所使用的用户名。 |
| Host | 客户端 IP 地址及其端口号。 |
| db | 执行命令时所处的数据库。 |
| trans_count | 客户端会话已完成的事务数量。 |
| svr_session_count | ODP 与 OceanBase 数据库之间维持的会话总数量。 |
| state | 客户端会话状态，存在如下几个状态：   - MCS_INIT（初始化） - MCS_ACTIVE_READER（激活） - MCS_KEEP_ALIVE（保活） - MCS_HALF_CLOSE（半关闭） - MCS_CLOSED（已关闭） |
| tid | 线程 ID。 |
| pid | 进程 ID。 |
| using_ssl | 客户端会话是否使用 SSL 协议传输。 |

## 查看服务端连接

目前暂不支持直接通过 ODP 查看服务端连接（Server Session，即 ODP 和 OBServer 节点间的连接）。可以使用 `root` 用户登录 OceanBase 数据库的 sys 租户查看集群内的所有 Server，之后直连对应的 OBServer 节点查看连接。

1. 使用 `root` 用户登录 OceanBase 数据库的 sys 租户查看集群内的所有 Server。

   ```shell
   obclient> select svr_ip,svr_port,zone,inner_port,status from oceanbase.__all_server;
   +------------+------+--------+
   | svr_ip     | zone | status |
   +------------+------+--------+
   | 10.10.10.1 | z3   | ACTIVE |
   | 10.10.10.2 | z2   | ACTIVE |
   | 10.10.10.3 | z1   | ACTIVE |
   +------------+------+--------+
   3 rows in set

   ```
 2. 选择想要查看的 OBServer 节点，直连该 OBServer 节点，以直连 `10.10.10.1`，SQL 端口为 `2881` 为例。

   ```shell
   [admin@test001 ~]$ obclient -h10.10.10.1 -P2881 -uroot@sys -p****** -Doceanbase -A

   ```
 3. 执行 `show processlist;` 命令查看当前 OBServer 节点的所有连接。

   ```shell
   obclient> show processlist;
   +------------+---------+------------------+-----------+---------+------+--------+------------------+
   | Id         | User    | Host             | db        | Command | Time | State  | Info             |
   +------------+---------+------------------+-----------+---------+------+--------+------------------+
   | 3221812197 | root    | 10.10.10.1:48563 | NULL      | Query   |    0 | ACTIVE | show processlist |
   | 3222117829 | proxyro | 10.10.10.1:37876 | oceanbase | Sleep   |    6 | SLEEP  | NULL             |
   | 3221709618 | root    | 10.10.10.1:51390 | NULL      | Sleep   |  831 | SLEEP  | NULL             |
   +------------+---------+------------------+-----------+---------+------+--------+------------------+
   3 rows in set

   ```

## 相关文档

- 更多查看客户端连接的常用操作信息，请参见 [客户端连接](https://www.oceanbase.com/docs/common-odp-doc-cn-1000000000050276)。
 - 更多查看服务端连接的常用操作信息，请参见 [服务端连接](https://www.oceanbase.com/docs/common-odp-doc-cn-1000000000050274)。
 - 如果您正在使用 OceanBase 云平台（OceanBase Cloud Platform，OCP）管理 OceanBase 集群和 ODP 进群，那么您也可以通过 OCP 检查 ODP 连接信息，详细信息请参见 [健康巡检](https://www.oceanbase.com/docs/enterprise-oceanbase-ocp-cn-10000000000380238)。

 上一篇 下一篇 ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
