zoukankan      html  css  js  c++  java
  • Zabbix Agent升级

     

    最近对Zabbix Server进行了升级,所以陆陆续续对Zabbix Agent也做了升级,下面是这几天工作的一个小结,鉴于经验有限和认知有限等各方面因素,下文很难面面俱到,如有疏漏或不足之处,敬请指正!

     

     

    Linux系统:

     

     

     

    1:检查Zabbix Agent的版本信息

     

    # zabbix_agentd -V
    # zabbix_agentd --version
     
     
    # zabbix_agentd --version
    zabbix_agentd (daemon) (Zabbix) 3.0.9
    Revision 67444 19 April 2017, compilation time: Apr 23 2017 13:50:27
     
    Copyright (C) 2017 Zabbix SIA
    License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
    This is free software: you are free to change and redistribute it according to
    the license. There is NO WARRANTY, to the extent permitted by law.

     

     

    2:检查Zabbix Agent服务的状态 

     

    RHEL(CentOS) 5/6
     
    # service zabbix-agent status
    zabbix_agentd (pid  4437) is running...
     
     
    RHEL(CentOS) 7/8
     
    # systemctl status zabbix-agent

     

     

    3:关闭Zabbix Agent服务

     

     

    如果Zabbix Agent服务处于运行状态,那么最好关闭zabbix-agent服务

     

    RHEL(CentOS) 5/6

     

    # service zabbix-agent stop
     
    Shutting down Zabbix agent: [  OK  ]

     

     

    RHEL(CentOS) 7/8

     

    # systemctl stop zabbix-agent

     

     

    4:升级Zabbix Agent

     

     

    zabbix升级的方式有多种,要根据对应的系统版本,选择合适的安装包:

     

     

    YUM方式:

     

     

    $ sudo yum upgrade 'zabbix-agent-*'

     

    $ sudo yum upgrade 'zabbix-agent2-*'

     

     

     

    RPM方式安装(RHEL 5.7

     

    #sudo rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/5/x86_64/zabbix-agent-5.0.1-1.el5.x86_64.rpm

     

    如果服务器没有联网,那么就上传到服务器,在本地安装

     

     

    案例1 RHEL 5.7

     

    #sudo rpm -Uvh zabbix-agent-5.0.1-1.el5.x86_64.rpm
     
     
    #rpm -Uvh /tmp/zabbix-agent-5.0.1-1.el5.x86_64.rpm 
    warning: /tmp/zabbix-agent-5.0.1-1.el5.x86_64.rpm: Header V3 RSA/SHA512 signature: NOKEY, key ID a14fe591
    Preparing...                ########################################### [100%]
       1:zabbix-agent           warning: /etc/zabbix/zabbix_agentd.conf created as /etc/zabbix/zabbix_agentd.conf.rpmnew
    ########################################### [100%]

     

     

    案例2CentOS 7.8

     

    # rpm -Uhv zabbix-agent-5.0.1-1.el7.x86_64.rpm 
    warning: zabbix-agent-5.0.1-1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:zabbix-agent-5.0.1-1.el7         warning: /etc/zabbix/zabbix_agentd.conf created as /etc/zabbix/zabbix_agentd.conf.rpmnew
    ################################# [ 50%]
    Cleaning up / removing...
       2:zabbix-agent-3.0.9-1.el7         ################################# [100%]

     

     

     

    5:修改Zabbix Agent的配置文件的相关参数

     

     

    首先备份旧的zabbix_agentd.conf参数文件,重命名zabbix_agentd.conf.rpmnewzabbix_agentd.conf。 修改相关参数.

     

    # mv zabbix_agentd.conf zabbix_agentd.conf.old

    # mv zabbix_agentd.conf.rpmnew  zabbix_agentd.conf

     

    查找Zabbix Agent的配置文件位置。其实这个不是必须的。上面安装过程有提示信息,明确了配置文件路径。

     

    方法1:

    #locate zabbix_agentd.conf

     

    方法2:

    #rpm -ql zabbix-agent | grep zabbix_agentd.conf

     

    方法3:

    # find / -name "zabbix_agentd.conf"

     

     

    6:防火墙设置

     

     

    视情况而定,有时候需要修改防火墙(Zabbix Server变化了),有时候可能不需要修改(如果Zabbix Server没有变化则不需要)。

     

    方式1:开放10050端口

     

    -A RH-Firewall-1-INPUT -p tcp -m tcp --dport 10050 -j ACCEPT

     

    重启防火墙服务

    # service iptables restart

     

     

    CentOS 7/8 firewalld的设置

     

     

    # firewall-cmd --permanent --add-port=10050/tcp

    # firewall-cmd --reload

     

     

     

     

     

    7:验证ZabbixAgent的版本信息和日志

     

     

    # service zabbix-agent status
    zabbix_agentd is stopped
    # service zabbix-agent start
    Starting Zabbix agent: [  OK  ]
    # zabbix_agentd --version
    zabbix_agentd (daemon) (Zabbix) 5.0.1
    Revision c2a0b03480 25 May 2020, compilation time: May 28 2020 05:06:02
     
    Copyright (C) 2020 Zabbix SIA
    License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
    This is free software: you are free to change and redistribute it according to
    the license. There is NO WARRANTY, to the extent permitted by law.

     

    设置开机自启动(CentOS 5/6

     

    # chkconfig --list  | grep zabbix-agent

    # chkconfig  zabbix-agent on

     

     

    设置开机自启动(CentOS 7/8

     

    sudo systemctl is-enabled zabbix-agent 

    sudo systemctl enable zabbix-agent      #设置开机启动

    sudo systemctl restart zabbix-agent

     

     

    # systemctl status zabbix-agent
    # systemctl start zabbix-agent
    # systemctl status zabbix-agent
    ● zabbix-agent.service - Zabbix Agent
       Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
       Active: active (running) since Sun 2020-07-05 09:26:04 CST; 6s ago
      Process: 11180 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
     Main PID: 11182 (zabbix_agentd)
       CGroup: /system.slice/zabbix-agent.service
               ├─11182 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
               ├─11183 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
               ├─11184 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
               ├─11185 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
               ├─11186 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
               └─11187 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

     

     

     

     

     

     

    Windows系统

     

     

    下载安装介质

     

    下载Zabbix Agent 5.0.1的客户端,目前官网提供(32/64位;加密和非加密)四种方式:

     

     

    https://www.zabbix.com/download_agents?version=5.0+LTS&release=5.0.1&os=Windows&os_version=Any&hardware=amd64&encryption=OpenSSL&packaging=Archive

     

     

    注意:i386amd64其实就是指32位与64Zabbix Agent客户端

     

    clip_image001

     

     

    zabbix_agent-5.0.132位下载载地址:

     

     

    https://www.zabbix.com/downloads/5.0.1/zabbix_agent-5.0.1-windows-i386-openssl.zip

    https://www.zabbix.com/downloads/5.0.1/zabbix_agent-5.0.1-windows-i386.zip

     

     

     

    zabbix_agent-5.0.164位下载载地址:

     

     

    https://www.zabbix.com/downloads/5.0.1/zabbix_agent-5.0.1-windows-amd64-openssl.zip

    https://www.zabbix.com/downloads/5.0.1/zabbix_agent-5.0.1-windows-amd64.zip

     

     

     

     

     

    校检文件有效性

     

     

    # md5sum zabbix_agent-5.0.1-windows-i386.zip 
    3e91e1c193bfbc1c0133f26b728b7033  zabbix_agent-5.0.1-windows-i386.zip
    # sha1sum zabbix_agent-5.0.1-windows-i386.zip 
    c031ce47e705173fb9cedf518d45b32beead9711  zabbix_agent-5.0.1-windows-i386.zip
    # sha256sum zabbix_agent-5.0.1-windows-i386.zip 
    fee7e678464c8726abd66af5a83e79fd472381617b765cda541faedbb188eec2  zabbix_agent-5.0.1-windows-i386.zip

     

    clip_image002

     

     

     

    打包生成安装文件

     

     

    zabbix_agent-5.0.1-windows-i386.zip解压出来的bin文件中的文件放到下面目录

     

    C:zabbixinwin32

     

    zabbix_agent-5.0.1-windows-amd64.zip解压出来的bin文件中的文件放到下面目录

     

    C:zabbixinwin64

     

    将上面任意中一个压缩包解压出来的zabbix_agentd.conf放到下面目录,并修改相关参数

     

    C:zabbixconf

     

     

    将上面文件重新打包成zabbix_agent_install.zip,然后选择一台要升级客户端的Windows服务器。

     

     

    选择Zabbix Agent 服务,找到其安装路径,如下所示

     

    clip_image003

     

     

    停止Zabbix Agent服务

     

    C:zabbixinwin64>C:zabbixinwin64zabbix_agentd.exe -c c:zabbixconfzabbix_agentd.conf -x
    zabbix_agentd.exe [3028]: service [Zabbix Agent] stopped successfully

     

    卸载Zabbix Agent

     

    C:zabbixinwin64>C:zabbixinwin64zabbix_agentd.exe -c c:zabbixconfzabbix_agentd.conf -d
    zabbix_agentd.exe [7148]: service [Zabbix Agent] uninstalled successfully
    zabbix_agentd.exe [7148]: event source [Zabbix Agent] uninstalled successfully

     

     

    注意上面方式卸载Zabbix Agent后,Zabbix Agent对应的文件并没有删除,所以你最好手工删除。

     

     

     

    注意事项:如果你在命令窗口,例如,进入了C:zabbixinwin32目录,然后在删除文件时,可能遇到部分文件删除不了的情形,如下所示,退出cmd窗口即可

     

    clip_image004

     

    删除文件后,解压打包文件zabbix_agent_install.7z,修改zabbix_agentd.conf文件中的参数hostname, 然后按照下面命令安装

     

     

    64Zabbix Agent安装

     

    C:zabbixinwin64zabbix_agentd.exe -c c:zabbixconfzabbix_agentd.conf -i

     

     

    启动Zabbix Agent服务

    C:zabbixinwin64zabbix_agentd.exe -c c:zabbixconfzabbix_agentd.conf -s

     

     

     

    32Zabbix Agent安装

     

    C:zabbixinwin32zabbix_agentd.exe -c c:zabbixconfzabbix_agentd.conf -i

     

     

    启动Zabbix Agent服务

    C:zabbixinwin32zabbix_agentd.exe -c c:zabbixconfzabbix_agentd.conf -s

     

     

    上面方式都是手工安装,在实际生产环境中,服务器数量众多,这个可是一个体力活,所以,我们还是要批量安装和更新Zabbix Agent。这个需要借助ansible puppet工具来实现,目前公司还没有部署这些工具。后续研究部署了相关工具后再整理相关知识。

     

     

  • 相关阅读:
    LeetCode 258 Add Digits
    LeetCode 231 Power of Two
    LeetCode 28 Implement strStr()
    LeetCode 26 Remove Duplicates from Sorted Array
    LeetCode 21 Merge Two Sorted Lists
    LeetCode 20 Valid Parentheses
    图形处理函数库 ImageTTFBBox
    php一些函数
    func_get_arg(),func_get_args()和func_num_args()的用法
    人生不是故事,人生是世故,摸爬滚打才不会辜负功名尘土
  • 原文地址:https://www.cnblogs.com/kerrycode/p/13267341.html
Copyright © 2011-2022 走看看