https://www.zabbix.com/cn/download?zabbix=4.4&os_distribution=centos&os_version=7&db=mysql&ws=apache

服务端

1.准备工作

测试环境:
关闭SElinux、防火墙
centos7.6

关闭SELinux与防火墙

  1. #1.关闭SElinux
  2. setenforce 0
  3. vim /etc/selinux/config
  4. SELINUX=disabled
  5. #2.关闭防火墙
  6. systemctl stop firewalld
  7. systemctl disable firewalld

安装httpd

  1. #1.安装
  2. yum install -y httpd
  3. #2.开机自启
  4. systemctl enable httpd
  5. #3.启动
  6. systemctl start httpd

安装Mariadb

  1. #1.安装
  2. yum install -y mariadb mariadb-server
  3. #2.设置自启动
  4. systemctl enable mariadb
  5. #3.启动
  6. systemctl start mariadb
  7. #4.数据库安全初始化
  8. mysql_secure_installation
  9. #5.连接数据库后创建zabbix所需的数据库与系统用户
  10. MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
  11. MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';

2.安装Zabbix

添加Zabbix软件仓库

  1. #1.安装软件仓库
  2. rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
  3. #2.修改软件仓库配置
  4. vim /etc/yum.repo.d/zabbix.repo
  5. [zabbix]
  6. name=Zabbix Official Repository - $basearch
  7. baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/
  8. ...

安装Zabbix服务端和前端

  1. yum install zabbix-server-mysql zabbix-web-mysql

导入数据

  1. zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
  2. #连接mysql查看是否导入成功
  3. MariaDB [(none)]> use zabbix
  4. MariaDB [(none)]> show tables;

3.配置Zabbix

  1. #1.修改与zabbix与数据库连接配置
  2. vim /etc/zabbix/zabbix_server.conf
  3. DBHost=localhost
  4. DBName=zabbix
  5. DBUser=zabbix
  6. DBPassword=zabbix
  7. #2.修改前端的时区配置
  8. vim /etc/httpd/conf.d/zabbix.conf
  9. php_value max_execution_time 300
  10. php_value memory_limit 128M
  11. php_value post_max_size 16M
  12. php_value upload_max_filesize 2M
  13. php_value max_input_time 300
  14. php_value always_populate_raw_post_data -1
  15. # php_value date.timezone Asia/Shanghai

4.启动

  1. #加入自启
  2. systemctl enbale zabbix-server
  3. #启动
  4. systemctl start zabbix-server

访问本机IP完成初始化

客户端

  1. #1.获取客户端
  2. wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.18-1.el7.x86_64.rpm
  3. #2.安装
  4. rpm -ivh zabbix-agent-4.0.18-1.el7.x86_64.rpm
  5. #3.配置客户端
  6. cat /etc/zabbix/zabbix_agentd.conf
  7. PidFile=/var/run/zabbix/zabbix_agentd.pid
  8. LogFile=/var/log/zabbix/zabbix_agentd.log
  9. LogFileSize=0
  10. Server=127.0.0.1 #服务端的IP地址
  11. ServerActive=127.0.0.1
  12. Hostname=Zabbix server
  13. Include=/etc/zabbix/zabbix_agentd.d/*.conf
  14. #4.开启自启
  15. systemctl enable zabbix-agentd
  16. #5.启动
  17. systemctl start zabbix-agentd