zabbix java gateway配置实战案例

时光怂恿深爱的人放手 提交于 2020-04-27 07:06:12

           zabbix java gateway配置实战案例

                              作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 

 

 

 

一.部署tomcat服务

  博主推荐阅读:
    CentOS:
      https://www.cnblogs.com/yinzhengjie/p/12199468.html

    Ubuntu:
      https://www.cnblogs.com/yinzhengjie2020/p/12315341.html

 

二.基于zabbix源码包编译安装zabbix java gateway

1>.编译安装zabbix java gateway(其实可以单独编译安装,不一定要和zabbix server部署在一起)

  博主推荐阅读:
    https://www.cnblogs.com/yinzhengjie2020/p/12305427.html

2>.查看编译安装时zabbix java gateway的安装目录

 

3>.修改zabbix java gateway的监听地址

[root@zabbix203.yinzhengjie.org.cn ~]# cp /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh-`date +%F`      #修改之前需要先做好备份
[root@zabbix203.yinzhengjie.org.cn ~]# hostname -i
172.200.5.203
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# grep LISTEN_IP /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh 
# LISTEN_IP="0.0.0.0"
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (LISTEN_IP=)"0.0.0.0"@\1"172.200.5.203"@' /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh 
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# grep LISTEN_IP /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
LISTEN_IP="172.200.5.203"
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (LISTEN_IP=)"0.0.0.0"@\1"172.200.5.203"@' /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh

4>.修改zabbix java gateway的监听端口

[root@zabbix203.yinzhengjie.org.cn ~]# grep LISTEN_PORT /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
# LISTEN_PORT=10052
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (LISTEN_PORT=)10052@\12020@' /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# grep LISTEN_PORT /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
LISTEN_PORT=2020
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (LISTEN_PORT=)10052@\12020@' /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh

5>.修改zabbix java gateway的pid存放路径

[root@zabbix203.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/pid/
total 8
drwxr-xr-x 2 zabbix zabbix 56 2月  16 14:28 ./
drwxr-xr-x 9 zabbix zabbix 87 2月  14 12:20 ../
-rw-rw-r-- 1 zabbix zabbix  4 2月  16 14:28 zabbix_agentd.pid
-rw-rw-r-- 1 zabbix zabbix  4 2月  16 14:28 zabbix_server.pid
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/pid/
total 8
drwxr-xr-x 2 zabbix zabbix 56 2月  16 14:28 ./
drwxr-xr-x 9 zabbix zabbix 87 2月  14 12:20 ../
-rw-rw-r-- 1 zabbix zabbix  4 2月  16 14:28 zabbix_agentd.pid
-rw-rw-r-- 1 zabbix zabbix  4 2月  16 14:28 zabbix_server.pid
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# grep ^PID_FILE /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
PID_FILE="/tmp/zabbix_java.pid"
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#(PID_FILE=)"/tmp/zabbix_java.pid"#\1"/yinzhengjie/softwares/zabbix/pid/zabbix_java.pid"#' /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# grep ^PID_FILE /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
PID_FILE="/yinzhengjie/softwares/zabbix/pid/zabbix_java.pid"
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's#(PID_FILE=)"/tmp/zabbix_java.pid"#\1"/yinzhengjie/softwares/zabbix/pid/zabbix_java.pid"#' /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh

6>.修改zabbix java gateway的后台工作进程数量(生产环境推荐和服务器core数量相同)

[root@zabbix203.yinzhengjie.org.cn ~]# grep START_POLLERS /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
# START_POLLERS=5
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (START_POLLERS=)5@\132@' /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# grep START_POLLERS /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
START_POLLERS=32
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (START_POLLERS=)5@\132@' /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh

7>.修改zabbix java gateway的采集数据的超时时间(超时时间范围为1-30,默认时3秒,生产环境推荐设置为30秒)

[root@zabbix203.yinzhengjie.org.cn ~]# grep TIMEOUT /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
# TIMEOUT=3
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (TIMEOUT=)3@\130@' /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]# grep TIMEOUT /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh
TIMEOUT=30
[root@zabbix203.yinzhengjie.org.cn ~]# 
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# sed -r -i 's@# (TIMEOUT=)3@\130@' /yinzhengjie/softwares/zabbix/sbin/zabbix_java/settings.sh

8>.启动zabbix java gateway服务

[root@zabbix203.yinzhengjie.org.cn ~]# /yinzhengjie/softwares/zabbix/sbin/zabbix_java/startup.sh

 

三.使用apt工具安装zabbix gateway组件

1>.将默认的Ubuntu软件源改为阿里的软件源

[root@zabbix_java253.yinzhengjie.org.cn ~]# vim /etc/apt/sources.list
[root@zabbix_java253.yinzhengjie.org.cn ~]# 
[root@zabbix_java253.yinzhengjie.org.cn ~]# cat /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
[root@zabbix_java253.yinzhengjie.org.cn ~]# 
[root@zabbix_java253.yinzhengjie.org.cn ~]#
[root@zabbix_java253.yinzhengjie.org.cn ~]# vim /etc/apt/sources.list
[root@zabbix_java253.yinzhengjie.org.cn ~]# apt-get update

2>.安装zabbix java gateway软件

[root@zabbix_java253.yinzhengjie.org.cn ~]# apt-get -y install zabbix-java-gateway

3>.修改zabbix java gateway的配置文件并重启服务

[root@zabbix_java253.yinzhengjie.org.cn ~]# cp /etc/zabbix/zabbix_java_gateway.conf /etc/zabbix/zabbix_java_gateway.conf-`date +%F`
[root@zabbix_java253.yinzhengjie.org.cn ~]# 
[root@zabbix_java253.yinzhengjie.org.cn ~]# vim /etc/zabbix/zabbix_java_gateway.conf
[root@zabbix_java253.yinzhengjie.org.cn ~]# 
[root@zabbix_java253.yinzhengjie.org.cn ~]# egrep -v "^#|^$" /etc/zabbix/zabbix_java_gateway.conf
LISTEN_IP="172.200.5.253"
LISTEN_PORT=10052
PID_FILE="/var/run/zabbix/zabbix_java_gateway.pid"
START_POLLERS=32
TIMEOUT=30
[root@zabbix_java253.yinzhengjie.org.cn ~]# 
[root@zabbix_java253.yinzhengjie.org.cn ~]# systemctl restart zabbix-java-gateway.service 
[root@zabbix_java253.yinzhengjie.org.cn ~]#

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!