關閉防火牆
systemctl stop firewalld
systemctl disable firewalld
關閉SELinux
vim /etc/selinux/config
2)重新啓動伺服器
reboot
建立使用者
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
上傳zabbix安裝包並解壓
鏈接:https://pan.baidu.com/s/1kernkNFKw-KHAbd93hECwg
提取碼:sp89
tar -zxvf zabbix-4.2.8.tar.gz
建立zabbix數據庫和表
1)進入/export/servers/zabbix-4.2.8/database/mysql路徑
cd /export/servers/zabbix-4.2.8/database/mysql
2)進入MySQL用戶端執行建表語句,並匯入zabbix提供的sql指令碼
mysql>
create database zabbix default character set utf8 collate utf8_bin;
use zabbix;
source schema.sql;
source data.sql;
source images.sql;
編譯環境準備
mysql
鏈接:https://pan.baidu.com/s/1-ikXWFltzQrur1lPZxo4DQ
提取碼:fnot
1)上傳並安裝安裝MySQL相關rpm包
rpm -ivh MySQL-devel-5.6.24-1.el6.x86_64.rpm
rpm -ivh MySQL-embedded-5.6.24-1.el6.x86_64.rpm
rpm -ivh MySQL-shared-5.6.24-1.el6.x86_64.rpm
rpm -ivh MySQL-shared-compat-5.6.24-1.el6.x86_64.rpm
2)安裝所需依賴
sudo rpm -ivh http://www.city-fan.org/ftp/contrib/yum-repo/rhel6/x86_64/city-fan.org-release-2-1.rhel6.noarch.rpm
sudo yum-config-manager --enable city-fan.org
sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/Packages/l/libnghttp2-1.6.0-1.el6.1.x86_64.rpm
sudo rpm -e --nodeps libxml2-python-2.7.6-21.el6.x86_64
sudo yum install -y libcurl libcurl-devel libxml2 libxml2-devel net-snmp-devel libevent-devel pcre-devel gcc-c++
我按順序安裝失敗了!建議第二個最後在安!如果報錯看下面 下麪這篇文章
https://blog.csdn.net/qq_46548855/article/details/107886091
編譯及安裝
1)進入/export/servers/zabbix-4.2.8路徑
cd /export/servers/zabbix-4.2.8
2)編譯安裝
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make install
修改組態檔
1)修改zabbix-server組態檔
vim /usr/local/etc/zabbix_server.conf
DBHost=hadoop102
DBName=zabbix
DBUser=root
DBPassword=root
2)修改zabbix-agent組態檔 分發
vim /usr/local/etc/zabbix_agentd.conf
Server=hadoop102
#ServerActive=127.0.0.1
#Hostname=Zabbix server
編寫系統服務指令碼
1)編輯zabbix-server檔案
vim /etc/init.d/zabbix-server
2)內容如下
#!/bin/sh
#
# chkconfig: - 85 15
# description: Zabbix server daemon
# config: /usr/local/etc/zabbix_server.conf
#
### BEGIN INIT INFO
# Provides: zabbix
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: Start and stop Zabbix server
# Description: Zabbix server
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
if [ -x /usr/local/sbin/zabbix_server ]; then
exec=/usr/local/sbin/zabbix_server
else
exit 5
fi
prog=zabbix_server
conf=/usr/local/etc/zabbix_server.conf
pidfile=/tmp/zabbix_server.pid
timeout=10
if [ -f /etc/sysconfig/zabbix-server ]; then
. /etc/sysconfig/zabbix-server
fi
lockfile=/var/lock/subsys/zabbix-server
start()
{
echo -n $"Starting Zabbix server: "
daemon $exec -c $conf
rv=$?
echo
[ $rv -eq 0 ] && touch $lockfile
return $rv
}
stop()
{
echo -n $"Shutting down Zabbix server: "
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)加執行許可權
chmod +x /etc/init.d/zabbix-server
4)編輯zabbix-agent檔案
vim /etc/init.d/zabbix-agent
5)內容如下
#!/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
6)加執行許可權
chmod +x /etc/init.d/zabbix-agent
部署httpd
1)安裝httpd
yum -y install httpd
2)修改httpd組態檔
vim /etc/httpd/conf/httpd.conf
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
</IfModule>
3)拷貝zabbix-web的php檔案到httpd的指定目錄
mkdir /var/www/html/zabbix
cp -a /export/servers/zabbix-4.2.8/frontends/php/* /var/www/html/zabbix/
安裝php5.6
1)安裝yum源
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -ivh epel-release-6-8.noarch.rpm remi-release-6.rpm
2)啓用yum源
yum-config-manager --enable remi-php56
3)安裝php及相關元件
yum install -y php php-bcmath php-mbstring php-xmlwriter php-xmlreader php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
這裏如果報錯conflict 請看這篇文章
https://blog.csdn.net/qq_46548855/article/details/107886477
啓動Zabbix-Server
1)啓動
service zabbix-server start
2)開機自啓
chkconfig --add zabbix-server
chkconfig zabbix-server on
啓動Zabbix-Agent
1)啓動
service zabbix-agent start
2)開機自啓
chkconfig --add zabbix-agent
chkconfig zabbix-agent on
啓動Zabbix-Web(httpd)
1)啓動
service httpd start
2)開機自啓
chkconfig httpd on
Zabbix登錄
1)瀏覽器存取http://hadoop102/zabbix
下載檔案,複製程式碼,儲存到下面 下麪那個檔案中!
登錄,使用者名稱:Admin,密碼zabbix
建立使用者
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
編譯環境準備
yum -y install gcc-c++ pcre-devel
解壓Zabbix安裝包
將安裝包上傳至/export/servers路徑並解壓到當前路徑
tar -zxvf zabbix-4.2.8.tar.gz
編譯及安裝
1)進入/export/servers/zabbix-4.2.8路徑,執行以下編譯安裝命令
./configure --enable-agent
make install
2)修改zabbix-agent組態檔
建議使用拷貝過去
vim /usr/local/etc/zabbix_agentd.conf
Server=hadoop102
#ServerActive=127.0.0.1
#Hostname=Zabbix server
編輯系統服務指令碼
1)編輯zabbix-agent檔案
vim /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
啓動Zabbix-Agent
1)啓動
service zabbix-agent start
2)開機自啓
chkconfig --add zabbix-agent
chkconfig zabbix-agent on