码迷,mamicode.com
首页 > 数据库 > 详细

centos安装postgresql数据库过程

时间:2014-12-25 10:10:46      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:posrgresql在centos上安装   在linux上安装。   

1.1.1  软件安装

  1.设置用户组和用户级别

    Postgresql不能以root身份运行,要以其他的身份运行,所以必须建立对应的用户和组。

(1)新增database用户组:groupadd database

(2)新增pgsql用户属于postgresql用户组:useradd -g database pgsql

(3)修改pgsql用户密码:passwd pgsql(这里设置密码为postgres

2. 操作系统信息:centos 5  x86

3.准备安装包,下载PostgreSQL源码:http://www.postgresql.org/ftp/source,现在已经更新到了9.1beta版本了,本次安装使用8.4.6

4.上传下载到的postgresql-8.4.6.tar.gz到/pgsql目录下。

 5

  1. [pgsql@localhost opt]$$ cd pgsql

  2. [pgsql@localhost opt]$$tar -zxvf postgresql-8.4.6.tar.gz

  3. [pgsql@localhost opt]$ cd postgresql-8.4.6/  

  4. [pgsql@localhost postgresql-8.4.6]$./configure --prefix=/opt/postgresql 

  5. [pgsql@localhost postgresql-8.4.6]$make

  6. [pgsql@localhost postgresql-8.4.6]$make install


6.报错  

[pgsql@vps postgresql-8.4.6]$ make install

make -C doc install

make[1]: Entering directory `/home/pgsql/pgsql/postgresql-8.4.6/doc‘

mkdir -p -- /opt/postgresql/share/doc//html

mkdir: cannot create directory `/opt/postgresql‘: Permission denied

make[1]: *** [installdirs] Error 1

make[1]: Leaving directory `/home/pgsql/pgsql/postgresql-8.4.6/doc‘

make: *** [install] Error 2

[pgsql@vps postgresql-8.4.6]$ make install

make -C doc install

make[1]: Entering directory `/home/pgsql/pgsql/postgresql-8.4.6/doc‘

mkdir -p -- /opt/postgresql/share/doc//html

mkdir: cannot create directory `/opt/postgresql‘: Permission denied

make[1]: *** [installdirs] Error 1

make[1]: Leaving directory `/home/pgsql/pgsql/postgresql-8.4.6/doc‘

make: *** [install] Error 2

  处理办法,把opt的改为777.

8.初始化数据库。

  1. [pgsql@localhost postgresql-8.4.2]$ cd /opt/postgresql/bin/  

  2. [pgsql@localhost bin]$./initdb --encoding=utf8 -D /opt/postgresql/data  

初始化完成后屏幕打印如下信息:

Success. You can now start the database server using:


    ./postgres -D /home/pgsql/data

or

    ./pg_ctl -D /home/pgsql/data -l logfile start

10. 启动数据库


  1. [postgres@localhost bin]$./postgres -D /opt/postgresql/data  

当然,可以通过日志重写向,将启动信息写入日志,例如:

  1. [postgres@localhost bin]$ ./pg_ctl -D /opt/postgresql/data/ - /home/pgsql/log/pg_server.log start  

将日志信息记录在文件/home/pgsql/log/pg_server.log中,

11.安装完毕。


本文出自 “不一样的地域” 博客,谢绝转载!

centos安装postgresql数据库过程

标签:posrgresql在centos上安装   在linux上安装。   

原文地址:http://changeing.blog.51cto.com/4079776/1595691

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!