newliver

newliver的博客

他的个人主页  他的博客

在Centos5.5部署Postgresql8.3及安装python psycopg2库包小记

newliver  2010年11月29日 星期一 19:51 | 2072次浏览 | 0条评论

在Centos5.5部署Postgresql8.3及安装python psycopg2库包小记

操作系统:Centos5.5
数据库:postgresql8.3

在网易源上搜索postgresql,发现在服务器目前最新的为8.4,保守一些,那就安装8.3的吧

第一步,搜索源找到相关包名称:

yum search postgresql

第二步,安装数据库包:

yum install postgresql postgresql-libs postgresql-server

第三步,配置pg_hba.conf文件:

cd /var/lib/pgsql/data/

vi pg_hba.conf

#-------以下为pg_hba.conf修改部分----------#

# "local" is for Unix domain socket connections only
local   all         all                               ident sameuser
local   all         all         trust
# IPv4 local connections:
host    all         all          127.0.0.1/32           ident sameuser
host    all         all          127.0.0.1/32           md5
host    all         all           192.168.1.101/32   trust

#------------------------------------------------------------#
trust
无条件地允许联接,这个方法允许任何可以与PostgreSQL 数据库联接的用户以他们期望的任意 PostgreSQL 数据库用户身份进行联接,而不需要口令。

md5
要求客户端提供一个 MD5 加密的口令进行认证,这个方法是允许加密口令存储在pg_shadow里的唯一的一个方法。

第四步:重新启动服务

/etc/init.d/postgresql restart

一切Ok,表示启动服务成功

第五步:安装PgAdmin3

可以到官方网站下载pgadmin3 windows版本及linux版本,它是一个客户端管理工具

第六步:连接数据库

打开pgadmin3,点击“新建服务器登记”
填写名称:192.168.1.102(连接数据库ip)
主机端口:5432
维护数据库:自己选择
用户名密码,自己创建的

第七步:不管在使用easy_install psycopg2还是使用psycopg2源码包编译安装(个人机子实践安装出错),出错内容如下:
#------------------------------------------------------------------------------------------------------#
running install
running build
running build_py
running build_ext
Warning: Unable to find 'pg_config' filebuilding 'psycopg2._psycopg' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1
-DPSYCOPG_VERSION="2.2.2 (dt dec ext pq3)" -DPSYCOPG_EXTENSIONS=1
-DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1
-I/usr/local/include/python2.6 -I. -c psycopg/psycopgmodule.c -o
build/temp.linux-i686-2.6/psycopg/psycopgmodule.o
-Wdeclaration-after-statement

。。。。

error: command 'gcc' failed with exit status 1

#------------------------------------------------------------------------------------------------------#

使用源安装开发包解决:

yum install postgresql-devel

在重新使用easy_install 或者源码编译即可~


参考资料:  http://www.chinaunix.net/jh/18/8176.html

评论

我的评论:

发表评论

请 登录 后发表评论。还没有在Zeuux哲思注册吗?现在 注册 !

暂时没有评论

Zeuux © 2024

京ICP备05028076号