Zabbix 是一个企业级分布式开源监控解决方案。ta能够监控众多网络参数和服务器的健康度、完整,灵活的告警机制,允许用户为几乎任何事件配置基于邮件的告警。这样用户可以快速响应服务器问题。ta基于存储的数据提供出色的报表和数据可视化功能。这些功能使得 Zabbix 成为容量规划的理想选择。并且是免费的。Zabbix 是根据 GPL 通用公共许可证的第二版编写和发布的。这意味着产品源代码是免费发布的,可供公共使用。
关闭防火墙:
systemctl stop filewalld systemctl disable filewalld 关闭selinux: cd /etc/selinux/config SELINUX=disabled # 永久关闭
# 先备份CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
# 进入CentOS-Base.repo修改
/etc/yum.repos.d/CentOS-Base.repo
修改配置文件中的内容如下:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
最后执行
yum makecache
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/{zabbix-server-mysql-4.0.20-1.el7.x86_64.rpm,zabbix-web-4.0.22-1.el7.noarch.rpm}
yum install -y httpd php zabbix-server-mysql-4.0.20-1.el7.x86_64.rpm zabbix-web-mysql
yum install -y mariadb-server #安装数据库服务
sed -ri.bak '/# DBPassword=/cDBPassword=zabbix' /etc/zabbix/zabbix_server.conf #修改zabbix数据库密码为zabbix
sed -ri.bak 's/ #(.*)date.timezone.*/\1date.timezone Asia\/Shanghai/' /etc/httpd/conf.d/zabbix.conf #修改时区为国内
systemctl start mariadb #启动数据库
mysql_secure_installation ##初始化数据库
# 进入后输入y并设置数据库新密码,然后所有选项都选y即可完成配置
myslq -u root -p
create database zabbix character set utf8 collate utf8_bin; #创建zabbix数据库
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; ##创建数据库管理用户
quit # 退出数据库
zcat /usr/share/doc/zabbix-server-mysql-4.0.20/create.sql.gz | mysql -uzabbix -pzabbix zabbix #将数据表写入到zabbix库中
systemctl start zabbix-server.service httpd mariadb.service
systemctl enable zabbix-server.service httpd mariadb.service
http:ip/zabbix/setup.php
一路next即可。(注意配置中“0”代表3306端口)服务器端部署完毕!进入web页面后点击右上角的小人图标,设置一下语言喜好即可。
客户端只需要在本地安装部署zabbix-agent即可。下载地址(各位按照自己的系统版本选择合适要下载即可)
http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/ 下载rpm包并进行安装: rpm -ivh ******* 配置:
vim /etc/zabbix/zabbix_agentd.conf
# 做出如下修改配置
Server=*.*.*.* # 修改为服务器端ip地址
ServerActive=*.*.*.* # 修改为服务器端ip地址
Hostname=servername # 指定本机名称
# 退出保存即可
agent是通过10050端口出去的
systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service
查看端口
netstat -antlp
在:配置->主机->创建主机
若安装过程中,有错误,可以通过查看日志来排查
/var/log/zabbix 根据日志中的报错,在/etc/zabbix下的配置文件中进行检查。