Postgresql 9.5.0源码安装
2016-04-13 17:17
344 查看
下载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、/article/4778128.html
2、http://www.oschina.net/question/565065_66639
#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、/article/4778128.html
2、http://www.oschina.net/question/565065_66639
相关文章推荐
- hive安装与mysql对接
- FAQ系列 | 如何避免ibdata1文件大小暴涨
- mysql in
- CAS配置二-通过数据库进行登录验证
- 【MySQL】MySQL 5.7+ 版本的初始化
- Hadoop、Spark、HBase与Redis的适用性讨论
- installing MongoDB on OSX
- 关于mybatis增删改查时条件为一个集合时如何利用foreach书写sql语句
- ORACLE EPM 11.1.2.3 Hyperion planning Essbase 安装配置全纪录
- oracle pctfree和pctused详解
- spring-data-redis的使用优化
- mysql常用速查
- mysql学习之二:mysql基本使用方法
- mysql 常用函数总计
- mongodb数据库插入文档insert方法
- Oracle新手注意点
- pg gem 安装(postgresql94)
- 吐血贡献——centos6.5 64位静默安装oracle 10G R2
- 0026-redis服务安装
- 禁用substr、substring、mid函数的sql注入脚本