最近對Zabbix Server進行了升級,因此陸陸續續對Zabbix Agent也作了升級,下面是這幾天工做的一個小結,鑑於經驗有限和認知有限等各方面因素,下文很難面面俱到,若有疏漏或不足之處,敬請指正!html
Linux系統:redis
1:檢查Zabbix Agent的版本信息windows
# 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服務app
若是Zabbix Agent服務處於運行狀態,那麼最好關閉zabbix-agent服務tcp
RHEL(CentOS) 5/6工具
# service zabbix-agent stop
Shutting down Zabbix agent: [ OK ]
RHEL(CentOS) 7/8加密
# systemctl stop zabbix-agent
4:升級Zabbix Agentspa
zabbix升級的方式有多種,要根據對應的系統版本,選擇合適的安裝包:rest
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%]
案例2:CentOS 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.rpmnew爲zabbix_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
注意:i386與amd64其實就是指32位與64的Zabbix Agent客戶端。
zabbix_agent-5.0.1的32位下載載地址:
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.1的64位下載載地址:
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
打包生成安裝文件
將zabbix_agent-5.0.1-windows-i386.zip解壓出來的bin文件中的文件放到下面目錄
C:\zabbix\bin\win32
將zabbix_agent-5.0.1-windows-amd64.zip解壓出來的bin文件中的文件放到下面目錄
C:\zabbix\bin\win64
將上面任意中一個壓縮包解壓出來的zabbix_agentd.conf放到下面目錄,並修改相關參數
C:\zabbix\conf
將上面文件從新打包成zabbix_agent_install.zip,而後選擇一臺要升級客戶端的Windows服務器。
選擇Zabbix Agent 服務,找到其安裝路徑,以下所示
中止Zabbix Agent服務
C:\zabbix\bin\win64>C:\zabbix\bin\win64\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.conf -x
zabbix_agentd.exe [3028]: service [Zabbix Agent] stopped successfully
卸載Zabbix Agent
C:\zabbix\bin\win64>C:\zabbix\bin\win64\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_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:\zabbix\bin\win32目錄,而後在刪除文件時,可能遇到部分文件刪除不了的情形,以下所示,退出cmd窗口便可
刪除文件後,解壓打包文件zabbix_agent_install.7z,修改zabbix_agentd.conf文件中的參數hostname, 而後按照下面命令安裝
64位Zabbix Agent安裝
C:\zabbix\bin\win64\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.conf -i
啓動Zabbix Agent服務
C:\zabbix\bin\win64\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.conf -s
32位Zabbix Agent安裝
C:\zabbix\bin\win32\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.conf -i
啓動Zabbix Agent服務
C:\zabbix\bin\win32\zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.conf -s
上面方式都是手工安裝,在實際生產環境中,服務器數量衆多,這個但是一個體力活,因此,咱們仍是要批量安裝和更新Zabbix Agent。這個須要藉助ansible 和puppet工具來實現,目前公司尚未部署這些工具。後續研究部署了相關工具後再整理相關知識。