资源规划
组件 | bigdata-node1 | bigdata-node2 | bigdata-node3 |
---|---|---|---|
OS | centos7.6 | centos7.6 | centos7.6 |
JDK | jvm | jvm | jvm |
Zookeeper | QuorumPeerMain | QuorumPeerMain | QuorumPeerMain |
Influxdb | N.A | Influxdb | N.A |
JmxTrans | N.A | jmxtrans | N.A |
Grafana | N.A | Grafana | N.A |
JMX监控
开启JMX监控(zk默认会在ipv4和ipv6上各开一个端口用来支持jmx调用):
vi ~/modules/zookeeper-3.4.10/bin/zkServer.sh
配置如下:
# JMX Config
JMXLOCALONLY=false
JMXDISABLE=false
JMXPORT=8999
JMXAUTH=false
JMXSSL=false
验证:
sudo netstat -lnpt |grep 8999
也可以通过jconsole工具远程连接JMX。
zk监控文件配置(根据JmxTrans部署方式调整zk-jmxtrans.json,如果**JmxTrans部署在一个节点上,则可以编写多个json文件,注意修改IP、alias信息;如果JmxTrans是分布式部署在zk的节点上,则IP可以统一为localhost,这样配置文件即可保持一致**):
{
"servers": [
{
"port": 8999,
"host": "localhost",
"alias": "zk",
"queries": [
{
"resultAlias": "zkQuorum",
"outputWriters" : [
{
"@class" : "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url" : "http://192.168.0.102:8086/",
"database" : "zkdb",
"username": "root",
"password": "123456"
} ],
"obj": "org.apache.ZooKeeperService:name0=ReplicatedServer_id*",
"attr": [
"QuorumSize"
]
},
{
"resultAlias": "zkCluster",
"outputWriters" : [
{
"@class" : "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url" : "http://192.168.0.102:8086/",
"database" : "zkdb",
"username": "root",
"password": "123456"
} ],
"obj": "org.apache.ZooKeeperService:name0=ReplicatedServer_id*,name1=replica*,name2=*",
"attr": [
"MaxClientCnxnsPerHost",
"MaxRequestLatency",
"AvgRequestLatency",
"MinRequestLatency",
"MaxSessionTimeout",
"MinSessionTimeout",
"OutstandingRequests",
"PacketsReceived",
"PacketsSent",
"PendingRevalidationCount",
"TickTime"
]
},
{
"resultAlias": "zkCount",
"outputWriters" : [
{
"@class" : "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url" : "http://192.168.0.102:8086/",
"database" : "zkdb",
"username": "root",
"password": "123456"
} ],
"obj": "org.apache.ZooKeeperService:name0=ReplicatedServer_id*,name1=replica*,name2=*,name3=InMemoryDataTree",
"attr": [
"NodeCount",
"WatchCount"
]
},
{
"resultAlias": "Clients",
"outputWriters" : [
{
"@class" : "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url" : "http://192.168.0.102:8086/",
"database" : "zkdb",
"username": "root",
"password": "123456"
} ],
"obj": "org.apache.ZooKeeperService:name0=ReplicatedServer_id*,name1=replica*,name2=*,name3=Connections,name4=*,name5=*",
"attr": [
"AvgLatency",
"LastLatency",
"MaxLatency",
"MinLatency",
"OutstandingRequests",
"PacketsReceived",
"PacketsSent"
]
},
{
"resultAlias": "Memory",
"outputWriters" : [
{
"@class" : "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url" : "http://192.168.0.102:8086/",
"database" : "zkdb",
"username": "root",
"password": "123456"
} ],
"obj": "java.lang:type=Memory",
"attr": [
"HeapMemoryUsage",
"NonHeapMemoryUsage"
]
},
{
"resultAlias": "Process",
"outputWriters" : [
{
"@class" : "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url" : "http://192.168.0.102:8086/",
"database" : "zkdb",
"username": "root",
"password": "123456"
} ],
"obj": "java.lang:type=OperatingSystem",
"attr": [
"OpenFileDescriptorCount",
"ProcessCpuLoad"
]
},
{
"resultAlias": "Threading",
"outputWriters" : [
{
"@class" : "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url" : "http://192.168.0.102:8086/",
"database" : "zkdb",
"username": "root",
"password": "123456"
} ],
"obj": "java.lang:type=Threading",
"attr": [
"ThreadCount"
]
}
],
"numQueryThreads": 2
}
]
}
注意:建议JmxTrans启动前,在Influxdb中配置好,zk存储数据库,已经数据库用户口令,以便于采集和Grafana中使用。
-- 启动Influxdb
influx
-- 创建用户,并分配权限
create user "root" with password '123456' with all privileges;
create database zkdb;
参考
【jmxtrans+influxdb+grafana监控zookeeper实战】https://www.jianshu.com/p/a911ec9effb4
【ZooKeeper官网JXM指标说明】http://zookeeper.apache.org/doc/r3.4.6/zookeeperJMX.html