CentOS 7 x86_64 编译安装zabbix-2.4.2出错 MySQL library not found

本文详细介绍了在编译Zabbix时遇到的MySQL库和SQLite3库找不到的问题,提供了确认已安装相关包、安装缺失的MySQL-devel包以及检查并创建libmysqlclient.so链接文件的解决方案。同时,还解决了因缺少必要的头文件导致的zabbix源代码编译错误,并通过指定自定义编译路径来解决SQLite3库未找到的问题。

1、hecking for mysql_config... configure: error: MySQL library not found

checking for mysql_config... /usr/bin/mysql_config

checking for main in -lmysqlclient ... no

configure: error: Not found mysqlclient library

解决:

确认安装了mysql mysql-devel mysql-server 包

解决:

zabbix编译时找不到mysql.h文件

需要安装 mysql-devel 包 yum install mysql-devel


查找系统内有没有 libmysqlclient.so 

有的yum安装的mysql没有这个文件,需要自行链接一下

cd /usr/lib/mysql/

[root@test mysql]# ln -s libmysqlclient.so.15.0.0 libmysqlclient.so

[root@test mysql]# ln -s libmysqlclient_r.so.15.0.0 libmysqlclient_r.so

网上有些资料说的是64位的,注意识别

2、

In file included from ../../../include/db.h:25,
                 from db.c:22:
../../../include/zbxdb.h:67:20: error: mysql.h: No such file or directory
../../../include/zbxdb.h:68:21: error: errmsg.h: No such file or directory
../../../include/zbxdb.h:69:27: error: mysqld_error.h: No such file or directory
In file included from ../../../include/db.h:25,
                 from db.c:22:
../../../include/zbxdb.h:71: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
../../../include/zbxdb.h:174: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
../../../include/zbxdb.h:175: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
../../../include/zbxdb.h:177: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘zbx_db_fetch’
In file included from db.c:22:
../../../include/db.h:546: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
../../../include/db.h:548: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
../../../include/db.h:549: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘DBfetch’
../../../include/db.h:586: error: expected declaration specifiers or ‘...’ before ‘MYSQL_ROW’
db.c:34: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
db.c: In function ‘zbx_db_connect’:
db.c:119: error: ‘conn’ undeclared (first use in this function)
db.c:119: error: (Each undeclared identifier is reported only once
db.c:119: error: for each function it appears in.)
db.c:121: error: ‘CLIENT_MULTI_STATEMENTS’ undeclared (first use in this function)
db.c:145: error: ‘CR_CONN_HOST_ERROR’ undeclared (first use in this function)
db.c:146: error: ‘CR_SERVER_GONE_ERROR’ undeclared (first use in this function)
db.c:147: error: ‘CR_CONNECTION_ERROR’ undeclared (first use in this function)
db.c:148: error: ‘CR_SERVER_LOST’ undeclared (first use in this function)
db.c:149: error: ‘ER_SERVER_SHUTDOWN’ undeclared (first use in this function)
db.c:150: error: ‘ER_ACCESS_DENIED_ERROR’ undeclared (first use in this function)
db.c:151: error: ‘ER_ILLEGAL_GRANT_FOR_TABLE’ undeclared (first use in this function)
db.c:152: error: ‘ER_TABLEACCESS_DENIED_ERROR’ undeclared (first use in this function)
db.c:153: error: ‘ER_UNKNOWN_ERROR’ undeclared (first use in this function)
db.c: In function ‘zbx_db_close’:
db.c:350: error: ‘conn’ undeclared (first use in this function)
db.c: At top level:
db.c:409: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
db.c: In function ‘zbx_db_vexecute’:
db.c:656: error: ‘conn’ undeclared (first use in this function)
db.c:668: error: ‘CR_CONN_HOST_ERROR’ undeclared (first use in this function)
db.c:669: error: ‘CR_SERVER_GONE_ERROR’ undeclared (first use in this function)
db.c:670: error: ‘CR_CONNECTION_ERROR’ undeclared (first use in this function)
db.c:671: error: ‘CR_SERVER_LOST’ undeclared (first use in this function)
db.c:672: error: ‘ER_SERVER_SHUTDOWN’ undeclared (first use in this function)
db.c:673: error: ‘ER_ACCESS_DENIED_ERROR’ undeclared (first use in this function)
db.c:674: error: ‘ER_ILLEGAL_GRANT_FOR_TABLE’ undeclared (first use in this function)
db.c:675: error: ‘ER_TABLEACCESS_DENIED_ERROR’ undeclared (first use in this function)
db.c:676: error: ‘ER_UNKNOWN_ERROR’ undeclared (first use in this function)
db.c: At top level:
db.c:825: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
db.c:1124: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
db.c:1139: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘zbx_db_fetch’
make[3]: *** [db.o] Error 1
make[3]: Leaving directory `/tmp/zabbix-1.8.4/src/libs/zbxdb'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/tmp/zabbix-1.8.4/src/libs'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/zabbix-1.8.4/src'
make: *** [all-recursive] Error 1


2、

configure: error: SQLite3 library not found

解决:

自己编译一个sqlite3再指定

--with-sqlite3=/usr/local/app/tools/sqlite3

3、

../../../include/sysinc.h:383:24: error: curl/curl.h: No such file or directory
make[3]: *** [md5.o] Error 1

解决:

加环境变量

base_dir=/usr/local/app/tools
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/app/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/local/app/libxml2/bin:/usr/local/app/ruby/bin:/usr/kerberos/bin:/usr/local/app/mysql/bin:/home/kingnet/bin:/usr/local/app/tools/libxml2/bin:/usr/local/app/tools/sqlite3/bin:/usr/local/app/tools/ruby/bin:/usr/kerberos/bin:/usr/local/app/tools/mysql/bin:/home/kingnet/bin:/usr/local/app/tools/mysql/bin
export LD_LIBRARY_PATH=/usr/local/app/tools/libevent/lib:/usr/local/app/tools/sqlite3/lib:/usr/local/app/tools/zlib/lib:/usr/local/app/tools/bzip2/lib:/usr/local/app/tools/mysql/lib/mysql:/usr/local/app/tools/logserver/lib:/usr/local/app/tools/tokyocabinet/lib:/usr/local/app/tools/tokyotyrant/lib:/usr/local/app/tools/curl/lib
export C_INCLUDE_PATH=$base_dir/curl/include
export CPLUS_INCLUDE_PATH=$base_dir/curl/include

[root@opennms ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com zabbix-agent2-plugins | 2.9 kB 00:00:00 zabbix-agent2-plugins/x86_64/primary_db | 3.1 kB 00:00:00 No package zabbix-apache-conf available. Resolving Dependencies --> Running transaction check ---> Package zabbix-server-mysql.x86_64 0:5.0.47-1.el7 will be installed --> Processing Dependency: libOpenIPMI.so.0()(64bit) for package: zabbix-server-mysql-5.0.47-1.el7.x86_64 --> Processing Dependency: libOpenIPMIposix.so.0()(64bit) for package: zabbix-server-mysql-5.0.47-1.el7.x86_64 --> Processing Dependency: libodbc.so.2()(64bit) for package: zabbix-server-mysql-5.0.47-1.el7.x86_64 ---> Package zabbix-web-mysql.noarch 0:2.4.1-2.el7 will be installed --> Processing Dependency: zabbix-web = 2.4.1-2.el7 for package: zabbix-web-mysql-2.4.1-2.el7.noarch --> Processing Dependency: php-mysql for package: zabbix-web-mysql-2.4.1-2.el7.noarch --> Running transaction check ---> Package OpenIPMI-libs.x86_64 0:2.0.27-1.el7 will be installed --> Processing Dependency: OpenIPMI-modalias = 2.0.27-1.el7 for package: OpenIPMI-libs-2.0.27-1.el7.x86_64 ---> Package OpenIPMI-perl.x86_64 0:2.0.27-1.el7 will be installed ---> Package php-mysql.x86_64 0:5.4.16-48.el7 will be installed --> Processing Dependency: php-pdo(x86-64) = 5.4.16-48.el7 for package: php-mysql-5.4.16-48.el7.x86_64 ---> Package unixODBC.x86_64 0:2.3.1-14.el7 will be installed --> Processing Dependency: libltdl.so.7()(64bit) for package: unixODBC-2.3.1-14.el7.x86_64 ---> Package zabbix-web-mysql.noarch 0:2.4.1-2.el7 will be installed --> Processing Dependency: zabbix-web = 2.4.1-2.el7 for package: zabbix-web-mysql-2.4.1-2.el7.noarch --> Running transaction check ---> Package OpenIPMI-modalias.x86_64 0:2.0.27-1.el7 will be installed --> Processing Dependency: OpenIPMI for package: OpenIPMI-modalias-2.0.27-1.el7.x86_64 ---> Package libtool-ltdl.x86_64 0:2.4.2-22.el7_3 will be installed ---> Package php-pdo.x86_64 0:5.4.16-48.el7 will be installed --> Processing Dependency: php-common(x86-64) = 5.4.16-48.el7 for package: php-pdo-5.4.16-48.el7.x86_64 ---> Package zabbix-web-mysql.noarch 0:2.4.1-2.el7 will be installed --> Processing Dependency: zabbix-web = 2.4.1-2.el7 for package: zabbix-web-mysql-2.4.1-2.el7.noarch --> Running transaction check ---> Package OpenIPMI.x86_64 0:2.0.27-1.el7 will be installed ---> Package php-common.x86_64 0:5.4.16-48.el7 will be installed --> Processing Dependency: libzip.so.2()(64bit) for package: php-common-5.4.16-48.el7.x86_64 ---> Package zabbix-web-mysql.noarch 0:2.4.1-2.el7 will be installed --> Processing Dependency: zabbix-web = 2.4.1-2.el7 for package: zabbix-web-mysql-2.4.1-2.el7.noarch --> Running transaction check ---> Package libzip.x86_64 0:0.10.1-8.el7 will be installed ---> Package zabbix-web-mysql.noarch 0:2.4.1-2.el7 will be installed --> Processing Dependency: zabbix-web = 2.4.1-2.el7 for package: zabbix-web-mysql-2.4.1-2.el7.noarch --> Finished Dependency Resolution Error: Package: zabbix-web-mysql-2.4.1-2.el7.noarch (zabbix-local) Requires: zabbix-web = 2.4.1-2.el7 Available: zabbix-web-5.0.19-2.el7.noarch (zabbix-local) zabbix-web = 5.0.19-2.el7 You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest 错了,怎么解决
最新发布
07-15
### 问题分析 在安装 `zabbix-web-mysql` 时,系统提示依赖冲突:需要 `zabbix-web = 2.4.1-2.el7`,但实际可用版本为 `5.0.19-2.el7`。这表明当前的 Zabbix 软件包版本与仓库中其他组件版本不兼容,通常发生在使用了不同版本的 Zabbix 仓库或手动下载了不匹配的 RPM 包。 解决此类问题的核心在于确保所有 Zabbix 组件(包括前端、数据库支持和服务器)都来自相同的官方版本,并且通过正确的软件仓库进行安装[^1]。 ### 解决方案 #### 1. 清理已安装Zabbix 相关组件 首先,卸载当前已安装Zabbix 软件包以避免版本冲突: ```bash yum remove zabbix-web zabbix-server-mysql zabbix-web-mysql ``` #### 2. 确保使用正确的 Zabbix 仓库 检查是否添加了正确的 Zabbix 官方仓库。对于 RHEL/CentOS 7 系统,应使用如下命令导入 Zabbix 6.0 的仓库配置: ```bash rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/7/x86_64/zabbix-release-6.0-4.el7.noarch.rpm ``` 该步骤确保后续安装的所有 Zabbix 包均为一致版本,如 `zabbix-web-6.0.*` 和 `zabbix-web-mysql` 的对应版本[^1]。 #### 3. 安装指定版本的 zabbix-web 如果必须使用旧版本的 `zabbix-web`(例如 2.4.1),可以通过手动下载并安装特定版本的 RPM 文件实现: ```bash wget https://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-web-2.4.1-2.el7.noarch.rpm rpm -ivh zabbix-web-2.4.1-2.el7.noarch.rpm ``` 此方法适用于特定需求,但在大多数情况下推荐使用统一版本的官方仓库进行部署[^1]。 #### 4. 使用 yum 的 exclude 功能限制版本升级 若需长期保持特定版本的 Zabbix 组件,可以在 `/etc/yum.conf` 中添加以下内容以防止自动升级: ```ini exclude=zabbix* ``` 然后在安装过程中显式指定所需版本,例如: ```bash yum install zabbix-web-2.4.1 zabbix-web-mysql-2.4.1 ``` 这样可以避免因仓库更新导致的版本不一致问题[^1]。 #### 5. 使用 DNF 模块流(适用于 CentOS 8 或 RHEL 8) 对于支持模块化管理的系统,可以使用 DNF 模块来控制 Zabbix 的版本: ```bash dnf module list zabbix dnf module enable zabbix:6.0 ``` 启用后,再执行标准安装命令即可确保所有组件版本一致: ```bash dnf install zabbix-server-mysql zabbix-web-mysql ``` ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值