微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

最近帮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中遇到的一些问题,还需加强其相关知识的学习才能不断提高。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐