环境准备
- 关闭防火墙和selinux
systemctl stop firewalld && setenforce 0
- 安装zabbix的yum源
访问zabbix的官网即可zabbix.com
配置zabbix-server
安装zabbix
- 配置zabbix仓库
rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-2.el7.noarch.rpm
- 更新yum源
yum clean all
yum makecache
- 安装zabbix
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
安装数据库mariadb
yum -y install mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb
mysqladmin -uroot password "zabbix"
mysql -u root -pzabbix
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
flush privileges;
- 导入数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
输入密码
- 查看数据是否导入
use zabbix;
show tables;
修改配置文件
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost #数据库对外的主机
DBName=zabbix #数据库名称
DBUser=zabbix #数据库用户
DBPassword=zabbix #数据库密码
systemctl start zabbix-server
systemctl enable zabbix-server
- 查看端口是否启动
ss -auntpl | grep 10051
- 配置web GUI
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai #设置时区
- 启动httpd
systemctl start httpd
systemctl enable httpd
浏览器访问
http://192.168.192.131/zabbix/setup.php
默认用户名:Admin
默认密码:zabbix
- 具体操作如下
配置zabbix-agent
下载安装zabbix-agent
其安装跟zabbix-server安装一样
- 修改配置文件
vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.192.131 # zabbix服务器的地址
ServerActive=192.168.192.131 #主动模式 zabbix-server-ip
Hostname=zabbix-agent-none1
UnsafeUserParameters=1 # 是否限制用户自定义 keys 使用特殊字符 1是可以启用特殊字符 0是不可以启用特殊字符
systemctl start zabbix-agent
systemctl enable zabbix-agent