Linux安装zabbix网络监控系统
一、LNMP环境的搭建
二、zabbix安装
1、安装zabbix所需的组件:
- # yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath
2、下载并解压源码包
- # wget http://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/1.8.2/zabbix-1.8.2.tar.gz
- # tar zxvf zabbix-1.8.2.tar.gz
3、数据库创建及导入
- # mysql -uroot -p
- mysql>create database zabbix;
- mysql>quit;
- # cd zabbix-1.8.2/create/schema/
- # cat mysql.sql | mysql -uroot -p****** zabbix
- # cd ../data/
- # cat data.sql | mysql -uroot -p****** zabbix
- # cat images_mysql.sql | mysql -uroot -p****** zabbix
4、开始编译、安装zabbix
- # cd zabbix-1.8.2
服务端编译:
- # ./configure --prefix=/usr/local/zabbix --enable-server --with-mysql --with-net-snmp --with-jabber --with-libcurl
注:如果在安装过程中报configure: error: Not found Jabber library,则:
- # wget http://iksemel.googlecode.com/files/iksemel-1.4.tar.gz
- # tar zxvf iksemel-1.4.tar.gz
- # cd iksemel-1.4
- # ./configure
- # make && make install然后再执行
- # ./configure --prefix=/usr/local/zabbix --enable-server --with-mysql --with-net-snmp --with-jabber=/usr/local --with-libcurl
客户端编译:
- # ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-jabber=/usr/local --with-libcurl
- # make && make install
5、添加系统中zabbix对应的服务与端口
- # vi /etc/services
添加以下内容:
- zabbix-agent 10050/tcp Zabbix Agent
- zabbix-agent 10050/udp Zabbix Agent
- zabbix-trapper 10051/tcp Zabbix Trapper
- zabbix-trapper 10051/udp Zabbix Trapper
6、复制并修改一些必需的文件
- # mkdir /etc/zabbix
- # cp zabbix-1.8.2/misc/conf/* /etc/zabbix
- # cp zabbix-1.8.2/frontends/php/* /var/www/zabbix //zabbix对应的Web目录,可根据需要设置
- # useradd zabbix -M -s /sbin/nologin //创建zabbix用户(zabbix组也会一起被创建)
- # chown zabbix:zabbix /var/www/zabbix
- # cd /var/www/zabbix/include
- # vi db.inc.php
将以下内容添加进db.inc.php和setup.inc.php:
- $DB_TYPE="MYSQL";
- $DB_SERVER="localhost";
- $DB_DATABASE="zabbix";
- $DB_USER="root";
- $DB_PWD="";
7、修改zabbix主程序的配置文件:
- /etc/zabbix/zabbix_server.conf
- StartPollers=6
- StartTrappers=5
- ListenPort=10051
- HousekeepingFrequency=1
- SenderFrequency=30
- DebugLevel=3
- Timeout=5
- UnreachablePeriod=45
- UnavailableDelay=15
- UnavailableDelay=60
- PidFile=/var/tmp/zabbix_server.pid
- LogFile=/var/log/zabbix_server.log
- PingerFrequency=30
- DBHost=localhost
- DBName=zabbix
- DBUser=root
- DBPassword=
- DBSocket=/var/lib/mysql/mysql.sock
- /etc/zabbix/zabbix_agent.conf
(详细配置略,只需将相关的参数设成自己实际参数即可,注意相关文件的真实路径。)
- /etc/zabbix/zabbix_agentd.conf
(详细配置略,只需将相关的参数设成自己实际参数即可,注意相关文件的真实路径。)
8、复制zabbix的启动程序
- # cp zabbix-1.8.2/misc/init.d/redhat/zabbix_* /etc/init.d/
9、修改启动程序文件内的具体参数
- # vi /etc/init.d/zabbix_server_ctl确保内容如下(注意程序正确的路径):# base zabbix dir
- BASEDIR=/usr/local/zabbix
- # PID file
- PIDFILE=/var/tmp/zabbix_server.pid
- # binary file
- ZABBIX_SUCKERD=$BASEDIR/sbin/zabbix_server
- # vi /etc/init.d/zabbix_agentd_ctl确保内容如下(注意程序正确的路径):# base zabbix dir
- BASEDIR=/usr/local/zabbix
- # pid file (as of 1.0 beta 10)
- PIDFILE=/var/tmp/zabbix_agentd.pid
- # binary file
- ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_agentd
10、启动zabbix
创建日志文件:
- # touch /var/log/zabbix_agentd.log
- # touch /var/log/zabbix_server.log
- # chown zabbix:zabbix zabbix_*[code][code]# cd /usr/local/zabbix/sbin
- # /etc/init.d/zabbix_server
- # /etc/init.d/zabbix_agentd如果在执行命令的时候出现:
- ./zabbix_server: error while loading shared libraries: libiksemel.so.3: cannot open shared object file: No such file or directory
则执行:
- # updatedb
- # locate libiksemel.so.3
- /usr/local/lib/libiksemel.so.3
- # ldd zabbix_server
- linux-gate.so.1 => (0x00b02000)
- libcurl.so.3 => /usr/lib/libcurl.so.3 (0x0075e000)
- libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00c0d000)
- libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00b78000)
- libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00c48000)
- libcom_err.so.2 => /lib/libcom_err.so.2 (0x009ee000)
- libresolv.so.2 => /lib/libresolv.so.2 (0x008c0000)
- libdl.so.2 => /lib/libdl.so.2 (0x005db000)
- libidn.so.11 => /usr/lib/libidn.so.11 (0x006b8000)
- libssl.so.6 => /lib/libssl.so.6 (0x00c70000)
- libcrypto.so.6 => /lib/libcrypto.so.6 (0x00110000)
- libnetsnmp.so.10 => /usr/lib/libnetsnmp.so.10 (0x00934000)
- libm.so.6 => /lib/libm.so.6 (0x005e1000)
- libwrap.so.0 => /usr/lib/libwrap.so.0 (0x00243000)
- libmysqlclient.so.16 => /usr/lib/libmysqlclient.so.16 (0x00cc6000)
- libiksemel.so.3 => not found
- libc.so.6 => /lib/libc.so.6 (0x00496000)
- libz.so.1 => /usr/lib/libz.so.1 (0x00685000)
- libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00c3d000)
- libkeyutils.so.1 => /lib/libkeyutils.so.1 (0x00b64000)
- /lib/ld-linux.so.2 (0x00473000)
- libnsl.so.1 => /lib/libnsl.so.1 (0x00745000)
- libpthread.so.0 => /lib/libpthread.so.0 (0x0060a000)
- libcrypt.so.1 => /lib/libcrypt.so.1 (0x0079f000)
- libselinux.so.1 => /lib/libselinux.so.1 (0x00623000)
- libsepol.so.1 => /lib/libsepol.so.1 (0x0063d000)
- # ln -s /usr/local/lib/libiksemel.so.3 /lib/ //在/lib创建一个软链接即可
【编辑推荐】