如何搭建zabbix server端
Posted 人生不设限
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何搭建zabbix server端相关的知识,希望对你有一定的参考价值。
1.背景介绍:
nginx:1.9.3 安装路径/data/nginx
php:5.5.27 安装路径 /data/php
mysql:5.6.28 安装路径/usr/local/mysql
zabbix server:3.2.8 安装路径 /data/zabbix
软件下载目录 /usr/local/src
2.nginx安装
# yum install pcre*
# yum install openssl*
# yum install openssl-devel
# cd /usr/local/src
# wget http://nginx.org/download/nginx-1.9.3.tar.gz
# tar -zxvf nginx-1.9.3.tar.gz
# cd nginx-1.9.3
# ./configure --prefix=/data/nginx \
--with-http_ssl_module --with-http_spdy_module \
--with-http_stub_status_module \
--with-pcre
# make && make install
# ln –s /data/nginx /usr/local/nginx
# mkdir /data/nginx/sites-enabled
# cd /data/nginx/conf
# vi nginx.conf #在http{}内,server前添加以下内容
include /usr/local/nginx/sites-enabled/*.conf;
# vi /data/nginx/conf/fcgi.conf
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
# cd /data/nginx/sites-enabled
# vi test.zabbix.com.conf
#for test.zabbix.com
log_format zabbix ‘$http_x_real_ip - $remote_user [$time_local] "$request" ‘
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent" $http_x_forwarded_for‘ ‘"$request_time"‘;
access_log /usr/local/nginx/logs/access_zabbix.log zabbix;
server
{
listen 80;
server_name test.zabbix.com;
if ($http_user_agent ~* "(Googlebot|Baiduspider|Sosospider)" ) {
return 403;
}
root /usr/local/zabbix/frontends;
index index.php;
location ~ "\.(js|ico|gif|jpg|png|css)$" {
expires 1w;
}
location / {
fastcgi_ignore_client_abort on;
fastcgi_pass unix:/dev/shm/php.socket;
fastcgi_index index.php;
include fcgi.conf;
index index.php;
if (!-e $request_filename) {
rewrite . /index.php last;
break;
}
}
}
# /data/nginx/sbin/nginx -t
# /data/nginx/sbin/nginx
# /data/nginx/sbin/nginx -s reload
# vi /etc/rc.local
# /data/nginx/sbin/nginx
3.php安装
# yum install gcc make gd-devel libjpeg-turbo-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel –y
# cd /etc/yum.repos.d/
# wget http://www.atomicorp.com/installers/atomic
# bash atomic
# yum install php-mcrypt -y
# yum install libmcrypt -y
# yum install libmcrypt-devel -y
# ./configure --prefix=/data/php \
--enable-fpm \
--with-fpm-user=daemon \
--with-fpm-group=daemon \
--with-config-file-path=/usr/local/php/etc \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-gd \
--with-zlib \
--with-libxml-dir \
--with-curl \
--with-mhash \
--with-xmlrpc \
--with-mcrypt \
--with-openssl \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-ftp \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap \
--disable-debug \
--disable-ipv6 \
--with-gettext \
--enable-calendar \
--enable-dom
# make && make install
# ln –s /data/php /usr/local/php
# vi /etc/profile
export PHP_HOME=/usr/local/php
export PATH=$PATH:$PHP_HOME/bin
# source /etc/profile
# cd /usr/local/src/php-5.5.27
# cp -rf sapi/fpm/php-fpm.conf /usr/local/php/etc/
# cp -rf sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# cp -rf php.ini-production /usr/local/php/etc/php.ini
# echo "/etc/init.d/php-fpm start">>/etc/rc.local
# cd /usr/local/php/etc
# echo ";error_log = /usr/local/php/var/log/php-fpm.log
;log_level = notice
;emergency_restart_threshold = 10
;emergency_restart_interval = 1m
;process_control_timeout = 5
;daemonize = yes
;listen.owner = daemon
;listen.group = daemon
;listen.mode = 0666
;pm = dynamic
;pm.max_children = 256
;pm.min_spare_servers = 128
;pm.max_spare_servers = 256
;pm.max_requests = 1024(*)
;request_terminate_timeout = 600s(*)
;request_slowlog_timeout = 300s
;rlimit_files = 65536
;rlimit_core = 65536">> php-fpm.conf
# vi php.ini
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone = PRC
# /etc/rc.d/init.d/php-fpm start
4.安装mysql(此步骤略去)
5.zabbix安装
zabbix 官网:https://www.zabbix.com/download
# cd /usr/local/src
# tar -zxvf zabbix-3.2.8.tar.gz
# cd zabbix-3.2.8
# ./configure --prefix=/data/zabbix/ \
--enable-server \ //开启server端,做zabbix server的机器编译时必须加入
--enable-agent \ //开启agent端,被监控的机器编译时必须加入,server端也应加入
--enable-proxy \ //开启proxy端,打算使用zabbix proxy功能的机器编译时必须加入
--with-mysql=/usr/local/mysql/bin/mysql_config \ //整合mysql。编译时报找不到mysql_config时,应当加入源码安装路径中的绝对路径
--with-net-snmp \ //整合邮件发送模块。编译时报找不到net-snmp-config时,应当加入绝对路径
--with-libcurl \ //整合curl模块
--with-libxml2 //整合libxml2模块
# make && make install
# yum install fping -y
# cd /usr/local/src/zabbix-3.2.8/database/mysql
mysql>create database zabbix default charset utf8;
mysql -uroot -p zabbix<schema.sql
mysql -uroot -p zabbix<images.sql
mysql -uroot -p zabbix<data.sql
mysql>grant all privileges on zabbix.* to [email protected] identified by ‘zabbix‘;
# cp /usr/local/src/zabbix-3.2.8/conf/zabbix_server.conf /data/zabbix/etc/
# mkdir -p /data/zabbix/log
# vim /data/zabbix/etc/zabbix_server.conf
ListenPort=10051
LogFile= /data/zabbix/log/zabbix_server.log
LogFileSize=1024
DebugLevel=3
PidFile= /data/zabbix/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/tmp/mysql.sock
DBPort=43306
StartPollers=10
StartPollersUnreachable=10
StartTrappers=10
StartPingers=5
ListenIP=0.0.0.0
HousekeepingFrequency=1
CacheSize=1024M
StartDBSyncers=10
HistoryCacheSize=1024M
TrendCacheSize=512M
ValueCacheSize=32M
Timeout=20
AlertScriptsPath= /data/zabbix/share/alertscripts
ExternalScripts= /data/zabbix/share/externalscripts
LogSlowQueries=3000
# mkdir /data/zabbix/frontends
# cp -r /usr/local/src/zabbix-3.2.8/frontends/php/* /data/zabbix/frontends/
# chown -R zabbix.zabbix /data/zabbix
# chown -R daemon.daemon /usr/local/nginx/
# /data/zabbix/sbin/zabbix_server
6.重启加载
# /etc/init.d/php-fpm stop
# /etc/init.d/php-fpm start
# /usr/local/nginx/sbin/nginx -s reload
7.访问
http://172.16.59.98/
以上是关于如何搭建zabbix server端的主要内容,如果未能解决你的问题,请参考以下文章