Fork me on GitHub

解决cannot create PGC_POSTMASTER variables after startup问题

最近,在Ubuntu18下搭建PostgreSQL10.06测试环境,添加rum插件没有问题,但是在添加pg_jieba的时候碰到了cannot create PGC_POSTMASTER variables after startup问题。

在postgres的源码guc.c里头,有这么一句:

 1 /*
 2 * Only allow custom PGC_POSTMASTER variables to be created during shared
 3 * library preload; any later than that, we can't ensure that the value
 4 * doesn't change after startup. This is a fatal elog if it happens; just
 5 * erroring out isn't safe because we don't know what the calling loadable
 6 * module might already have hooked into.
 7 */
 8 if (context == PGC_POSTMASTER &&
 9 !process_shared_preload_libraries_in_progress)
10 elog(FATAL, "cannot create PGC_POSTMASTER variables after startup");

说是需要在共享库预加载的时候才能够创建PGC_POSTMASTER变量,但是尝试了重启系统并不能解决任何问题。

最后在/etc/postgresql/10/main/postgresql.conf文件中,找到如下一行,添加pg_jieba:

shared_preload_libraries = ‘pg_jieba’

重新启动postgres服务。这时候再使用命令查看动态库状态:

# SHOW shared_preload_libraries;
 shared_preload_libraries
--------------------------
 pg_jieba
(1 row)

SHOW

jieba插件已经显示预加载了。这时候再创建扩展:

# CREATE EXTENSION "pg_jieba";
CREATE EXTENSION

成功启动_(:з」∠)_

posted @ 2019-03-10 17:59  webberg  阅读(470)  评论(0编辑  收藏  举报