zabbix监控系统的搭建
系统版本:
[root@localhost ~]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)
[root@localhost ~]# cat /proc/version
Linux version 3.10.0-957.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 8 23:39:32 UTC 2018
zabbix
zabbix组件
zabbix agent:部署在被监控主机上,负责采集被监控主机上的数据,并将采集到的数据发送给zabbix server
zabbix server:负责接收agent发送的数据,统计数据、管理数据
zabbix database:用于存储所有zabbix的配置信息以及监控数据
zabbix web:管理员通过web界面管理、配置以及查看相关监控信息
zabbix-proxy:分布式监控,用来分担zabbix server的压力
版本
- zabbix稳定版:LTS代表稳定版,官方提供技术支持时间长达5年时间(免费)
- zabbix标准版:不带LTS标签,官方提供技术支持时间7个月(免费)
查询地址:https://www.zabbix.com/cn/life_cycle_and_release_policy
准备环境;
脚本
=系统环境初始化脚本=
——>>> 关闭防火墙与SELinux <<<——
——>>> 创建阿里仓库 <<<——
——>>> 设置时区并同步时间 <<<——
安装 Zabbix 存储库
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm [root@localhost ~]# yum clean all
安装 Zabbix 服务器和代理
[root@localhost ~]# yum install zabbix-server-mysql zabbix-agent
安装 Zabbix 前端
[root@localhost ~]# yum install centos-release-scl
编辑文件 /etc/yum.repos.d/zabbix.repo 并启用 zabbix-frontend repository
[root@localhost ~]# ls /etc/yum.repos.d/zabbix.repo [root@localhost ~]# vim /etc/yum.repos.d/zabbix.repo …… [zabbix-frontend] name=Zabbix Official Repository frontend - $basearch baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend enabled=1 #修改为1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 ……
安装 Zabbix 前端软件包
[root@localhost ~]# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
安装mariadb-server数据库
[root@localhost ~]# yum -y install mariadb-server
启动数据库,并且永久自启
[root@localhost ~]# systemctl start mariadb.service [root@localhost ~]# systemctl enable mariadb.service
进入数据库
[root@localhost ~]# mysql
创建zabbix库
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
创建zabbix用户 并且设置密码为123456
MariaDB [(none)]> create user zabbix@localhost identified by '123456';
zabbix用户授权,可以访问zabbix库内的所有表
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
查看数据库 的库
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | | zabbix | +--------------------+
切换用户
MariaDB [(none)]> use zabbix;
查看zabbix库内的表,(此处无表格)
MariaDB [zabbix]> show tables; Empty set (0.00 sec)
在Zabbix服务器主机上导入初始架构和数据。系统将提示您输入新创建的密码
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix Enter password: 输入mariadb设置的密码
进入数据库查看zabbix库内的表格
[root@localhost ~]# mysql MariaDB [(none)]> use zabbix MariaDB [zabbix]> show tables; +----------------------------+ | Tables_in_zabbix | +----------------------------+ | acknowledges | | actions | | alerts | | application_discovery | | application_prototype | | application_template | | applications | | auditlog | …… | widget | | widget_field | +----------------------------+ 166 rows in set (0.00 sec)
为Zabbix服务器配置数据库
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf SocketDir=/var/run/zabbix ### Option: DBHost # Database host name. # If set to localhost, socket is used for MySQL. # If set to empty string, socket is used for PostgreSQL. # # Mandatory: no # Default: # DBHost=localhost ### Option: DBName # Database name. # # Mandatory: yes # Default: # DBName= DBName=zabbix `数据库库名` ### Option: DBSchema # Schema name. Used for PostgreSQL. # # Mandatory: no # Default: # DBSchema= ### Option: DBUser # Database user. # # Mandatory: no # Default: # DBUser= DBUser=zabbix `数据库用户名` ### Option: DBPassword # Database password. # Comment this line if no password is used. # # Mandatory: no # Default: DBPassword=123456 `数据库密码`
为Zabbix前端配置PHP
[root@localhost ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf php_value[date.timezone] = Asia/Shanghai
启动 Zabbix 服务器和代理进程
启动Zabbix服务器和代理进程,并使其在系统启动时启动。
[root@localhost ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm [root@localhost ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
zabbix日志
[root@localhost ~]# ls /var/log/zabbix/ zabbix_agentd.log zabbix_server.log
浏览器访问 本机ip192.168.70.10
全部项目 还行 后才能继续配置
密码输入数据库中zabbix用户的密码
登录初始账户和密码
进入
zabbix界面汉化
用户
创建普通用户
1-7表示周一至周日 00::00-24:00表示24小时
普通用户登录
Amin修改密码后登录



