源码安装Bottled Water for PostgreSQL

2016-11-03  本文已影响255人  nagioswork

按照官方文档,安装的步骤为:

Paste_Image.png

第一步,安装postgreSQL9.5
<pre>
wget http://get.enterprisedb.com/postgresql/postgresql-9.5.5-1-linux-x64.run
chmod +x postgresql-9.5.5-1-linux-x64.run
./postgresql-9.5.5-1-linux-x64.run
</pre>
按照提示的信息安装并创建完成数据库
第二步,安装[libsnappy],libsnapp可以通过yum进行安装;也可以到 wget https://github.com/google/snappy/tarball/master下载源码
<pre>
yum install snappy
yum install snappy-devel
</pre>
第三步,安装avro-c
<pre>
wget http://apache.fayea.com/avro/avro-1.8.1/c/avro-c-1.8.1.tar.gz
tar -zxvf avro-c-1.8.1.tar.gz
cd avro-c-1.8.1/
mkdir build
cd build/
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=RelWithDebInfo
提示cmake不存在,通过yum安装了cmake
yum install cmake
</pre>
再次执行cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=RelWithDebInfo
<pre>
[root@gp-node2 build]# cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=RelWithDebInfo
Enabled deflate codec
-- Found Snappy: /lib64/libsnappy.so
Enabled snappy codec
Enabled lzma codec
-- checking for module 'jansson>=2.3'
-- package 'jansson>=2.3' not found
CMake Error at CMakeLists.txt:178 (message):
libjansson >=2.3 not found

-- Configuring incomplete, errors occurred!
</pre>
需要安装jansson,
<pre>
yum install jansson-devel
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile

依赖关系解决

================================================================================================================================================================================================================================================================
Package 架构 版本 源 大小
================================================================================================================================================================================================================================================================
正在安装:
jansson-devel x86_64 2.4-6.el7 base 8.3 k

事务概要

安装 1 软件包

总下载量:8.3 k
安装大小:9.7 k
Is this ok [y/d/N]: y
Downloading packages:
jansson-devel-2.4-6.el7.x86_64.rpm | 8.3 kB 00:00:12
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : jansson-devel-2.4-6.el7.x86_64 1/1
验证中 : jansson-devel-2.4-6.el7.x86_64 1/1

已安装:
jansson-devel.x86_64 0:2.4-6.el7

完毕!
</pre>
再次执行 cmake
<pre>
[root@gp-node2 build]# cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=RelWithDebInfo
Enabled deflate codec
Enabled snappy codec
Enabled lzma codec
-- checking for module 'jansson>=2.3'
-- found jansson, version 2.4
-- Searching for asciidoc...
-- Configuring done
-- Generating done
-- Build files have been written to: /data/avro-c-1.8.1/build
然后
make
make test
make install
</pre>
第四步,刚才安装avro-c,已经完成了安装
第五步,安装libcurl
<pre>
yum install libcurl
</pre>
第六步,安装a Kafka client
<pre>
git clone https://github.com/edenhill/librdkafka.git
cd librdkafka
./configure
make
make install
</pre>
下载并安装/bottledwater-pg
<pre>
git clone https://github.com/confluentinc/bottledwater-pg.git
cd bottledwater-pg/
make
</pre>
提示找不到/usr/bin/ld: warning: libssl.so.1.0.0, needed by /opt/PostgreSQL/9.5/lib/libpq.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libcrypto.so.1.0.0, needed by /opt/PostgreSQL/9.5/lib/libpq.so, not found (try using -rpath or -rpath-link)
设置环境变量
<pre>
<[root@gp-node2 bottledwater-pg]# vi /opt/PostgreSQL/9.5/pg_env.sh

!/bin/sh

The script sets environment variables helpful for PostgreSQL

export PATH=/opt/PostgreSQL/9.5/bin:$PATH
export PGDATA=/opt/PostgreSQL/9.5/data
export PGDATABASE=postgres
export PGUSER=postgres
export PGPORT=5432
export PGLOCALEDIR=/opt/PostgreSQL/9.5/share/locale
export MANPATH=$MANPATH:/opt/PostgreSQL/9.5/share/man
<b>export LD_LIBRARY_PATH=/opt/PostgreSQL/9.5/lib </b>
</pre>
提示Package libsnappy was not found * 和Package avro-c was not found *
分别在/usr/lib64/pkgconfig目录下增加
<pre>
[root@gp-node2 pkgconfig]# more avro-c.pc
Name: avro-c
Description: C library for parsing Avro data
Version: 1.8.1
URL: http://avro.apache.org/
Libs: -L/usr/local/avro-c/lib -lavro
Cflags: -I/usr/local/avro-c/include
Requires: zlib liblzma libsnappy
[root@gp-node2 pkgconfig]# more libs
libsasl2.pc libselinux.pc libsepol.pc libsnappy.pc libssl.pc
[root@gp-node2 pkgconfig]# more libsnappy.pc
Name: libsnappy
Description: Snappy is a compression library
Version: 1.1.2
URL: https://google.github.io/snappy/
Libs: -L/usr/lib64 -lsnappy
Cflags: -I/usr/include
</pre>
提示找不到curl.h,执行yum install crul-devel
<pre>
[root@gp-node2 bottledwater-pg]# make
make -C ext all
make[1]: 进入目录“/data/bottledwater-pg/ext”
make[1]: 对“all”无需做任何事。
make[1]: 离开目录“/data/bottledwater-pg/ext”
make -C client all
make[1]: 进入目录“/data/bottledwater-pg/client”
make[1]: 对“all”无需做任何事。
make[1]: 离开目录“/data/bottledwater-pg/client”
make -C kafka all
make[1]: curl-config:命令未找到
make[1]: 进入目录“/data/bottledwater-pg/kafka”
gcc bottledwater.c -c -std=c99 -D_POSIX_C_SOURCE=200809L -I../client -I../ext -I/opt/PostgreSQL/9.5/include -I/opt/PostgreSQL/9.5/include/postgresql/server -I/usr/local/avro-c/include -DAVRO_1_8 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -o bottledwater.o
In file included from table_mapper.h:4:0,
from json.h:5,
from bottledwater.c:2:
registry.h:5:23: 致命错误:curl/curl.h:没有那个文件或目录

include <curl/curl.h>

                   ^

编译中断。
make[1]: *** [bottledwater.o] 错误 1
make[1]: 离开目录“/data/bottledwater-pg/kafka”
make: *** [all] 错误 2

yum install curl-devel
</pre>
解决完上述的依赖问题后再次执行make
<pre>
[root@gp-node2 bottledwater-pg]# make
make -C ext all
make[1]: 进入目录“/data/bottledwater-pg/ext”
make[1]: 对“all”无需做任何事。
make[1]: 离开目录“/data/bottledwater-pg/ext”
make -C client all
make[1]: 进入目录“/data/bottledwater-pg/client”
make[1]: 对“all”无需做任何事。
make[1]: 离开目录“/data/bottledwater-pg/client”
make -C kafka all
make[1]: 进入目录“/data/bottledwater-pg/kafka”
gcc bottledwater.c -c -std=c99 -D_POSIX_C_SOURCE=200809L -I../client -I../ext -I/opt/PostgreSQL/9.5/include -I/opt/PostgreSQL/9.5/include/postgresql/server -I/usr/local/avro-c/include -DAVRO_1_8 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -o bottledwater.o
gcc json.c -c -std=c99 -D_POSIX_C_SOURCE=200809L -I../client -I../ext -I/opt/PostgreSQL/9.5/include -I/opt/PostgreSQL/9.5/include/postgresql/server -I/usr/local/avro-c/include -DAVRO_1_8 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -o json.o
gcc registry.c -c -std=c99 -D_POSIX_C_SOURCE=200809L -I../client -I../ext -I/opt/PostgreSQL/9.5/include -I/opt/PostgreSQL/9.5/include/postgresql/server -I/usr/local/avro-c/include -DAVRO_1_8 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -o registry.o
gcc table_mapper.c -c -std=c99 -D_POSIX_C_SOURCE=200809L -I../client -I../ext -I/opt/PostgreSQL/9.5/include -I/opt/PostgreSQL/9.5/include/postgresql/server -I/usr/local/avro-c/include -DAVRO_1_8 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -o table_mapper.o
gcc logger.c -c -std=c99 -D_POSIX_C_SOURCE=200809L -I../client -I../ext -I/opt/PostgreSQL/9.5/include -I/opt/PostgreSQL/9.5/include/postgresql/server -I/usr/local/avro-c/include -DAVRO_1_8 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -o logger.o
gcc bottledwater.o json.o registry.o table_mapper.o logger.o ../client/libbottledwater.a -o bottledwater -L/opt/PostgreSQL/9.5/lib -lpq -lrdkafka -lz -lpthread -L/usr/local/avro-c/lib -lavro -lz -llzma -lsnappy -lcurl -ljansson
make[1]: 离开目录“/data/bottledwater-pg/kafka”
[root@gp-node2 bottledwater-pg]#
[root@gp-node2 bottledwater-pg]#
[root@gp-node2 bottledwater-pg]#
[root@gp-node2 bottledwater-pg]#
[root@gp-node2 bottledwater-pg]#
[root@gp-node2 bottledwater-pg]#
[root@gp-node2 bottledwater-pg]# make install
make -C ext install
make[1]: 进入目录“/data/bottledwater-pg/ext”
/bin/mkdir -p '/opt/PostgreSQL/9.5/lib/postgresql'
/bin/mkdir -p '/opt/PostgreSQL/9.5/share/postgresql/extension'
/bin/mkdir -p '/opt/PostgreSQL/9.5/share/postgresql/extension'
/usr/bin/install -c -m 755 bottledwater.so '/opt/PostgreSQL/9.5/lib/postgresql/bottledwater.so'
/usr/bin/install -c -m 644 .//bottledwater.control '/opt/PostgreSQL/9.5/share/postgresql/extension/'
/usr/bin/install -c -m 644 .//bottledwater--0.1.sql '/opt/PostgreSQL/9.5/share/postgresql/extension/'
make[1]: 离开目录“/data/bottledwater-pg/ext”
</pre>
到此,安装完成,后续开始进行配置
============================================================================================
1、修改postges的设置,修改postgresql.conf文件在的如下几个选项:
wal_level = logical
max_wal_senders = 8
wal_keep_segments = 4
max_replication_slots = 4
修改pg_hba.conf,增加同步的账户
host replication repuser 0.0.0.0/0 md5

重启postgres服务
2、创建账号,创建扩展
<pre>
-bash-4.2$ psql
Password:
psql.bin (9.5.5)
Type "help" for help.

postgres=#
postgres=# CREATE ROLE repuser REPLICATION LOGIN PASSWORD 'repuser';
postgres=# create extension bottledwater;
CREATE EXTENSION
</pre>

上一篇下一篇

猜你喜欢

热点阅读