PostgreSQL RPM 安装笔记

On 2023/02/06, in PostgreSQL, by admin

测试环境:REHL 5.3
PostgreSQL版本:8.4.2

1. 首先检查下是否已经有PostgreSQL安装程序(俺的机器有pg-libs 8.1,无视之)

shell> rpm -qa | grep postgres

2. 下载最新的8.4.2RPM安装包,这个FTP速度挺快的。:)

shell> wget http://ftp.easynet.be/postgresql/binary/v8.4.2/linux/rpms/redhat/rhel-5-x86_64/postgresql-server-8.4.2-1PGDG.rhel5.x86_64.rpm
shell> wget http://ftp.easynet.be/postgresql/binary/v8.4.2/linux/rpms/redhat/rhel-5-x86_64/postgresql-contrib-8.4.2-1PGDG.rhel5.x86_64.rpm
shell> wget http://ftp.easynet.be/postgresql/binary/v8.4.2/linux/rpms/redhat/rhel-5-x86_64/postgresql-libs-8.4.2-1PGDG.rhel5.x86_64.rpm
shell> wget http://ftp.easynet.be/postgresql/binary/v8.4.2/linux/rpms/redhat/rhel-5-x86_64/postgresql-devel-8.4.2-1PGDG.rhel5.x86_64.rpm
shell> wget http://ftp.easynet.be/postgresql/binary/v8.4.2/linux/rpms/redhat/rhel-5-x86_64/postgresql-8.4.2-1PGDG.rhel5.x86_64.rpm
shell> wget http://ftp.easynet.be/postgresql/binary/v8.4.2/linux/rpms/redhat/rhel-5-x86_64/postgresql-plpython-8.4.2-1PGDG.rhel5.x86_64.rpm

3. 安装PostgreSQL(要注意下顺序),首先需要更新pg-libs版本。
后面几个不需要的话可以不装。主要是一些扩展功能。

shell> rpm -ivh postgresql-libs-8.4.2-1PGDG.rhel5.x86_64.rpm
shell> rpm -ivh postgresql-8.4.2-1PGDG.rhel5.x86_64.rpm
shell> rpm -ivh postgresql-server-8.4.2-1PGDG.rhel5.x86_64.rpm
shell> rpm -ivh postgresql-contrib-8.4.2-1PGDG.rhel5.x86_64.rpm
shell> rpm -ivh postgresql-devel-8.4.2-1PGDG.rhel5.x86_64.rpm
shell> rpm -ivh postgresql-plpython-8.4.2-1PGDG.rhel5.x86_64.rpm

4. RPM安装完后,需要初始化PostgreSQL库。service初次启动会提示。
如果是源码安装这个过程就是对应的initdb -D,指定data目录。RPM默认对应目录是/var/lib/pgsql/data。

shell> service postgresql initdb

5. service启动PostgreSQL

shell> service postgresql start

到上面这一步基本是安装完成了。下面的是修改数据库用户密码和登陆相关。

6. 切换到postgres用户,修改数据库密码。(注意系统用户和数据库用户密码是两个概念,虽然名字都叫postgres)
修改完需要重启数据库,这里咱不重启,等修改完认证配置再一起重启。

shell> su - postgres
shell> psql
postgres=# ALTER USER postgres WITH PASSWORD '123456';
postgres=# \q

7. 修改认证文件/var/lib/pgsql/data/pg_hba.conf,登陆使用密码。md5格式。

shell> vi /var/lib/pgsql/data/pg_hba.conf
修改ident为md5 (local, host)

8. service重启PostgreSQL

shell> service postgresql restart

9. 再次进入测试,应该会提示输入密码鸟 :)

shell>psql -U postgres
Tagged with:  

One Response to PostgreSQL RPM 安装笔记

  1. [...] PostgreSQL 9.0 安装乱乱记 11.10.2023 · Posted in CentOS, Database, Python 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。之后参照鱼哥的教程(点击)下载了并安装了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均得到鱼哥大力帮助,表示感谢。 Tags: CentOS, Postgresql [...]

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

iBlog by PageLines

WP SlimStat