当前位置:网站首页>【从零开始学zabbix】一丶Zabbix的介绍与部署Zabbix
【从零开始学zabbix】一丶Zabbix的介绍与部署Zabbix
2022-06-24 13:02:00 【是泡泡】
Zabbix的介绍与部属
前言
大家好,docker篇完结之后苦思冥想了很久不知道做什么,看了一下感觉做监控方面文章并不多,于是过来撰写一下zabbix的文章,普罗米修斯的话要后面去了,zabbix也是很有意思的一个东西,如果你没有学过可以来跟着一起学一下,这个东西比较简单,可视化,学过的话可以当作复习来看一看,废话就不多说了,直接开始正题了。
什么是监控
监控的意思就是监视,控制的意思,利用监控我们可以在一些悲剧发生之前做出提醒及时解决,防止悲剧的发生。比如机房过热,监控提醒,开启空调,防止悲剧发生。
随着用户的增多,服务随时可能会被系统oom out of memory 内存溢出
,你怎么判断,web服务是因为用户访问过多,达到了瓶颈?还是程序代码bug导致的,内存过多?为了防止这种情况,我们一般都会有两手保证,一是网站上线之前进行压力测试,二是进行监控,比如这个网站最多承受3000用户访问,我们应该设置一个70%-80%的监控,当用户访问超过服务器承受能力的70%甚至80%的时候,我们就需要进行扩容了!如果不这么设置的话,等到快满了的时候再去扩容?就来不及了!
Zabbix部署
zabbix很有意思啊,两个版本,一个LTS版本会支持五年,一个标准版只支持七个月,所以官网一般都是半年一更新。这里我们就使用zabbix4.0版本了。
1.下载源,配置yum
zabbix官网 访问很慢
由于zabbix官网上下载很慢,而且访问也很慢,这里使用清华的源。wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
地址我也给找好了,可以看url自己找一下复制链接wget也可以,用我的也可以。
然后我们解压
rpm -ivh zabbix-release-4.0-2.el7.noarch.rpm
解压完之后配置yum仓库
vim /etc/yum.repos.d/zabbix.repo
我们需要把baseurl=这一行的前面改成清华的!经过对比可以发现清华的只是前面改变了
https://mirrors.tuna.tsinghua.edu.cn/zabbix
所以我们只需要替换这里就行
%s#http://repo.zabbix.com#https://mirrors.tuna.tsinghua.edu.cn/zabbix#g
然后再把gpgcheck都改成0,最终如下
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/debuginfo
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=0
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0
2.安装zabbix服务端和zabbix-web前端
这里我们需要改一下镜像源为阿里的,不然会报错没有依赖
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
#安装服务和web
yum install zabbix-server-mysql zabbix-web-mysql -y
3.安装mariadb,创建zabbix库,授权zabbix用户
这里都是指令,我们就一路顺下去。
yum install mariadb-server -y
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
输入这个指令之后回车,然后n,然后一路y就行了,这是删除匿名用户啥的用的
mysql
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to [email protected] identified by '123456';
#修改字符集 建表 授权等
退出mariadb 导入zabbix表结构和初始数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p123456 zabbix
检查zabbix库是否导入成功
mysql -uroot zabbix -e 'show tables'
如果出现表就是成功了
4.配置启动zabbix-server
我们这里修改一下配置文件就好
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
只需要让这四个和我的一样就行,可以:/查找。
启动zabbix-server
systemctl start zabbix-server
systemctl enable zabbix-server
检查一下服务
netstat -lntup
如果可以看到zabbxi.server 那就是成功了,如果没有并且没有报错,那是说明你的服务启动了但是监听端口没有,把防火墙和selinux关闭重启试试。
setenforce 0
getenforce
systemctl stop firewalld.service
如果还不行,就在zabbix的安装目录下找到etc/zabbix_server.conf文件,将ListenIP=0.0.0.0前的注释去掉
5.修改Zabbix前端的PHP配置,并启动httpd
vim /etc/httpd/conf.d/zabbix.conf
找到php_value date.timezone这一行,把时区改成
php_value date.timezone Asia/Shanghai
保存之后启动和开机自启
systemctl start httpd
systemctl enable httpd
6.前端zabbix-web的安装
然后我们访问http://ip/zabbix就可以了!跟着网页的提示注册。
登录的账号密码是下面的
Admin
zabbix
后期修改zabbix数据库密码的时候,需要修改的配置文件:
/etc/zabbix/web/zabbix.conf.php
可以看到界面是这样的!
写在最后
如果我的文章帮助到你了,希望你可以给我个关注,点赞,收藏支持一下,这将是我更新的动力,目前在更新从零开始学zabbix,准备更新从零开始学kubernetes,感谢你们的支持!
边栏推荐
- Kotlin composite suspend function
- 杰理之可能出现有些芯片音乐播放速度快【篇】
- 项目经理的晋级之路
- 2022煤矿瓦斯抽采操作证考试题及模拟考试
- Kotlin asynchronous flow
- 居家办公更要高效-自动化办公完美提升摸鱼时间 | 社区征文
- Jerry has opened a variety of decoding formats, and the waiting time from card insertion to playback is long [chapter]
- 4个不可不知的“安全左移”的理由
- Telecommuting: camping at home office gadgets | community essay solicitation
- 如何在物联网低代码平台中进行任务管理?
猜你喜欢
Baidu map API drawing points and tips
SAP Marketing Cloud 功能概述(三)
数商云:加强供应商管理,助推航空运输企业与供应商高效协同
Rongyun communication has "hacked" into the heart of the bank
Jerry's infrared filtering [chapter]
Autorf: learn the radiation field of 3D objects from single view (CVPR 2022)
Eight major trends in the industrial Internet of things (iiot)
One click to generate University, major and even admission probability. Is it so magical for AI to fill in volunteer cards?
npm包【详解】(内含npm包的开发、发布、安装、更新、搜索、卸载、查看、版本号更新规则、package.json详解等)
**Unity中莫名其妙得小问题-灯光和天空盒
随机推荐
Zhiyuan community weekly 86: Gary Marcus talks about three linguistic factors that can be used for reference in large model research; Google puts forward the Wensheng graph model parti which is compar
Vulnerability management mistakes that CIOs still make
Unity 热力图建立方法
Jerry's test mic energy automatic recording automatic playback reference [article]
谷歌WayMo提出R4D: 采用参考目标做远程距离估计
Use of kotlin arrays, collections, and maps
百度地图API绘制点及提示信息
#21Set经典案例
Jericho turns on shouting in all modes to increase mic automatic mute [chapter]
万用表测量电阻图解及使用注意事项
Activity生命周期
智源社区周刊#86:Gary Marcus谈大模型研究可借鉴的三个语言学因素;谷歌提出媲美Imgen的文生图模型Parti;OpenAI提出视频预训练模型VPT,可玩MC游戏
2022 coal mine gas drainage operation certificate examination questions and simulation examination
Google waymo proposed r4d: remote distance estimation using reference target
Mit-6.824-lab4a-2022 (ten thousand words explanation - code construction)
2022年江西省安全员B证考试题库模拟考试平台操作
居家办公更要高效-自动化办公完美提升摸鱼时间 | 社区征文
Gatling 性能测试
杰理之检测 MIC 能量自动录音自动播放参考【篇】
NPM package [details] (including NPM package development, release, installation, update, search, uninstall, view, version number update rules, package.json details, etc.)