作者:justnicetwo | 来源:互联网 | 2014-05-28 15:41
Linux安装版为CentOS5.5,以root用户身份登录[root@centos55~]#uname-aLinuxcentos55.tyler.org2.6.18-194.el5#1SMPFriApr214:58:35EDT2010i686i686i386GNU/LinuxPostGreSQL9.0.2安装文件po
Linux安装版为CentOS 5.5,以root用户身份登录
[root@
centos55 ~]# uname -a
Linux centos55.tyler.org 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35
EDT 2010 i686 i686 i386 GNU/Linux
PostGreSQL 9.0.2安装文件
postgresql-9.0.2.tar.bz2 存放在 /src目录下
在/tmp目录下解压源文件
[root@centos55 ~]# cd /tmp
[root@centos55 tmp]# tar jxvf /src/postgresql-9.0.2.tar.bz2
执行配置,PostGreSQL9将安装至/opt/pgsql下
[root@centos55 tmp]# cd postgresql-9.0.2/
[root@centos55 postgresql-9.0.2]# ./configure
--prefix=/opt/pgsql
编译源文件
[root@centos55 postgresql-9.0.2]# make
安装编译后的二进制文件到/opt/pgsql目录下
[root@centos55 postgresql-9.0.2]# make install
[root@centos55 postgresql-9.0.2]# ls /opt/pgsql
bin include lib share
添加系统对.so动态链接库的搜索
[root@centos55 lib]# echo
"/opt/pgsql/lib" >> /etc/ld.so.conf
[root@centos55 lib]# ldconfig
创建数据库管理员用户
[root@centos55 postgresql-9.0.2]# adduser postgres
输入用户postgres登录密码 123456
[root@centos55 postgresql-9.0.2]# passwd postgres
Changing password for user postgres.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
初始化表空间
[root@centos55 postgresql-9.0.2]# mkdir /opt/pgsql/data/
[root@centos55 postgresql-9.0.2]# chown postgres
/opt/pgsql/data/
[root@centos55 postgresql-9.0.2]# su - postgres
[postgres@centos55 ~]$ /opt/pgsql/bin/initdb -D /opt/pgsql/data/
[postgres@centos55 ~]$ ls /opt/pgsql/data/
base
pg_ident.conf pg_subtrans
pg_xlog
serverlog
global pg_multixact
pg_tblspc postgresql.conf
pg_clog
pg_notify pg_twophase
postmaster.opts
pg_hba.conf pg_stat_tmp
PG_VERSION postmaster.pid
自启动
[root@centos55 postgresql-9.0.2]# cp
/tmp/postgresql-9.0.2/contrib/start-scripts/linux
/etc/init.d/pgsql
[root@centos55 start-scripts]# chmod u+x
/etc/init.d/pgsql
修改/etc/init.d/pgsql启动角本,将缺省安装目录由/usr/local/pgsql改为
/opt/pgsql
[root@centos55 start-scripts]# vi /etc/init.d/pgsql
将第32行
prefix=/usr/local/pgsql
改为
prefix=/opt/pgsql
将第35行
PGDATA="/usr/local/pgsql/data"
改为
PGDATA="/opt/pgsql/data"
设置开机自启动
[root@centos55 start-scripts]# chkconfig --level 2345
pgsql on
[root@centos55 start-scripts]# chkconfig --list pgsql
pgsql
0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用
6:关闭
创建数据库
[root@centos55 postgresql-9.0.2]# su - postgres
[postgres@centos55 bin]$ /opt/pgsql/bin/createdb test
测试
[postgres@centos55 bin]$ /opt/pgsql/bin/psql test
psql (9.0.2)
Type "help" for help.
test=#