Centos7 Zabbix3.4分布式mysql

介绍:

当需要监控的设备有很多,设备产生的监控数据需要很大的磁盘空间。为了保证数据的安全性,可以把zabbix-web和zabbix-mysql分离。如果有更高的要求,mysql还可以搭建主从集群。

实验环境:

  系统           角色            IP
Centos7.6    Zabbix-Server    192.168.14.217
Centos7.6    Zabbix-mysql     192.168.14.218
Centos7.6    Zabbix-agent     192.168.14.212

一、Zabbix-server端的部署

1、测试环境,关闭防火墙和selinux

#更改主机名
[root@localhost ~]# hostnamectl set-hostname zabbix-server
#关闭防火墙和selinux
[root@zabbix-server ~]# systemctl stop firewalld.service
[root@zabbix-server ~]# systemctl disable firewalld.service
[root@zabbix-server ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
[root@zabbix-server ~]# setenforce 0

2、安装zabbix rpm包(注意链接会更新)

[root@zabbix-server ~]# rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm

3、安装Server端的服务

[root@zabbix-server ~]# yum -y install zabbix-server-mysql zabbix-web-mysql

4、修改zabbix_server配置文件

[root@zabbix-server ~]# cat /etc/zabbix/zabbix_server.conf |grep -v "^$"|grep -v "^#"
ListenPort=10051             #监听端口
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=192.168.14.218        #zabbix-mysql主机的IP地址
DBName=zabbix                #zabbix-mysql数据库名
DBUser=zabbix                #zabbix-mysql的登录用户名
DBPassword=zabbix            #zabbix-mysql的登录密码
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

Centos7 Zabbix3.4分布式mysql_第1张图片

5、修改zabbix前端PHP配置

[root@zabbix-server ~]# vi /etc/httpd/conf.d/zabbix.conf
# php_value date.timezone Europe/Riga 改为》》 php_value date.timezone Asia/Shanghai

Centos7 Zabbix3.4分布式mysql_第2张图片

6、拷贝数据库文件到zabbix-mysql主机

[root@zabbix-server ~]# scp /usr/share/doc/zabbix-server-mysql-3.4.15/create.sql.gz  [email protected]:/root/

7、启动服务

#zabbix-web服务
[root@zabbix-server ~]# systemctl start httpd
[root@zabbix-server ~]# systemctl enable  httpd
#zabbix-server服务
[root@zabbix-server ~]# systemctl start  zabbix-server
[root@zabbix-server ~]# systemctl enable zabbix-server

二、Zabbix-mysql端的部署

1、测试环境,关闭防火墙和selinux

#修改主机名
[root@localhost ~]# hostnamectl set-hostname zabbix-mysql
#关闭防火墙和selinux
[root@zabbix-mysql ~]# systemctl stop firewalld.service
[root@zabbix-mysql ~]# systemctl disable firewalld.service
[root@zabbix-mysql ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
[root@zabbix-mysql ~]# setenforce 0

2、可选,删除系统自带数据库

[root@zabbix-mysql ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
[root@zabbix-mysql ~]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

3、安装数据库

[root@zabbix-mysql ~]# yum install mariadb-server mariadb –y

4、启动服务

[root@zabbix-mysql ~]# systemctl start mariadb
[root@zabbix-mysql ~]# systemctl enable  mariadb

5、创建数据库,用户和密码(要跟zabbix-server配置文件一致),并运行远程登录

[root@zabbix-mysql ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.65-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 character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'192.168.14.%' IDENTIFIED BY 'zabbix';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
Bye

6、导入数据库文件

[root@zabbix-mysql ~]# zcat create.sql.gz | mysql -uzabbix -pzabbix  zabbix

三、Zabbix-server端的Web配置

1、浏览器访问zabbix-server

Centos7 Zabbix3.4分布式mysql_第3张图片

Centos7 Zabbix3.4分布式mysql_第4张图片

Centos7 Zabbix3.4分布式mysql_第5张图片

Centos7 Zabbix3.4分布式mysql_第6张图片

2、登录之后查看zabbi-server服务是否正常

Centos7 Zabbix3.4分布式mysql_第7张图片

四、Zabbix-agent部署

1、修改zabbix-agent配置文件

[root@localhost ~]# vi /etc/zabbix/zabbix_agentd.conf |grep -v "^$"|grep -v "^#"
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.14.217                    #zabbix-server主机的IP
ServerActive=192.168.14.217              #zabbix-server主机的IP
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agentd.d/*.conf

2、重启服务

[root@localhost ~]# systemctl restart zabbix-agent 

3、zabbix-web添加主机

Centos7 Zabbix3.4分布式mysql_第8张图片

4、查看状态

Centos7 Zabbix3.4分布式mysql_第9张图片

至此zabbix的web页面和mysql分布式部署成功。

你可能感兴趣的:(#,Zabbix)