離線電商數倉(六十三)之叢集監控(三)Zabbix(三)安裝agent節點(centos)
阿新 • • 發佈:2020-09-06
Zabbix安裝之agent節點
1建立使用者
sudo groupadd --system zabbix sudo useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
2 編譯環境準備
sudo yum -y install gcc-c++ pcre-devel
3 解壓Zabbix安裝包
將安裝包上傳至/opt/software路徑並解壓到當前路徑
tar -zxvf zabbix-4.2.8.tar.gz
4 編譯及安裝
1)進入/opt/software
./configure --enable-agent
sudo make install
2)修改zabbix-agent配置檔案
sudo vim /usr/local/etc/zabbix_agentd.conf Server=hadoop102 #ServerActive=127.0.0.1 #Hostname=Zabbix server
5 編輯系統服務指令碼
1)編輯zabbix-agent檔案
sudovim/etc/init.d/zabbix-agent
2)內容如下
#!/bin/sh # # chkconfig: - 86 14 # description: Zabbix agent daemon # processname: zabbix_agentd # config:/usr/local/etc/zabbix_agentd.conf # ### BEGIN INIT INFO # Provides: zabbix-agent # Required-Start: $local_fs $network # Required-Stop: $local_fs $network # Should-Start: zabbix zabbix-proxy # Should-Stop: zabbix zabbix-proxy # Default-Start: # Default-Stop: 0 1 2 3 4 5 6 # Short-Description: Start and stop Zabbix agent # Description: Zabbix agent ### END INIT INFO # Source function library. ./etc/rc.d/init.d/functions if [ -x /usr/local/sbin/zabbix_agentd ]; then exec=/usr/local/sbin/zabbix_agentd else exit 5 fi prog=zabbix_agentd conf=/usr/local/etc/zabbix_agentd.conf pidfile=/tmp/zabbix_agentd.pid timeout=10 if [ -f /etc/sysconfig/zabbix-agent ]; then . /etc/sysconfig/zabbix-agent fi lockfile=/var/lock/subsys/zabbix-agent start() { echo -n $"Starting Zabbix agent: " daemon $exec -c $conf rv=$? echo [ $rv -eq 0 ] && touch $lockfile return $rv } stop() { echo -n $"Shutting down Zabbix agent: " killproc -p $pidfile -d $timeout $prog rv=$? echo [ $rv -eq 0 ] && rm -f $lockfile return $rv } restart() { stop start } case "$1" in start|stop|restart) $1 ;; force-reload) restart ;; status) status -p $pidfile $prog ;; try-restart|condrestart) if status $prog >/dev/null ; then restart fi ;; reload) action $"Service ${0##*/} does not support the reload action: " /bin/false exit 3 ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" exit 2 ;; esac
3)加執行許可權
sudochmod+x /etc/init.d/zabbix-agent
3.6 啟動Zabbix-Agent
1)啟動
sudoservicezabbix-agent start
2)開機自啟
sudo chkconfig --add zabbix-agent
sudo chkconfig zabbix-agent on