Zabbix簡介
zabbix(音同 zæbix)是一個基於WEB界面的提供分布式系統監視以及網絡監視功能的企業級的開源解決方案。
zabbix能監視各種網絡參數,保證服務器系統的安全運營;並提供靈活的通知機制以讓系統管理員快速定位/解決存在的各種問題。
zabbix由2部分構成,zabbix server與可選組件zabbix agent。
zabbix server可以通過SNMP,zabbix agent,ping,端口監視等方法提供對遠程服務器/網絡狀態的監視,數據收集等功能,它可以運行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
官方中文文檔:https://www.zabbix.com/documentation/3.4/zh/manual
Zabbix 通過 C/S 模式采集數據,通過 B/S 模式在 web 端展示和配置。
被監控端:主機通過安裝 agent 方式采集數據,網絡設備通過 SNMP 方式采集數據
Server 端:通過收集 SNMP 和 agent 發送的數據,寫入數據庫(MySQL,ORACLE 等) ,
再通過 php+apache 在 web 前端展示。
Zabbix 運行條件:
Server:Zabbix Server 需運行在 LAMP(Linux+Apache+Mysql+PHP)環境下(或者
LNMP),對硬件要求低
Agent:目前已有的 agent 基本支持市面常見的 OS,包含 Linux、HPUX、Solaris、Sun 、
windows
SNMP:支持各類常見的網絡設備
zabbix優劣勢
優點:
開源,無軟件成本投入;
Server 對設備性能要求低;
支持設備多,自帶多種監控模板;
支持分布式集中管理,有自動發現功能,可以實現自動化監控;
開放式接口,擴展性強,插件編寫容易;
當監控的 item 比較多服務器隊列比較大時可以采用被動狀態,被監控客戶端主動從server 端去下載需要監控的 item 然后取數據上傳到 server 端。這種方式對服務器的負載比較小。Api 的支持,方便與其他系統結合;
缺點:
需在被監控主機上安裝 agent,所有數據都存在數據庫里,產生的數據據很大,瓶頸主要在數據庫;
Zabbix安裝部署
系統環境
IP |
主機名 |
功能 |
系統 |
192.168.128.165 |
compute |
Zabbix_server |
CentOS 7.4.17 |
192.168.128.166 |
controller |
Zabbix_agent |
CentOS 7.4.17 |
1、 先把ip和主機名寫入/hosts文件(兩台都要) [root@compute ~]# echo "192.168.128.166 controller" >>/etc/hosts [root@compute ~]# echo "192.168.128.165 compute" >>/etc/hosts 2、修改yum源(兩台都要) [root@compute~]#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo [root@compute ~]# yum clean all && yum makecache [root@compute ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
3、關閉iptables和selinux
時間同步
[root@compute ~]# yum install -y ntp [root@compute ~]# systemctl start ntpd 加入定時任務中: * * * * * /usr/sbin/ntpdate time.asia.apple.com && hwclock -w >/dev/null 2>&1
Server端部署
rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y yum install -y mariadb-server [root@compute ~]# systemctl start mariadb [root@compute ~]# systemctl enable mariadb [root@compute ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 375 Server version: 10.1.20-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin; MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; MariaDB [(none)]> quit; #導入數據庫 [root@compute ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix #修改zabbix_server.config添加DBHost、DBPassword [root@compute ~]# grep ^[a-Z] /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 DBName=zabbix DBUser=zabbix SNMPTrapperFile=/var/log/snmptrap/snmptrap.log Timeout=4 AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts LogSlowQueries=3000 DBHost=localhost DBPassword=zabbix #啟動zabbix_servera服務 [root@compute ~]# systemctl start zabbix-server [root@compute ~]# systemctl enable zabbix-server #修改httpd中的zabbix.conf [root@compute ~]# vim /etc/httpd/conf.d/zabbix.conf 設置php.ini正確的時區 php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value always_populate_raw_post_data -1 php_value date.timezone Asia/Shanghai #啟動httpd服務 [root@compute ~]# systemctl enable httpd [root@compute ~]# systemctl start httpd
客戶端zabbix_Agent部署
rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm yum install -y zabbix-agent #修改/etc/zabbix/zabbix_agentd.conf #Server=127.0.0.1 Server=192.168.128.165 #ServerActive=127.0.0.1 ServerActive=192.168.128.165 //server端ip HostName=controller //主機名唯一的 HostMetadataItem=system.uname //設置默認模板,server端自動發現 #啟動agent服務 systemctl start zabbix-agent systemctl enable zabbix-agent
配置zabbix_web
1.瀏覽器打開http://192.168.128.165/zabbix進入界面
2.環境檢測
3.初始化數據庫,密碼為zabbix數據庫密碼
4.詳細信息如默認,Name任意取
5.全部配置概要
6.安裝
7.登錄zabbix,默認賬號/密碼:Admin/zabbix