Skip to content

Latest commit

 

History

History
167 lines (151 loc) · 9.03 KB

1.Zabbix4.0的安装.md

File metadata and controls

167 lines (151 loc) · 9.03 KB

@[toc] Github:https://github.com/ThanlonSmith/Zabbix-Tutorial

1. Zabbix架构

在这里插入图片描述 Zabbix Agent:Zabbix的客户端,负责 数据收集上传 Zabbix Server:Zabbix的服务端,负责数据汇总处理,告警策略,告警发送等 Zabbix Web:Zabbix的前端界面,提供友好的展示和操作界面,负责数据的展示、监控系统的配置管理、用户权限配置管理等功能 Database:配置数据存储的数据库,Zabbix支持多种数据库,包括MySQL、Oracle、DB2等 Java GateWay:Java网关,负责通过JVM监控收集Java应用性能数据 Zabbix Proxy:Zabbix代理,分布式部署架构会用到,主要是收集设备数据的监控数据并将数据发送给对应的Zabbix Server

数据通过Zabbix客户端收集并发送给Zabbix服务端,Zabbix服务端负责存储、分析数据、触发报警等任务。用户或者管理员可以通过Zabbix前端页面进行数据展示和配置管理。如果设备规模较多,并且分布在多地域或者多机房,都可以通过Zabbix Proxy实现分布式架构部署。

2. Zabbix Server组成

在这里插入图片描述 Zabbix Server由下面的一些列进程组成,每种进程有自己的特定功能。

3. 安装版本说明

       官方有标准版和长期支持版,因为官方对于长期支持版本支持的时间相对会长很多,所以我们会选择长期支持版本。Zabbix的4.0版本为当前日期最新的长期支持版本,所以接下来就安装这个版本。如果使用源码包安装,可能有些包没有启用。后期想用,它是不支持额外添加模块的,只能重新编译安装一次。所以,此外建议使用二进制包来安装,官方已经把该需要的功能都编译好了。

4. 安装repo源
# 安装zabbix的repo源:
[root@localhost ~]# rpm -ivh https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
# 替换为清华源的地址:
[root@localhost ~]# vim /etc/yum.repos.d/zabbix.repo
:%s#repo.zabbix.com#mirror.tuna.tsinghua.edu.cn/zabbix#g
5. 安装zabbix-server-mysql
[root@localhost ~]# yum install zabbix-server-mysql -y
6. 安装zabbix-web-mysql
[root@localhost ~]# yum install zabbix-web-mysql -y
7. 安装与配置数据库mariadb-server
# 安装mariadb-server
[root@localhost ~]# yum install mariadb-server -y

# 设置开机自启
root@localhost ~]# systemctl enable mariadb
[root@localhost ~]# systemctl is-enabled mariadb
enabled

# 数据库安全初始化(/etc/mysq.cnf的[mysqld]下添加skip-grant-tables,设置密码部分为n,其他为y)
[root@localhost ~]# mysql_secure_installation

# 创建数据库
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;

# 数据库授权
MariaDB [(none)]> grant all on zabbix.* to zabbix@'%' identified by '123456';
MariaDB [(none)]> flush privileges;

# 查找zabbix的sql文件
[root@localhost ~]# rpm -ql zabbix-server-mysql
[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-4.0.20/
[root@localhost zabbix-server-mysql-4.0.20]# ls
AUTHORS  ChangeLog  COPYING  create.sql.gz  NEWS  README
[root@localhost zabbix-server-mysql-4.0.20]# file create.sql.gz 
create.sql.gz: gzip compressed data, was "create.sql", from Unix, last modified: Mon Apr 27 09:04:32 2020
[root@localhost zabbix-server-mysql-4.0.20]# gzip -d create.sql.gz 

# 将sql文件导入到数据库中
[root@localhost zabbix-server-mysql-4.0.20]# mysql -uzabbix -p123456 zabbix <create.sql
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
| auditlog                   |
| auditlog_details           |
| autoreg_host               |
| conditions                 |
| config                     |
| corr_condition             |
| corr_condition_group       |
| corr_condition_tag         |
| corr_condition_tagpair     |
| corr_condition_tagvalue    |
| corr_operation             |
……
8. 修改zabbix-server配置文件
# 需要补充下密码,打开DBHost
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
如果mysql也是在本机上面,但是不是通过yum安装的,而是通过二进制或者编译安装可能需要配置socket路径,否则可能连接不上mysql

# 过滤需要修改的配置文件,进行检查
[root@localhost ~]# grep -Ev '^$|#' /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
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

# 设置zabbix开机自启
[root@localhost ~]# systemctl enable zabbix-server

# 启动zabbix
[root@localhost ~]# systemctl start zabbix-server

# 检查是否正常启动,默认端口是10051
[root@localhost ~]# netstat -nlp|grep 10051

# 如果没有权限则关闭selinux
[root@localhost ~]# setenforce 0

# setenforce 0是临时关闭防火墙,这里是永久关闭
[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

# 如果没有启动可以检查下启动日志
[root@localhost ~]# tailf /var/log/zabbix/zabbix_server.log
9. 修改zabbix-web配置文件
# 装好zabbix后就会在httpd的conf下就会多一个zabbix配置文件,启动httpd
oot@localhost ~]# systemctl start httpd

# 查看是否启动并用本地及其测试端口能否通
[root@localhost ~]# netstat -tunlp|grep 80

# 如果不通,关闭iptable防火墙
[root@localhost ~]# systemctl stop firewalld

这个时候就可以通过本机访问这台服务器了: 在这里插入图片描述

10. 配置时区

可以发现时区是未知的: 在这里插入图片描述 配置时区:

# 编辑时区默认是注释
[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
# 通过apache来调整php的参数,重启httpd服务
[root@localhost ~]# systemctl restart httpd

成功配置时区: 在这里插入图片描述

11. 配置数据库连接

在这里插入图片描述

12. 配置Zabbix Server

填写zabbix server的名字,这个名字将作为标题: 在这里插入图片描述 没有什么问题,下一步就可以:在这里插入图片描述 直接Finish: 在这里插入图片描述

13. Zabbix登录

默认的用户名是:Admin,密码是:zabbix 在这里插入图片描述 正常登录则Zabbix安装成功: 在这里插入图片描述

Github:https://github.com/ThanlonSmith/Zabbix-Tutorial