centos 7.4 + postgresql 10.1 + pg_amqp
上传 pg_amqp 到 /tmp 目录下
[root@tpg-1 tmp]# yum install lrzsz
[root@tpg-1 tmp]# rz
[root@tpg-1 tmp]# ls -l
-rw-r--r--. 1 root root 48444 Dec 13 11:34 pg_amqp-0.3.0.zip
[root@tpg-1 tmp]# unzip pg_amqp-0.3.0.zip
[root@tpg-1 tmp]# ls -l
drwxr-xr-x. 5 root root 109 May 20 2011 pg_amqp-0.3.0
-rw-r--r--. 1 root root 48444 Dec 13 11:34 pg_amqp-0.3.0.zip
开始编译
[root@tpg-1 tmp]# cd pg_amqp-0.3.0
[root@tpg-1 tmp]# env LDFLAGS="-lpthread" gmake
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -I. -I./ -I/usr/pgsql-10/include/server -I/usr/pgsql-10/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o src/pg_amqp.o src/pg_amqp.c
src/pg_amqp.c: In function ‘amqp_local_phase2’:
src/pg_amqp.c:99:3: warning: enumeration value ‘XACT_EVENT_PARALLEL_COMMIT’ not handled in switch [-Wswitch]
switch(event) {
^
src/pg_amqp.c:99:3: warning: enumeration value ‘XACT_EVENT_PARALLEL_ABORT’ not handled in switch [-Wswitch]
src/pg_amqp.c:99:3: warning: enumeration value ‘XACT_EVENT_PRE_COMMIT’ not handled in switch [-Wswitch]
src/pg_amqp.c:99:3: warning: enumeration value ‘XACT_EVENT_PARALLEL_PRE_COMMIT’ not handled in switch [-Wswitch]
src/pg_amqp.c:99:3: warning: enumeration value ‘XACT_EVENT_PRE_PREPARE’ not handled in switch [-Wswitch]
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -I. -I./ -I/usr/pgsql-10/include/server -I/usr/pgsql-10/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o src/librabbitmq/amqp_debug.o src/librabbitmq/amqp_debug.c
src/librabbitmq/amqp_debug.c:44:6: warning: no previous prototype for ‘amqp_dump’ [-Wmissing-prototypes]
void amqp_dump(void const *buffer, size_t len) {
存在一些警告,安装过程没有关注,貌似也没啥影响,pg_amqp.so可以正常使用
[root@tpg-1 tmp]# env LDFLAGS="-lpthread" gmake install
修改参数
-bash-4.2$ cat postgresql.conf |grep -i preload
shared_preload_libraries = 'pg_amqp.so' # (change requires restart)
postgresql.conf 的其它参数值依据数据库的作用和机器配置设置
[root@tpg-1 ~]# systemctl status postgresql-10.service
[root@tpg-1 ~]# systemctl start postgresql-10.service
-bash-4.2$ psql
create database testdb;
\l
\c testdb
select name,default_version,installed_version
from pg_available_extensions
where 1=1
order by name;
create extension amqp;
select *
from pg_extension;
参考:
https://github.com/omniti-labs/pg_amqp
https://pgxn.org/dist/pg_amqp/
http://blog.163.com/digoal@126/blog/static/16387704020120182524830
备注:
在 centos 7.4 + pgsql9.1 环境编译pg_amqp时,启动pgsql时报下错误,第一个通过德哥的文章解决了,第二步不知道什么原因导致的,先记录下
FATAL: could not load library “/usr/lib/postgresql/9.1/lib/src/pg_amqp.so”: /usr/lib/postgresql/9.1/lib/src/pg_amqp.so: undefined symbol: pthread_key_create
FATAL: could not load library “/usr/lib/postgresql/9.1/lib/src/pg_amqp.so”: /usr/lib/postgresql/9.1/lib/src/pg_amqp.so: undefined symbol: pthread_getspecific