目录
- Zabbix安装之server节点
- 集群规划
- 准备工作
- Zabbix-server/agent编译及安装
- 部署Zabbix-web
- Zabbix启动
- Zabbix安装之agent节点(另外两条虚拟机)
Zabbix安装之server节点
集群规划
准备工作
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
关闭SELinux
- 修改配置文件/etc/selinux/config
vim /etc/selinux/config
2)重启服务器
reboot
Zabbix-server/agent编译及安装
创建用户
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++
我按顺序安装失败了!建议第二个最后在安!如果报错看下面这篇文章编译及安装
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配置文件(大概在85行)
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
部署Zabbix-web
部署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及相关组件(如果报错在末尾加上–skip-broken)
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 请看这篇文章
Zabbix启动
启动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
Zabbix安装之agent节点(另外两条虚拟机)
创建用户
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