Prepare two centos7 virtual machines
Turn off firewall time synchronization
先安装ntpdate
[root@localhost ~]# yum -y install ntpdate
[root@localhost ~]# ntpdate pool.ntp.org
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
1. Upload zabbix yum source to install zabbix_server
[root@localhost ~]# ls
anaconda-ks.cfg zabbix_Aliyun.repo
[root@localhost ~]# mv zabbix_Aliyun.repo /etc/yum.repos.d/
[root@localhost ~]# yum -y install zabbix-server-mysql zabbix-agent zabbix-web-mysql maraidb mariadb-server
1. Start mysql to create a zabbix database authorized user
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# 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)
2. Import the data into the zabbix database
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-4.2.8/create.sql.gz |mysql -uzabbix -pzabbix zabbix
进入mysql数据库查看下是否导入成功
[root@localhost ~]# mysql
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| zabbix |
+--------------------+
5 rows in set (0.00 sec)
MariaDB [(none)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [zabbix]> show tables;
有数据为导入成功
3. Configure to start zabbix
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
只改下password,剩下不用改
Modify the time zone, otherwise the page will report an error for a while
[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
改成上海时区
Start zabbix and view the port
[root@localhost ~]# systemctl start zabbix-server zabbix-agent httpd
[root@localhost ~]# netstat -nltpu |egrep "10050 |10051 |80"
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 14840/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 14845/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 14840/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 14845/zabbix_server
tcp6 0 0 :::80 :::* LISTEN 14838/httpd
4. Visit zabbix
Modify Chinese interface
The page data is garbled to solve the garbled
[root@localhost ~]# cd /usr/share/zabbix/assets/fonts/
有个软连接 把他删除了 上传个中文字体 改成原来的名字即可
[root@localhost fonts]# ll
lrwxrwxrwx. 1 root root 33 9月 23 00:05 graphfont.ttf -> /etc/alternatives/zabbix-web-font
[root@localhost fonts]# rm -rf graphfont.ttf
[root@localhost fonts]# mv simkai.ttf graphfont.ttf
2. Upload zabbix yum source to install zabbix_agent
[root@localhost ~]# ls
anaconda-ks.cfg zabbix_Aliyun.repo
[root@localhost ~]# mv zabbix_Aliyun.repo /etc/yum.repos.d/
[root@localhost ~]# yum -y install zabbix-agent
1. Configure and start zabbix_agent
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
[root@localhost ~]# systemctl start zabbix-agent
查看端口
[root@localhost ~]# netstat -nltpu |grep 10050
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 13461/zabbix_agentd
tcp6 0 0 :::10050 :::* LISTEN 13461/zabbix_agentd
2. Test whether it is connected to the server
Download zabbix-get test on server
[root@localhost ~]# yum -y install zabbix-get
[root@localhost ~]# zabbix_get -s 192.168.27.137 -k agent.ping
1
返回值为1 则为 ok
3. Install the software to be monitored. I have installed httpd here
[root@localhost ~]# yum -y install httpd
启动httpd 并查看端口
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# netstat -nltpu |grep 80
tcp6 0 0 :::80 :::* LISTEN 13459/httpd
Three. Enter the zabbix page to configure the host to add monitoring items
Add host first
Create monitoring items
If it is to monitor other application ports, just change it
Add trigger
Tick the send message to
Add alarm media
Can qq receive under test
Enable action
Four. Turn off/on the test on zabbix_agent
[root@localhost ~]# systemctl stop httpd
[root@localhost ~]# systemctl start httpd