Postgresql数据库安装中文全文搜索插件zhparser的问题
Posted ginponson
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Postgresql数据库安装中文全文搜索插件zhparser的问题相关的知识,希望对你有一定的参考价值。
在PG数据库的基础上加装zhparser中文全文搜索插件,说实话,挺怕这些单独编译安装的插件的,因为安装PG数据库方法的不同,最后可能导致安装的插件各种安装不上,这里说一下我遇到的坑,系统环境是Centos7, yum安装的PG9.6。
1、INSTALL
关于安装方法,可以直接到上面看https://github.com/amutu/zhparser
2、make的时候缺少pgxs.mk
[[email protected] zhparser]# PG_CONFIG=/usr/pgsql-9.6/bin/pg_config make && make install
Makefile:19: /usr/pgsql-9.6/lib/pgxs/src/makefiles/pgxs.mk: No such file or directory
make: *** No rule to make target `/usr/pgsql-9.6/lib/pgxs/src/makefiles/pgxs.mk'. Stop.
解决方法:
[[email protected] zhparser]# export PATH=/usr/pgsql-9.6/bin:$PATH
[[email protected] zhparser]# yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
[[email protected] zhparser]# yum install postgresql96-devel.x86_64
3、创建zhparser的时候提示Permission denied
ERROR: could not open file "/usr/pgsql-9.6/share/tsearch_data/qc_dict_jupiter.txt" for writing: Permission denied
HINT: COPY TO instructs the PostgreSQL server process to write a file. You may want a client-side facility such as psql's \copy.
CONTEXT: SQL statement "copy (select word, tf, idf, attr from zhparser.zhprs_custom_word) to '/usr/pgsql-9.6/share/tsearch_data/qc_dict_jupiter.txt' encoding 'utf8'"
PL/pgSQL function sync_zhprs_custom_word() line 11 at EXECUTE
解决方法:
chown -R postgres:postgres /usr/pgsql-9.6/share/tsearch_data/
4、ERROR: ?must be superuser to alter superusers
[[email protected] data]# sudo -u postgres /usr/pgsql-9.6/bin/postgres --single -D /var/lib/pgsql/9.6/data/
PostgreSQL stand-alone backend 9.6
backend> ALTER USER postgres WITH SUPERUSER;
backend>
以上是关于Postgresql数据库安装中文全文搜索插件zhparser的问题的主要内容,如果未能解决你的问题,请参考以下文章
PostgreSQL(全文搜索)与 ElasticSearch