zabbix是一个开源监控解决方案

zabbix由2部分构成,zabbix server(服务端)与可选组件zabbix agent(客户端)

官网:www.zabbix.com

zabbix服务端安装

环境准备

关闭SeLinux

vi /etc/selinux/config

关闭防火墙

systemctl disable firewalld.service

安装Apache

yum install -y httpd

httpd服务开机进行自启

systemctl enable httpd

启动httpd服务

systemctl start httpd

查看httpd服务状态

systemctl status httpd

安装MySql

yum install -y mariadb mariadb-server

设置开机自启动

systemctl enable mariadb

启动mysql服务

systemctl start mariadb

查看mysql服务状态

systemctl status mariadb

输入mysql命令查看是否成功安装

安装php

yum install -y php php-mysql

安装zabbix

安装仓库

rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

安装相关包

yum install -y zabbix-server-mysql zabbix-get zabbix-web zabbix-web-mysql zabbix-agent zabbix-sender

创建数据库

mysql
create database zabbix character set utf8 collate utf8_bin;

show databases;

grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';

flush privileges;

exit;

导入数据表

进入zabbix目录

cd /usr/share/doc/zabbix-server-mysql-3.4.15/

解压create.sql.gz

gunzip create.sql.gz
mysql
use zabbix;

source create.sql;

exit;

zabbix服务端配置

配置文件目录

cd /etc/zabbix
vi zabbix_server.conf

修改DBHost、DBName、DBUser、DBPassword、DBSocket选项

  • DBHost=localhost
  • DBName=zabbix
  • DBUser=zabbix
  • DBPassword=zabbix
  • DBSocket=/var/lib/mysql/mysql.sock
systemctl start zabbix-server.service
systemctl enable zabbix-server.service

配置PHP

cd /etc/httpd/conf.d
vi zabbix.conf
php_value date.timezone Asia/Shanghai

systemctl restart httpd

WEB安装

浏览器ip/zabbix访问

Admin/zabbix

设置界面语言为中文

zabbix客户端配置

cd /usr/local/src/
wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
yum install -y zabbix-agent
vim /etc/zabbix/zabbix_agentd.conf
  • Server=服务端IP(被动模式)
  • ServerActive=服务端IP(主动模式)
  • Hostname=Zabbix #客户端名字在服务端设置的主机名(与web界面一样)
systemctl start zabbix-agent
systemctl enable zabbix-agent
systemctl stop firewalld

WEB添加主机

配置 -> 主机 -> 创建主机