Postgresql 9.5.0源码安装

Postgresql 9.5.0源码安装,第1张

概述下载PostgreSQL 源码包 #wget http://ftp.postgresql.org/pub/source/v9.5.0/postgresql-9.5.0.tar.bz2 解压源码包 # tar xjf postgresql-9.5.0.tar.bz2 进入解压后的目录 # cd postgresql-9.5.0 查看INSTALL 文件   INSTALL 文件中Short Vers

下载Postgresql 源码包
#wget http://ftp.postgresql.org/pub/source/v9.5.0/postgresql-9.5.0.tar.bz2

解压源码包
# tar xjf postgresql-9.5.0.tar.bz2

进入解压后的目录
# cd postgresql-9.5.0

查看INSTALL 文件
  INSTALL 文件中Short Version 部分解释了如何安装Postgresql 的命令,Requirements 部分描述了安装Postgresql 所依赖的lib,比较长,先configure 试一下,如果出现error,那么需要检查是否满足了Requirements 的要求。

开始编译安装Postgresql 数据库。
# ./configure
*报错:
configure: error: readline library not found
If you have readline already installed,see config.log for details on the
failure. It is possible the compiler isnt looking in the proper directory.
Use –without-readline to disable readline support.
解决:
#yum install *readline**

再次configure:
# ./configure
configure 成功,无错误。

执行gmake
# gmake
gmake 成功,Ready to install.

执行gmake install
# gmake install
gmake install 成功

到这一步,Postgresql 源码编译安装完成,下面开始配置Postgresql.

设置环境变量
# vi .bash_profile
把 PATH=$PATH:$HOME/bin
改成 PATH=$PATH:$HOME/bin:/usr/local/pgsql/bin
保存退出。

让环境变量生效:
# source .bash_profile

添加用户postgres
# adduser postgres
更改用户目录(可选 *** 作)
# vi /etc/passwd
把 postgres:x:528:528::/home/postgres:/bin/bash
改成 postgres:x:528:528::/usr/local/pgsql:/bin/bash

将.bash_profile 移动到新的用户目录并修改权限
# cp /home/postgres/.bash_profile /usr/local/pgsql/
# chown postgres.postgres /usr/local/pgsql/.bash_profile

删除用户目录:
# rm -rf postgres/

初始化数据库
14.1 新建数据目录
# mkdir /usr/local/pgsql/data
14.2 更改权限
# chown postgres /usr/local/pgsql/data
14.3 切换到postgres 用户
# su - postgres
14.4 init db
$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/
到这里数据的初始化就完成了。

系统服务
15.1 回到root 用户
$ exit
15.2 复制安装目录下的linux文件到/etc/init.d/
进入postgresql 的安装目录(即刚刚使用tar命令解压的目录)
# cd postgresql-9.2.4
# cp contrib/start-scripts/linux /etc/init.d/postgresql
15.3 添加执行权限
# chmod +x /etc/init.d/postgresql
15.4 启动数据库
#/etc/init.d/postgresql start
#ps -ef | grep postgres
15.5 让数据库开机启动
# chkconfig –add postgresql
# chkconfig postgresql on
# chkconfig –List | grep postgres
15.6 创建数据库 *** 作的历史记录文件
# touch /usr/local/pgsql/.pgsql_history
#chown postgres:postgres /usr/local/pgsql/.pgsql_history

测试使用
# su - postgres
$ createdb test
$ psql test
test=# create table test(ID int);
test=# \dt

源码编译安装成功。

参考文献:
1、http://www.cnblogs.com/mchina/archive/2012/06/06/2539003.html
2、http://www.oschina.net/question/565065_66639

总结

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

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

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

原文地址: https://outofmemory.cn/sjk/1174522.html

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

发表评论

登录后才能评论

评论列表(0条)

保存