Zabbix安装 --源码安装

硬件需求

下表是几个硬件配置的示例:

名称

平台

CPU/内存

数据库

监控主机数量

小型

CentOS

虚拟应用

MySQL InnoDB

100

中型

CentOS

2 CPU cores/2GB

MySQL InnoDB

500

大型

RedHat Enterprise Linux

4 CPU cores/8GB

RAID10 MySQL InnoDB or PostgreSQL

>1000

巨大型

RedHat Enterprise Linux

8 CPU cores/16GB

快速RAID10 MySQL InnoDB or PostgreSQL

>10000

数据库管理系统

 

软件

版本

备注

MySQL

5.0.3或以上

使用MySQL作为Zabbix后端数据库。需要InnoDB引擎。

Oracle

10g或以上

使用Oracle作为Zabbix后端数据库。

PostgreSQL

8.1或以上

使用PostgreSQL作为Zabbix后端数据库。
建议使用PostgreSQL 8.3以上的版本。以 提供更好的VACUUM性能. 。

SQLite

3.3.5或以上

使用SQLite作为Zabbix后端数据库。

IBM DB2

9.7或以上

使用IBM DB2作为Zabbix后端数据库。

Zabbix前端需要使用下列软件:

软件

版本

备注

Apache

1.3.12或以上

 

PHP

5.4.0或以上

 

zabbix运行环境(LAMP),包括Linux,数据库mysql,前端容器apache和php

zabbix软件,包括server,proxy,agent

 

一.    LAMP环境安装

新建以下三个用户

www 用于运行apache

mysql用于运行Mysql

zabbix用于运行zabbix

 

[root@localhost etc]# groupadd www

[root@localhost etc]# useradd www -g www

[root@localhost etc]# groupadd mysql

[root@localhost etc]# useradd mysql -g mysql

[root@localhost etc]# groupadd www

[root@localhost etc]# useradd www -g www

[root@localhost etc]# groupadd zabbix

[root@localhost etc]# useradd zabbix -g zabbix

 

 

支持包安装

Apache安装需要

yum -y install pcre-devel

yum -y install zlib-devel

 

从apache网站上下载apr,apr-util,并解压复制到srclib目录中。

cp –rf   apr-1.6.3  apr

cp –rf   apr-util-1.5.4  apr-util

 

mysql安装需要

yum -y install autoconf

 

PHP安装需要

yum -y install libxml2-devel

yum -y install openssl-devel

yum -y install libjpeg-devel

yum -y install libpng-devel

yum -y install openldap-devel

yum -y install bzip2-devel

yum install freetype-devel (不要加-y)

 

zabbix安装需要

yum -y install net-snmp-devel

yum -y install libevent-devel

yum -y install curl-devel

yum install mysql-devel (不要加  -y )

Apache安装

  1. 上传介质 httpd-2.4.33.tar.gz
  2. 解压 [root@localhost softwares]# tar -xzvf httpd-2.4.33.tar.gz
  3. 编译安装

[root@localhost httpd-2.4.33]# ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support --disable-userdir

Make

Make install

apache安装过程中产生的错误

错误:

configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.

configure: error: Bundled APR-Util requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.

解决方法:

下载apr-1.6.3.tar.gz,apr-util-1.5.4.tar.gz

解压

[root@localhost softwares]# tar -xzvf apr-1.6.3.tar.gz

[root@localhost softwares]# tar -xzvf apr-util-1.5.4.tar.gz

复制

[root@localhost httpd-2.4.33]# cd srclib/

[root@localhost srclib]# cp -rf /tmp/softwares/apr-1.6.3 ./apr

[root@localhost srclib]# cp -rf /tmp/softwares/apr-util-1.5.4 apr-util

 

错误:

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

解决方法:

安装pcre,pcre-devel

[root@localhost httpd-2.4.33]# yum -y install pcre

[root@localhost httpd-2.4.33]# yum -y install pcre-devel

 

错误:

checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

解决方法:

 [root@localhost httpd-2.4.33]# yum -y install zlib

[root@localhost httpd-2.4.33]# yum -y install zlib-devel

 

 

错误:

xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory

 #include <expat.h>

                   ^

compilation terminated.

make[3]: *** [xml/apr_xml.lo] Error 1

make[3]: Leaving directory `/tmp/softwares/httpd-2.4.33/srclib/apr-util'

make[2]: *** [all-recursive] Error 1

make[2]: Leaving directory `/tmp/softwares/httpd-2.4.33/srclib/apr-util'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/tmp/softwares/httpd-2.4.33/srclib'

make: *** [all-recursive] Error 1

解决方法:

 [root@localhost httpd-2.4.33]# yum -y install expat-devel

 

错误:

/tmp/softwares/httpd-2.4.33/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_GetErrorCode'

/tmp/softwares/httpd-2.4.33/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler'

/tmp/softwares/httpd-2.4.33/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_ParserCreate'

/tmp/softwares/httpd-2.4.33/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler'

/tmp/softwares/httpd-2.4.33/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_ParserFree'

/tmp/softwares/httpd-2.4.33/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetUserData'

/tmp/softwares/httpd-2.4.33/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_StopParser'

/tmp/softwares/httpd-2.4.33/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_Parse'

/tmp/softwares/httpd-2.4.33/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_ErrorString'

/tmp/softwares/httpd-2.4.33/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetElementHandler'

collect2: error: ld returned 1 exit status

make[1]: *** [httpd] Error 1

make[1]: Leaving directory `/tmp/softwares/httpd-2.4.33'

make: *** [all-recursive] Error 1

解决方法:

降arp-util版本为1.5.4

[root@localhost srclib]# cp -rf /tmp/softwares/apr-util-1.5.4 ./apr-util

 

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message

 

Mysql安装

  1. 上传介质 mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
  2. 解压 tar –zxvf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
  3. 更名到/usr/local/mysql (配置文件中的默认路径)

mv mysql-5.6.40-linux-glibc2.12-x86_64 /usr/local/mysql

  1. 初始化数据库

cd /usr/local/mysql

mkdir /data/mysql ;

chown -R mysql:mysql /data/mysql

./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

  1. 配置文件

复制文件到/etc/目录

cp support-files/my-***.cnf  /etc/my.cnf

配置my.cnf

[client]

port = 3306

socket = /var/lib/mysql/mysql.sock

[mysql]

#这个配置段设置启动MySQL服务的条件;在这种情况下,no-auto-rehash确保这个服务启动得比较快。

no-auto-rehash

[mysqld]

user = mysql

port = 3306

socket = /var/lib/mysql/mysql.sock

basedir = /usr/local/mysql

datadir = /data/mysql/data

open_files_limit = 10240

  1. 配置自启动

cp support-files/mysql.server /etc/init.d/mysqld

chmod 755 /etc/init.d/mysqld

修改启动脚本中的参数datadir

vim /etc/init.d/mysqld

修改其中的参数datadir=/data/mysql(前面初始化数据库时定义的目录)

加入系统服务项,并设定开机启动,启动mysql

chkconfig --add mysqld

chkconfig mysqld on

service mysqld start

 

Mysql安装过程中产生的错误

错误:

[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:

Data::Dumper

解决方法:

yum -y  install autoconf

错误:

ERROR! The server quit without updating PID file (/data/mysql/ZABBIXT03.pid).

解决方法:

chmod 755 /etc/init.d/mysqld

PHP安装

  1. 上传介质 php-7.2.5.tar.gz
  2. 解压 tar –zxcv php-7.2.5.tar.gz
  3. 复制ldap包  cp -frp /usr/lib64/libldap* /usr/lib/
  4. 编译   cd php-7.2.5

./configure --prefix=/usr/local/php  --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --enable-soap --enable-ftp --enable-mbstring --enable-sockets --enable-exif --disable-ipv6 --enable-bcmath --with-gettext --with-ldap

  1. 安装

make&&make install

  1. php配置文件

mkdir /usr/local/php/etc

cp php.ini-dist /usr/local/php/etc/php.ini

 

PHP安装过程中产生的错误

错误:

configure: error: libxml2 not found. Please check your libxml2 installation.

解决方法:

yum -y install libxml2

yum -y install libxml2-devel

错误:

configure: error: Cannot find OpenSSL's <evp.h>

解决方法:

yum -y install openssl

yum -y install openssl-devel

错误:

configure: error: Please reinstall the BZip2 distribution

解决方法:

yum -y install bzip2-devel

错误:

configure: error: jpeglib.h not found.

解决方法:

yum -y install libjpeg-devel

错误:

configure: error: png.h not found.

解决方法:

yum install libpng

yum -y install libpng-devel

 

configure: error: freetype-config not found.

yum install freetype-devel

 

错误:

configure: error: Cannot find ldap.h

解决方法:

yum -y install openldap

yum -y install openldap-devel

错误:

configure: error: Cannot find ldap libraries in /usr/lib.

解决方法:

cp -frp /usr/lib64/libldap* /usr/lib/

错误:

make 过程中的问题

/usr/bin/ld: ext/ldap/.libs/ldap.o: undefined reference to symbol 'ber_scanf'

/usr/bin/ld: note: 'ber_scanf' is defined in DSO /lib64/liblber-2.4.so.2 so try adding it to the linker command line

/lib64/liblber-2.4.so.2: could not read symbols: Invalid operation

collect2: error: ld returned 1 exit status

make: *** [sapi/cli/php] Error 1

解决方法:

-Run your configure command
-edit Makefile
-Find the line that starts with "EXTRA_LIBS ="
-Add the following to the end of the line " -llber"

apache结合php

  1. 在apache中打开php配置,配置文件为httpd.conf

vim /usr/local/apache2/conf/httpd.conf

在AddType application XXXX最后一行添加如下配置

AddType application/x-httpd-php .php

在dir_module 中增加 index.php

<IfModule dir_module>

    DirectoryIndex index.html index.php

</IfModule>

  1. 已经选项为apache性能配置项,去掉以下行的#

#Include conf/extra/httpd-mpm.conf

#Include conf/extra/httpd-info.conf

#Include conf/extra/httpd-vhosts.conf

#Include conf/extra/httpd-default.conf

 

配置apache的进程管理以及虚拟主机

配置Apache进程管理

配置文件为:/usr/local/apache2/conf/extra/httpd-mpm.conf

 

将配置文件中下面一段修改为如下:

 

<IfModule mpm_prefork_module>

    ServerLimit          2048    新添加

    StartServers          5

    MinSpareServers      5

    MaxSpareServers      10

    MaxClients           1024 默认最大为256,设置为超过256必须增加有ServerLimit

    MaxRequestsPerChild   0

</IfModule>

说明:

配置Apache缺省httpd设置

配置文件为:/usr/local/apache2/conf/extra/httpd-default.conf

将配置文件中下面一段:

将KeepAlive On 改为KeepAlive Off

 

  1. 配置Apache的访问权限

vim /usr/local/apache2/conf/httpd.conf

修改成如下

<Directory />

    AllowOverride none

    Require all granted

</Directory>改成:

  1. 配置Apache的运行账户

vim /usr/local/apache2/conf/httpd.conf

修改成如下

User www Group www

配置完上述内容之后,启动Apache:

/usr/local/apache2/bin/apachectl start

【测试LAMP是否成功】

在/usr/local/apache2/htdocs 目录中添加如下文件index.php

vim /usr/local/apache2/htdocs /index.php

写入:

<?php

phpinfo();

?>

保存后,然后在浏览器中输入 http://你配置的域名/index.php 看是否能看到php的相关配置信息。

 

二. Zabbix安装

从源代码安装

1.   上传介质zabbix-3.4.2.tar.gz

2.   解压tar –zxvf zabbix-3.4.2.tar.gz

3.   编译安装

cd zabbix-3.4.2.

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

安装 server,agent 如需要安装proxy 加参数 --enable-proxy 

--with-net-snmp  用于snmp 监控,如交换机,物理机监控

 --with-libcurl --with-libxml2  虚拟机监控

--with-openipmi 用于IPMI 监控,如物理机监控

(使用zabbix用户安装,需要先在/usr/local下新建zabbix并chown给zabbix用户。)

Make install

4.   数据库创建

shell> mysql -uroot -p<password>

mysql> create database zabbix character set utf8 collate utf8_bin;

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';

mysql> quit;

shell> cd database/mysql

shell> mysql -uzabbix -p<password> zabbix < schema.sql

# stop here if you are creating database for Zabbix proxy

shell> mysql -uzabbix -p<password> zabbix < images.sql

shell> mysql -uzabbix -p<password> zabbix < data.sql

5.   安装前端web

在/usr/local/apache2/htdocs 目录中新建zabbix

mkdir /usr/local/apache2/htdocs/zabbix

cd  zbbix-3.4.2/frontends/php

cp -a . /usr/local/apache2/htdocs/zabbix

 

访问//<server_ip_or_name>/zabbix

 

调整参数

根据zabbix要求调整php参数,参数文件/usr/local/php/etc/php.ini

 

 

 

Vim /usr/local/php/etc/php.ini

修改

post_max_size

max_execution_time

max_input_time

 

date.timezone = Asia/Shanghai

配置文件

cp  zabbix.conf.php  /usr/local/apache2/htdocs/zabbix/conf/zabbix.conf.php

vi /usr/local/apache2/htdocs/zabbix/conf/zabbix.conf.php

global $DB;

$DB['TYPE']        = 'MYSQL';

$DB['SERVER']     = '10.1.49.130';

$DB['PORT']        = '0';

$DB['DATABASE']   = 'zabbix';

$DB['USER']        = 'zabbix';

$DB['PASSWORD']  = 'zabbix123';

 

// Schema name. Used for IBM DB2 and PostgreSQL.

$DB['SCHEMA'] = '';

 

$ZBX_SERVER      = '10.1.49.131';

$ZBX_SERVER_PORT = '10051';

$ZBX_SERVER_NAME = 'zabbix server';

Zabbix安装过程中产生的错误

错误:

configure: error: MySQL library not found

解决方法:

yum install mysql-devel

 

错误:

configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

解决方法:

yum install -y net-snmp

yum install -y net-snmp-devel

 

错误:

configure: error: Unable to use libevent (libevent check failed)

解决方法:

yum -y install libevent-devel

 

错误:

configure: error: Curl library not found

解决方法:

yum -y install curl

yum -y install curl-devel

错误:

zabbix  Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

解决方法:

有两个方法

  1. 修改/etc/my.cnf 配置的mysql sock位置改成/tmp/mysql.sock,

 [mysql
  socket=/tmp/mysql.sock

  1. 做连接

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock;

 

转载于:https://www.cnblogs.com/omg8684/p/9633328.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装 Zabbix Proxy 需要以下步骤: 1. 安装 Zabbix Proxy 的依赖包: ``` sudo apt-get install fping libcurl4-openssl-dev libiksemel-dev libxml2-dev libsnmp-dev python-dev ``` 2. 下载 Zabbix Proxy 的源码包: ``` wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.1.tar.gz ``` 3. 解压源码包: ``` tar -zxvf zabbix-5.0.1.tar.gz ``` 4. 进入解压后的目录: ``` cd zabbix-5.0.1 ``` 5. 编译并安装 Zabbix Proxy: ``` ./configure --enable-proxy --prefix=/usr/local/zabbix-proxy make install ``` 6. 创建 Zabbix Proxy 的日志文件和运行用户: ``` sudo mkdir /var/log/zabbix-proxy sudo chown zabbix:zabbix /var/log/zabbix-proxy sudo useradd -r -s /usr/sbin/nologin zabbix ``` 7. 配置 Zabbix Proxy: 编辑 `/usr/local/zabbix-proxy/etc/zabbix_proxy.conf` 文件: ``` Server=<Zabbix Server IP> Hostname=<Hostname of Zabbix Proxy> LogFile=/var/log/zabbix-proxy/zabbix_proxy.log LogFileSize=0 PidFile=/var/run/zabbix/zabbix_proxy.pid DBName=<Zabbix database name> DBUser=<Zabbix database username> DBPassword=<Zabbix database password> DBHost=<Zabbix database host> DBPort=<Zabbix database port> ProxyMode=0 ProxyLocalBuffer=0 HeartbeatFrequency=60 ConfigFrequency=3600 DataSenderFrequency=1 StartPollers=5 ``` 注意:将 `<Zabbix Server IP>`、`<Hostname of Zabbix Proxy>`、`<Zabbix database name>`、`<Zabbix database username>`、`<Zabbix database password>`、`<Zabbix database host>`、`<Zabbix database port>` 替换为你自己的配置。 8. 启动 Zabbix Proxy: ``` sudo /usr/local/zabbix-proxy/sbin/zabbix_proxy -c /usr/local/zabbix-proxy/etc/zabbix_proxy.conf ``` 9. 设置 Zabbix Proxy 开机自启动: 编辑 `/etc/systemd/system/zabbix-proxy.service` 文件: ``` [Unit] Description=Zabbix Proxy After=syslog.target network.target [Service] User=zabbix Group=zabbix ExecStart=/usr/local/zabbix-proxy/sbin/zabbix_proxy -c /usr/local/zabbix-proxy/etc/zabbix_proxy.conf Restart=on-failure [Install] WantedBy=multi-user.target ``` 保存并退出。 10. 重新加载 systemd 配置,并启动 Zabbix Proxy 服务: ``` sudo systemctl daemon-reload sudo systemctl start zabbix-proxy sudo systemctl enable zabbix-proxy ``` 现在你已经成功安装Zabbix Proxy,并启动了服务,可以使用 Zabbix Server 进行监控了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值