Technical articles
Zabbix简介
Zabbix是一款基于WEB界面的提供分布式系统监视以及网络监视功能的开源监控软件。Zabbix由zabbix server(服务端,默认端口10051)和可选组件zabbix agent(客户端,默认端口10050)2部分组成。Zabbix也通过SNMP协议(默认161端口)监控各种网络服务、网络硬件设备的状态。
Zbbix主要监控类型
1.硬件监控 路由器、交换机、防火墙等2.系统监控 CPU、内存、磁盘、网络、进程、 TCP等3.服务监控 nginx、 php、 tomcat、 redis、 memcache、 mysql等4.WEB 监控 请求时间、响应时间、加载时间等5.日志监控 ELk(收集、存储、分析、展示)6.安全监控 Firewalld、 WAF(Nginx+lua)、安全宝、牛盾云、安全狗等7.网络监控 smokeping 多机房8.流量监控 监控网卡进/出流量
标注:zabbix官方安装操作说明
https://www.zabbix.com/documentation/4.0/manual/installation/install_from_packages/rhel_centos
标注:zabbix官方RPM下载地址
http://repo.zabbix.com/
标注:请自行关闭Linux防火墙及SElinux(如果需要开通防火墙请放行端口 80/10050/10051)
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo yum makecache
#==》安装MySQL官方仓库源[root@test yum.repos.d]# rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm[root@test yum.repos.d]# yum -y install yum-utils[root@test yum.repos.d]# yum-config-manager --enable mysql57-community[root@test yum.repos.d]# yum-config-manager --disable mysql80-community[root@test yum.repos.d]# yum repolist all | grep mysql[root@zabbix ~]# yum -y install mysql-community-server[root@zabbix ~]# systemctl start mysqld[root@zabbix ~]# systemctl enable mysqld[root@zabbix ~]# systemctl status mysqld[root@zabbix ~]# grep 'temporary password' /var/log/mysqld.log2019-09-10T12:21:39.099636Z 1 [Note] A temporary password is generated for root@localhost: li_;Mhw#.3?M[root@zabbix ~]# mysql -uroot -p'li_;Mhw#.3?M'mysql> set password=password("#AAAaaa111#"); mysql> flush privileges;
[root@zabbix ~]# rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
[root@zabbix ~]# yum -y install zabbix-server-mysql[root@zabbix ~]# yum -y install zabbix-proxy-mysql[root@zabbix ~]# yum -y install zabbix-web-mysql
[root@zabbix ~]# mysql -uroot -p'#AAAaaa111#'mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by '#AAAaaa111#'; mysql> flush privileges;
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.12/create.sql.gz | mysql -uzabbix -p zabbixEnter password: #==》输入MySQL数据库zabbix密码
[root@zabbix ~]# vim /etc/zabbix/zabbix_server.confDBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=#AAAaaa111#
systemctl start zabbix-server.service systemctl enable zabbix-server.service systemctl status zabbix-server.service
[root@zabbix ~]# vim /etc/httpd/conf.d/zabbix.confphp_value date.timezone Asia/Shanghai
systemctl start httpd systemctl enable httpd systemctl status httpd
标注:提示已经成功安装了zabbix前端,配置文件/etc/zabbix/web/zabbix.conf.php被创建
标注:zabbix默认登录用户Admin 密码zabbix
标注:打开图形之后会发现语言有乱码情况,原因是缺少字体
下载字体并替换现有的字体
[root@zabbix ~]# yum -y install wqy-microhei-fonts[root@zabbix ~]# cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/zabbix/assets/fonts/graphfont.ttf
刷新zabbix网页就显示正常
标注:zabbix-agent客户端(数据采集)—>zabbix-server(数据分析|报警)—> 数据库(数据存储)<—zabbix web(数据展示)
标注:客户端与服务端的安装包有要求,建议安装版本相同的,否则可能会出现连接失败
[root@web01 ~]#rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm[root@web01 ~]# yum -y install zabbix-agent
[root@web01 ~]# vim /etc/zabbix/zabbix_agentd.confPidFile=/var/run/zabbix/zabbix_agentd.pidLogFile=/var/log/zabbix/zabbix_agentd.logLogFileSize=0Server=10.0.0.33 #==》zabbix监控服器IP地址ServerActive=127.0.0.1Hostname= web01 #==》填写客户端主机名称Include=/etc/zabbix/zabbix_agentd.d/*.conf
[root@web01 ~]# systemctl start zabbix-agent.service[root@web01 ~]# systemctl enable zabbix-agent.service[root@web01 ~]# systemctl status zabbix-agent.service[root@web01 ~]# ss -tlunp | grep 10050
标注:监控Nginx服务状态
[root@web01 ~]# ss -tlunp | grep -c 801
#==》创建Nginx监听状态的信息的文件[root@web01 ~]# vim /etc/zabbix/zabbix_agentd.d/nginx_status.confUserParameter=nginx_status[*],ss –tlunp | grep -c $1#==》重启zabbix-agent服务[root@web01 ~]# systemctl restart zabbix-agent.service
[root@zabbix ~]# yum -y install zabbix-get.x86_64[root@zabbix ~]# zabbix_get -s 10.0.0.60 -k nginx_status[80]1
标注:可参数zabbix官网技术文档说明
https://www.zabbix.com/documentation/4.0/zh/manual/appendix/macros/supported_by_location
下一篇:安装部署jumpserver