Postgresql数据库的安装指引

前端之家收集整理的这篇文章主要介绍了Postgresql数据库的安装指引前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
@H_123_403@
1、解压数据库































cd /usr/local/src






























tar -jxvf postgresql-8.4.14.tar.bz2


























































2、进入数据库文件
cd postgresql-8.4.14

  将数据库安装指定到特定的目录postgresql





































  (postgresql文件夹是新建)






./configure --prefix=/usr/local/postgresql/





































有可能出现以下报错提示找不到readline,但readline已经安装,说明缺少了readline-devel可通过yum安装

A、配置/etc/yum.repos.d/rhel-debuginfo.repo (注意linux版本不一样配置也会有所不同)





[base]

































name=Server Local Sources


























baseurl=file:///media/rhel/Server























enable=1
































gpcheck=1
































gpgkey=file:///media/rhel/RPM-GPG-KEY-redhat-release















B、挂载光驱的系统盘






























  新建一个目录用于挂载点:mkdir /media/rhel



















mount /dev/cdrom /media/rhel























C、验证挂载是否成功查看df -Th
























D、yum安装相关软件




























yum makecache 清理缓存


























yum install readline -devel

























  yum install read*



























3、编译&安装
gmake

































gmake install





































4、增加postgresql专用用户
useradd postgres





































5、切换postgres用户之前,先建立数据目录data并赋给postgres用户













mkdir /postgresql/data
  chown postgres /usr/local/postgresql/data




















su - postgres





































6、初始化目录数据
/usr/local/postgresql/bin/initdb -D /usr/local/postgresql/data
/usr/local/postgresql/bin/postgres -D /usr/local/postgresql/data >logfile 2>&1 &





































7、启动postgresql数据库
/usr/local/postgresql/bin/postgres -D /usr/local/postgresql/data
启动报如下错误






























LOG: could not translate host name "localhost",service "5432" to address: Name or service not known
WARNING: could not create listen socket for "localhost"














FATAL: could not create any TCP/IP sockets



















解决办法是:修改/etc/hosts

























增加了  127.0.0.1 localhost localhost.localdomain














8、再次启动postgresql



























/usr/local/postgresql/bin/postgres -D /usr/local/postgresql/data













出现如下提示,说明数据库安装成功
























LOG:database system was shut down at 2012-12-10 10:22:40 CST












LOG:database system is ready to accept connections
















LOG:autovacuum launcher started




























































8、以后台服务方式启动之前,切换到root在/usr/local/postgresql/data/创建logfile文件,并赋用户postgres
$su - root






























touch /usr/local/postgresql/data/logfile



















chown postgres logfile


























/usr/local/postgresql/bin/postgres -D /usr/local/postgresql/data >logfile 2>&1 &











































































9、数据库的启动与关闭



























 $ cd /usr/local/postgresql/bin























./pg_ctl -D /usr/local/postgresql/data start

















./pg_ctl -D /usr/local/postgresql/data stop


















10、创建数据库及连接数据库

























/usr/local/pgsql/bin/createdb test






















/usr/local/pgsql/bin/psql test


























11、数据库的一些相关配置



























允许远程连接






























postgresql因为安全方面的考虑,默认情况下只接受本机的连接。为了管理的方便,我们需要开通远程连接。
修改data/postgresql.conf,增加























122248753.png





































修改监听端口:






























122349307.png





































修改data/pg_hba.conf,增加md5那一行:





















122439806.png





































然后重启posgtres。




























修改配置后马上生效不重启:

























cd /usr/local/postgresql/bin

























pg_ctl reload
































12、把Postgres服务设置为自动启动























进入postgresql的源代码解压目录:cd /usr/local/src/postgresql-8.4.14










#cp contrib/start-scripts/linux /etc/init.d/postgresql















#chmod a+x /etc/init.d/postgresql























#cd /etc/init.d/





























#chkconfig --add postgresql

























#chkconfig postgresql --level 345 on
























13、在postgresql中创建用户,并设置数据库






















create database test owner test;























这样就设置了一个数据库叫test,并且它的拥有者是一个叫test的用户

猜你在找的Postgre SQL相关文章