一、系统环境准备
1、关闭防火墙(可以选择开放对应的端口,默认为tcp/udp 10050、10051)
systemctl stop firewalld && systemctl disable firewalld
2、关闭SELinux:
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
3、重启reboot
二、安装并配置zabbix
1、安装 zabbix rpm 源,使用阿里云 zabbix 源
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all && yum makecache fast
2、安装zabbix服务端组件 zabbix server 和 agent
yum install zabbix-server-mysql zabbix-agent -y
3、安装zabbix前端组件
yum install centos-release-scl -y
4、编辑配置文件 vi /etc/yum.repos.d/zabbix.repo,将[zabbix-frontend]下的 enabled 改为 1(1-启用;0-不启用)
5、安装zabbix前端页面、初始数据库、PHP及httpd组件
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
三、安装并配置MySQL数据库
1、安装 centos7 默认的 mariadb 数据库
yum install mariadb-server -y
2、启动数据库,并配置开机自动启动
systemctl enable --now mariadb
3、使用以下命令初始化 mariadb 并配置 root 密码
回车键按一下 然后设置密码
后面的都是n/n/n/n
4、使用 root 用户进入 mysql,并建立 zabbix 数据库,注意数据库编码
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'longfei';
grant all privileges on zabbix.* to zabbix@localhost;
quit;
5、使用以下命令导入 zabbix 数据库,zabbix 数据库用户为 zabbix,密码为 longfei
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
四、zabbix配置初始化
1、配置数据库连接信息
修改 zabbix server 配置文件vi /etc/zabbix/zabbix_server.conf 里的数据库密码
DBPassword=longfei 注意“#”删除不然不起作用
2、配置时区信息
vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf ,修改时区
php_value[date.timezone] = Asia/Shanghai
3、配置字体,避免前台监控图形中文乱码
yum -y install wqy-microhei-fonts
cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
4、启动zabbix相关服务并设置开机自启动
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
5、浏览器上访问前端,进行初始化安装
使用浏览器访问http://xxxx/zabbix
输入刚配置的数据库 zabbix 用户的密码:longfei
6、登录账号为 Admin,密码: zabbix
进入系统后,默认是英文显示,点击左下角User settings,设置语言为中文即可
vi /etc/zabbix/zabbix_agentd.conf
service Zabbix-agent restart
systemctl restart zabbix-agent.service
防火墙建议开启
开启防火墙:
systemctl start firewalld && systemctl enable firewalld
firewall-cmd --zone=public --add-port=10050/tcp --permanent
firewall-cmd --zone=public --add-port=10050/udp --permanent
firewall-cmd --zone=public --add-port=10051/tcp --permanent
firewall-cmd --zone=public --add-port=10051/udp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
systemctl restart firewalld
这是查看端口打开文件 cat /etc/firewalld/zones/public.xml
Centos7安装被监控端zabbix-agent-5.0
一、安装步骤
1.关闭防火墙。
systemctl stop firewalld && systemctl disable firewalld
setenforce 0
2.下载
自己下载上传,是zabbix-agent-5.0.0-1
3.安装
rpm -ivh zabbix-agent-5.0.0-1.el7.x86_64.rpm
4.修改配置文件。
在/etc/zabbix/zabbix_agentd.conf文件中搜索以Server开头的,将Server=127.0.0.1 修改成 Server=******(server主机ip)。
vim /etc/zabbix/zabbix_agentd.conf
5.启动,并设置开机自启
systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service
二、添加到监控主机
在web界面依次点击:配置-主机-创建主机。
在主机页面填写主机名称、群组、Interfaces,在模板界面添加模板即可。
防火墙建议开启
开启防火墙:
systemctl start firewalld && systemctl enable firewalld
firewall-cmd --zone=public --add-port=10050/tcp --permanent
firewall-cmd --zone=public --add-port=10050/udp --permanent
firewall-cmd --zone=public --add-port=10051/tcp --permanent
firewall-cmd --zone=public --add-port=10051/udp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
systemctl restart firewalld
这是查看端口打开文件 cat /etc/firewalld/zones/public.xml