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

Zabbix实战-简易教程(4)--Server端安装

时间:2017-09-10 01:08:56      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:脚本   nec   listen   chkconfig   read   alt   启动脚本   hup   setting   

 

zabbix server安装

在数据库安装完成后,接着开始安装server端了。

3.2.1 安装rpm源

Zabbix 2.2 for RHEL5, Oracle Linux 5, CentOS 5:
Zabbix 2.2 for RHEL6, Oracle Linux 6, CentOS 6:
 

3.2.2 安装mysql

 上面已经完成。

3.2.3 安装server

yum install zabbix-server-mysql zabbix-web-mysql zabbix-sender
yum install zabbix-agent

3.2.4 初始化数据库

Create zabbix database and user on MySQL.
# mysql -uroot
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by zabbix;
mysql> exit
Import initial schema and data.
# cd /usr/share/doc/zabbix-server-mysql-2.2.0/create
# mysql -uroot -p zabbix < schema.sql
# mysql -uroot -p zabbix < images.sql
# mysql -uroot -p zabbix < data.sql

3.2.5 配置文件修改

# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

Start Zabbix server process.

# service zabbix-server start

3.2.6 配置zabbix web前端

Apache configuration file for Zabbix frontend is located in /etc/httpd/conf.d/zabbix.conf. Some PHP settings are already configured.
 
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
date.timezone = Asia/Shanghai

3.2.7 安装nginx

nginx-1.6.2.tar.gz
openssl-1.0.1c.tar.gz
pcre-8.34.tar.gz
zlib-1.2.8.tar.gz

 

yum -y install openssl openssl-devel
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx  --with-http_stub_status_module  --with-http_ssl_module
可能会提示libpcre.so.1找不到
ln -s /usr/local/lib/libpcre.so.1 /lib64/
安装php-fpm
yum install php php-fpm
 

3.2.8 初始化web

chown -R nginx:nginx /usr/share/zabbix/
chown -R nginx:nginx /etc/zabbix/web/

 

 
# cat nginx.conf|grep -v "#"
user  nginx;
worker_processes  4;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        charset utf-8;
        access_log  /var/log/nginx/zabbix.access.log;
        error_log   /var/log/nginx/zabbix.error.log;
        location / {
             root   /usr/share/zabbix/;
             allow 你的IP;
             deny all;
             index  index.php index.html index.htm;
        }
       
        location ~ \.php$ {
            root           /usr/share/zabbix/;
             fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/share/zabbix$fastcgi_script_name;
            include        fastcgi_params;
        }
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
   }
   
}

 

设置nginx启动脚本
 
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig:   - 85 15
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse #               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /usr/local/nginx/conf/nginx.conf
# pidfile:     /usr/local/nginx/logs/nginx.pid
 
# Source function library.
. /etc/rc.d/init.d/functions
 
# Source networking configuration.
. /etc/sysconfig/network
 
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
 
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
 
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
 
lockfile=/var/lock/subsys/nginx
 
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
 
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
 
restart() {
    configtest || return $?
    stop
    start
}
 
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}
 
force_reload() {
    restart
}
 
configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}
 
rh_status() {
    status $prog
}
 
rh_status_q() {
    rh_status >/dev/null 2>&1
}
 
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac


3.2.9 Server端web配置
 技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

 


 

 

 

 

Zabbix实战-简易教程(4)--Server端安装

标签:脚本   nec   listen   chkconfig   read   alt   启动脚本   hup   setting   

原文地址:http://www.cnblogs.com/skyflask/p/7499913.html

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