版权声明:本文为博主原创文章,转载请注明出处:https://twocups.cn/index.php/2021/06/28/41/

同步时间以及设置时区

我们这一章是对将要部署 Zabbix 客户端的机器进行操作的。

首先,我们需要将所有服务器的时间同步。一般服务器之间的时间同步用 ntp 就可以,不过连接外网和连接内网的机器同步方式有些许不同,这个可以根据自己的情况去查一下,网上有很多教程。

然后,我们在设置时区之前先看下机器的时区是否正确。

timedatectl

结果:
    Local time: Thu 2021-06-17 11:02:30 CST
Universal time: Thu 2021-06-17 03:02:30 UTC
      RTC time: Thu 2021-06-17 03:02:29
      Time zone: Asia/Shanghai (CST, +0800)
    NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
    DST active: n/a

结果中时区显示的是“Asia/Shanghai”,“+0800”代表东八区,说明我们时区已经是正确的了。如果不是,那么设置一下就行。

mv /etc/localtime{,.bak}
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

离线部署Zabbix客户端

客户端的部署就比服务端简单多了。由于我们在客户端上只需要装“zabbix-agent2”,所以我们可以不用上一章在服务端上的那种批量安装方式。

yum localinstall *.rpm

通过这条指令,我们可以直接本地安装 zabbix-agent2.rpm。这个包在服务端的 /zabbix_repo 里面是有的,我们把它传输到客户端上安装即可。

安装完我们启动 zabbix-agent2,并且设置开机自启。

systemctl enable --now zabbix-agent2

启动后,我们再检查下端口,看是不是在10050端口运行。

netstat -tunlp|grep zabbix

结果:
tcp6       0      0 :::10050               :::*                   LISTEN      11838/zabbix_agent2

接下来,我们修改 zabbix-agent2 的配置文件,需要改动的地方有三处。

vim /etc/zabbix/zabbix_agent2.conf

Server=服务端ip地址
ServerActive=服务端ip地址
Hostname=服务端主机名

如果不清楚主机名,用指令“hostname”查看一下就行。有的企业里面直接用指令“hostname”查到的主机名都是一样的,那么去“/etc/hostname”里面查一下看看,一般都是独立的名字了。

cat /etc/hostname

Zabbix服务端检测客户端是否连接上

我们回到 Zabbix 客户端的机器上,安装一下 zabbix-get。

yum localinstall *.rpm

安装完之后服务端就可以通过指令“zabbix_get”向客户端请求信息了。

zabbix_get -s '客户端ip' -p 10050 -k "agent.ping"

结果:
1

结果为1就代表服务端和客户端已经连通了。zabbix-get 还可以发送其他的指令,有兴趣可以自己去研究一下。

Zabbix服务端前端页面

我们通过“服务端ip/zabbix”登陆 Zabbix 前端页面。我们首先要设置页面语言为中文。

我们从左侧栏“User settings”进入用户设置,然后就在第一列“User”里面,将语言改为中文,然后“Update”更新即可。

这时,如果进入左侧栏“监控-主机”,然后对指定主机选中“图形”,就能看到指定主机各项数值的图形化显示。可是由于我们刚才将语言改成了中文,所以这里图形下面会出现乱码。我们只需要在服务端安装字体即可。

我们先从客户端下载字体的 rpm 文件。

yum install --downloadonly   --downloaddir=/zabbix_repo wqy-microhei-fonts

我们从客户端的 /zabbix_repo地址下找到字体文件的rpm包,然后传到服务端上,并且安装。

yum localinstall *.rpm

安装完字体之后,我们将其设置为系统字体。

\cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

我们在指令“cp”前面加了反斜杠,是为了临时取消使用指令别名。因为我们运行指令“cp”的时候,实际运行的指令其实是“cp -i”。我们在前面加上反斜杠,就相当于临时把这条指令还原成单纯的“cp”了。

此时,Zabbix 前端页面就能正确显示中文了。

添加客户端主机

我们进入左侧栏“配置-主机”,这时我们可以看到 Zabbix 已经在监控服务端本身了。我们需要通过右上角的“创建主机”按钮将客户端也添加进监控。

在添加主机页面,我们先在主机这一栏填写主机名称、群组和客户端IP地址。主机名称必须是主机的hostname,否则会提示hostname错误。群组填 Linux servers,客户端的 ip 地址直接填写即可。

填完以后我们先不要点添加,先进入模版一栏。如果已经点了添加,也没事,再次进入设置页面的模版一栏即可。我们为我们的监控主机选择一个监控模版,输入“linux”就会弹出很多模版,选择“Template OS Linux by Zabbix agent”就行。

添加完主机之后,我们返回主机页面,只要可用性显示绿色的“ZBX”,就说明监控成功。

到这里,Zabbix 服务端和客户端的配置就基本完成了。我们想要看监控机器的信息的话,可以直接进入左侧栏“检测-主机”查看。在主机页面,我们可以在“最新数据”一栏查看具体的数据,也可以在“图形”一栏查看图像化的数据。

林皓伟

《【Zabbix系列】第四章:离线部署Zabbix客户端》有 9 条评论
  1. Just want to say your article is as surprising. The clarity in your post is simply excellent and i can assume you are an expert on this subject. Well with your permission allow me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please continue the gratifying work. Alva Carolla

  2. I wanted to put you that tiny remark to be able to say thanks a lot over again on the pleasing solutions you have provided in this case. It was really shockingly open-handed with you to make publicly precisely what many of us might have offered for an ebook to get some dough for themselves, notably now that you might have tried it in case you desired. These smart ideas as well served to be the good way to fully grasp that other people online have the identical interest really like my personal own to learn more related to this matter. I am sure there are numerous more pleasant periods in the future for many who read carefully your site. Ron Fico

  3. Penis pumps accommodate placing a tube express more all the penis and then pumping old-fashioned the musicality to concoct a vacuum. The vacuum draws blood into the penis and makes it swell. Vacuum devices reking.exproc.se/online-konsultation/hypofyseinsufficiens.php are every at the wink of an eye adapted to in the knee-high to a grasshopper stipulations treatment of impotence. But overusing a penis baffled can devastation the pack of the penis, pre-eminent to weaker erections. Joseph Blechman

  4. I have really noticed that credit improvement activity needs to be conducted with tactics. If not, you might find yourself endangering your rating. In order to reach your goals in fixing your credit score you have to make sure that from this minute you pay your complete monthly dues promptly prior to their appointed date. It is really significant on the grounds that by never accomplishing this, all other activities that you will decide to use to improve your credit rank will not be successful. Thanks for expressing your thoughts. Hershel Hagen

  5. Firstly, you hold o dippy the penis as you mirage up this is the inimitable allure to show to elevate your penis, unified collusively be demented hither the penis chairlady, and another all over is enveloping that hand. When you engross firti.livetsmukt.com/instruktioner/nimue-produkter.php on the penis, you should overextend, and switch your penis thrash with a view 30 times, preserve that make up to the left. Then you can possess a allow to remain of non-presence; use your penis a minuscule bit. Then, discourse on the penis, elongate it, and transformation it to the peaches, do it looking in behalf of 30 times and learn a intermission in the vanguard you soften to another side. Erich Snoots

  6. I loved as much as you will obtain performed proper here. The cartoon is attractive, your authored subject matter stylish. nevertheless, you command get bought an impatience over that you wish be handing over the following. sick definitely come further previously again as exactly the similar nearly a lot incessantly inside case you defend this increase. Antony Neves

  7. After all, we should remember compellingly reintermediate mission-critical potentialities whereas cross functional scenarios. Phosfluorescently re-engineer distributed processes without standardized supply chains. Quickly initiate efficient initiatives without wireless web services. Interactively underwhelm turnkey initiatives before high-payoff relationships. Holisticly restore superior interfaces before flexible technology. Ted Syas

  8. I wish to express my admiration for your kind-heartedness giving support to people that really want help with that field. Your very own dedication to passing the solution all through appears to be particularly beneficial and has really encouraged folks much like me to get to their desired goals. Your insightful useful information can mean this much to me and additionally to my office colleagues. Many thanks; from each one of us. Matthew Galbreth

  9. I think the problem for me is the energistically benchmark focused growth strategies via superior supply chains. Compellingly reintermediate mission-critical potentialities whereas cross functional scenarios. Phosfluorescently re-engineer distributed processes without standardized supply chains. Quickly initiate efficient initiatives without wireless web services. Interactively underwhelm turnkey initiatives before high-payoff relationships. Carlton Farnsworth

发表回复

您的电子邮箱地址不会被公开。