一.准备环境
1.准备二台centos7的虚拟机
2.关掉防火墙 时间同步
先安装ntpdate
[root@localhost ~]# yum -y install ntpdate
[root@localhost ~]# ntpdate pool.ntp.org
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
二. zabbix-server端部署
1.上传zabbix yum源 安装zabbix相关应用
[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
2.启动mysql 创建zabbix数据库 授权用户
[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)
3.把数据导入zabbix数据库
[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;
有数据为导入成功
4.配置启动zabbix
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
只改下password,剩下不用改
修改下时区,不然一会页面报错
[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
改成上海时区
启动zabbix 并查看端口
[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
5.访问zabbix
修改中文界面
页面数据有乱码 解决乱码
[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
三.zabbix-agent端部署
1.上传zabbix源 安装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
2.配置启动zabbix-agent
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
[root@localhost ~]# systemctl start zabbix-agent
四.在zabbix页面创建主机