欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

centos7.5 源码安装zabbix3.4

程序员文章站 2022-03-18 19:21:39
...

官方中文手册:https://www.zabbix.com/documentation/3.4/zh/manual

安装要求

支持的数据库
centos7.5 源码安装zabbix3.4
前端软件
centos7.5 源码安装zabbix3.4
我这里使用的是LNMP环境,环境的搭建可自行百度,给出我的PHP配置

./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/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-ldap \
--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

php.ini一定要满足如下的配置,否则后面zabbix安装不了

max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone Asia/Shanghai

下载并安装

先关闭selinux

vim /etc/selinux/config
SELINUX=disabled

依赖包

yum -y install net-snmp-devel libxml2-devel libcurl-deve libevent libevent-devel

下载源码包

wget https://excellmedia.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.11/zabbix-3.4.11.tar.gz
tar zxf zabbix-3.4.11.tar.gz

编译

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

安装

make 
make install

创建zabbix用户和用户组,并更改zabbix目录权限

groupadd -g 502 zabbix
useradd -g 502 -u 502 zabbix
chown -R zabbix: /usr/local/zabbix

创建zabbix数据库,并导入表结构

[aaa@qq.com local]# mysql -uroot -p
mysql> create database zabbix default charset utf8;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| zabbix             |
+--------------------+
5 rows in set (0.00 sec)

mysql> use zabbix
Database changed
mysql> source /root/zabbix-3.4.11/database/mysql/schema.sql;
mysql> source /root/zabbix-3.4.11/database/mysql/images.sql;
mysql> source /root/zabbix-3.4.11/database/mysql/data.sql;

创建日志目录

mkdir -p /log/zabbix
chown zabbix: /log/zabbix

配置 zabbix_server

vim /usr/local/zabbix/etc/zabbix_server.conf
PidFile=/tmp/zabbix_server.pid
LogFile=/log/zabbix/zabbix_server.log
DBName=zabbix
DBUser=root
DBPassword=password
DBPort=3306

配置zabbix_agentd

vim /usr/local/zabbix/etc/zabbix_agentd.conf
PidFile=/tmp/zabbix_agentd.pid
LogFile=/log/zabbix/zabbix_agentd.log

启动zabbix_server 和 zabiix_agent服务

/usr/local/zabbix/sbin/zabbix_server
/usr/local/zabbix/sbin/zabbix_agentd

zabbix 管理网站配置

拷贝前端php文件至web服务器的html目录

cp -rf /root/zabbix-3.4.11/frontends/php/ /usr/local/nginx/html/zabbix
chown -R nginx: /usr/local/nginx/html/zabbix

浏览器访问http://ip/zabbix/index.php会出先如下安装向导页面
欢迎界面
centos7.5 源码安装zabbix3.4

需求检查
centos7.5 源码安装zabbix3.4

MySQL 配置
centos7.5 源码安装zabbix3.4

server详细信息
centos7.5 源码安装zabbix3.4

安装前信息
centos7.5 源码安装zabbix3.4

安装完成
centos7.5 源码安装zabbix3.4

登陆页面
centos7.5 源码安装zabbix3.4
默认的账号:admin 密码:zabbix

至此OK!!


遇到的问题:
1.启动zabbix_server时报错

zabbix_server: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory

解决方法:

ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib64


2.PHP LDAP off Warning
centos7.5 源码安装zabbix3.4

解决方法:
此问题通常是编译php时候,没有添加编译ldap模块(–with-zlib)
首先查看源码安装的php模块中是否有ldap.so

[aaa@qq.com frontends]# ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
总用量 2120
-rwxr-xr-x 1 root root 1340288 723 14:57 opcache.a
-rwxr-xr-x 1 root root  623648 723 14:57 opcache.so

如果有就直接在php.ini文件里添加extension=ldap.so,如果没有需要重新编译

[root@MySql ldap]# cd /root/php-5.6.37/ext/ldap
[root@MySql ldap]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
[root@MySql ldap]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-ldap
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
........

[root@nms ldap]# make && make install 
如果编译的时候报错 configure: error: Cannot find ldap libraries in /usr/lib
是因为使用的64位OS,只需要cp -rf /usr/lib64/libldap* /usr/lib/   即可

再次查看

[aaa@qq.com ldap]# ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
总用量 2120
-rwxr-xr-x 1 root root  199896 724 11:52 ldap.so
-rwxr-xr-x 1 root root 1340288 723 14:57 opcache.a
-rwxr-xr-x 1 root root  623648 723 14:57 opcache.so
[aaa@qq.com ldap]# vim /usr/local/php/etc/php.ini
extension=ldap.so

centos7.5 源码安装zabbix3.4
然后重启服务

3.PHP option “always_populate_raw_post_data” must be set to “-1”
解决方法

vim /usr/local/php/etc/php.ini
将always_populate_raw_post_data = -1 前的注释去掉
相关标签: zabbix