qconf安装过程遇到的问题及解决方案

背景

近期,项目中引入一个配置中心服务,主要目的是界面化管理项目中的配置文件,做了一番调研决定用qconf。qconf有以下特点能很好地满足需求:
- 一处修改,所有机器实时同步更新
- 高效读取配置
- 安装部署方便,使用简单
- 服务器宕机、网络中断、集群迁移等异常情况对用户透明
- 支持c/c++、shell、php、python、lua、java、go、node 等语言

但是在安装的过程中遇到很多棘手问题

安装过程

1. 先clone下来:

git clone https://github.com/Qihoo360/QConf

按照教程进行编译:

mkdir build && cd build
cmake ..
make

问题一:提示找不到gdbm.h头文件

/alidata/QConf/agent/qconf_dump.cc:1:18: fatal error: gdbm.h: No such file or directory
compilation terminated.
agent/CMakeFiles/qconf_agent.dir/build.make:206: recipe for target 'agent/CMakeFiles/qconf_agent.dir/qconf_dump.cc.o' failed
make[2]: *** [agent/CMakeFiles/qconf_agent.dir/qconf_dump.cc.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'agent/CMakeFiles/qconf_agent.dir/all' failed
make[1]: *** [agent/CMakeFiles/qconf_agent.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

google了一下,发现要安装一个gdbm库。
解决方法:

root@gdbm$ apt install libgdbm-dev

问题二:提示找不到libgdbm.a文件

解决头文件后,继续make又一报错:提示找不到libgdbm.a文件

[root@build]# make
make[2]: *** No rule to make target `../agent/../deps/gdbm/_install/lib/libgdbm.a', needed by `agent/qconf_agent'.  Stop.
make[1]: *** [agent/CMakeFiles/qconf_agent.dir/all] Error 2
make: *** [all] Error 2

问题三:提示/missing: line 81: aclocal-1.14: command not found错误

根据提示,应该是libgdbm.a未找到,进入cd ../deps/gdbm/手动make,还是报错:

[root@gdbm]# make
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /data/home/QConf/deps/gdbm/build-aux/missing aclocal-1.14 -I m4
/data/home/QConf/deps/gdbm/build-aux/missing: line 81: aclocal-1.14: command not found
WARNING: 'aclocal-1.14' is missing on your system.
         You should only need it if you modified 'acinclude.m4' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'aclocal' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>
make: *** [aclocal.m4] Error 127

google了一番,aclocal是在automake中,但是系统已经安装过了。

http://blog.kukiel.net/2010/01/automake-aclocal-command-not-found.html

巧妙的解决方案

尝试了很多网上的方法,问题太多,各种环境依赖被折腾得不行,还是未能解决,
于是回到问题二缺少libgdbm.a静态库,要不直接下载一个库试试行不行?

  1. 直接下载:

    https://ftp.gnu.org/gnu/gdbm/

  2. 编译出libgdbm.a文件,copy到../deps/gdbm/_install/lib/libgdbm.a,然后回到一开始的build目录,继续make

[root@ build]# make
Linking CXX executable qconf_agent
[ 46%] Built target qconf_agent
[ 48%] Building CXX object driver/c++/CMakeFiles/qconf.dir/src/qconf.cc.o
[ 51%] Building CXX object driver/c++/CMakeFiles/qconf.dir/src/driver_api.cc.o
[ 53%] Building CXX object driver/c++/CMakeFiles/qconf.dir/src/driver_common.cc.o
[ 56%] Building CXX object driver/c++/CMakeFiles/qconf.dir/__/__/base/qconf_format.cc.o
[ 58%] Building CXX object driver/c++/CMakeFiles/qconf.dir/__/__/base/qconf_shm.cc.o
[ 61%] Building CXX object driver/c++/CMakeFiles/qconf.dir/__/__/base/qconf_msg.cc.o
[ 64%] Building CXX object driver/c++/CMakeFiles/qconf.dir/__/__/base/qconf_log.cc.o
[ 66%] Building CXX object driver/c++/CMakeFiles/qconf.dir/__/__/base/qlibc/md5.c.o
[ 69%] Building CXX object driver/c++/CMakeFiles/qconf.dir/__/__/base/qlibc/qhash.c.o
[ 71%] Building CXX object driver/c++/CMakeFiles/qconf.dir/__/__/base/qlibc/qhasharr.c.o
Linking CXX shared library libqconf.so
[ 71%] Built target qconf
[ 74%] Building CXX object driver/c++/CMakeFiles/qconf_static.dir/src/qconf.cc.o
[ 76%] Building CXX object driver/c++/CMakeFiles/qconf_static.dir/src/driver_api.cc.o
[ 79%] Building CXX object driver/c++/CMakeFiles/qconf_static.dir/src/driver_common.cc.o
[ 82%] Building CXX object driver/c++/CMakeFiles/qconf_static.dir/__/__/base/qconf_format.cc.o
[ 84%] Building CXX object driver/c++/CMakeFiles/qconf_static.dir/__/__/base/qconf_shm.cc.o
[ 87%] Building CXX object driver/c++/CMakeFiles/qconf_static.dir/__/__/base/qconf_msg.cc.o
[ 89%] Building CXX object driver/c++/CMakeFiles/qconf_static.dir/__/__/base/qconf_log.cc.o
[ 92%] Building CXX object driver/c++/CMakeFiles/qconf_static.dir/__/__/base/qlibc/md5.c.o
[ 94%] Building CXX object driver/c++/CMakeFiles/qconf_static.dir/__/__/base/qlibc/qhash.c.o
[ 97%] Building CXX object driver/c++/CMakeFiles/qconf_static.dir/__/__/base/qlibc/qhasharr.c.o
Linking CXX static library libqconf.a
[ 97%] Built target qconf_static
[100%] Building CXX object driver/sh/CMakeFiles/qconf_client.dir/qconf.cc.o
Linking CXX executable qconf
[100%] Built target qconf_client

搞定!完美解决!!

总结

有时遇到问题,如果直面问题解决不了,不妨换一种思路解决,说不定会有奇效~。

你可能感兴趣的:(后端)