码迷,mamicode.com
首页 > 其他好文 > 详细

zabbix安装一(debian)

时间:2015-06-06 15:12:01      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:zabbix

一、基础环境说明
1、zabbix官网
www.zabbix.com

2、zabbix介绍
Zabbix is the ultimate enterprise-level software designed for monitoring availability
and performance of IT infrastructure components. Zabbix is open source and comes at no cost.

3、当前版本
cat /etc/debian_version
7.8

4、共安装三部分内容
1)安装zabbix-server
2)安装zabbix-web前端
3)安装zabbix-agent

5、参考
https://www.zabbix.com/documentation/2.2/manual/
zabbix监控系统深度实践(书)
http://www.zabbix.net.cn/(社区)

二、安装zabbix-server(1-9步骤)
1、下载并解压zabbix
1)下载
axel -n 10 http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.9/zabbix-2.2.9.tar.gz
2)解压
tar zxvf zabbix-2.2.9.tar.gz

2、编译三部曲(安装在/opt/zabbix)
cd zabbix-2.2.9
1)./configure --enable-server --enable-agent --with-mysql --with-libxml2 --with-net-snmp --with-openipmi --with-libcurl --with-unixodbc --prefix=/opt/zabbix
2)make
3)make install

编译参数说明
--enable-server         Turn on build of Zabbix server(支持server)
--enable-agent          Turn on build of Zabbix agent and client utilities(支持agent)
--with-mysql[=ARG]      use MySQL client library [default=no],optionally specify path to mysql_config(支持mysql功能)
--with-libxml2[=ARG]    use libxml2 client library [default=no],optionally specify path to xml2-config
--with-net-snmp[=ARG]   use Net-SNMP package [default=no],optionally specify path to net-snmp-config(支持snmp监控)
--with-openipmi[=DIR]   Include OPENIPMI support [default=no].DIR is the OPENIPMI base install directory,
default is to search through a number of common places for the OPENIPMI files.(支持ipmi)
--with-libcurl[=DIR]    use cURL package [default=no], optionally specify path to curl-config
--with-unixodbc[=ARG]   use ODBC driver against unixODBC package [default=no],optionally specify
full path to odbc_config binary.

从2.2.0版本开始支持virtual machine监控 编译的时候加上--with-libxml2 and --with-libcurl
Support of monitoring VMware environments is available in Zabbix starting with version 2.2.0.
For virtual machine monitoring to work, Zabbix should be compiled with the --with-libxml2 and --with-libcurl compilation options.

编译时提示需要安装的包
1)configure: error: no acceptable C compiler found in $PATH
需要安装apt-get -y install gcc
2)configure: error: MySQL library not found
需要安装apt-get -y install libghc6-hsql-mysql-dev
3)configure: error: LIBXML2 library not found
需要安装apt-get -y install libxml2-dev
4)configure: error: unixODBC library not found
需要安装apt-get -y install unixodbc-dev
5)configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
需要安装apt-get -y install libsnmp-dev
6)configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h
需要安装apt-get -y install libopenipmi-dev
7)configure: error: Curl library not found
需要安装apt-get -y install libghc6-curl-dev
8)make命令
需要安装apt-get -y install make
9)编译完成后将相关命令进行软链接操作
设置命令的快捷方式(软链接)
ln -s /opt/zabbix/bin/* /usr/local/bin/
ln -s /opt/zabbix/sbin/* /usr/local/sbin/
ll /usr/local/bin
lrwxrwxrwx 1 root staff 26 May 29 08:47 zabbix_get -> /opt/zabbix/bin/zabbix_get
lrwxrwxrwx 1 root staff 29 May 29 08:47 zabbix_sender -> /opt/zabbix/bin/zabbix_sender
ll /usr/local/sbin
lrwxrwxrwx 1 root staff 29 May 29 08:47 zabbix_agent -> /opt/zabbix/sbin/zabbix_agent
lrwxrwxrwx 1 root staff 30 May 29 08:47 zabbix_agentd -> /opt/zabbix/sbin/zabbix_agentd
lrwxrwxrwx 1 root staff 30 May 29 08:47 zabbix_server -> /opt/zabbix/sbin/zabbix_server

3、相关数据库配置
1)安装mysql-server
apt-get -y install mysql-server-5.5
2)建zabbix库(root密码是redhat)
mysql -uroot -p"redhat" -S /var/run/mysqld/mysqld.sock -e "create database zabbix character set utf8 collate utf8_bin;"
3)授权(我这边mysql是监听在192.168.1.124)
grant all privileges on zabbix.* to zabbix@"192.168.1.124" identified by ‘123456‘;
flush privileges;
4)使用zabbix用户导入sql语句 按照这个顺序来
1)mysql -uzabbix -p"123456" -h"192.168.1.124" zabbix < /root/zabbix-2.2.9/database/mysql/schema.sql
2)mysql -uzabbix -p"123456" -h"192.168.1.124" zabbix < /root/zabbix-2.2.9/database/mysql/images.sql
3)mysql -uzabbix -p"123456" -h"192.168.1.124" zabbix < /root/zabbix-2.2.9/database/mysql/data.sql

4、创建用户
1)建zabbix组
groupadd zabbix
2)添加zabbix用户并加入到zabbix组
useradd -s /bin/false -g zabbix zabbix

5、修改配置让zabbix server连接上mysql
1)先备份下需要修改的文件
cp /opt/zabbix/etc/zabbix_server.conf /opt/zabbix/etc/zabbix_server.conf.bak
2)修改配置
cat /opt/zabbix/etc/zabbix_server.conf |egrep -v "^$|^#"
ListenPort=10051
LogFile=/var/log/zabbix_server/zabbix_server.log
PidFile=/var/run/zabbix_server/zabbix_server.pid
DBHost=192.168.1.124
DBName=zabbix
DBUser=zabbix
DBPassword=123456
ListenIP=192.168.1.124
AlertScriptsPath=${datadir}/zabbix/alertscripts

6、修改启动脚本
1)复制模板的脚本
cp /root/zabbix-2.2.9/misc/init.d/debian/zabbix-server /etc/init.d/
2)修改脚本内容
diff /root/zabbix-2.2.9/misc/init.d/debian/zabbix-server /etc/init.d/zabbix-server
10c10
< PID=/tmp/$NAME.pid
---
> PID=/var/run/zabbix_server/$NAME.pid
3)给脚本执行权限
chmod +x /etc/init.d/zabbix-server

7、建目录并做日志切割处理
1)建目录
mkdir /var/log/zabbix_server
mkdir /var/run/zabbix_server
2)把目录权限交给zabbix
chown zabbix:zabbix /var/log/zabbix_server -R
chown zabbix:zabbix /var/run/zabbix_server -R
3)日志切割
cat /etc/logrotate.d/zabbix_server
/var/log/zabbix_server/zabbix_server.log{
    daily
    rotate 7
    compress
    missingok
    notiempty
    create 0640 zabbix zabbix
    shardscripts
}

8、启动zabbix-server服务
1)/etc/init.d/zabbix-server start
Starting Zabbix server daemon: zabbix_server
2)查看zabbix_server启动日志
cat /var/log/zabbix_server/zabbix_server.log
 43736:20150529:095819.674 Starting Zabbix Server. Zabbix 2.2.9 (revision 52686).
 43736:20150529:095819.674 ****** Enabled features ******
 43736:20150529:095819.674 SNMP monitoring:           YES
 43736:20150529:095819.674 IPMI monitoring:           YES
 43736:20150529:095819.674 WEB monitoring:            YES
 43736:20150529:095819.675 VMware monitoring:         YES
 43736:20150529:095819.675 Jabber notifications:       NO
 43736:20150529:095819.675 Ez Texting notifications:  YES
 43736:20150529:095819.675 ODBC:                      YES
 43736:20150529:095819.675 SSH2 support:               NO
 43736:20150529:095819.675 IPv6 support:               NO
 43736:20150529:095819.675 ******************************
 43736:20150529:095819.675 using configuration file: /opt/zabbix/etc/zabbix_server.conf
 43736:20150529:095819.686 current database version (mandatory/optional): 02020000/02020001
 43736:20150529:095819.686 required mandatory version: 02020000
 43740:20150529:095819.721 server #2 started [db watchdog #1]
 43739:20150529:095819.722 server #1 started [configuration syncer #1]
 43742:20150529:095819.724 server #4 started [poller #2]
 43741:20150529:095819.735 server #3 started [poller #1]
 43743:20150529:095819.739 server #5 started [poller #3]
 43745:20150529:095819.743 server #7 started [poller #5]
 43744:20150529:095819.748 server #6 started [poller #4]
 43749:20150529:095819.756 server #8 started [unreachable poller #1]
 43752:20150529:095819.763 server #10 started [trapper #2]
 43751:20150529:095819.764 server #9 started [trapper #1]
 43755:20150529:095819.774 server #11 started [trapper #3]
 43756:20150529:095819.775 server #12 started [trapper #4]
 43757:20150529:095819.776 server #13 started [trapper #5]
 43761:20150529:095819.781 server #14 started [icmp pinger #1]
 43762:20150529:095819.782 server #15 started [alerter #1]
 43764:20150529:095819.786 server #16 started [housekeeper #1]
 43764:20150529:095819.786 executing housekeeper
 43766:20150529:095819.799 server #17 started [timer #1]
 43767:20150529:095819.801 server #18 started [http poller #1]
 43771:20150529:095819.815 server #20 started [history syncer #1]
 43774:20150529:095819.823 server #22 started [history syncer #3]
 43773:20150529:095819.825 server #21 started [history syncer #2]
 43770:20150529:095819.827 server #19 started [discoverer #1]
 43778:20150529:095819.837 server #23 started [history syncer #4]
 43764:20150529:095819.842 housekeeper [deleted 0 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 0.050062 sec, idle 1 hour(s)]
 43780:20150529:095819.845 server #24 started [escalator #1]
 43781:20150529:095819.846 server #25 started [proxy poller #1]
 43736:20150529:095819.849 server #0 started [main process]
 43783:20150529:095819.851 server #26 started [self-monitoring #1]
3)查看zabbix-server进程
 root@192.168.1.124:~# ps aux |grep zabbix
zabbix    43736  0.0  0.3 161016  3552 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server
zabbix    43739  0.0  0.2 161024  2628 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: configuration syncer [synced configuration in 0.001632 sec, idle 60 sec]
zabbix    43740  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: db watchdog [synced alerts config in 0.001054 sec, idle 60 sec]
zabbix    43741  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: poller #1 [got 0 values in 0.000002 sec, idle 5 sec]
zabbix    43742  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: poller #2 [got 0 values in 0.000003 sec, idle 5 sec]
zabbix    43743  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: poller #3 [got 0 values in 0.000004 sec, idle 5 sec]
zabbix    43744  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: poller #4 [got 0 values in 0.000002 sec, idle 5 sec]
zabbix    43745  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: poller #5 [got 0 values in 0.000003 sec, idle 5 sec]
zabbix    43749  0.0  0.3 162840  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000004 sec, idle 5 sec]
zabbix    43751  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection]
zabbix    43752  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection]
zabbix    43755  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection]
zabbix    43756  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection]
zabbix    43757  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection]
zabbix    43761  0.0  0.1 161340  2008 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000006 sec, idle 5 sec]
zabbix    43762  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.000148 sec, idle 30 sec]
zabbix    43764  0.0  0.2 161264  2256 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: housekeeper [deleted 0 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 0.050062 sec, idle 1 hour(s)]
zabbix    43766  0.0  0.2 161016  2248 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.000016 sec, 0 maintenances in 0.000663 sec, idle 30 sec]
zabbix    43767  0.0  0.2 161016  2244 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: http poller #1 [got 0 values in 0.000515 sec, idle 5 sec]
zabbix    43770  0.0  0.3 162516  3276 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000871 sec, idle 60 sec]
zabbix    43771  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000002 sec, idle 5 sec]
zabbix    43773  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000001 sec, idle 5 sec]
zabbix    43774  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000001 sec, idle 5 sec]
zabbix    43778  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000002 sec, idle 5 sec]
zabbix    43780  0.0  0.1 161016  1992 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: escalator [processed 0 escalations in 0.000148 sec, idle 3 sec]
zabbix    43781  0.0  0.1 161016  1996 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000003 sec, idle 5 sec]
zabbix    43783  0.0  0.1 161016  1772 ?        S    09:58   0:00 /usr/local/sbin/zabbix_server: self-monitoring [processed data in 0.000003 sec, idle 1 sec]
root      43791  0.0  0.0   7836   888 pts/1    S+   10:01   0:00 grep --color=auto zabbix
4)查看zabbix监听端口
netstat -tupnl |grep zabbix
tcp        0      0 192.168.1.124:10051     0.0.0.0:*               LISTEN      43736/zabbix_server

9、将zabbix-server加入到开机启动
1)使用update-rc.d命令
update-rc.d zabbix-server defaults
2)查看下是否在开机启动里了
runlevel
N 2
ll /etc/rc2.d/
lrwxrwxrwx 1 root root  23 May 29 10:17 S02zabbix-server -> ../init.d/zabbix-server

三、安装zabbix-web前端




四、安装zabbix-agent

本文出自 “7928217” 博客,请务必保留此出处http://7938217.blog.51cto.com/7928217/1659042

zabbix安装一(debian)

标签:zabbix

原文地址:http://7938217.blog.51cto.com/7928217/1659042

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!