实现zabbix监控web服务 微信 邮件 报警
部署zabbix
[root@192 ~]# cd /etc/yum.repos.d/
[root@192 yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo zabbix.repo
[root@192 yum.repos.d]# cat zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=0
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0
[root@192 ~]# yum -y install httpd mariadb mariadb-server zabbix-server zabbix-agent zabbix-server-mysql zabbix-web-mysql
建库 建表 导数据
[root@192 ~]# mysql
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on *.* to 'zabbix'@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
验证用户是否创建成功
[root@192 ~]# mysql -uzabbix -pzabbix -h localhost
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
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)]> exit
[root@192 ~]# zcat /usr/share/doc/zabbix-server-mysql-4.4.8/create.sql.gz | mysql -uzabbix -pzabbix zabbix
查看是否成功
[root@192 ~]# mysql
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| zabbix |
+--------------------+
5 rows in set (0.01 sec)
MariaDB [(none)]> use zabbix;
Database changed
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
修改配置文件
[root@192 ~]# cd /etc/zabbix/
[root@192 zabbix]# vim zabbix_server.conf
DBPassword=zabbix
修改时区
[root@192 ~]# vim /etc/php.ini
date.timezone = Asia/Shanghai
设置开机自启并启动
[root@192 ~]# systemctl enable httpd zabbix-server zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@192 ~]# systemctl start httpd zabbix-server zabbix-agent
[root@192 ~]# netstat -nltpu | grep -E "80|10050|10051"
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 20259/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 20254/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 20259/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 20254/zabbix_server
tcp6 0 0 :::80 :::* LISTEN 20249/httpd
修改乱码问题
[root@192 ~]# cd /usr/share/zabbix/assets/fonts/
[root@192 fonts]# ls
graphfont.ttf
[root@192 fonts]# rm -rf graphfont.ttf
[root@192 fonts]# rz
[root@192 fonts]# mv simkai.ttf graphfont.ttf
[root@192 fonts]# systemctl restart httpd
部署zabbix-agent端
传入上面一样的zabbix-repo
安装zabbix-agent并修改配置文件
[root@192 yum.repos.d]# yum -y install zabbix-agent
[root@192 zabbix]# vim zabbix_agentd.conf
ServerActive=192.168.59.4
Server=192.168.59.4
设置开机自启并启动
[root@192 ~]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@192 ~]# systemctl start zabbix-agent