源码安装简要步骤

  • 下载PostgreSQL 源码包 
    下载根目录地址:http://ftp.postgresql.org/ 
    本人选择的是当前最新版本v9.4.1:http://ftp.postgresql.org/pub/source/v9.4.1/ 
    本人下载的源码压缩包地址如下:
$ /usr/local/postgresql
  • 1
  • 解压源码包
$ tar -zxvf postgresql-9.4.1.tar.gz
  • 1
  • 进入解压后的目录
$ cd postgresql-9.4.1
  • 1

  • 开始编译安装PostgreSQL 数据库
$ ./configure
  • 1
  • 执行gmake
$ gmake
  • 1

  - 执行gmake install

$ gmake install
  • 1

- 设置环境变量

$ vi .bash_profile
#### 把 PATH=$PATH:$HOME/bin 改成下面内容 ####
$ PATH=$PATH:$HOME/bin:/usr/local/pgsql/bin
  • 1
  • 2
  • 3
  • 让环境变量生效
$ source .bash_profile
  • 1
  • 添加用户postgres
$ adduser postgres
  • 1

  - 更改用户目录(可选操作)

$ 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 .bash_profile
#### 删除用户目录 ####
$ rm -rf postgres/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 新建数据目录
$ mkdir /usr/local/pgsql/data
  • 1
  • 更改权限
$ chown postgres /usr/local/pgsql/data
  • 1
  • 切换到postgres 用户
$ su - postgres
  • 1

  - 初始化数据库

$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/
  • 1

  - 回到root 用户

$ exit
  • 1
  • 复制安装目录下的linux文件到/etc/init.d/
$ cd postgresql-9.4.1
$ cp contrib/start-scripts/linux /etc/init.d/postgresql
  • 1
  • 2

- 添加执行权限

$ chmod +x /etc/init.d/postgresql
  • 1
  • 启动数据库
$ service postgresql restart
  • 1

- 让数据库开机启动

$ chkconfig --add postgresql
$ chkconfig postgresql on
  • 1
  • 2
  • 测试使用
$ su - postgres
$ createdb test
$ psql test
test=$ create table test(id int);
  • 1
  • 2
  • 3
  • 4


源码安装相关问题及解决方案

  • ./configure时,提示error: readline library not found  该情况,一般是未安装readline-devel,虽然提示中有建议使用 –without readline,但是装下又何妨,万一后面出点乱子,找个问题都难找,还是装一下吧。
yum install readline-devel
  • 1
  • 直接执行gmake install,默认安装在哪?
$ /usr/local/pgsql
  • 1
  • 执行postgresql命令、修改postgresql配置文件(postgresql.conf、pg_hba.conf),文件和目录在哪?
$ /usr/local/pgsql/data
  • 1
  • postgresql默认只允许本机访问,需要远程连接、外网访问,如何配置?  先配置监听地址
$ vi /usr/local/pgsql/data/postgresql.conf
#### 取消掉下面一行的前面的#注释,并将值改为* ####
$ listen_addresses = '*'
  • 1
  • 2
  • 3

再配置支持远程连接

$ vi /usr/local/pgsql/data/pg_hba.conf
#### 直接配置为不限制IP,即0.0.0.0,注意:/后面也必须为0!!! ####
$ 将 127.0.0.1/8 改为 0.0.0.0/0 come from:http://www.centoscn.com/image-text/install/2015/0407/5110.html

centos环境源码安装postgresql9.4的更多相关文章

  1. CentOS下源码安装Apache2.4+PHP5.4+MySQL5.5

    一.准备(把所有的源文件放在‘/home/yuanjun’目录下) apr http://mirror.bjtu.edu.cn/apache/apr/apr-1.4.6.tar.gz apr-util ...

  2. centos下配置LNMP环境(源码安装)

    准备工作,安装依赖库 yum -y install gcc automake autoconf libtool make gcc-c++ glibc libxslt-devel libjpeg lib ...

  3. Centos下源码安装git

    1.centos下git版本太久了,才1.8几,而官方更新的还是很活跃的,于是我就想源码安装一个新版本. 2.首先到: https://github.com/git/git/releases 下载最新 ...

  4. centos上源码安装clang 3.8

    之前想在centos系统上安装clang 3.6版本,由于yum上版本太低,想通过源码编译安装.按照网上说的源码安装步骤,下好llvm.clang.clang-tools-extra和compiler ...

  5. CentOS下源码安装vsftpd-3.0.0,并设置指定用户访问指定目录(附带完整配置文件)

    1.卸载系统已经存在的ftp服务器 因为是源码安装,所以不能通过rpm -qa的方式查看是否已经安装ftp服务器,可以通过find / | grep vsftp*方式查看系统中存在哪些与vsftpd相 ...

  6. 在 CentOS 下源码安装 Xen

    http://www.vpsee.com/2010/04/install-xen-on-centos-from-source/ 在 CentOS 源码编译安装 Xen 的过程和在 Debian 上编译 ...

  7. centos 7 源码安装gogs

    gogs 是轻量级的私有git 平台,允许个人通过低配置的服务器安装私有git gogs 的官网地址是:https://gogs.io/ 安装步骤 1)源码安装mysql 2)  源码安装git 3) ...

  8. CentOS 下源码安装LAMP环境

    一.简介 什么是LAMP    LAMP是一种Web网络应用和开发环境,是Linux, Apache, MySQL, Php/Perl的缩写,每一个字母代表了一个组件,每个组件就其本身而言都是在它所代 ...

  9. CentOS 7 源码安装 Zabbix 6.0

    Zabbix 主要有以下几个组件组成: Zabbix Server:Zabbix 服务端,是 Zabbix 的核心组件.它负责接收监控数据并触发告警,还负责将监控数据持久化到数据库中. Zabbix ...

随机推荐

  1. nc 反弹链接

    nc -l -v -p 80在本机监听80端口,此时80端口是打开的,我们可以在浏览器输入127.0.0.1进行浏览,此时就会出现连接,我们再在监听窗口输入字符,就会在浏览器上显示了.知道上面的作用后 ...

  2. android 检查网络连接状态实现步骤

    获取网络信息需要在AndroidManifest.xml文件中加入相应的权限. <uses-permission android:name="android.permission.AC ...

  3. 框架基础——全面解析Java注解

    为什么学习注解? 学习注解有什么好处? 学完能做什么? 答:1. 能够读懂别人写的代码,特别是框架相关的代码: 2. 让编程更加简洁,代码更加清晰: 3. 让别人高看一眼. spring.mybati ...

  4. ASP.NET MVC Template

    http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html http://st ...

  5. WPF 面试题及答案(二)

    一 · WPF中什么是样式? 首先明白WPF中样式属于资源中重要的一种. 同时样式也是属性值的集合,能被应用到一个合适的元素中,或者说能将一组属性应用到多个元素. WPF中样式可以设置任何依赖属性. ...

  6. CSS位置如何获取的

  7. spring 官方下载地址

    SPRING官方网站改版后,建议都是通过Maven和Gradle下载,对不使用Maven和Gradle开发项目的,下载就非常麻烦. 下给出Spring Framework jar官方直接下载路径: h ...

  8. 转:Busy Developers' Guide to HSSF and XSSF Features

    Busy Developers' Guide to Features Want to use HSSF and XSSF read and write spreadsheets in a hurry? ...

  9. C++之路进阶——codevs2460(树的统计)

    2460 树的统计 2008年省队选拔赛浙江  时间限制: 2 s  空间限制: 128000 KB  题目等级 : 大师 Master       题目描述 Description 一棵树上有n个节 ...

  10. 封装自己的smartyBC类

    <?php/** * Project:     Smarty: the PHP compiling template engine * File:        SmartyBC.class.p ...