标签:
分布式监控系统Zabbix-3.0.3的安装记录
环境说明
zabbix-server:192.168.1.30 #zabbix的服务端(若要监控本机,则需要配置本机的Zabbix agent,下面会提到)
zabbix-agent:192.168.1.7 #zabbix的客户端(被监控端,需要配置Zabbix agent,下面会提到)
一、zabbix-server端的操作记录(192.168.1.30 )
zabbix服务器端要提前安装好LNMP环境(mysql,nginx,php5的安装目录均是/usr/local)
创建Zabbix运行的用户:
[root@Zabbix-server ~]# groupadd zabbix
[root@Zabbix-server ~]# useradd -g zabbix zabbix
安装libcurl和net-snmp:
[root@Zabbix-server ~]# yum install net-snmp-devel curl-devel
安装Fping:
[root@Zabbix-server ~]# cd /usr/local/src
[root@Zabbix-server src]# wget -c http://fping.org/dist/fping-3.4.tar.gz
[root@Zabbix-server src]# tar zxvf fping-3.4.tar.gz
[root@Zabbix-server src]# # cd fping-3.4
[root@Zabbix-server fping-3.4]# ./configure
[root@Zabbix-server fping-3.4]# make && make install
[root@Zabbix-server fping-3.4]# chown root:zabbix /usr/local/sbin/fping
[root@Zabbix-server fping-3.4]# chmod 4710 /usr/local/sbin/fping
安装Zabbix Server:
[root@Zabbix-server ~]# cd /usr/local/src
[root@Zabbix-server src]# wget -c http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz/download
[root@Zabbix-server src]# tar zxvf zabbix-3.0.3.tar.gz
[root@Zabbix-server src]# cd zabbix-3.0.3
[root@Zabbix-server zabbix-3.0.3]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl
[root@Zabbix-server zabbix-3.0.3]# make && make install
Zabbix Server配置与启动
创建Zabbix数据库和MySQL用户:
[root@Zabbix-server ~]# mysql -p
........
mysql> create schema zabbix character set utf8;
Query OK, 1 row affected (0.05 sec)
mysql> create user ‘zabbix‘@‘%‘ identified by ‘123456‘;
Query OK, 0 rows affected (0.16 sec)
mysql> grant all on zabbix.* to ‘zabbix‘@‘%‘;
Query OK, 0 rows affected (0.03 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)
导入Zabbix初始数据:
切换到zabbix的解压目录下,这里是/usr/local/src目录下
[root@Zabbix-server ~]# cd /usr/local/src
[root@Zabbix-server src]# cd zabbix-3.0.3
[root@Zabbix-server zabbix-3.0.3]#cd database/mysql/
[root@Zabbix-server mysql]# pwd
/usr/local/src/zabbix-3.0.3/database/mysql
[root@Zabbix-server mysql]# ls
data.sql images.sql schema.sql
[root@Zabbix-server mysql]# mysql -uroot - #登陆mysql,进行zabbix初始数据导入
mysql> set sql_log_bin=0;
mysql> source ./schema.sql;
mysql> source ./images.sql;
mysql> source ./data.sql;
mysql> set sql_log_bin=1;
编辑/usr/local/zabbix/etc/zabbix_server.conf:
[root@Zabbix-server ~]#vim /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/usr/local/zabbix/logs/zabbix_server.log
PidFile=/usr/local/zabbix/logs/zabbix_server.pid
DBHost=192.168.1.30
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=3306
FpingLocation=/usr/local/sbin/fping
从安装目录拷贝zabbix_server脚本,并编辑:
[root@Zabbix-server ~]# cd /usr/local/src
[root@Zabbix-server src]# cd zabbix-3.0.3
[root@Zabbix-server zabbix-3.0.3]# cp misc/init.d/fedora/core5/zabbix_server /etc/init.d/
[root@Zabbix-server zabbix-3.0.3]# mkdir -p /usr/local/zabbix/logs
[root@Zabbix-server zabbix-3.0.3]# chown -R zabbix:zabbix /usr/local/zabbix
[root@Zabbix-server zabbix-3.0.3]# vim /etc/init.d/zabbix_server
[root@Zabbix-server zabbix-3.0.3]# cat /etc/init.d/zabbix_server
...
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_server"
CONF_FILE="/usr/local/zabbix/etc/zabbix_server.conf"
...
start() {
...
daemon $ZABBIX_BIN -c $CONF_FILE
...
}
调整防火墙规则(开放端口10051):
[root@Zabbix-server ~]# vim /etc/sysconfig/iptables
...
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10051 -j ACCEPT
...
[root@Zabbix-server ~]# /etc/init.d/iptables restart
启动Zabbix Server:
[root@Zabbix-server ~]# service zabbix_server start #也可以直接/usr/local/zabbix/sbin/zabbix_server方式启动
Starting Zabbix Server: [ OK ]
停止Zabbix Server:
[root@Zabbix-server ~]# service zabbix_server stop
Stopping Zabbix Server: [ OK ]
配置开机自动启动:
[root@Zabbix-server ~]# chkconfig --add zabbix_server
[root@Zabbix-server ~]# chkconfig --level 35 zabbix_server on
Zabbix的Web前端
在安装目录将frontends拷贝到指定的web root:
[root@Zabbix-server ~]# mkdir -p /data/www/zabbix
[root@Zabbix-server ~]# cd /usr/local/src
[root@Zabbix-server src]# cd zabbix-3.0.3
[root@Zabbix-server zabbix-3.0.3]#cp -a frontends/php/* /data/www/zabbix/
[root@Zabbix-server zabbix-3.0.3]# chown -R www:www /data/www/zabbix
Nginx配置:
[root@Zabbix-server ~]# cat /usr/local/nginx/conf/nginx.conf
...
server {
listen 80;
server_name zabbix.zrwm.com;
error_log logs/zabbix_error.log;
access_log logs/zabbix_access.log;
root /data/www/zabbix;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
...
php.ini配置:
[root@Zabbix-server ~]# cat /usr/local/php5/etc/php.ini
...
memory_limit = 128M
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
session.auto_start = 0 ;必须为0
mbstring.func_overload = 2
...
注:PHP需要至少开启扩展:gd,bcmath,ctype,libXML,xmlreader,xmlwriter,session,sockets,mbstring,gettext,mysql
如下,查看是否包括了上面所提到的扩展模块
[root@Zabbix-server ~]# /usr/local/php5/bin/php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mcrypt
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib
[Zend Modules]
访问Web界面http://zabbix.zrwm.com,进行相关web配置,配置完成后使用默认用户admin(密码:zabbix)登陆即可.
二、zabbix客户端的操作记录(192.168.1.7)
安装Zabbix,配置Zabbix agent:
[root@bastion-IDC ~]# cd /usr/local/src/
[root@bastion-IDC src]# wget -c wget -c http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz/download
[root@bastion-IDC src]# cd zabbix-3.0.3
[root@bastion-IDC zabbix-3.0.3]# ./configure --prefix=/usr/local/zabbix --enable-agent
[root@bastion-IDC zabbix-3.0.3]# make && make install
[root@bastion-IDC zabbix-3.0.3]# cp misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/
配置zabbix_agentd:
[root@bastion-IDC ~]# groupadd zabbix
[root@bastion-IDC ~]# useradd -g zabbix zabbix
[root@bastion-IDC ~]# mkdir -p /usr/local/zabbix/logs
[root@bastion-IDC ~]# chown zabbix:zabbix -R /usr/local/zabbix/
[root@bastion-IDC ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf
[root@bastion-IDC ~]# cat /usr/local/zabbix/etc/zabbix_agentd.conf
...
PidFile=/usr/local/zabbix/logs/zabbix_agentd.pid
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Server=192.168.1.30
ListenPort=10050
ServerActive=192.168.1.30
Hostname=192.168.1.7
Timeout=15
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
...
配置Zabbix Agent启动脚本:
[root@bastion-IDC ~]# cat /etc/init.d/zabbix_agentd
...
prog="Zabbix Agent"
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"
CONF_FILE="/usr/local/zabbix/etc/zabbix_agentd.conf"
...
start() {
...
daemon $ZABBIX_BIN -c $CONF_FILE
...
}
...
开启防火墙端口10050:
[root@bastion-IDC ~]# cat /etc/sysconfig/iptables
...
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10050 -j ACCEPT
...
[root@bastion-IDC ~]# /etc/init.d/iptables restart
启动zabbix_agentd:
[root@bastion-IDC ~]# /etc/init.d/zabbix_agentd start
Starting Zabbix Agent: [ OK ]
配置开机自动启动:
[root@bastion-IDC ~]# chkconfig --add zabbix_agentd
[root@bastion-IDC ~]# chkconfig --level 35 zabbix_agentd on
测试下zabbix agent是否正常工作:
[root@bastion-IDC ~]# /usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf -t system.uptime
system.uptime [u|68301]
到此,zabbix3.0.3监控系统的基本环境安装完成~后续会更新zabbix监控项添加的操作记录,敬请期待~~
标签:
原文地址:http://www.cnblogs.com/kevingrace/p/5762147.html