zabbix3 0 源码安装server端详细过程

news/2024/7/1 18:18:55
               

安装文档地址:https://www.zabbix.com/documentation/3.0/

下载地址:http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/

 

-->背景rpm安装

上次,从rpm安装到放弃http://blog.csdn.net/mchdba/article/details/51226751 ,事后仔细想了下,虽然rpm安装不成功,但是还有别的办法可以一试,比如resource,所以准备下载tar.gz准备源码安装。


对zabbix的安装做个大概的简介,zabbix安装需要安装以下4个重要的模块

(1)zabbix_server,zabbix服务器端,提供基础服务监控

(2)zabbix_agentd,zabbix客户端,为被监控的服务器与zabbix_server保持监控联系状态

(3)php,zabbix管理工程组件,zabbix-web是php工程

(4)nginx,通过nginx来控制访问zabbix-web工程界面

(5)mysql,存储zabbix监控数据和基础信息


1,关闭selinux

[root@hch_test_121_12 zabbix-server-mysql-3.0.1]#  setenforce 0                                                                                                                                               

 

setenforce: SELinux is disabled

 

[root@hch_test_121_12  zabbix-server-mysql-3.0.1]# getenforce

 

Disabled

 

[root@hch_test_121_12  zabbix-server-mysql-3.0.1]#

 

 

2,准备安装nginx

# 为了支持rewrite功能,我们需要安装pcre                                                                                                                                                                                             

 

yum install -y pcre* 

 

# 需要ssl的支持,如果不需要ssl支持,请跳过这一步  

 

yum install -y openssl*

 

# 安装nginx:

 

tar -xvf nginx-1.8.1.tar.gz

 

cd nginx-1.8.1

 

./configure  --prefix=/usr/local/nginx-1.8.1 --with-http_ssl_module  --with-http_spdy_module --with-http_stub_status_module --with-pcre

 

 

 

#--with-http_stub_status_module:支持nginx状态查询

 

#--with-http_ssl_module:支持https

 

#--with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持

 

#--with-pcre:为了支持rewrite重写功能,必须制定pcre

 

 

 

cd /usr/local/

 

ln -s nginx-1.8.1 nginx

 

/usr/local/nginx/sbin/nginx

 

 

 

3,安装php

Php5.6.20下载地址:

http://php.net/get/php-5.6.20.tar.gz/from/a/mirror                                                                                                                                                                                             

        

 原blog地址:http://blog.csdn.net/mchdba/article/details/51263871,谢绝转载。

 

开始源码安装php:

# 准备依赖的组件包

 

yum install gcc make gd-devel  libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y

 

# 安装命令

 

tar -xvf php-5.6.20.tar.bz2

 

cd php-5.6.20

 

./configure   --prefix=/usr/local/php-5.6.20  --with-config-file-path=/usr/local/php-5.6.20/etc --with-bz2 --with-curl  --enable-ftp --enable-sockets --disable-ipv6 --with-gd  --with-jpeg-dir=/usr/local --with-png-dir=/usr/local  --with-freetype-dir=/usr/local --enable-gd-native-ttf  --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar  --with-gettext --with-libxml-dir=/usr/local --with-zlib  --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd  --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath

 

make

 

make install

 

 

 

cd /usr/local

 

ln -s php-5.6.20 php

 

cp /soft/php-5.6.20/php.ini-production  /usr/local/php/etc/php.ini

 

cp /soft/php-5.6.20/sapi/fpm/php-fpm.conf  /usr/local/php/etc/php-fpm.conf

 

ln -s /usr/local/php/sbin/* /usr/sbin/

 

 

 

# 启动php-fpm

 

php-fpm

 

[root@hch_test_121_12 local]# php-fpm

 

[root@hch_test_121_12 local]#

 

 

 

# check下是否启动成功

 

[root@hch_test_121_12 local]# netstat  -ntpl|grep 9000

 

tcp         0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      527/php-fpm         

 

[root@hch_test_121_12 local]#

 

配置php.ini参数, vim /usr/local/php/etc/php.ini:

 

                                                                                                                                                                                                                                         
    

Pre-requisite

Minimum value

Description

PHP version

5.4.0

PHP memory_limit option

128MB

In php.ini:  memory_limit    = 128M

PHP post_max_size option

16MB

In php.ini:  post_max_size    = 16M

PHP upload_max_filesize option

2MB

In php.ini:
    upload_max_filesize = 2M

PHP max_execution_time option

300 seconds (values 0 and -1 are allowed)

In php.ini:
    max_execution_time = 300

PHP max_input_time option

300 seconds (values 0 and -1 are allowed)

In php.ini:
    max_input_time = 300

PHP session.auto_start option

must be disabled

In php.ini:
    session.auto_start = 0

Database support

One of: IBM DB2, MySQL, Oracle, PostgreSQL, SQLite

One of the following modules must be installed:
    ibm_db2, mysql, oci8, pgsql, sqlite3

bcmath

php-bcmath

mbstring

php-mbstring

PHP mbstring.func_overload option

must be disabled

In php.ini:
    mbstring.func_overload = 0

PHP always_populate_raw_post_data    option

must be disabled

Required only for PHP versions 5.6.0 or newer.
    In php.ini:
    always_populate_raw_post_data = -1

sockets

php-net-socket. Required for user script support.

gd

2.0 or higher

php-gd. PHP GD extension must support PNG images (--with-png-dir), JPEG (--with-jpeg-dir) images and    FreeType 2 (--with-freetype-dir).

libxml

2.6.15

php-xml or php5-dom

xmlwriter

php-xmlwriter

xmlreader

php-xmlreader

ctype

php-ctype

session

php-session

gettext

php-gettext
    Since Zabbix 2.2.1, the PHP gettext extension is not a mandatory requirement    for installing Zabbix. If gettext is not installed, the frontend will work    as usual, however, the translations will not be available.

 

 

4,配置nginx

修改nginx配置文件/usr/local/nginx/conf/nginx.conf:

server {

 

         listen  80;

 

          server_name   ys.zabbix.com;

 

         access_log  /usr/local/nginx/logs/zabbix.access.log;                                                                                                                                                                      

 

          

 

         index  index.php index.html index.html;

 

         root  /usr/local/nginx/html/zabbix;

 

          

 

         location  /

 

         {

 

                   try_files  $uri $uri/ /index.php?$args;

 

         }

 

          

 

         location  ~ .*\.(php)?$

 

         {

 

                   expires  -1s;

 

                   try_files  $uri =404;

 

                   fastcgi_split_path_info  ^(.+\.php)(/.+)$;

 

                   include  fastcgi_params;

 

                   fastcgi_param  PATH_INFO $fastcgi_path_info;

 

                   fastcgi_index  index.php;

 

                   fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

 

                   fastcgi_pass  127.0.0.1:9000;

 

          

 

         }

 

}

 

如果没有启用dns域名系统的话,可以在/etc/hosts加下ip地址和域名的配置:

# vim /etc/hosts

 

192.168.121.12 ys.zabbix.com                                                                                                                                                                                                                    

 

# 启动nginx服务

 

/usr/local/nginx/sbin/nginx

 

添加测试的info.php,在nginx的html目录:

mkdir -p /usr/local/nginx/html/zabbix

 

vim /usr/local/nginx/html/zabbix/info.php                                                                                                                                                                                                    

 

# info.php录入以下内容

 

<?php

 

phpinfo();

 

?>

 

 

nginx将会连接回环地址9000端口执行PHP文件,需要使用tcp/ip协议,速度比较慢.建议大家换成使用socket方式连接。将fastcgi_pass127.0.0.1:9000;改成fastcgi_passunix:/var/run/phpfpm.sock;

 

检测php+nginx是否配置成功,在浏览器打开网址:ys.zabbix.com/info.php或者http://192.168.121.12/info.php,如下所示D:\study\zabbix\2.png:

 

 

5,开始安装zabbix

注明php要5.4以上,curl需要7.20以上,下载地址是:

tar zxvf zabbix-3.0.2.tar.gz

 

cd zabbix-3.0.2

 

./configure --prefix=/usr/local/zabbix  --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp  --with-libcurl --with-libxml2

 

make

 

make install

 

 

6,准备mysql数据库

安装mysql数据库:

http://blog.csdn.net/mchdba/article/details/51138063

 

创建zabbix的数据库:

mysql> create database zabbix charset  set utf8;

 

Query OK, 1 row affected (0.00 sec)

 

 

 

mysql> grant all privileges on  zabbix.* to zabbix@'10.%' identified by 'zabbix0418';                                                                                                      

 

Query OK, 0 rows affected (0.00 sec)

 

 

 

mysql> grant all privileges on  zabbix.* to zabbix@'192.%' identified by 'zabbix0418';

 

Query OK, 0 rows affected (0.01 sec)

 

 

 

mysql>

 

PS:字符集要设置为utf8mb4,防止界面切换到中文的时候乱码。

 

导入create.sql.gz文件,建立zabbix-server的数据库(ps,以前的版本可能叫啥schema.sql之类的):

mysql> source “/data/create.sql”;                                                                                                                                                                                               

 

 

7,开始配置zabbix数据库

编辑数据库配置文件,一般默认在/etc/zabbix/目录下:

 

# vim /etc/zabbix/zabbix_server.conf                                                                                                                                                                                        

 

DBHost=192.168.121.61

 

DBName=zabbix

 

DBUser=zabbix

 

DBPassword=zabbix0418

 

DBPort=3307

 

DBSocket=/usr/local/mysql/mysql.sock

 

 

8,启动zabbix

# 启动:

 

/usr/local/zabbix/sbin/zabbix_server -c  /etc/zabbix/zabbix_server.conf

 

查看后台进程:

 

[root@hch_test_121_12 zabbix-3.0.2]# ps  -eaf|grep zabbix_server

 

zabbix    28130     1  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf

 

zabbix    28131 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: configuration syncer [waiting 60 sec  for processes]

 

zabbix    28132 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: db watchdog [synced alerts config in  0.003818 sec, idle 60 sec]

 

zabbix    28133 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: poller #1 [got 0 values in 0.000006  sec, idle 5 sec]

 

zabbix    28134 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: poller #2 [got 0 values in 0.000005  sec, idle 5 sec]

 

zabbix    28135 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: poller #3 [got 0 values in 0.000005  sec, idle 5 sec]

 

zabbix    28136 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: poller #4 [got 0 values in 0.000005  sec, idle 5 sec]

 

zabbix    28137 28130  0 17:46 ?        00:00:00 /usr/local/zabbix/sbin/zabbix_server:  poller #5 [got 0 values in 0.000006 sec, idle 5 sec]

 

zabbix    28138 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: unreachable poller #1 [got 0 values in  0.000006 sec, idle 5 sec]

 

zabbix    28139 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: trapper #1 [processed data in 0.000000  sec, waiting for connection]

 

zabbix    28140 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: trapper #2 [processed data in 0.000000  sec, waiting for connection]

 

zabbix    28141 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: trapper #3 [processed data in 0.000000  sec, waiting for connection]

 

zabbix    28142 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: trapper #4 [processed data in 0.000000  sec, waiting for connection]

 

zabbix    28144 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: trapper #5 [processed data in 0.000000  sec, waiting for connection]

 

zabbix    28145 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: icmp pinger #1 [got 0 values in  0.000007 sec, idle 5 sec]

 

zabbix    28147 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail  in 0.001611 sec, idle 30 sec]

 

zabbix    28148 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: housekeeper [startup idle for 30  minutes]

 

zabbix    28149 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: timer #1 [processed 0 triggers, 0  events in 0.000000 sec, 0 maintenances in 0.000000 sec, idle 9 sec]

 

zabbix    28150 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: http poller #1 [got 0 values in  0.001078 sec, idle 5 sec]

 

zabbix    28151 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: discoverer #1 [processed 0 rules in  0.000791 sec, idle 60 sec]

 

zabbix    28153 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: history syncer #1 [synced 0 items in  0.000001 sec, idle 1 sec]

 

zabbix    28154 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: history syncer #2 [synced 0 items in  0.000001 sec, idle 1 sec]

 

zabbix    28155 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: history syncer #3 [synced 0 items in  0.000001 sec, idle 1 sec]

 

zabbix    28157 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: history syncer #4 [synced 0 items in  0.000001 sec, idle 1 sec]

 

zabbix    28159 28130  0 17:46 ?        00:00:00 /usr/local/zabbix/sbin/zabbix_server:  escalator #1 [processed 0 escalations in 0.000517 sec, idle 3 sec]

 

zabbix    28160 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: proxy poller #1 [exchanged data with 0  proxies in 0.000004 sec, idle 5 sec]

 

zabbix    28162 28130  0 17:46 ?        00:00:00  /usr/local/zabbix/sbin/zabbix_server: self-monitoring [processed data in  0.000005 sec, idle 1 sec]

 

root      28178 18398  0 17:46 pts/2    00:00:00 grep zabbix_server

 

[root@hch_test_121_12 zabbix-3.0.2]#

 

 

9,Zabbix管理网站配置

先找zabbix的管理网站应用,默认是在源码解压缩下面的frontends/php/目录,然后copy到/usr/local/nginx/html/zabbix:

# 如果不记得源码安装目录,可以通过find / -name frontends全盘检索找到                                                                                                                                                                     

 

unalias cp

 

cp   -r -f /soft/zabbix-3.0.2/frontends/php/* /usr/local/nginx/html/zabbix/

 

单独为zabbix配置php.ini:

# vim /usr/local/php/etc/php.ini                                                                                                                                                                                                                                                  

 

max_execution_time = 300

 

memory_limit = 128M

 

post_max_size = 16M

 

upload_max_filesize = 2M

 

max_input_time = 300

 

date.timezone = PRC

 

 

然后打开网址,http://ys.zabbix.com,出现如下界面D:\study\zabbix\3.png

 

 

 

 

10,Zabbix管理界面打开失败

zabbix编译报错信息:

checking for main in -lnetsnmp... yes

 

checking for localname in struct  snmp_session... yes                                                                                                                                                                                                                 

 

checking for gawk... (cached) gawk

 

checking for curl-config... no

 

configure: error: Curl library not found

 

 

 

# 需要安装curl组件,而且需要在7.20版本以上:

 

yum install -y libcurl*

 

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow


http://www.niftyadmin.cn/n/3653824.html

相关文章

delphi for php 支持中文的方法

其实很简单的。。在Tool->Options中点击Editor Options&#xff0c;把use utf-8 to create new units and forms的勾去掉。然后再点击PHP&#xff0c;把default charset设为gb2312&#xff0c;再勾上set these values on php.ini。点击ok好了&#xff0c;现在放心的使用中文…

MySQL DBA 面试题目小结

总结了招聘MySQL DBA的第一轮基础面试题目&#xff0c;欢迎大家补充&#xff1a;1&#xff0c; mysql的复制原理以及流程。&#xff08;1&#xff09;先问基本原理流程&#xff0c;3个线程以及之间的关联。&#xff08;2&#xff09;再问一致性延时性&#xff0c;数据恢复。&am…

动态语言崛起 Delphi For PHP能否挽救Borland?

年年岁岁花相似&#xff0c;岁岁年年人不同。IT领域几乎每年都会有新的东西诞生。但每次又会给人们以不同的惊喜。这不&#xff0c;在刚刚过去了2006年&#xff0c;IBM和微软也先后推出了自己的新产品&#xff1a;Viper(DB2 9)和Vista。 然而&#xff0c;在2006年因为要卖掉自己…

MySQL5 7 利用keepalived来实现mysql双主高可用方案的详细过程

服务器准备Keepalived:192.168.13.15Keepalived:192.168.13.16Mysql-m1: 192.168.13.15Mysql-m2: 192.168.13.161&#xff0c;在m1、m2上准备mysql5.7环境在两台服务器上安装mysql5.7&#xff0c;安装mysql参考如下&#xff1a;http://blog.csdn.net/mchdba/article/details/51…

@Interceptor 铪铪铪铪铪铪铪

EJB3 為了可以支援 AOP ( swanky : AOP Presentation - http://www.ice.ntnu.edu.tw/~swanky/presentation/PL_AOP.pdf ) 所以建立了Interceptors 的觀念.不過, 雖然是放在 ejb3 api 的製作之中, 但是他的 package 為 javax.interceptor.*, 換句話說, 未來有機會可能會移出 ejb…

@Interceptors and inv.proceed()铪铪

寫了一個小程式測試了一下, Interceptors 他的流程StatelessInterceptors({AuditInterceptor.class, SecurityInterceptor.class})public class AuditInterceptor {AroundInvoke public Object auditOperation(InvocationContext inv) throws Exception {try {System.out.print…

PLSQL 经常自动断开失去连接的解决过程

问题背景&#xff1a;情况是这样的&#xff0c;很多开发同事的plsql上班时间开着8个小时&#xff0c;有时候他们出去抽烟后或者中午吃完饭&#xff0c;回来在plsql上面执行就报错无响应&#xff0c;然后卡住了半天动弹不了&#xff0c;非得重新登录plsql才生效&#xff0c;我猜…

JasperForge 正式開張

搞 Java Web solution 的, 在需要用到 Report Engine 的時候, 通常會先想.. 我能不能使用 jasperReport 作為我的 ReportEngine, 利用 iReport 當作我的 template Report Designer. 很高興的, JasperSoft 將這些都整合起來放到了 JasperForge, 更提出了一個新的 BI 專案, Jaspe…