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 安裝依賴包
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
1.3 啟動apache和mariadb
[[email protected] ~]# systemctl start httpd.service
[[email protected] ~]# systemctl start mariadb.service
[[email protected] ~]# netstat -antp | grep 80
tcp 0 0 192.168.80.4:22 192.168.80.100:53566 ESTABLISHED 89143/sshd: [email protected]
tcp 0 52 192.168.80.4:22 192.168.80.100:65438 ESTABLISHED 95371/sshd: [email protected]
tcp6 0 0 :::80 :::* LISTEN 102264/httpd
[[email protected] ~]# netstat -antp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 102596/mysqld
1.4 初始化資料庫
[[email protected] ~]# 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();
?>
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiI2EzX4xSZz91ZsAzNfRHLGZkRGZkRfJ3bs92YsAjMfVmepNHL21SS2ATbiVTT5dzNvlHc1AzQyVTQClGVF5UMR9Fd4VGdsATNfd3bkFGazxycykFaKdkYzZUbapXNXlleSdVY2pESa9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnL4ImNmNDM2ATOwQzYzQTN5MzYyQTNyMmM1QWMkV2Y1Q2Lc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
1.6 對zabbix使用者授權
[[email protected] ~]# 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的關聯性