作者:何cecilio | 来源:互联网 | 2014-05-28 15:41
PostgreSQL9已经发布了,我属于新版本控,于是计划着在VPS(winserver2003)和服务器(CentOS5.5)上安装,先不讲过程,结果是服务器上已成功安装,VPS主动放弃。在些提醒各位,PostgreSQL9安装很纠结,选择需慎重。一、VPS(winserver2003)直接在官网
PostgreSQL 9已经发布了,我属于新版本控,于是计划着在VPS( win server 2003)和服务器(CentOS
5.5)上安装,先不讲过程,结果是服务器上已成功安装,VPS主动放弃。在些提醒各位,PostgreSQL
9安装很纠结,选择需慎重。
一、VPS(win server 2003)
直接在官网下载 win安装包.exe文件,按照8.4版本的习惯一路直下,在安装完成的时候出现 “ Problem running
post-install step. Installation may not complete correctly. The
database cluster initialisation failed.”
GG一下,看到有人讲在非英文系统下安装时Local选择非默认语言,如Singapore或c(别听那些不靠谱的说选Chinese,在9.0版本中压根没那选项)。于是把自己电脑上(
win
xp)的8.4卸载,重新安装选择Singapore(新加坡,对中文支持比较好),依然一路直下,OK搞定。然后把VPS卸载重新安装,依然出错,泪流满面……把公司另台电脑格掉装上win
server
2003,安装时local选Singapore,结果成功。后来又在VPS上尝试local时选C或者其他,依然失败,然后又拿8.4甚至8.3版本安装失败依然。在其他win系统(包括同版本的win
server 2003)中可正常安装,好吧VPS,到期我就换掉你丫的。
win正常安装pg9请注意:中文版系统安装时local一定选择非默认语言。
二、服务器(CentOS 5.5)
一直想给服务器(使用CentOS)装上PostgreSQL,最初的时候使用yum,结果一看是在Down
8.3版本(丫的先不说9.0版已经横空出世,8.4版可出来N久了),直接ctrl+C。
之后参照鱼哥(smallfish)的教程(点击)下载了并安装了pg9初始化时:
service postgresql initdb
Usage: /etc/init.d/postgresql
{start|stop|restart|reload|status}
@##@!¥¥@#什么东东,可以使用了吗?
service postgresql start
Starting PostgreSQL: ok
service postgresql stop
Stopping PostgreSQL: pg_ctl: PID file
"/usr/local/pgsql/data/postmaster.pid" does not exist
Is server running?
什么状况?欲哭无泪……于是等yum安装Pg版本升级到9.0。前天几发现已经到9.0了:
yum postgresql postgresql-server
最后出现:
apr-util-1.2.7-11.el5_5.1.i386 from installed has depsolving
problems
--> Missing Dependency: libpq.so.4 is needed by package
apr-util-1.2.7-11.el5_5.1.i386 (installed)
lxphp-5.2.1-400.i386 from installed has depsolving problems
--> Missing Dependency: libpq.so.4 is needed by package
lxphp-5.2.1-400.i386 (installed)
Error: Missing Dependency: libpq.so.4 is needed by package
lxphp-5.2.1-400.i386 (installed)
Error: Missing Dependency: libpq.so.4 is needed by package
apr-util-1.2.7-11.el5_5.1.i386 (installed)
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
package-cleanup --dupes
rpm -Va --nofiles --nodigest
看到这些真是心灰意冷,感觉服务器被我折腾的千疮百孔……
后来就去Gtalk去问鱼哥,操作如下:
查看rpm安装包
[root@localhost ~]# rpm -qa | grep postgres
postgresql-libs-8.1.22-1.el5_5.1
postgresql90-libs-9.0.0-1PGDG.rhel5
postgresql90-contrib-9.0.0-1PGDG.rhel5
postgresql90-devel-9.0.0-1PGDG.rhel5
postgresql90-9.0.0-1PGDG.rhel5
postgresql90-server-9.0.0-1PGDG.rhel5
貌似装好了?太貌似了。可是依然:
service postgresql initdb
Usage: /etc/init.d/postgresql
{start|stop|restart|reload|status}
service postgresql start
Starting PostgreSQL: ok
service postgresql stop
Stopping PostgreSQL: pg_ctl: PID file
"/usr/local/pgsql/data/postmaster.pid" does not exist
Is server running?
源码安装一次,然后rpm安装一次,2个混乱了?/usr/local/pgsql/源码编译的prefix,那么把编译的直接删除,MV到一个临时目录下,清理干净/var/local/pgsql、/var/lib/pgsql,mv走/init.d/postgres。按照依赖删除rpm。
全部删除完毕,重新rpm安装初始化时:
[root@localhost home]# service postgresql initdb
/usr/local/pgsql/bin/postmaster not found
要么编译安装吧,基本选项就是prefix,指定个目录就OK了。可是依然无法初始化……
最后,把由鱼哥持刀(当然不是杀鱼:)解决
原因:initdb不支持gb编码,需手动指定编码、手动指定initdb目录。
操作:
export LC_ALL=UTF8
initdb -D /var/lib/pgsql/9.0/data(此目录为rpm安装默认目录)
另:安装psycopg2
使用easy_install和下载安装均报错:
[root@localhost psycopg2-2.2.2]# python setup.py install
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
在包含自 psycopg/psycopgmodule.c:32 的文件中:
./psycopg/psycopg.h:31:22: 错误:libpq-fe.h:没有那个文件或目录
In file included from psycopg/psycopgmodule.c:33:
./psycopg/connection.h:95: 错误:expected specifier-qualifier-list
before ‘PGconn’
./psycopg/connection.h:116: 错误:expected ‘)’ before ‘*’ token
./psycopg/connection.h:117: 错误:expected ‘)’ before ‘*’ token
./psycopg/connection.h:118: 错误:expected ‘)’ before ‘*’ token
./psycopg/connection.h:119: 错误:expected ‘)’ before ‘*’ token
./psycopg/connection.h:123: 错误:expected declaration specifiers or
‘...’ before ‘PGconn’
In file included from psycopg/psycopgmodule.c:34:
./psycopg/cursor.h:60: 错误:expected specifier-qualifier-list before
‘PGresult’
In file included from psycopg/psycopgmodule.c:35:
./psycopg/green.h:63: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘*’ token
在包含自 psycopg/psycopgmodule.c:36 的文件中:
./psycopg/lobject.h:31:28: 错误:libpq/libpq-fs.h:没有那个文件或目录
In file included from psycopg/psycopgmodule.c:36:
./psycopg/lobject.h:51: 错误:expected specifier-qualifier-list before
‘Oid’
./psycopg/lobject.h:57: 错误:expected declaration specifiers or ‘...’
before ‘Oid’
./psycopg/lobject.h:57: 错误:expected declaration specifiers or ‘...’
before ‘Oid’
psycopg/psycopgmodule.c: In function ‘psyco_register_type’:
psycopg/psycopgmodule.c:269: 错误:‘cursorObject’ 没有名为 ‘string_types’
的成员
psycopg/psycopgmodule.c:272: 错误:‘connectionObject’ 没有名为
‘string_types’ 的成员
error: command 'gcc' failed with exit status 1
原因:pg目录里lib和include没有加入编译,找不到头文件和lib共享库
操作:
export C_INCLUDE_PATH=/usr/pg-90/include
export LIBRARY_PATH=/usr/pg-90/lib
然后: easy_install psycopg2或者解开下载压缩包python setup.py install就搞定了。
以上安装pg9和psycopg2均得到鱼哥大力帮助,表示感谢。