zabbix之被动模式之编译安装proxy

#:准备源码包,编译安装

root@ubuntu:/usr/local/src# ls
zabbix-4.0.12.tar.gz
root@ubuntu:/usr/local/src# tar xf zabbix-4.0.12.tar.gz
root@ubuntu:/usr/local/src# cd zabbix-4.0.12/

#:安装依赖包(可以自行去掉一些没必要装的)

root@ubuntu:/usr/local/src/zabbix-4.0.12# apt-get  install   apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu-core fping libapache2-mod-php   libapache2-mod-php7.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libfontconfig1 libgd3 libiksemel3   libjbig0 libjpeg-turbo8 libjpeg8 liblua5.2-0 libodbc1 libopenipmi0 libsensors4 libsnmp-base libsnmp30 libsodium23 libssh2-1  libtiff5 libwebp6 libxpm4 php-bcmath php-common php-gd php-ldap php-mbstring php-mysql php-xml php7.2-bcmath php7.2-cli  php7.2-common php7.2-gd php7.2-json php7.2-ldap php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline   php7.2-xml snmpd  ssl-cert ttf-dejavu-core      libmysqlclient-dev  libxml2-dev  libxml2 snmp  libsnmp-dev   libevent-dev  openjdk-8-jdk curl libcurl4-openssl-dev

#:编译安装

root@ubuntu:/usr/local/src/zabbix-4.0.12# ./configure --enable-proxy --prefix=/apps/zabbix_proxy --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
root@ubuntu:/usr/local/src/zabbix-4.0.12# make && make install

#:找一台apt安装的把启动脚本考到本机改一下

root@ubuntu:/usr/local/src/zabbix-4.0.12# vim /lib/systemd/system/zabbix-proxy.service

[Unit]
Description=Zabbix Proxy
After=syslog.target
After=network.target

[Service]
Environment="CONFFILE=/apps/zabbix_proxy/etc/zabbix_proxy.conf"
EnvironmentFile=-/etc/default/zabbix-proxy
Type=forking
Restart=on-failure
PIDFile=/run/zabbix/zabbix_proxy.pid
KillMode=control-group
ExecStart=/apps/zabbix_proxy/sbin/zabbix_proxy -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=infinity

[Install]
WantedBy=multi-user.target

#;创建数据库并授权

mysql> create database zabbix_proxy_passive character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix_proxy_passive.* to 'zabbix'@'192.168.7.%' identified by 'centos';
Query OK, 0 rows affected, 1 warning (0.00 sec)

#;修改passive的配置文件

root@ubuntu:/usr/local/src/zabbix-4.0.12# vim /apps/zabbix_proxy/etc/zabbix_proxy.conf
ProxyMode=1  #;改成被动模式
Server=192.168.7.105
ServerPort=10051
Hostname=magedu-linux37-proxy-passive
ListenPort=10051
PidFile=/run/zabbix/zabbix_proxy.pid   #:这个要和启动脚本的路径一样
DBHost=192.168.7.106
DBName=zabbix_proxy_passive
DBPassword=centos
ProxyLocalBuffer=720
ProxyOfflineBuffer=720
StartPollers=5
StartHTTPPollers=20(这个可以适当的加一些)
CacheSize=8M (这个要调大一些)
StartDBSyncers=4 (和DB同步的进程也要适当调大一些)
HistoryCacheSize=16M(历史数据的缓存大小)
HistoryIndexCacheSize=4M(历史数据的索引大小)
Timeout=30 (这个必须要调大)
        在被动模式下心跳,配置更新时间可以不配

#:更新时间配置到server端(否则添加上主机更新特别慢)

root@ubuntu:~# vim /apps/zabbix_server/etc/zabbix_server.conf
ProxyConfigFrequency=60
ProxyDataFrequency=60

#:改完后初始化proxy的数据库

root@ubuntu:/usr/local/src/zabbix-4.0.12/database/mysql# cd /usr/local/src/zabbix-4.0.12/database/mysql/
root@ubuntu:/usr/local/src/zabbix-4.0.12/database/mysql# mysql -uzabbix -pcentos -h 192.168.7.106 zabbix_proxy_passive < schema.sql

#:启动服务

root@ubuntu:/usr/local/src/zabbix-4.0.12/database/mysql# systemctl start zabbix-proxy.service

 

 

#:找一台agent主机测试

#:修改agent配置文件

root@ubuntu:~# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.7.105,192.168.7.110 #;指向server和proxy

添加主机

 

 

 

 

找一台空闲主机安装Java-gateway

#:准备jdk包 解压安装

root@ubuntu:/usr/local/src# tar xf jdk-8u191-linux-x64.tar.gz 
root@ubuntu:/usr/local/src# ln -sv /usr/local/src/jdk1.8.0_191/ /usr/local/jdk

#;配置环境变量

root@ubuntu:/usr/local/src# vim /etc/profile
export JAVA_HOME=/usr/local/jdk
export TOMCAT_HOME=/apps/tomcat
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$TOMCAT_HOME/bin:$PATH
export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar

root@ubuntu:/usr/local/src# source /etc/profile
root@ubuntu:/usr/local/src# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

#:将Java命令软连接到/usr/bin

root@ubuntu:/usr/local/src# ln -sv /usr/local/jdk/bin/java /usr/bin

#:配置apt源,安装gateway

root@ubuntu:/usr/local/src# wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-2+bionic_all.deb
root@ubuntu:/usr/local/src# dpkg -i zabbix-release_4.0-2+bionic_all.deb
root@ubuntu:/usr/local/src# apt update
root@ubuntu:/usr/local/src# apt install zabbix-java-gateway

#:修改gateway的配置文件

root@ubuntu:/usr/local/src# vim /etc/zabbix/zabbix_java_gateway.conf
LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
START_POLLERS=5(机器多的话可以多开几个)
TIMEOUT=30

#:启动服务
root@ubuntu:/usr/local/src# systemctl start zabbix-java-gateway


#;在网页添加主机
posted @ 2019-09-22 15:12  Linus小跟班  阅读(668)  评论(0编辑  收藏  举报