glcui 发表于 2019-1-24 10:11:13

centos7 yum安装zabbix监控

  一、安装zabbix server

  1、升级系统组件到最新版本
  # yum -y update
  2、安装过程中为了方便,关闭seliunx和防火墙
  3、安装mysql5.7,操作过程请另外参考文件(省略)
http://blog.运维网.com/13941177/C:/Users/Administrator/AppData/Local/YNote/data/qq1644FB913F181336BE941720CBB4F047/0553ec5dba084e50bdfe52210e70d9f5/clipboard.pnghttp://s1.运维网.com/images/20181106/1541512812676939.png
  4、安装Apache
  # yum -y install httpd
  # systemctl start httpd.service #启动
  # systemctl stop httpd.service #停止
  # systemctl restart httpd.service #重启
  # systemctl enable httpd.service #开机启动
  # systemctl disable httpd.service #开机不启动
  5.1、安装php(参考php5.6安装手册)
  # yum -y install php56w.x86_64 (省略了一部分操作)
  5.2、安装php扩展
  # yum install php-mysqlnd php-gd libjpeg* php-snmp php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash php-common php-ctype php-xml php-xmlreader php-xmlwriter php-session php-mbstring php-gettext php-ldap php-mysqli --skip-broken
  # yum install wget telnet net-tools python-paramiko gcc gcc-c++ dejavu-sans-fonts python-setuptools python-devel sendmail mailx net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC
http://blog.运维网.com/13941177/C:/Users/Administrator/AppData/Local/YNote/data/qq1644FB913F181336BE941720CBB4F047/9dbd685f3c284bf0a205b1f2eeb34f1a/clipboard.pnghttp://s1.运维网.com/images/20181106/1541512831876434.png
  6、数据库授权
  mysql>create database zabbix character set utf8; #创建数据库
  mysql> grant all privileges on zabbix.* to yuzhuan@'%' identified by 'Yuzhuan@123';
  mysql>flush privileges;
  7.1、安装 Zabbix源3.4
  # rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
  7.2、安装zabbix
  # yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-java-gateway zabbix-web
  7.3、导入 zabbix 所需信息
  # cd /usr/share/doc/zabbix-server-mysql-3.4.8/
http://blog.运维网.com/13941177/C:/Users/Administrator/AppData/Local/YNote/data/qq1644FB913F181336BE941720CBB4F047/e1f71b5947624ad788e1d7ba158d4929/clipboard.pnghttp://s1.运维网.com/images/20181106/1541512839149096.png
  # zcat create.sql.gz | mysql -uroot zabbix -p
  7.4、配置 zabbix 参数
  # vim /etc/zabbix/zabbix_server.conf
  DBPassword 配置为第 126 行中设置的自定义密码
http://blog.运维网.com/13941177/C:/Users/Administrator/AppData/Local/YNote/data/qq1644FB913F181336BE941720CBB4F047/130850c5fbe1424f8b8bbba885941bce/clipboard.pnghttp://s1.运维网.com/images/20181106/1541512845286066.png
  CacheSize=512M
  (CacheSize在385行)
  HistoryCacheSize=128M
  (HistoryCacheSize在410行)
  HistoryIndexCacheSize=128M
  (HistoryIndexCacheSize在419行)
  TrendCacheSize=128M
  (TrendCacheSize在428行)
  ValueCacheSize=256M
  (ValueCacheSize在438行)
  Timeout=30
  (Timeout在448)
  其它参数保持默认值即可
  如果需要监控VMware虚拟机,则还需要设置以下选项参数:
  StartVMwareCollectors=2
  (StartVMwareCollectors在272行
  VMwareCacheSize=256M
  (VMwareCacheSize 在298行)
  VMwareTimeout=300
  (VMwareTimeout在306行)
  7.5、配置 Apache 中的 PHP 参数(8GB 内存为例)
  # vim /etc/httpd/conf.d/zabbix.conf
  php_value max_execution_time 600
  php_value memory_limit 256M
  php_value post_max_size 32M
  php_value upload_max_filesize 32M
  php_value max_input_time 600
  php_value always_populate_raw_post_data -1
  date.timezone 去掉注释符号#,并将值修改为 Asia/Shanghai
  7.6、关闭服务,重启系统
  # systemctl stop mysqld && reboot
  7.7、 启动zabbix
  # systemctl start mysqld       #启动数据库
  # systemctl start httpd         #启动Apache
  # systemctl start zabbix-server#启动zabbix
  7.7在浏览器中输入 http://zbx监控服务器的IP地址/zabbix,进行 zabbix 的页面初始化配置
  http://192.168.232.133/zabbix/
http://blog.运维网.com/13941177/C:/Users/Administrator/AppData/Local/YNote/data/qq1644FB913F181336BE941720CBB4F047/d417db1eb8434e55ac0581f6c8b8437e/clipboard.pnghttp://s1.运维网.com/images/20181106/1541512869973027.png
  补充:
  故障问题收集:https://blog.csdn.net/zhangrandl/article/details/38339169
  1、修改zabbix链接的数据库IP地址、账号,密码
  # vim /etc/zabbix/web/zabbix.conf.php
  2、查看zabbix日志
  # cat /var/log/zabbix/zabbix_server.log
  3;常见报错
http://blog.运维网.com/13941177/C:/Users/Administrator/AppData/Local/YNote/data/qq1644FB913F181336BE941720CBB4F047/f3fe0b25e5704e92b22d58c17ef43e41/clipboard.pnghttp://s1.运维网.com/images/20181106/1541512911592286.png
  解决思路:内存和cup查看均未监控,并发现10050端口未启动,安装zabbix_agent,配置相关参数即可
  # vim zabbix_agentd.conf
  Server=192.168.232.133
  ServerActive=192.168.232.133
  Hostname=192.168.232.133
  4.1、Zabbix discoverer processes more than 75% busy报错
  4.2.原因
  1)配置的每个discovery任务在一定时间内占用1个discovery进程,而zabbix_server.conf中默认配置只有1个discovery(被注释,默认生效);
  2)同时为了快速验证自动发现效果,将discovery任务的"Delay"时间由默认的3600s设置成60s。
  总结:两个原因导致平均时间内discovery processes过高而报警。
  4.3、解决方法
  1) 修改zabbix_server.conf中discovery进程数量;
  #StartDiscoverers可根据设置的discovery任务数量设置,范围是0~250
  # sed -i 's|# StartDiscoverers=1|StartDiscoverers=2|g' /etc/zabbix/zabbix_server.conf
  # systemctl restart zabbix-server
  2) 将discovery任务的"Delay"时间设置足够长,降低平均时间内进程的占用率。
http://blog.运维网.com/13941177/C:/Users/Administrator/AppData/Local/YNote/data/qq1644FB913F181336BE941720CBB4F047/24135c3884394bc0a34bebf4e782aaf9/clipboard.pnghttp://s1.运维网.com/images/20181106/1541512918732776.png
  5.1,日志报错:
  no active checks on server : host not found
  原因:主机明设置问题
  解决方法:
http://blog.运维网.com/13941177/C:/Users/Administrator/AppData/Local/YNote/data/qq1644FB913F181336BE941720CBB4F047/ac644880168942669cd8ecc5f804ec95/clipboard.pnghttp://s1.运维网.com/images/20181106/1541512924572430.png
  二、安装zabbix agengt
  1、安装新版3.4
  # rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
  2、安装zabbix agengt
  # yum clean all
  # yum -y install zabbix-agent
  3、配置
  # vim /etc/zabbix/zabbix_agentd.conf
  sed -i "s/Server=127.0.0.1/Server=192.168.232.133/" /etc/zabbix/zabbix_agentd.confsed -i "s/ServerActive=127.0.0.1/ServerActive=192.168.232.133/" /etc/zabbix/zabbix_agentd.conf      (主动模式)sed -i "s/Hostname=Zabbix server/Hostname=192.168.232.130/" /etc/zabbix/zabbix_agentd.conf
  4、开启防火墙端口
  # firewall-cmd --zone=public --add-port=10050/tcp --permanent
  # firewall-cmd --reload
http://blog.运维网.com/13941177/C:/Users/Administrator/AppData/Local/YNote/data/qq1644FB913F181336BE941720CBB4F047/e8706b09f5bd4c0e9b010fe3eb2e33fe/clipboard.pnghttp://s1.运维网.com/images/20181106/1541512932551231.png
  5、启动服务
  # systemctl start zabbix-agent.service



页: [1]
查看完整版本: centos7 yum安装zabbix监控