一、zabiix分布式原理图:
zabbix分布式管理原理图.pngzabbix分布式就相当于在基础环境中搭建了一个中转站zabbix-porxy,porxy可以把其监控项全部收纳起来,等待zabbix-server服务器的读取。(用分布式项目优势,可以在内网中对要进行监控的服务器进行监控)
二、准备实验环境:
zabbix分布式管理环境部署图.png服务器角色 ip 服务器名
zabbix-server 10.0.0.71 zabbix
zabbix-proxy 10.0.0.7/172.16.1.7 web01
zabbix-agent 172.16.1.20 web02-jk
需要部署的程序:
zabbix-server 部署的程序:zabbix-server-mysql 、zabbix-web-mysql、mariadb-server、httpd(内外网都需要)
zabbix-proxy 部署的程序:mariadb-server、zabbix-proxy(内外网都需要)
zabbix-agent 部署的程序:zabbix-agent、把外网关闭(只保存内网172.16.1.20)
1、 zabbix-server的搭建在第59课已经有搭建过,这里不做说明。
2、 zabbix-proxy的环境部署(在web01上部署):
2.1 官网下载zabbix源:
image.png2.2 修改zabbix.repo源:
[root@web01 yum.repos.d]# vim zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0
2.3 安装zabbix-proxy:
[root@web01 yum.repos.d]# yum install -y zabbix-proxy-mysql
[root@web01 yum.repos.d]# rpm -qa zabbix-proxy-mysql
zabbix-proxy-mysql-4.0.10-1.el7.x86_64
2.4 安装mariadb-server:
[root@web01 ]# yum install -y mariadb-server
[root@web01 yum.repos.d]# rpm -qa mariadb-server
mariadb-server-5.5.60-1.el7_5.x86_64
2.5 优化数据库(mysql安全初始化):
[root@zabbix yum.repos.d]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] n
... skipping.
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
2.6 创建数据库:
[root@web01 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 37
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 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_proxy charset utf8;
MariaDB [(none)]> grant all on zabbix_proxy.* to zabbix_proxy@localhost identified by '123456';
MariaDB [(none)]> select user,host from mysql.user;
+--------------+------------+
| user | host |
+--------------+------------+
| root | 127.0.0.1 |
| bbs | 172.16.1.% |
| root | ::1 |
| bbs | localhost |
| root | localhost |
| zabbix_proxy | localhost |
| root | web01 |
+--------------+------------+
7 rows in set (0.02 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| bbs |
| mysql |
| performance_schema |
| test |
| zabbix_proxy |
+--------------------+
6 rows in set (0.00 sec)
2.7 导入初始化数据库并启动数据库、设置开机自启:
[root@web01 ~]# zcat /usr/share/doc/zabbix-proxy-mysql-4.0.10/schema.sql.gz |mysql -uzabbix_proxy -p123456 zabbix_proxy
[root@web01 ~]#systemctl start mariadb.server
[root@web01 ~]#systemctl enable mariadb.server
2.8 修改zabbix-proxy配置文件,启动proxy,并开机自启:
84AAC784-8B7E-426b-A371-DFFDAC6CD622.png
[root@web01 ~]# systemctl start zabbix-proxy
[root@web01 ~]# systemctl enable zabbix-proxy
2.9 修改zabbix-agent配置文件, 启动zabbix-agent服务并设置开机自启:
zabiix-agent配置.png
[root@web01 ~]# systemctl start zabbix-proxy
[root@web01 ~]# systemctl enable zabbix-proxy
2.10 添加hosts解析:
zabbix-server服务器上添加:
10.0.0.7 web01 sh-porxy
zabbix-proxy(web01)服务器上添加:
172.16.1.20 web02-jk
2.11 zabbix-server服务器的web端配置如下:
zabbix监控分布式配置1-1.png zabbix监控分布式配置1-2.png zabbix监控分布式配置2-1.png zabbix监控分布式配置2-2.png zabbix监控分布式配置2-3.png zabbix监控分布式配置2-4.png
2.12 检测数据:
zabbix监控分布式配置3.png zabbix监控分布式配置4.png
网友评论