1.zabbix版本的升级
Zabbix客户端的升级
[root@lb01 ~]# wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.2/rhel/7/x86_64/zabbix-get-5.2.2-1.el7.x86_64.rpm
[root@lb01 ~]# rpm -Uvh zabbix-get-5.2.2-1.el7.x86_64.rpm
#升级完,配置文件并没有多大的区别,并且升级完它的配置文件名为zabbix_agentd.conf.rpmnew,并不影响原配置文件的使用
Zabbix服务端的升级
[root@zabbix-server ~]# zabbix_server -V
zabbix_server (Zabbix) 5.0.8
4.0 --> 5.0
下面进行安装4.0并进行升级
安装
1.安装zabbix的release源
[root@kafka-node3 ~]# rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
[root@kafka-node3 ~]# sed -i 's#http://repo.zabbix.com#https://mirrors.tuna.tsinghua .edu.cn/zabbix#g' /etc/yum.repos.d/zabbix.repo
2.安装php
[root@kafka-node3 ~]# yum install -y php-fpm.x86_64 php-gd.x86_64 php-bcmath.x86_64 php-xml.x86_64 php-mbstring.x86_64 php-ldap.x86_64 php-mysqlnd.x86_64
3.安装nginx
[root@kafka-node3 ~]# yum install -y nginx
4.配置nginx的zabbix配置文件
[root@kafka-node3 ~]# cat /etc/nginx/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name zabbix.ming.com;
location / {
root /zabbix;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /zabbix;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /zabbix$fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
include fastcgi_params;
}
}
}
[root@kafka-node3 ~]# nginx -t
[root@kafka-node3 ~]# systemctl start nginx.service
[root@kafka-node3 ~]# vim /etc/php-fpm.d/www.conf
user = nginx
group = nginx
[root@kafka-node3 ~]# systemctl start php-fpm.service
[root@kafka-node3 ~]# mkdir /zabbix
[root@kafka-node3 ~]# wget https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.28.tar.gz
[root@kafka-node3 ~]# tar -xf zabbix-4.0.28.tar.gz
[root@kafka-node3 ~]# cp -ap zabbix-4.0.28/frontends/php/* /zabbix
[root@kafka-node3 ~]# chown -R nginx.nginx /zabbix
[root@kafka-node3 ~]# systemctl restart nginx.service
5.创建session目录并授权
[root@kafka-node3 ~]# mkdir /var/lib/php/session
[root@kafka-node3 ~]# chown -R nginx.nginx /var/lib/php/session
6.修改php的配置文件
[root@kafka-node3 ~]# vim /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
[root@kafka-node3 ~]# systemctl restart php-fpm.service
[root@kafka-node3 ~]# systemctl restart nginx
7.安装数据库、配置并导入数据
[root@kafka-node3 ~]# yum install -y mariadb-server
[root@kafka-node3 ~]# systemctl start mariadb.service
[root@kafka-node3 ~]# mysqladmin password
[root@kafka-node3 ~]# mysql -uroot -p123456
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> create user 'zabbix'@'localhost' identified by '123456';
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost';
[root@kafka-node3 ~]# yum install -y zabbix-server-mysql.x86_64
[root@kafka-node3 ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.28/create.sql.gz |mysql -uroot -p123456 zabbix
账号 Admin
密码 zabbix
[root@kafka-node3 ~]# egrep -v '^$|#' /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBSocket=/var/lib/mysql/mysql.sock
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
[root@kafka-node3 ~]# systemctl start zabbix-server.service
#页面配置图在下面
升级
1.更新zabbix-server的release源
[root@kafka-node3 /etc/yum.repos.d]# rpm -Uvh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
2.停止zabbix server服务
[root@kafka-node3 ~]# systemctl stop zabbix-server.service
3.备份数据库,防止出现意外
[root@kafka-node3 ~]# mysqldump -uroot -p123456 -B zabbix|gzip >zabbix_server.sql
4.停止数据库
[root@kafka-node3 ~]# systemctl stop mariadb.service
5.安装新版本
[root@kafka-node3 ~]# rm -rf /var/cache/yum/x86_64/*
[root@kafka-node3 ~]# yum makecache
[root@kafka-node3 ~]# yum install -y zabbix-server-mysql.x86_64
[root@kafka-node3 ~]# systemctl start mariab-server
[root@kafka-node3 ~]# systemctl start zabbix-server
#在zabbix-server启动的时候,数据库会进行自动升级
6.升级zabbix-web
[root@kafka-node3 ~]# wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.8.tar.gz
[root@kafka-node3 ~]# cp -ap /zabbix/conf/zaabix.conf.php /tmp
[root@kafka-node3 ~]# tar xf zabbix-5.0.8.tar.gz
[root@kafka-node3 ~]# \cp -a zabbix-5.0.8/ui/* /zabbix
7.卸载低版本php,进行php的升级
[root@kafka-node3 ~]# yum remove -y php-*
[root@kafka-node3 ~]# yum install -y epel-release
[root@kafka-node3 ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@kafka-node3 ~]# yum install php72w-fpm php72w-gd.x86_64 php72w-bcmath.x86_64 php72w-xml.x86_64 php72w-mbstring.x86_64 php72w-ldap.x86_64 php72w-mysqlnd.x86_64 -y
2.zabbix分布式监控
场景:
我们有不同机房,我们该如何监控?(不同网段,不在一个局域网中)
传统:各个主机需要有一个公网IP,当然,这是非常浪费资源,且不安全,例如我们的数据库,暴漏在公网环境下无疑是非常危险的
改进:我们可用zabbix-proxy来进行管理不同机房的机器,每个proxy只需要一个公网IP和和一个内网IP
图示:
实现:
zabbix-proxy 10.0.0.8 172.16.1.8(公网 私网)
1.安装数据库,并进行数据库的操作
[root@zabbix_proxy~]# yum install -y mariadb-server
[root@zabbix_proxy~]# systemctl start mariadb.service
[root@zabbix_proxy~]# systemctl enable mariadb.service
[root@zabbix_proxy~]# mysql
create database zabbix character set utf8 collate utf8_bin;
grant all on zabbix.* to zabbix@localhost identified by '123456';
2.安装proxy
[root@zabbix_proxy~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm/etc/yum.repos.d/zabbix.repo
[root@zabbix_proxy~]# sed -i 's#http://repo.zabbix.com#https://mirrors.tuna.tsinghu a.edu.cn/zabbix#g' /etc/yum.repos.d/zabbix.repo
[root@zabbix_proxy~]# yum install zabbix-proxy-mysql -y
3.导入表结构
[root@zabbix_proxy~]# zcat /usr/share/doc/zabbix-proxy-mysql-5.0.8/schema.sql.gz |mysql -uzabbix -p123456 zabbix
4.修改配置文件
[root@zabbix_proxy~]# vim /etc/zabbix/zabbix_proxy.conf
Server=10.0.0.71
ServerPort=10051
Hostname=tj_proxy
....
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
5.启动
[root@zabbix_proxy~]# systemctl start zabbix-proxy.service
[root@zabbix_proxy~]# systemctl enable zabbix-proxy.service
[root@zabbix_proxy~]# netstat -lntup|grep 10051 #查看端口是否存在
页面操作
1.添加代理
2.agent配置
#简单的proxy配置
[root@web01~]# vim /etc/zabbix/zabbix_agentd.conf #修改
Server=172.16.1.8
ServerActive=172.16.1.8
Hostname=172.16.1.9 #本机内网IP地址
[root@web01~]# systemctl restart zabbix-agent.service
#自动注册+proxy配置,需要在zabbix-server配置自动注册规则
[root@web01~]# vim /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=172.16.1.8
ServerActive=172.16.1.8
Hostname=172.16.1.143
HostMetadata=web
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
3.zabbix监控java环境
###简介###
zabbix-server是c语言开发
tomcat是java开发,需要java-gateway做转换
java-getgateway安装在zabbix-server端。 大型架构,我们在proxy和zabbix-server上安装java—gateway
1.开启tomcat的监控接口
#增加一行,粘贴时注意需要修改IP地址为本机的ip地址
[root@web ~]# vim /app/apache-tomcat-8.0.27/bin/catalina.sh
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=10.0.0.143 -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
#重启生效
[root@web ~]# /app/apache-tomcat-8.0.27/bin/shutdown.sh
[root@web ~]# /app/apache-tomcat-8.0.27/bin/start.sh
#检验端口
[root@web ~]# netstat -lntup|grep 12345
2.zabbix-server安装zabbix-java-gateway来监控jvm
[root@zabbix-server ~]# yum install zabbix-java-gateway.x86_64 -y
[root@zabbix-server ~]# systemctl start zabbix-java-gateway.service
[root@zabbix-server ~]# systemctl enable zabbix-java-gateway.service
3.修改java-gateway的配置文件
[root@zabbix-server ~]# vim /etc/zabbix/zabbix_java_gateway.conf #修改
JavaGateway=127.0.0.1
JavaGatewayPort=10052
StartJavaPollers=3
[root@zabbix-server ~]# systemctl restart zabbix-java-gateway.service
4.web界面操作
配置成功....
4.zabbix性能优化
性能不足的时候:经常出现误报,断图,还有其他报警
优化;
zabbix的数据库
引擎改为:tokudb(具有很高的压缩比,性能不错)
机械硬盘改为固态硬盘
去掉无用的监控项
增加监控项的取值间隔,建议间隔60s
减少数据的保留周期,重要的监控项保留90天,其他一律3天
数据非常庞大,进行数据库的分区分表
zabbix-server服务优化
进程数
缓存大小
5.zabbix低级自动发现