环境:
主机:两台Centos7操作系统,一台zabbix-serer做服务器,一台做zabbix-agent客户端
网络:此环境虚拟机需连接互联网,虚拟机网卡选择NET模式
主机 | 地址 |
---|---|
zabbix-server (服务器端) | 192.168.27.136 |
hadoop-server(客户端) | 192.168.27.137 |
- SELinux 配置
#vim /etc/selinux/config //关闭selinux
SELINUX=disabled
# setenforce 0
- 关闭防火墙
#systemctl stop firewalld.service
#systemctl disable firewalld.service
- 添加 Zabbix 软件仓库
#rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
由于zabbix的yum源下载安装包速率很慢,换成清华yum源后下载速度较快
#vim /etc/yum.repos.d/zabbix.repo
把repo.zabbix.com替换成,mirrors.tuna.tsinghua.edu.cn/zabbix
快捷替换命令:%s#repo.zabbix.com#mirrors.tuna.tsinghua.edu.cn/zabbix#g
#yum clean all
#yum makecache
- 安装前端zabbix-server-mysql和zabbix-web-mysql
# yum install zabbix-server-mysql zabbix-web-mysql -y
- 安装配置数据库mariabd-server
# yum install mariadb-server.x86_64 -y
#systemctl enable mariadb.service
#systemctl start mariadb.service
#mysql_secure_installation
mysql>create database zabbix character set utf8 collate utf8_bin;
mysql>grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
- 导入zabbix初始的数据库 schema
# cd /usr/share/doc/zabbix-server-mysql-4.0.19
找到create-sql.gz并解压
# gzip -d create.sql.gz
导入初始数据
#mysql -uzabbix -pzabbix zabbix < create.sql
- 修改zabbix-server数据库配置文件
# vim /etc/zabbix/zabbix_server.conf ///修改这几处
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
8. 启动 Zabbix server 进程
# systemctl enable zabbix-server.service
# systemctl start zabbix-server.service
如zabbix服务启动失败,可以通过查看vim /var/log/zabbix/zabbix_server.log分析原因
- 修改zabbix-web前端配置并启动服务
#vi /etc/httpd/conf.d/zabbix.conf ///修改时区
php_value date.timezone Asia/Shanghai
# systemctl enable httpd
# systemctl start httpd
- 在游览器打开图形配置界面
如果zabbix所需环境都OK,直接下一步
输入zabbix数据库密码
默认账户:Admin
将语言设置成中文
- 系统提示服务器端zabbix server主机无法连接,这里需安装zabbix-agent服务
# yum install zabbix-agent -y
zabbix-agent配置文件中server地址默认指向127.0.0.1,所以不需修改。如果是客户端的话得修改地址,地址指向服务器端
#systemctl enable zabbix-agent.service
#systemctl start zabbix-agent.service
12. 服务器端告警已消除,zabbix server主机已被监控
13. 添加客户端主机,同样也需要安装zabbix-agent,不过要修改配置文件
#yum install zabbix-agent -y
# vim /etc/zabbix/zabbix_agentd.conf
修改server地址
#systemctl enable zabbix-agent.service
#systemctl start zabbix-agent.service
将客户端主机添加到监控中,监控模板按照系统所需自行选择