PosstgreSQL安装test_decoding-1.0版本插件

1.本文以解决此问题

PosstgreSQL安装test_decoding-1.0版本插件_第1张图片

postgres=# CREATE EXTENSION test_decoding;
ERROR:  could not open extension control file "/usr/pgsql-13/share/extension/test_decoding.control": No such file or directory

2.cd到extension目录 

cd /usr/local/postgresql-13.16/share/extension  
#各种安装方式不同时这个目录位置不同,yum安装的一般在/usr/pgsql-versiontag/share/extension

3.手动创建test_decoding.control和test_decoding--1.0.sql文件

[root@sulibao extension]# cat test_decoding.control 
# test_decoding extension
comment = 'test_decoding for logical decoding'
default_version = '1.0'
module_pathname = '\$libdir/test_decoding'
relocatable = false

[root@sulibao extension]# cat test_decoding--1.0.sql 
CREATE OR REPLACE FUNCTION test_decoding_slot_create(
    slot_name name, plugin name DEFAULT 'test_decoding'::name)
RETURNS void
AS '\$libdir/test_decoding', 'test_decoding_slot_create'
LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION test_decoding_slot_drop(
    slot_name name)
RETURNS void
AS '\$libdir/test_decoding', 'test_decoding_slot_drop'
LANGUAGE C STRICT;


#文件权限需要为644
[root@sulibao extension]# ll | grep test
-rw-r--r-- 1 root root   365 Mar 12 21:34 test_decoding--1.0.sql
-rw-r--r-- 1 root root   160 Mar 12 21:34 test_decoding.control

4.重启pg服务后进行查询

[root@sulibao extension]# systemctl restart postgresql-13.16.service
[root@sulibao extension]# psql -Upostgres
psql (13.16)
Type "help" for help.

postgres=# SELECT * FROM pg_available_extensions WHERE name = 'test_decoding';
     name      | default_version | installed_version |              comment               
---------------+-----------------+-------------------+------------------------------------
 test_decoding | 1.0             |                   | test_decoding for logical decoding
(1 row)

5.结论

此前方向错误,无需使用"CREATE EXTENSION test_decoding;"命令来下载该插件。

你可能感兴趣的:(运维日常,数据库,postgresql,test_decoding,运维,插件)