Zabbix安装配置及邮件报警

Posted 水木,年華

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Zabbix安装配置及邮件报警相关的知识,希望对你有一定的参考价值。

Zabbix安装配置及邮件报警
环境

zabbix   192.168.80.4/24  centos7.6
linux    192.168.80.1/24  centos7.6
windows  192.168.80.50/24

一、zabbix服务器的安装
1.部署LAMP架构
1.1 安装依赖包

[root@zabbix ~]# yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash

1.2 修改配置文件

vim /etc/httpd/conf/httpd.conf
95 ServerName www.my.com:80
164 <IfModule dir_module>
165     DirectoryIndex index.html index.php
166 </IfModule>
vim /etc/php.ini
878 date.timezone = PRC

1.3 启动apache和mariadb

[root@zabbix ~]# systemctl start httpd.service
[root@zabbix ~]# systemctl start mariadb.service
[root@zabbix ~]# netstat -antp | grep 80
tcp        0      0 192.168.80.4:22         192.168.80.100:53566    ESTABLISHED 89143/sshd: root@pt 
tcp        0     52 192.168.80.4:22         192.168.80.100:65438    ESTABLISHED 95371/sshd: root@pt 
tcp6       0      0 :::80                   :::*                    LISTEN      102264/httpd        
[root@zabbix ~]# netstat -antp | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      102596/mysqld       

1.4 初始化数据库

[root@zabbix ~]# 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] n  //是否删除匿名用户
 ... skipping.

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   //是否禁止root用户远程登录
 ... 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] n  //是否删除test库
 ... skipping.

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!

1.5 验证php网页是否可以打开

vi /var/www/html/index.php
<?php
phpinfo();
?>


1.6 对zabbix用户授权

[root@zabbix ~]# mysql 
Welcome to the MariaDB monitor.  Commands end with ; or \\g.
Your MariaDB connection id is 5
Server version: 5.5.68-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 ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'admin123';
Query OK, 0 rows affected (0.00 sec)

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

MariaDB [(none)]> 

1.7 验证php和mysql的联动性


以上是关于Zabbix安装配置及邮件报警的主要内容,如果未能解决你的问题,请参考以下文章

Zabbix安装配置及邮件报警

zabbix监控及邮件报警

Zabbix监控客户端及实现邮件微信报警

Zabbix配置邮件报警

编译安装zabbix3.4及实现邮件报警

使用 Zabbix 实现邮件自动报警