常规的编译安装操作步骤如下:
git clone https://github.com/ildus/clickhouse_fdw
sudo yum install libcurl-devel libuuid-devel
cd clickhouse_fdw
mkdir build && cd build
cmake ..
make && make install
出现的问题基本都在官方 Github 上给出解决方案了,所以如果大家安装细心的话,应该不会出现以下问题。
问题一:cmake 版本问题
错误:
[postgres@allinone build]$ cmake ..
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.5 or higher is required. You are running version 2.8.12.2
-- Configuring incomplete, errors occurred!
解决方法:
实际上服务器上是有 cmake 3 的,只需要将命令改为 cmake3 运行即可:
cmake3 ..
问题二:
错误:
CMake Error in src/CMakeLists.txt:
Target "clickhouse_fdw" requires the language dialect "CXX17" (with
compiler extensions), but CMake does not know the compile flags to use to
enable it.
...
解决方法:
需要升级 gcc:
wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-7.2.0/gcc-7.2.0.tar.gz
tar -xvzf gcc-7.2.0.tar.gz
cd gcc-7.2.0
./contrib/download_prerequisites
./configure \
--enable-bootstrap \
--enable-languages=c,c++,fortran,lto \
--with-bugurl=http://bugzilla.redhat.com/bugzilla \
--enable-shared \
--enable-threads=posix \
--enable-checking=release \
--disable-multilib \
--with-system-zlib \
--enable-__cxa_atexit \
--disable-libunwind-exceptions \
--enable-gnu-unique-object \
--enable-linker-build-id \
--with-gcc-major-version-only \
--enable-plugin \
--with-linker-hash-style=gnu \
--enable-initfini-array \
--enable-libmpx \
--enable-gnu-indirect-function \
--with-tune=generic \
--build=x86_64-redhat-linux
make -j4
sudo make install
sudo sh -c 'echo /usr/local/lib > /etc/ld.so.conf.d/1-gcc.conf'
sudo sh -c 'echo /usr/local/lib64 >> /etc/ld.so.conf.d/1-gcc.conf'
sudo ldconfig -v
也可以根据官方提供的方案,升级编译工具:devtoolset-7
https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ 具体步骤掠过。
升级完成后,将本地的 CMakeCache 删掉,重新执行即可。
问题三:
错误:
[ 58%] Building C object src/CMakeFiles/clickhouse_fdw.dir/http.c.o
In file included from /usr/include/curl/curl.h:2251:0,
from /home/postgres/clickhouse_fdw/src/include/clickhouse_internal.h:4,
from /home/postgres/clickhouse_fdw/src/http.c:10:
/home/postgres/clickhouse_fdw/src/http.c: In function ‘ch_http_simple_query’:
/home/postgres/clickhouse_fdw/src/http.c:148:31: error: ‘CURLOPT_PATH_AS_IS’ undeclared (first use in this function); did you mean ‘CURLOPT_MAIL_AUTH’?
curl_easy_setopt(conn->curl, CURLOPT_PATH_AS_IS, 1);
^
/home/postgres/clickhouse_fdw/src/http.c:148:31: note: each undeclared identifier is reported only once for each function it appears in
/home/postgres/clickhouse_fdw/src/http.c:159:32: error: ‘CURLOPT_XFERINFOFUNCTION’ undeclared (first use in this function); did you mean ‘CURLOPT_WRITEFUNCTION’?
curl_easy_setopt(conn->curl, CURLOPT_XFERINFOFUNCTION, curl_progressfunc);
^
/home/postgres/clickhouse_fdw/src/http.c:160:32: error: ‘CURLOPT_XFERINFODATA’ undeclared (first use in this function); did you mean ‘CURLOPT_WRITEDATA’?
curl_easy_setopt(conn->curl, CURLOPT_XFERINFODATA, conn);
^
make[2]: *** [src/CMakeFiles/clickhouse_fdw.dir/http.c.o] Error 1
make[1]: *** [src/CMakeFiles/clickhouse_fdw.dir/all] Error 2
make: *** [all] Error 2
解决方法:
从这里下载 curl 的所有包:https://cbs.centos.org/koji/buildinfo?buildID=1408
上传到服务器上,然后执行安装:
sudo rpm -Uvh *curl*rpm --nodeps
sudo yum install libmetalink
End~