- A+
目录
4.1. zabbix前端配置zabbix-proxy代理.
在zabbix大规模的监控中使用zabbix-agent主动模式会减轻zabbix-server的压力,但是zabbix-server端还是要进行数据的采集,压力还是比较大,而且在服务器多机房的情况下和一个zabbox-server跨机房监控的网络延迟也会是一个问题,所以说根据这些情况,zabbix提供了一个组件叫做zabbix-proxy,安装的组件名字叫做:zabbix-proxy-mysql,这个组件下载好后是连同proxy和mysql初始化的脚本都装好的。
zabbix-proxy也有两种模式,主动模式和被动模式,可以在配置文件/etc/zabbix/zabbix_proxy.conf中看到模式的配置,默认ProxyMode是0,0是主动模式,所以zabbix-proxy会主动连zabbix-server;1是被动模式,是要zabbix-server去连zabbix-proxy。
这里我们要知道zabbix-proxy只是一个数据收集器,它不用于计算、告警、触发等操作,它就有两个部分组成,一个zabbix-proxy的进程,然后一个是数据库,有数据他就往数据库中写。实时发送给zabbix-server。这里也可以设置zabbix-proxy收集到数据后先缓存到本地,然后定期传给zabbix-server数据,配置为项为:# ProxyLocalBuffer=0(默认0为不缓存)。另外还有当zabbix-proxy连接不上zabbix-server时,zabbix-proxy会先将数据缓存到本地一个小时再进行发送。这里的缓存时间也是可以配置的,配置项为:# ProxyOfflineBuffer=1,以小时为单位,当然这里也可以根据需要调整时间。
本文服务器环境:
Host |
HostName |
IP |
System Version |
Zabbix-server |
linux-node1 |
192.168.56.11 |
CentOS-6.7
|
Zabbix-agent |
linux-node2 |
192.168.56.12 |
|
Zabbix-proxy |
linux-node2 |
192.168.56.12 |
环境补充说明:
- 当前zabbix-server和zabbix-agent已经安装配置好,在主机中只添加了linux-node1,linux-node2配置zabbix-proxy的时候再添加。所以本文直接安装zabbix-proxy
- 因为zabbix-server和zabbix-proxy不能使用同一个数据库,所以zabbix-server连接的是node1的数据库,zabbix-proxy是node2的数据库
- zabbix版本:zabbix_3.4.7
1. 安装
在node2上面安装zabbix-proxy和mysql数据库
- #安装zabbix源
- rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm
- #下载zabbix-proxy
- yum -y install zabbix-proxy-mysql mysql mysql-server
提示:下载好之后在/etc/zabbix/在会生成proxy配置文件:zabbix_proxy.conf
2. 配置
2.1 配置zabbix-proxy
- [root@linux-node2 ~]# grep -vE '^$|#' /etc/zabbix/zabbix_proxy.conf
- ………………
- Server=192.168.56.11
- Hostname=linux-node2
- DBHost=192.168.56.12
- DBName=zabbix_proxy
- DBUser=zabbix_proxy
- DBPassword=123456
- ………………
2.2. 配置MySQL数据库
2.2.1 启动数据库
- [root@linux-node2 ~]# /etc/init.d/mysqld start
- Starting mysqld: [ OK ]
2.2.2 运行脚本命令对数据库进行安全设置
- [root@linux-node2 ~]# mysql_secure_installation
- NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
- SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
- In order to log into MySQL to secure it, we'll need the current
- password for the root user. If you've just installed MySQL, 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 MySQL
- root user without the proper authorisation.
- #是否设置root密码:
- Set root password? [Y/n] Y
- New password: 123456
- Re-enter new password: 123456
- Password updated successfully!
- Reloading privilege tables..
- ... Success!
- By default, a MySQL installation has an anonymous user, allowing anyone
- to log into MySQL 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.
- #是否关闭root远程登录?
- Disallow root login remotely? [Y/n] Y
- ... Success!
- By default, MySQL 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 MySQL
- installation should now be secure.
- Thanks for using MySQL!
2.2.3 创建zabbix_proxy数据库
- [root@linux-node2 ~]# mysql -uroot -p
- mysql> create database zabbix_proxy character set utf8 collate utf8_bin;
- Query OK, 1 row affected (0.01 sec)
- mysql> grant all on zabbix_proxy.* to zabbix_proxy@192.168.56.12 identified by '123456';
- Query OK, 0 rows affected (0.00 sec)
- mysql> flush privileges;
- Query OK, 0 rows affected (0.00 sec)
- mysql> quit
- Bye
- #创建好用户之后测试创建的用户是否能登录
- [root@linux-node2 ~]# mysql -h 192.168.56.12 -u zabbix_proxy -p123456
2.2.4 初始化数据库
- #查看初始化数据库的数据包
- [root@linux-node2 ~]# rpm -ql zabbix-proxy-mysql
- …………
- /usr/share/doc/zabbix-proxy-mysql-3.4.7/schema.sql.gz
- …………
- [root@linux-node2 ~]# zcat /usr/share/doc/zabbix-proxy-mysql-3.4.7/schema.sql.gz | mysql -h 192.168.56.12 -u zabbix_proxy -p zabbix_proxy
- Enter password:
3. 启动zabbix-proxy
- [root@linux-node2 ~]# /etc/init.d/zabbix-proxy start
- Starting Zabbix proxy: [ OK ]
- [root@linux-node2 ~]# netstat -lntup|grep 10051
- tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 86567/zabbix_proxy
- tcp 0 0 :::10051 :::* LISTEN 86567/zabbix_proxy
4. Zabbix web前端配置
4.1. zabbix前端配置zabbix-proxy代理
管理--agent代理程序--创建代理
4.2 配置node2的zabbix-agent
修改node2的zabbix-agent的配置
- [root@linux-node2 ~]# grep -vE '^$|#' /etc/zabbix/zabbix_agentd.conf
- …………
- Server=192.168.56.12
- ServerActive=192.168.56.12
- Hostname=linux-node2
- …………
- #重启下node2的zabbix-agent
- [root@linux-node2 ~]# /etc/init.d/zabbix-agent restart
- Shutting down Zabbix agent: [ OK ]
- Starting Zabbix agent: [ OK ]
4.3. zabbix-web前段配置增加node2
配置--主机--添加主机
选择好相应的模版,最后添加即可:
配置好之后稍等一下如图:
到这里配置完成,有错看日志~有错看日志~有错看日志~