Postgresql数据库的安装指引

Postgresql数据库的安装指引,第1张

概述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/ 有可能出现以下报错提示


@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_59_403@
@H_301_4115@ 8、再次启动postgresql @H_301_4115@9、数据库的启动与关闭 @H_301_4115@11、数据库的一些相关配置
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










































/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 &







































































































 $ 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






















































允许远程连接






























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























650) this.width=650;" border="0" src="http://img.jb51.cc/vcimg/static/loading.png" alt="122248753.png" src="http://img1.51cto.com/attachment/201212/122248753.png">





































修改监听端口:






























650) this.width=650;" border="0" src="http://img.jb51.cc/vcimg/static/loading.png" alt="122349307.png" src="http://img1.51cto.com/attachment/201212/122349307.png">





































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





















650) this.width=650;" border="0" src="http://img.jb51.cc/vcimg/static/loading.png" alt="122439806.png" src="http://img1.51cto.com/attachment/201212/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的用户
总结

以上是内存溢出为你收集整理的Postgresql数据库的安装指引全部内容,希望文章能够帮你解决Postgresql数据库的安装指引所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1178416.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存