简介
zabbix是完全开源的工具,整合了cacti和nagios等特性。
zabbix功能很强大,如何理解zabbix的功能,我们可以和cacti、nagios的功能对比一下:
- cacti是一款数据采集,数据存储,外加web界面展示的工具,它负责阈值范围内的实时变化,但是对超过阈值的告警功能很薄弱
优点:实时监控数据变化,以web页面的方式呈现,更直观。
缺点:告警不及时
- nagios是一款告警功能很强大的工具,它不关心阈值范围内的变化,只关心状态变化(超过阈值),然后报警。报警方式通过邮件,短信等。
优点:告警反映迅速。
缺点:监控主机数量有限,承载低
- zabbix = cacti + nagios
优点:基于两款工具优点于一身并更强大,实现企业级分布式监控。
缺点:2.2版本带宽占用大但是升级到2.4版本后更节省了带宽资源,其它再无发现。
一:Zabbix部署
主机 | ip | 部署 |
---|---|---|
server | 192.168.158.9 | LNMP、zabbix |
1.1:开局优化
关闭防火墙、网络管理、主机名修改(server、client),仅展示server操作
[root@192 ~]# hostnamectl set-hostname server
[root@192 ~]# su
[root@server ~]#
[root@server ~]# systemctl stop firewalld && systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@server ~]# setenforce 0 && sed -i "s/SELINUX=*/SELINUX=disabled/g" /etc/selinux/config
[root@server ~]# systemctl stop NetworkManager && systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service.
1.2:LNMP安装环境(使用yum安装的方式)
nagios是一款比较老的监控工具,但是因为插件太多,不是主流
cacti是一款图形化的监控分析工具
zabbix是基于web界面的提供分布式功能的监控工具,监控上线是300-500台
zabbix可以监控网络设备(例如思科、华为等)、服务器(例如IBM、联想、戴尔等)、应用监控(Apache、MQ、中间件、Tomcat等)和服务(HTTP、https、nginx、ssl等)等监控
zabbix使用的最稳定的版本是4.0,LTS是指测试,5.0版本在官网下载的时候比4.0版本多了一个nginx服务器的选择
ajax:异步刷新
zcat:不解压直接查看压缩包
1、安装nginx
[root@server ~]# wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm '//下载nginx软件包'
[root@server ~]# vim /etc/yum.repos.d/nginx.repo '//编辑yum源'
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
[root@server ~]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: base extras nginx-stable updates
Cleaning up list of fastest mirrors
[root@server ~]# yum makecache '//建立yum缓存'
[root@server ~]# systemctl start nginx
[root@server ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
网页测试:发现nginx搭建成功
2、安装mysql(mariadb)
[root@server ~]# yum -y install mariadb-server mariadb
[root@server ~]# systemctl start mariadb.service
[root@server ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@server ~]# netstat -ntap |grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 95170/mysqld
'//接下来执行mysql安全配置向导'
[root@server ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): '//初次运行直接回车'
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n