一:查询当前系统版本

  1. [root@localhost ~]# cat /etc/redhat-release #查询linux Centos版本
  2. CentOS Linux release 8.2.2004 (Core)
  3. [root@localhost ~]# uname -r #查询版本内核
  4. 4.18.0-193.el8.x86_64

二:关闭防火墙和selinux

  1. [root@localhost zabbix-server-mysql]# setenforce 0
  2. [root@localhost zabbix-server-mysql]# systemctl stop firewalld.service

三:部署底层环境LAMP
注意: zabbix 6.0 需要 安装10.6.5以上的Mariadb,而系统自带的为10.5,所以需要安装额外源

  1. cat <<EOF > /etc/yum.repos.d/mariadb.repo
  2. # MariaDB 10.6 CentOS repository list - created 2022-01-16 15:10 UTC
  3. # https://mariadb.org/download/
  4. [mariadb]
  5. name = MariaDB
  6. baseurl = https://mirrors.cloud.tencent.com/mariadb/yum/10.6/centos8-amd64
  7. module_hotfixes=1
  8. gpgkey=https://mirrors.cloud.tencent.com/mariadb/yum/RPM-GPG-KEY-MariaDB
  9. gpgcheck=1
  10. EOF

1.开始安装 底层环境

  1. [root@localhost itlaoxin]# dnf install mariadb mariadb-server httpd httpd-tools php php-cli php-json php-gd php-mbstring php-pdo php-xml php-mysqlnd php-pecl-zip wget -y

2.配置zabbix源

  1. [root@localhost ]# rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
  2. 获取https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
  3. 警告:/var/tmp/rpm-tmp.k7Xsgd: V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
  4. Verifying... ################################# [100%]
  5. 准备中... ################################# [100%]
  6. 正在升级/安装...
  7. 1:zabbix-release-6.0-1.el8 ################################# [100%]

3.安装zabbix

  1. [root@localhost ]# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2 -y

4.配置MySQL

  1. root@localhost ]# systemctl start mariadb && systemctl enable mariadb
  2. Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service /usr/lib/systemd/system/mariadb.service.
  3. [root@localhost ]# mysql
  4. Welcome to the MariaDB monitor. Commands end with ; or \g.
  5. Your MariaDB connection id is 3
  6. Server version: 10.6.7-MariaDB MariaDB Server
  7. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9. MariaDB [(none)]>
  10. 设置 数据库名: zabbix
  11. 用户名:zabbix
  12. 密码: 123456
  13. 让用户zabbix,能够通过本地访问数据库zabbix,使用123456作为密码
  14. MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
  15. Query OK, 1 row affected (0.001 sec)
  16. MariaDB [(none)]> grant all on zabbix.* to zabbix@'localhost' identified by '123456';
  17. Query OK, 0 rows affected (0.001 sec)
  18. MariaDB [(none)]> flush privileges;
  19. Query OK, 0 rows affected (0.001 sec)
  20. MariaDB [(none)]> quit
  21. Bye
  22. #导入初始架构和数据
  23. [root@localhost zabbix-server-mysql]# zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix
  24. #为zabbix server配置数据库
  25. [root@localhost ]# vim /etc/zabbix/zabbix_server.conf
  26. 124 DBPassword=123456
  27. [root@localhost zabbix-server-mysql]# grep DBPassword /etc/zabbix/zabbix_server.conf |grep -v ^#
  28. DBPassword=123456

5.启动Zabbix server和agent进程

  1. [root@localhost ]# systemctl restart zabbix-server zabbix-agent2 httpd php-fpm
  2. [root@localhost ]# systemctl enable zabbix-server zabbix-agent2 httpd php-fpm

1.打开浏览器输入本机地址:http://192.168.31.129/zabbix
image.png
2.如果没有问题就选择中文,下一步。
image.png
3.在选择下一步
image.png
4.输入用户名Admin,密码:zabbix,点击登录; 注意大小写。
image.png

四:配置被监控主机

  1. [root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm #下载YUM源
  2. [root@localhost ~]# dnf clean all #清理缓存
  3. [root@localhost ~]# dnf -y install zabbix-agent #安装agent
  4. [root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf #修改配置文件
  5. [root@localhost ~]# grep "^[a-Z]" /etc/zabbix/zabbix_agentd.conf
  6. PidFile=/run/zabbix/zabbix_agentd.pid
  7. LogFile=/var/log/zabbix/zabbix_agentd.log
  8. LogFileSize=0
  9. Server=127.0.0.1,192.168.10.30
  10. ListenPort=10050
  11. ListenIP=0.0.0.0
  12. StartAgents=3
  13. ServerActive=192.168.10.30
  14. Hostname=web1
  15. Include=/etc/zabbix/zabbix_agentd.d/*.conf
  16. [root@localhost ~]# systemctl restart zabbix-agent
  17. [root@localhost ~]# systemctl status zabbix-agent.service
  18. ● zabbix-agent.service - Zabbix Agent
  19. Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
  20. Active: active (running) since Mon 2022-06-27 06:01:40 EDT; 57min ago
  21. Process: 34735 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
  22. Main PID: 34738 (zabbix_agentd)
  23. Tasks: 6 (limit: 4839)
  24. Memory: 4.1M
  25. CGroup: /system.slice/zabbix-agent.service
  26. ├─34738 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
  27. ├─34739 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
  28. ├─34740 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
  29. ├─34741 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
  30. ├─34742 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
  31. └─34743 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

五:解决主机详情出现口口,中文乱码的情况

首先在windows上找个中文字体库文件,或者网上下载。拷贝zabbix安装目录解决乱码的情况。
image.png

  1. [root@localhost ~]# find / -name graphfont.ttf #查找字体所在位置
  2. /usr/share/zabbix/assets/fonts/graphfont.ttf
  3. [root@localhost ~]# find / -name "graphfont.ttf"
  4. /usr/share/zabbix/assets/fonts/graphfont.ttf
  5. [root@localhost ~]# cd /usr/share/zabbix/assets/fonts/
  6. [root@localhost fonts]# ls
  7. graphfont.ttf graphfont.ttf.bak
  8. [root@localhost fonts]# ll
  9. 总用量 11512
  10. lrwxrwxrwx 1 root root 33 6 27 04:02 graphfont.ttf -> /etc/alternatives/zabbix-web-font
  11. -rw-r--r-- 1 root root 11787328 6 27 08:40 graphfont.ttf.bak
  12. [root@localhost fonts]# mv graphfont.ttf.bak /usr/share/zabbix/assets/
  13. [root@localhost fonts]# cd ..
  14. [root@localhost assets]# ls
  15. fonts graphfont.ttf.bak img styles
  16. [root@localhost assets]# ll /usr/share/zabbix/assets/fonts/graphfont.ttf
  17. lrwxrwxrwx 1 root root 33 6 27 04:02 /usr/share/zabbix/assets/fonts/graphfont.ttf -> /etc/alternatives/zabbix-web-font
  18. [root@localhost assets]# ll /etc/alternatives/zabbix-web-font
  19. lrwxrwxrwx 1 root root 38 6 27 04:02 /etc/alternatives/zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttf
  20. [root@localhost assets]# mv /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/fonts/dejavu/DejaVuSans.ttfback
  21. [root@localhost assets]# ls
  22. fonts graphfont.ttf.bak img styles
  23. [root@localhost assets]# mv graphfont.ttf.bak /usr/share/fonts/dejavu/DejaVuSans.ttf

image.png
centos 7.9请参考以下文档

https://os.51cto.com/article/677056.html https://blog.csdn.net/ht9999i/article/details/125169447