zabbix配置-Centos7安装Zabbix4.0
一、服务器配置
1、初始配置:配置IP地址、主机名,关闭 kdump 与 SELinux
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
[root@localhost ~]# vim /etc/sysconfig/network
[root@localhost ~]# vim /etc/hosts
[root@localhost ~]# vim /etc/selinux/config
[root@localhost ~]# systemctl stop kdump
[root@localhost ~]# systemctl disable kdump
Removed symlink /etc/systemd/system/multi-user.target.wants/kdump.service.
[root@localhost ~]# reboot
2、部署LAMP
使用网络yum源
(1)安装Apache 和 Mariadb
[root@zbx ~]# yum install httpd -y
[root@zbx ~]# yum install mariadb-server -y
[root@zbx ~]# systemctl start httpd.service #开启httpd服务
[root@zbx ~]# systemctl enable httpd.service #设置httpd开机自启动
[root@zbx ~]# systemctl start mariadb.service #开启Mariadb服务
[root@zbx ~]# systemctl enable mariadb.service #设置Mariadb开机自启动
(2)安装PHP
安装php包
[root@zbx ~]# yum -y install php
安装PHP组件,使PHP支持 MariaDB
[root@zbx ~]# yum -y install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
重启MariaDB、 Apache
[root@zbx ~]# systemctl restart mariadb.service
[root@zbx ~]# systemctl restart httpd.service
3、部署Zabbix
(1)安装“Zabbix安装包”资源存储库
网址:http://www.zabbix.com/download.php
[root@zbx ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
[root@zbx ~]# yum clean all
(2)安装Zabbix
[root@zbx ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
[root@zbx ~]# yum install centos-release-scl -y
(3)对数据库进行初始化并创建Zabbix数据库
[root@zbx ~]# mysqladmin -u root password 9865321
[root@zbx ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.68-MariaDB MariaDB Server
Copyright © 2000, 2018, 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;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by ‘Z9865321’;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye
[root@zbx ~]# zcat /usr/share/doc/zabbix-server-mysql-*/create.sql.gz | mysql -uroot zabbix -p
Enter password:
(4)编辑Zabbix数据库配置文件并启动Zabbix服务
[root@zbx ~]# vim /etc/zabbix/zabbix_server.conf
[root@zbx ~]# systemctl start zabbix-server
[root@zbx ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
(5)修改 vim /etc/httpd/conf.d/zabbix.conf
[root@zbx ~]# vim /etc/httpd/conf.d/zabbix.conf
修改第20行
(6)配置防火墙
[root@zbx ~]# firewall-cmd --permanent --zone=public --add-port=10051/tcp
success
[root@zbx ~]# firewall-cmd --zone=public --add-port=10051/tcp
success
[root@zbx ~]# firewall-cmd --permanent --zone=public --add-port=80/tcp
success
[root@zbx ~]# firewall-cmd --zone=public --add-port=80/tcp
success
(7)启动 Zabbix server and agent
[root@zbx ~]# systemctl restart zabbix-server zabbix-agent httpd
[root@zbx ~]# systemctl enable zabbix-server zabbix-agent httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
(8)在WebUI中继续安装
[root@zbx ~]# firefox http://127.0.0.1/zabbix
在网页中打开zabbix
下一步
确保右侧全为OK,下一步
输入密码Z9865321,下一步
下一步
完成
第一次登录,用户名:Admin,密码:zabbix
右上角设置语言为中文
二、客户机配置
1、安装“Zabbix安装包”
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
2、安装zabbix-agent
[root@localhost ~]# yum -y install zabbix-agent
3、配置/etc/zabbix/zabbix_agentd.conf
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
修改第98、139行
4、开启zabbix-agent并设置开机自启动
[root@localhost ~]# systemctl start zabbix-agent.service
[root@localhost ~]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
5、关闭防火墙、沙盒
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
三、配置zabbix
配置—主机—创建主机
设置模板
添加完成
注:看到ZBX变成绿色字体后说明成功添加,这个时候查看图形信息即可。
若ZBX变成红色并出现下列提示,检查防火墙和沙盒是否关闭,是否联网,准备好后reboot重启,再刷新界面。
四、Windows客户机配置
1、关闭防火墙
2、安装zabbix-agent
打开网页
https://www.zabbix.com/download_agents
下载安装包
打开文件夹安装
安装完成
3、添加配置主机
配置—主机—创建主机
添加模板
完成!