6. 部署Zabbix监控

6. 部署Zabbix监控

 

6.1  安装mysql

[root@ubuntu ~]#hostnamectl set-hostname mysql-master;exit

[root@mysql-master ~]# apt install -y mysql-server

 

#配置mysql,不然后面登不进mysql

[root@mysql-master ~]# vim /etc/mysql/mysql.conf.d/mysqld.cnf

bind-address        = 0.0.0.0

 

#重启并开机启动

[root@mysql-master ~]# systemctl restart mysql

[root@mysql-master ~]# systemctl enable --now mysql

 

#mysql 进入数据库创建账户并授权

[root@mysql-master ~]# mysql

mysql> create database zabbix_server character set utf8 collate utf8_bin;

 

mysql> grant all privileges on zabbix_server.* to zabbix@'172.31.%.%' identified by 'Mmagedu0!';

 

mysql> flush privileges;

 

mysql> quit

 

 

 

6.2  zabbix-server配置

下载安装zabbix

 

#下载zabbix

[root@zabbix-server ~]#

wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3+bionic_all.deb

 

#安装zabbix

[root@zabbix-server ~]# dpkg -i zabbix-release_4.0-3+bionic_all.deb

 

[root@zabbix-server ~]# apt update

 

#安装Zabbix serverWeb前端,agent

[root@zabbix-server ~]# apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

 

 

zabbix server初始化数据库

# 测试zabbix用户登录数据库

[root@zabbix-server ~]# mysql -uzabbix -p'Mmagedu0!' -h 172.31.0.104

 

 

*************************************************************

查看源安装的一个数据库初始化包不存在

[root@zabbix-server ~]#ls /usr/share/doc/zabbix-server-mysql/

changelog.Debian.gz  copyright  NEWS.Debian.gz  README.Debian

 

原因是装完zabbix后又装了其他软件,把它给刷新不见了,方法是重新按顺序装一遍

*************************************************************

 

源安装的一个数据库初始化包create.sql.gz

[root@zabbix-server ~]#ls /usr/share/doc/zabbix-server-mysql/

changelog.Debian.gz  copyright  create.sql.gz

 

 

 

生成zabbix数据库:(在zabbix-server

[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p'Mmagedu0!' -h172.31.0.104 zabbix_server

 

再次进入数据库查看是否有多出zabbix相关的表

[root@zabbix-server ~]#mysql -uzabbix -p'Mmagedu0!' -h172.31.0.104

......

 

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| zabbix_server      |

+--------------------+

2 rows in set (0.00 sec)

 

mysql> use zabbix_server

 

mysql> show tables;

+----------------------------+

| Tables_in_zabbix_server    |

+----------------------------+

| acknowledges               |

| actions                    |

| alerts                     |

| application_discovery      |

 

 

修改zabbix-server的配置文件

[root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf

DBHost=172.31.0.104

DBName=zabbix_server

DBUser=zabbix

DBPassword=Mmagedu0!

DBPort=3306

 

修改php配置文件的时区

[root@zabbix-server ~]#vim /etc/zabbix/apache.conf

php_value date.timezone Asia/Shanghai

 

重启服务

[root@zabbix-server ~]# systemctl restart zabbix-server zabbix-agent apache2

 

 

 

 

6.4登录验证

 

浏览器登录:http://172.31.0.101/zabbix/setup.php

 

 

 

 

 

 

 

时区出错:

 

 

 

 

 

解决时区问题:

前面配置不生效,是放错地方,更改如下:

[root@zabbix-server ~]#vim /etc/zabbix/apache.conf  

 <IfModule mod_php7.c>

        php_value max_execution_time 300

        php_value memory_limit 128M

        php_value post_max_size 16M

        php_value upload_max_filesize 2M

        php_value max_input_time 300

        php_value max_input_vars 10000

        php_value always_populate_raw_post_data -1

        # php_value date.timezone Europe/Riga 

        php_value date.timezone Asia/Shanghai   #加这一行

 

重启

[root@zabbix-server ~]#systemctl restart zabbix-server zabbix-agent apache2

 

 

浏览器再次登录:http://172.31.0.101/zabbix/setup.php

 

 

 

下一步,配置数据库

 

 

zabbix server配置

 

 

 

 

信息确认

 

 

 

 

 

 

 

配置完成

 

 

 

 

 

 

 

登录界面

 

用户:Admin  密码:zabbix

 

 

 

 

 

 

 

 

 

 

 

zabbix登录后的监控图形界面

 

 

 

 

 

 

 

模拟故障

 

 

 

 

 

posted @ 2022-09-02 01:48  惊起千层浪  阅读(116)  评论(0编辑  收藏  举报