========================================基于CentOS 6.5部署zabbix========================================
一、下载安装包
[root@young ~]# cd /home/root/tools/
[root@young tools]# wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.6/zabbix-2.2.6.tar.gz
wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.4.14/zabbix-3.4.14.tar.gz
//其他版本请在下面的网站下载二进制包
http://www.zabbix.com/download.php
二、解压并导入zabbix数据库
[root@young tools]# tar zxf zabbix-3.4.14.tar.gz
[root@young tools]# cd zabbix-3.4.14.tar.gz/database/mysql/
#进入数据库,并创建zabbix库
mysql> create database zabbix character set utf8;
#创建zabbix用户
mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by '123456' with grant option; mysql> flush privileges;
#导入数据库
mysql> use zabbix;
mysql> source schema.sql;
mysql> source images.sql;
mysql> source data.sql;
三、添加zabbix用户,安装依赖包
[root@young mysql]# useradd -s /sbin/nologin zabbix -M
[root@young mysql]# yum install net-snmp-devel curl curl-devel mysql-devel -y
四、安装zabbix
#创建软链接
[root@young zabbix-2.2.6]# ln -s /usr/local/libiconv/lib/libiconv.so.2 /usr/lib/libiconv.so.2 #是配置立即生效
[root@young zabbix-2.2.6]# /sbin/ldconfig
#配置
[root@young zabbix-2.2.6]# ./configure --prefix=/application/zabbix-2.2.6 --enable-server
--enable-agent --with-net-snmp --with-libcurl --enable-proxy --with-mysql
#编译安装
[root@young zabbix-2.2.6]# make
[root@young zabbix-2.2.6]# make install
#创建软链接
[root@young zabbix-2.2.6]# cd /application/
[root@young application]# ln -s zabbix-2.2.6 zabbix
#添加系统软链接
[root@young application]# cd zabbix
[root@young zabbix]# ln -s /application/zabbix/sbin/* /usr/local/sbin/
[root@young zabbix]# ln -s /application/zabbix/bin/* /usr/local/bin/
五、添加zabbix服务对应的端口
[root@young zabbix]# cat >> /etc/services << EOF
> zabbix-agent 10050/tcp # Zabbix Agent
> zabbix-agent 10050/udp # Zabbix Agent
> zabbix-trapper 10051/tcp # Zabbix Trapper
> zabbix-trapper 10051/udp # Zabbix Trapper
> EOF
六、修改zabbix配置文件
[root@young zabbix]# cd etc/
#备份配置文件
[root@young etc]# cp zabbix_server.conf zabbix_server.conf.default
[root@young etc]# cp zabbix_agent.conf zabbix_agent.conf.default
[root@Zabbix_server 15:21:42~]# grep '^[a-Z]' /application/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBHost=127.0.0.1 #数据库ip地址
DBName=zabbix #数据库用户名
DBUser=zabbix #数据库名称
DBPassword=123456 #数据库密码
DBPort=3306
StartPollers=5
StartTrappers=2
VMwareCacheSize=512M
ListenIP=0.0.0.0
HistoryCacheSize=16M
TrendCacheSize=8M
ValueCacheSize=8M
Timeout=30
Timeout=4
AlertScriptsPath=/application/zabbix/share/zabbix/alertscripts #zabbix运行脚本存放目录
LogSlowQueries=3000
[root@young etc]# vim zabbix_agent.conf Include=/application/zabbix/etc/zabbix_agentd.conf.d/ UnsafeUserParameters=1 #启用自定义key
七、添加开机启动脚本
#服务端
[root@young zabbix]# cp /home/root/tools/zabbix-2.2.6/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server
#客户端
[root@young zabbix]# cp /home/root/tools/zabbix-2.2.6/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd
[root@young zabbix]# chmod +x /etc/rc.d/init.d/zabbix_server [root@young zabbix]# chmod +x /etc/rc.d/init.d/zabbix_agentd
#添加开机自启动
[root@young zabbix]# chkconfig zabbix_server on [root@young zabbix]# chkconfig zabbix_agentd on
八、配置zabbix的网站
[root@young zabbix]# cp -r /home/root/tools/zabbix-2.2.6/frontends/php /application/nginx/html/zabbix
[root@young zabbix]# chown -R nginx.nginx /application/nginx/html/zabbix
#启动zabbix的服务端和客户端
[root@young zabbix]# service zabbix_server start
[root@young zabbix]# service zabbix_agentd start
九、修改php配置文件参数
[root@young zabbix]# vim /application/php/lib/php.ini post_max_size =16M
max_execution_time =300
max_input_time =300 date.timezone = Asia/Shanghai
[root@young zabbix]# vim /application/php/etc/php-fpm.conf request_terminate_timeout = 300
#配置nginx的nginx.conf文件
[root@Zabbix_server 15:44:14~]# cat /data/opt/nginx/conf/nginx.conf
user www www;
pid /data/opt/nginx/run/nginx.pid;
error_log /data/opt/nginx/logs/error.log crit;
worker_processes auto;
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
server_tokens off;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zone crawler $binary_remote_addr 10m;
server {
listen 80 default_server;
server_name _;
return 444;
}
include vhost/*.conf ;
}
[root@Zabbix_server 15:44:19~]# cat /data/opt/nginx/conf/vhost/zabbix.conf
server
{
listen 80;
server_name 192.168.11.54;
index index.html index.htm index.php;
root /data/opt/nginx/html;
location ~ .php$ {
#fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
access_log off;
}
十、安装zabbix的web
在浏览器上打开网址:172.16.10.10/zabbix/setup.php
点击"Next",出现php time zone检查错误,需要在php.ini里添加一条配置"date.timezone = Asia/Shanghai"
点击"Next",测试数据库连接
点击"Next",默认设置
点击"Next",确定安装
安装完成!
账号:admin
密码:123456
========================================基于CentOS 6.5部署zabbix-agent========================================
添加zabbix用户,安装依赖包
useradd -s /sbin/nologin zabbix -M
一、下载yum源
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/6/ x86_64/zabbix-agent-3.4.14-1.el6.x86_64.rpm
#linux client端安装
yum -y install zabbix-agent zabbix-get zabbix-sender
二、配置文件修改
#查找配置文件地址,并事先做好相关备份
cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bak
grep '^[a-Z]' /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
EnableRemoteCommands=1 来至zabbix服务器的远程命令是否允许被执行
Server=zabbix_server_IP zabbix服务器ip地址
ServerActive=zabbix_server_IP 主动向zabbix_server发送监控内容
Hostname=name name配置的内容要和zabbix服务器配置的Host name一致
UnsafeUserParameters=1 是否启用自定义key,zabbix监控mysql、tomcat等数据时需要自定义key
Include=/etc/zabbix/zabbix_agentd.d/*.conf
三、开机自启动
chkconfig zabbix-agent on
service zabbix-agent start