Clickhouse查看当前连接数
dev-app80 :) select * from system.metrics where metric like '%Connection%'; SELECT * FROM system.metrics WHERE metric LIKE '%Connection%' Query id: 6d2e1536-9b84-4fd3-93c6-57c2ceecab64 ┌─metric────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TCPConnection │ 1 │ Number of connections to TCP server (clients with native interface), also included server-server distributed query connections │ │ MySQLConnection │ 0 │ Number of client connections using MySQL protocol │ │ HTTPConnection │ 0 │ Number of connections to HTTP server │ │ InterserverConnection │ 0 │ Number of connections from other replicas to fetch parts │ │ PostgreSQLConnection │ 0 │ Number of client connections using PostgreSQL protocol │ │ AsyncDrainedConnections │ 0 │ Number of connections drained asynchronously. │ │ ActiveAsyncDrainedConnections │ 0 │ Number of active connections drained asynchronously. │ │ SyncDrainedConnections │ 0 │ Number of connections drained synchronously. │ │ ActiveSyncDrainedConnections │ 0 │ Number of active connections drained synchronously. │ └───────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 9 rows in set. Elapsed: 0.003 sec.
其中,通过tcp_port配置的端口连接的会话,分类在“TCPConnection”里边,
通过http_port配置的端口连接的会话,分类在“HTTPConnection”里边。
当然除了这两个还有其他的,见上述查询结果。
这里主要发现了一点,执行上述SQL查询会话信息的时候,实际上我还用dbeaver工具通过端口http_port:8123创建了一个会话,但是“HTTPConnection”的值还是0。
注意,上边的查询是用命令clickhouse-client去连接查询的,使用的是tcp_port端口9000。
从OS层面看连接确实是存在:
[root@dev-app80 ~]# netstat -anp | grep -i 192.168.1.40 | grep -v ssh tcp 0 0 192.168.1.123:8123 192.168.1.40:54979 ESTABLISHED 9238/clickhouse-ser
我用dbeaver会话执行同样的语句就有值了,如下:
难道是HTTP server的会话在不活动的时候是不显示在system.metrics的“HTTPConnection”度量里边的?
于是我尝试用改会话(8123端口的会话)执行一条长SQL,然后再次从clickhouse-client命令行去查看。
从实验结果看,HTTP Server连接的会话在活动的时候才会计入system.metrics的度量“HTTPConnection”值里边。
标签:查看,端口,Number,连接数,server,connections,HTTPConnection,port,Clickhouse From: https://www.cnblogs.com/PiscesCanon/p/16716218.html