加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

使用Postgresql遇到的一些问题和解决办法

发布时间:2020-12-13 17:27:26 所属栏目:百科 来源:网络整理
导读:最近帮QA的同事新建一台postgresql测试服务器过程中遇到了些许问题,列举一下以作备份,也为以后使用做参考。 1. postgresql 默认的系统yum源里只有版本为8.4.18-1.el6_4, 而我需要安装9.2版本的。 到pgsql官网上去查看,它提供了一个安装9.2版本的的yum源

最近帮QA的同事新建一台postgresql测试服务器过程中遇到了些许问题,列举一下以作备份,也为以后使用做参考。

1. postgresql 默认的系统yum源里只有版本为8.4.18-1.el6_4, 而我需要安装9.2版本的。

到pgsql官网上去查看,它提供了一个安装9.2版本的的yum源地址:http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-sl92-9.2-8.noarch.rpm

使用如下命令安装该源

yuminstallhttp://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-sl92-9.2-8.noarch.rpm

安装pgsql-9.2的命令为

yuminstallpostgresql92-server

即可将包文件postgresql92-server-9.2.9-1PGDG.rhel6.x86_64 安装到系统

启动服务命令为service postgresql-9.2 start


2. 在导入一个数据库时出现错误"ERROR: type "hstore" does not exist"

按照网上提示的解决办法,执行一条SQL语句"create extension hstore;", 但是报另一条错误信息

"ERROR: could not open extension control file "/usr/pgsql-9.2/share/extension/hstore.control": No such file or directory"

进入文件路径/usr/pgsql-9.2/share/extension/, 发现下面的确没有hstore.control这个文件,于是怀疑是否有些相关的包文件未安装齐全,那么采取暴力一点的办法,把所有有关postgresql92的安装包全部装上,

yuminstallpostgresql92*
postgresql92-libs-9.2.9-1PGDG.rhel6.x86_64
postgresql92-pltcl-9.2.9-1PGDG.rhel6.x86_64
postgresql92-debuginfo-9.2.9-1PGDG.rhel6.x86_64
postgresql92-plpython-9.2.9-1PGDG.rhel6.x86_64
postgresql92-9.2.9-1PGDG.rhel6.x86_64
postgresql92-devel-9.2.9-1PGDG.rhel6.x86_64
postgresql92-contrib-9.2.9-1PGDG.rhel6.x86_64
postgresql92-odbc-09.02.0100-1PGDG.rhel6.x86_64
postgresql92-tcl-2.0.0-1.rhel6.x86_64
postgresql92-test-9.2.9-1PGDG.rhel6.x86_64
postgresql92-odbc-debuginfo-09.02.0100-1PGDG.rhel6.x86_64
postgresql92-jdbc-debuginfo-9.2.1002-1PGDG.rhel6.x86_64
postgresql92-tcl-debuginfo-2.0.0-1.rhel6.x86_64
postgresql92-server-9.2.9-1PGDG.rhel6.x86_64
postgresql92-jdbc-9.2.1002-1PGDG.rhel6.x86_64
postgresql92-plperl-9.2.9-1PGDG.rhel6.x86_64
postgresql92-docs-9.2.9-1PGDG.rhel6.x86_64

然后再进入路径/usr/pgsql-9.2/share/extension/,该有的文件都有了,再尝试导入数据库,未出现刚刚的那个错误


3. QA同事在测试服务器上启动程序时不能连接到数据库服务器

查看pgsql的配置文件/var/lib/pgsql/9.2/data/postgresql.conf,里面有相关的选项

-ConnectionSettings-
listen_addresses='localhost'#whatIPaddress(es)tolistenon;
#defaultsto'localhost';use'*'forall

原来这样启动方式只能玩单机版,局域网的其他服务器不能连接到该数据库服务器,更改为

listen_addresses='*'

另外还有一个配置文件/var/lib/pgsql/9.2/data/pg_hba.conf也需要修改,加入以下参数,允许所有网段访问该数据库,也可以特别指定一些网段如192.168.1.0/24等等

#IPv4localconnections:
hostallall0.0.0.0/0trust

重启pgsql后其他服务器可以连接数据库


这是目前使用postgresql中遇到的一些问题,还需加强其相关知识的学习才能不断提高。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读