Zabbix是一个基于Web界面的提供分布式系统监视以及网络监视功能的企业级开源解决方案。Zabbix能监视各种网络尝试,保证服务器系统的安全运营;并提供灵活的通知机制以让系统工程师快速定位/解决存在的问题。当我们的监控的服务器增多或者需要监控异地IDC服务器的时候,单台服务器的Server-Client架构可能就不能满足我们的需求了,此时就需要考虑使用分布式的Server-Proxy-Client/Server-Node-Client架构了。首先来了解下Zabbix节点模式架构,见下图:
我们可以使用node节点模式,建立一个层次结构的分布式监控。每一个节点是一个完整的zabbix服务器,和负责监视它自己的位置,zabbx支持高达一千个节点的分布式安装。
使用node节点的好处:
1、在大型的网络中,涉及多个地点建立一个多层次的监控,在层次结构中的节点会将监控的数据传输给其主节点。
2、一个节点可以在本地配置或通过拥有所有节点配置的主节点配置。
3、数据收集将变得更加可靠。如果主节点和子节点之间的通信发生故障时,节点可以保持正常运行状态,采集的数据信息和事件将存储在本地。当主节点和子节点的连接恢复时,子节点将有选择地将数据发送到主节点。
4、节点可以脱离成一个单一的zabbix服务器的工作,能独立监视数千台主机。
新节点的添加和删除,不影响现有节点的配置。无需重新启动所需的任何节点。
拓扑
简单实验拓扑如下:
Zabbix server(master)
1.ZabbixServer 系统版本和内核版本
cat/etc/redhat-release
CentOS release 5.9 (Final)
uname-rmos
Linux 2.6.18-348.18.1.el5 x86_64 GNU/Linux
2.安装Zabbix依赖软件包
yuminstall -y make gcc gcc-c++ httpd php php-mysql mysql mysql-server php-gdphp-common php-xml net-snmp net-snmp-devel net-snmp-utils curl-develmysql-devel gnutls openldap-devel OpenIPMI OpenIPMI-devel ncurses-develunixODBC unixODBC-devel mysql-connector-odbc *libX* alsa-lib jpackage-utils php-bcmathphp-mbstring java
3.安装额外依赖软件包(需要独立下载安装,系统默认仓库没有)
rpm-ivh libssh2-1.2.4-1.el5.x86_64.rpm
rpm -ivhlibssh2-devel-1.2.4-1.el5.x86_64.rpm
rpm -ivh fping-2.4b2-7.el5.art.x86_64.rpm
rpm -ivh iksemel-1.4-2_2.el5.x86_64.rpm
rpm -ivhiksemel-devel-1.4-2_2.el5.x86_64.rpm
rpm -ivhlibiksemel3-1.4-2_2.el5.x86_64.rpm
4.添加Zabbix运行账户,解压tar包
useradd-r zabbix
tar-zxvf zabbix-2.0.8.tar.gz
5.Mysql启动和配置
servicemysqld start
mysqladmin-u root password redhat
mysql-u root –p
>createdatabse zabbix character set utf8;
>grantall privileges on zabbix.* to zabbix@localhost identified by ‘redhat’;
>flushprivileges;
mysql-u zabbix -p zabbix </root/zabbix-2.0.8/database/mysql/schema.sql
mysql-u zabbix -p zabbix </root/zabbix-2.0.8/database/mysql/p_w_picpaths.sql
mysql-u zabbix -p zabbix </root/zabbix-2.0.8/database/mysql/data.sql
6.Zabbix编译安转
./configure--prefix=/usr/local/zabbix --enable-server --enable-agent-- with-mysql --with-net-snmp --with-libcurl--with-ldap --with-ssh2 --with-jabber --with-openipmi --with-unixodbc
make install
7.添加服务端口及描述,将下面内容加入services文件里
grepzabbix /etc/services
zabbix-agent10050/tcp# Zabbix Agent
zabbix-agent10050/udp# Zabbix Agent
zabbix-trapper10051/tcp# Zabbix Trapper
zabbix-trapper10051/udp# Zabbix Trapper
8.创建日志和PID存放目录,设定权限
mkdir /var/log/zabbix
mkdir/var/run/zabbix
chown -R zabbix.zabbix/usr/local/zabbix/etc/
chown -R zabbix.zabbix /var/run/zabbix/
chown -R zabbix.zabbix /var/log/zabbix/
9.配置zabbix_server.conf文件如下
cat/usr/local/zabbix/etc/zabbix_server.conf |grep -v ^#|grep -v ^$
NodeID=1
LogFile=/var/log/zabbix/zabbix_server.log
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbix
DBUser=zabbix
DBPassword=redhat
DBSocket=/var/lib/mysql/mysql.sock
10.配置zabbix_agentd.conf文件如下
cat /usr/local/zabbix/etc/zabbix_agentd.conf|grep -v ^#|grep -v ^$
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix_server_master
11.设定Zabbix server前端文件
cpzabbix-2.0.8/frontends/php/ /var/www/html/zabbix -rf
chown-R zabbix.zabbix /var/www/html/zabbix/
12.PHP.INI文件设置
vim/etc/php.ini
max_execution_time = 300
date.timezone =Asia/Shanghai
post_max_size = 32M
max_input_time = 300
13.重启服务,设定开机启动
servicehttpd restart ; chkconfig httpd on
servicemysqld restart ; chkconfig mysqld on
14.Zabbix服务脚本配置
cpzabbix-2.0.8/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
cpzabbix-2.0.8/misc/init.d/fedora/core/zabbix_server /etc/init.d/
chownzabbix.zabbix /etc/init.d/zabbix_*
vim/etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix
PIDFILE=/var/run/zabbix/$BINARY_NAME.pid
vim/etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix
PIDFILE=/var/run/zabbix/$BINARY_NAME.pid
15.启动Zabbix服务脚本,设定开机启动
servicezabbix_server restart ;chkconfig zabbix_server on
servicezabbix_agentd restart ;chkconfig zabbix_agentd on
16.前端安装配置,使用浏览器访问
firefox http://localhost/zabbix &
17.运行环境检查
18.数据库连接检查
19.服务主机信息
20.安装信息汇总
21.点击Download configuration file 下载该文件,拷贝到/var/www/html/zabbix/conf/下,点击Retry重试,点击Finish
22.修改数据库为分布式。
/etc/init.d/zabbix_server stop
/etc/init.d/zabbix_agentd stop
/usr/local/zabbix/sbin/zabbix_server -n 1 -c/usr/local/zabbix/etc/zabbix_server.conf
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
Zabbix server(node)
1.ZabbixServer 系统版本和内核版本
cat/etc/redhat-release
CentOS release 5.9 (Final)
uname-rmos
Linux 2.6.18-348.18.1.el5 x86_64 GNU/Linux
2.安装Zabbix依赖软件包
yuminstall -y make gcc gcc-c++ httpd php php-mysql mysql mysql-server php-gdphp-common php-xml net-snmp net-snmp-devel net-snmp-utils curl-develmysql-devel gnutls openldap-devel OpenIPMI OpenIPMI-devel ncurses-develunixODBC unixODBC-devel mysql-connector-odbc*libX* alsa-lib jpackage-utils php-bcmath php-mbstring java
3.安装额外依赖软件包(需要独立下载安装,系统默认仓库没有)
rpm-ivh libssh2-1.2.4-1.el5.x86_64.rpm
rpm -ivhlibssh2-devel-1.2.4-1.el5.x86_64.rpm
rpm -ivhfping-2.4b2-7.el5.art.x86_64.rpm
rpm -ivhiksemel-1.4-2_2.el5.x86_64.rpm
rpm -ivhiksemel-devel-1.4-2_2.el5.x86_64.rpm
rpm -ivhlibiksemel3-1.4-2_2.el5.x86_64.rpm
4.添加Zabbix运行账户,解压tar包
useradd-r zabbix
tar -zxvf zabbix-2.0.8.tar.gz
5.Mysql启动和配置
servicemysqld start
mysqladmin-u root password redhat
mysql-u root –p
>createdatabse zabbix character set utf8;
>grantall privileges on zabbix.* to zabbix@localhost identified by ‘redhat’;
>flushprivileges;
mysql-u zabbix -p zabbix </root/zabbix-2.0.8/database/mysql/schema.sql
mysql-u zabbix -p zabbix </root/zabbix-2.0.8/database/mysql/p_w_picpaths.sql
mysql-u zabbix -p zabbix </root/zabbix-2.0.8/database/mysql/data.sql
6.Zabbix编译安转
./configure--prefix=/usr/local/zabbix --enable-server --enable-agent-- with-mysql --with-net-snmp --with-libcurl--with-ldap --with-ssh2 --with-jabber --with-openipmi --with-unixodbc
make install
7.添加服务端口及描述,将下面内容加入services文件里
grepzabbix /etc/services
zabbix-agent10050/tcp# Zabbix Agent
zabbix-agent10050/udp# Zabbix Agent
zabbix-trapper10051/tcp# Zabbix Trapper
zabbix-trapper10051/udp# Zabbix Trapper
8.创建日志和PID存放目录,设定权限
mkdir /var/log/zabbix
mkdir/var/run/zabbix
chown -R zabbix.zabbix/usr/local/zabbix/etc/
chown -R zabbix.zabbix /var/run/zabbix/
chown -R zabbix.zabbix /var/log/zabbix/
9.配置zabbix_server.conf文件如下
cat/usr/local/zabbix/etc/zabbix_server.conf |grep -v ^#|grep -v ^$
NodeID=2
LogFile=/var/log/zabbix/zabbix_server.log
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbix
DBUser=zabbix
DBPassword=redhat
DBSocket=/var/lib/mysql/mysql.sock
10.配置zabbix_agentd.conf文件如下
cat /usr/local/zabbix/etc/zabbix_agentd.conf|grep -v ^#|grep -v ^$
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix_server_node1
11.设定Zabbix server前端文件
cpzabbix-2.0.8/frontends/php/ /var/www/html/zabbix -rf
chown-R zabbix.zabbix /var/www/html/zabbix/
12.PHP.INI文件设置
vim/etc/php.ini
max_execution_time = 300
date.timezone =Asia/Shanghai
post_max_size = 32M
max_input_time = 300
13.重启服务,设定开机启动
servicehttpd restart ; chkconfig httpd on
servicemysqld restart ; chkconfig mysqld on
14.Zabbix服务脚本配置
cpzabbix-2.0.8/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
cpzabbix-2.0.8/misc/init.d/fedora/core/zabbix_server /etc/init.d/
chownzabbix.zabbix /etc/init.d/zabbix_*
vim/etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix
PIDFILE=/var/run/zabbix/$BINARY_NAME.pid
vim/etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix
PIDFILE=/var/run/zabbix/$BINARY_NAME.pid
15.启动Zabbix服务脚本,设定开机启动
servicezabbix_server restart ;chkconfig zabbix_server on
servicezabbix_agentd restart ;chkconfig zabbix_agentd on
16.前端安装配置,使用浏览器访问
firefox http://localhost/zabbix &
安装步骤同master
17.修改数据库为分布式。
/etc/init.d/zabbix_server stop
/etc/init.d/zabbix_agentd stop
/usr/local/zabbix/sbin/zabbix_server -n 2 -c/usr/local/zabbix/etc/zabbix_server.conf
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
Zabbix client
这里就以一台Zabbixagent为例,其他Client设置都雷同。
1.ZabbixServer 系统版本和内核版本
cat/etc/redhat-release
CentOS release 5.9 (Final)
uname-rmos
Linux 2.6.18-348.18.1.el5 x86_64 GNU/Linux
2.添加Zabbix运行账户,解压tar包
useradd-r zabbix
tar-zxvf zabbix_agents_2.0.8.linux2_6.amd64.tar.gz
3.创建日志和PID存放目录,设定权限
mkdir/usr/local/zabbix_agent
mkdir/var/log/zabbix
mkdir/var/run/zabbix
chown-R zabbix.zabbix /var/run/zabbix/
chown-R zabbix.zabbix /var/log/zabbix/
chown-R zabbix.zabbix /usr/local/zabbix_agent/conf/
4.配置zabbix_agentd.conf文件如下
cat/usr/local/zabbix_agent/conf/zabbix_agentd.conf |grep -v ^#|grep -v ^$
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=192.168.150.129
ServerActive=192.168.150.129
Hostname=ws130.example.com
Zabbix Server前台设置
1.登录ZabbixServer(master)前端,在AdministrationàDM选项,然后选择Nodes,点击“Localnode ”,设置如图:
2.登录ZabbixServer(master)前端,在AdministrationàDM选项,然后选择Nodes,点击“Localnode ”,设置如图:
3.重启ZabbixServer(master)上的服务
service zabbix_server restart
service zabbix_agent restart
4.登录ZabbixServer(node1)前端,在AdministrationàDM选项,然后选择Nodes,新建主节点,设置如图:
5.在ZabbixServer(node1)上重启服务
servicezabbix_server restart
servicezabbix_agent restart
6.在master上选择要查看的节点
转载于:https://blog.51cto.com/coolsky/1306531