摘要:
通过influxdb端口的连接状态, 分析influxdb集群的网络拓扑结构
集群节点分布:
- 192.168.58.128
- 192.168.58.131
- 192.168.58.132
DEBUG: addMeta metaAddr = localhost:8091, newNodeAddr = 192.168.58.128:8091
Added meta node 1 at 192.168.58.128:8091
DEBUG: addMeta metaAddr = localhost:8091, newNodeAddr = 192.168.58.131:8091
Added meta node 3 at 192.168.58.131:8091
DEBUG: addMeta metaAddr = localhost:8091, newNodeAddr = 192.168.58.132:8091
Added meta node 4 at 192.168.58.132:8091
DEBUG: addData metaAddr = localhost:8091, newNodeAddr = 192.168.58.128:8088
add-data: EOF
DEBUG: addData metaAddr = localhost:8091, newNodeAddr = 192.168.58.131:8088
Added data node 5 at 192.168.58.131:8088
DEBUG: addData metaAddr = localhost:8091, newNodeAddr = 192.168.58.132:8088
Added data node 6 at 192.168.58.132:8088
root@localhost:~/work/influxdb-1.8.4# influxd-ctl show
Data Nodes:
2 192.168.58.128:8088
5 192.168.58.132:8088
6 192.168.58.131:8088
Meta Nodes:
1 192.168.58.128:8091
3 192.168.58.131:8091
4 192.168.58.132:8091
端口划分:
meta节点日志中记录的加入集群的日志:
DEBUG: services:meta:CreateMetaNode httpAddr = 192.168.58.128:8091, tcpAddr = 192.168.58.128:8089 ID= 1
ts=2022-02-24T12:31:57.354167Z lvl=info msg="Listening for signals" log_id=0ZrwJG9l000
DEBUG: meta::handler::serveJoinCluster, peers = [192.168.58.128:8091]
DEBUG: services:meta:CreateDataNode host = 192.168.58.128:8086, tcpHost = 192.168.58.128:8088 , ID=2
DEBUG: meta::handler::serveJoinCluster, peers = [192.168.58.128:8091]
DEBUG: services:meta:CreateMetaNode httpAddr = 192.168.58.131:8091, tcpAddr = 192.168.58.131:8089 ID= 3
DEBUG: services:meta:CreateMetaNode httpAddr = 192.168.58.132:8091, tcpAddr = 192.168.58.132:8089 ID= 4
2022-02-24T21:16:13.968+0800 [INFO] raft-state: Node at 192.168.58.128:8089 [Follower]: peers=["192.168.58.128:8089", "192.168.58.131:8089", "192.168.58.132:8089"]
2022-02-24T21:16:15.577+0800 [INFO] raft-state: Node at 192.168.58.128:8089 [Leader]: peers=["192.168.58.128:8089", "192.168.58.131:8089", "192.168.58.132:8089"]
DEBUG: services:meta:CreateDataNode host = 192.168.58.132:8086, tcpHost = 192.168.58.132:8088 , ID=5
DEBUG: services:meta:CreateDataNode host = 192.168.58.131:8086, tcpHost = 192.168.58.131:8088 , ID=6
数据端口:
8086端口: http端口, 供客户端连接
8088端口: tcp端口, 数据节点间互联
root@localhost:~/work/influxdb-1.8.4# lsof -i :8086
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
influxd 430622 root 8u IPv6 3991221 0t0 TCP *:d-s-n (LISTEN)
influxd 430622 root 11u IPv6 3993261 0t0 TCP localhost:d-s-n->localhost:46662 (ESTABLISHED)
influx 430674 root 6u IPv6 3991274 0t0 TCP localhost:46662->localhost:d-s-n (ESTABLISHED)
root@localhost:~/work/influxdb-1.8.4# lsof -i :8088
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
influxd 430622 root 6u IPv6 3990238 0t0 TCP *:radan-http (LISTEN)
influxd 430622 root 21u IPv6 4027211 0t0 TCP localhost.localdomain:radan-http->192.168.58.132:50816 (ESTABLISHED)
influxd 430622 root 32u IPv6 4027233 0t0 TCP localhost.localdomain:radan-http->192.168.58.131:59344 (ESTABLISHED)
meta节点端口:
root@localhost:~/work/influxdb-1.8.4# lsof -i :8091
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
influxd-m 8183 root 7u IPv6 55596 0t0 TCP *:jamlink (LISTEN)
influxd-m 8183 root 9u IPv6 52842 0t0 TCP localhost.localdomain:jamlink->localhost.localdomain:56166 (ESTABLISHED)
influxd-m 8183 root 13u IPv6 58195 0t0 TCP localhost.localdomain:jamlink->192.168.58.131:55332 (ESTABLISHED)
influxd-m 8183 root 16u IPv6 56797 0t0 TCP localhost.localdomain:jamlink->192.168.58.132:36260 (ESTABLISHED)
influxd 8206 root 7u IPv4 53858 0t0 TCP localhost.localdomain:56166->localhost.localdomain:jamlink (ESTABLISHED)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
influxd-m 8183 root 6u IPv6 55594 0t0 TCP *:8089 (LISTEN)
influxd-m 8183 root 10u IPv4 58194 0t0 TCP localhost.localdomain:33318->192.168.58.131:8089 (ESTABLISHED)
influxd-m 8183 root 12u IPv4 54176 0t0 TCP localhost.localdomain:39886->192.168.58.132:8089 (ESTABLISHED)
influxd-m 8183 root 14u IPv4 58174 0t0 TCP localhost.localdomain:33298->192.168.58.131:8089 (ESTABLISHED)
influxd-m 8183 root 15u IPv4 58179 0t0 TCP localhost.localdomain:39870->192.168.58.132:8089 (ESTABLISHED)
结论:
- 数据节点8086端口作为http协议供客户端使用
- 数据节点8088端口作为tcp端口用作各个数据节点连接