安装环境:centos7
server端:192.168.141.146
agent端: 192.168.141.147
关闭防火墙
关闭selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
server端:192.168.141.146 配置
1.配置安装zabbix的yum源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim zabbix_Aliyun.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.2/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.2/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
2.安装zabbix 相关组件
[root@localhost ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
3.安装mariadb,创建数据库授权用户
[root@localhost ~]# yum -y install mariadb-server mariadb
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# mysql
MariaDB [(none)]> create database zabbix charset utf8;
MariaDB [(none)]> grant all on zabbix.* to tom@'localhost' identified by '123';
MariaDB [(none)]> flush privileges;
编辑zabbix-server配置文件,配置数据库信息
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
#找到一下几个关键字进行修改
DBName=zabbix
DBUser=tom
DBPassword=123
4.导入zabbix初始数据库
[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-4.2.8/
[root@localhost zabbix-server-mysql-4.2.8]# zcat create.sql.gz | mysql -utom -p123 zabbix
5.修改时区
[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
修改/etc/php.ini里的时区也行
6.修改字体
[root@localhost ~]# cd /usr/share/zabbix/assets/fonts/
把原来的字体删掉
[root@localhost fonts]# rm -rf graphfont.ttf
把自己下载的字体上传改名即可(字体在网上搜索GB2312下载)
[root@localhost fonts]# mv simkai.ttf graphfont.ttf
7.启动所以服务,查看端口是否监听
[root@localhost ~]# systemctl restart zabbix-server zabbix-agent httpd
[root@localhost ~]# ss -ntl | grep 10051
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 :::10051 :::*
[root@localhost ~]# ss -ntl | grep 10050
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 :::10050 :::*
[root@localhost ~]# ss -ntl | grep 80
LISTEN 0 128 :::80 :::*
8.浏览器访问
192.168.141.146/zabbix
agent端192.168.141.147配置
1.客户端配置yum源,安装zabbix-agent
[root@bogon ~]# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
[root@bogon ~]# yum -y install zabbix-agent
2.编辑zabbix_agentd.conf
[root@bogon ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.141.146
ServerActive=192.168.141.146
3.开启服务查看端口
[root@bogon ~]# systemctl start zabbix-agent
[root@bogon ~]# ss -ntl | grep 10050
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 :::10050 :::*
在zabbix服务器上测试键值是否可以获取到数据 安装zabbix-get工具
[root@localhost ~]# yum -y install zabbix-get
[root@localhost ~]# zabbix_get -s 192.168.141.147 -k agent.ping
1
若返回值是1的话,说明正在监听
若返回值是0的话,说明没有监听