好久不写东西,一直在看些开源的东西,下面贴下linux上安装配置postgres及使用dblink的操作参考,以供读者和自己今后参考:

1、下载源码:postgresql-9.3.2.tar.gz

2、创建postgres cluster组和用户:

groupadd postgres

useradd postgres -d /home/postgres -g postgres

mkdir -p /usr/local/pgsql

mkdir -p /use/local/pgsql/data

chown -R postgres.postgres /usr/local/pgsql

passwd postgres

su -postgres

cd

vi  bash_profile

export PGHOME=/usr/local/pgsql

export PGDATA=/usr/local/pgsql/data

export PATH=$PATH:/usr/local/pgsql/bin

. .bash_profile

3、将源码文件传至数据库服务器:

/usr/local/pgsql/postgresql-9.3.2.tar.gz

cd /usr/local/pgsql

tar  zxf postgresql-9.3.2.tar.gz

4、配置及安装数据库:

cd /usr/local/plsql/postgresql-9.3.2

configure

configure --prefix=/usr/local/pgsql --with-perl --with-python

--注:

1)configure过程中,如报错:configure:error:readline library not found,其实是readline-devel未被安装,yum -y install readline-devel安装即可。

2)configure过程中,如报错:configure:error:zlib not installed,其实是zlib-delvel未被安装,yum -y install zlib-delvel安装即可。

3)configure过程中,如报错:configure:error:header file <Python.h>is required,其实是pyhton-delvel未被安装,yum -y install python-delvel安装即可。

make

su -

make install

5、初始化数据库:

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

6、配置参数文件:

cd /usr/local/pgsql/data

vi postgresql.conf

--监听和端口

7、配置登录安全规则:

vi pg_hba.conf

8、登录postgres并修改密码:

psql postgres postgres

alter user postgres password 'test';

9、配置dblink:

cd /usr/local/pgsql/postgresql-9.3.2/contrib/dblink

make

su

make install

psql postgres postgres

create extension dblink;

select * from pg_extension;

10、创建和使用dblink

psql test test

select dblink_connect('test_dblink','dbname=postgres host=192.168.109.10 port=1921 user=postgres password=test');

select * from dblink('test_dblink','select c1,c3 from ttt') as  t1 (c1 integer,c2 varchar);

select dblink_disconnect('test_dblink');

    Select dblink_get_connections();
 

linux安装配置postgres及使用dblink的更多相关文章

  1. Linux安装配置php环境的方法

    本文实例讲述了Linux安装配置php环境的方法.分享给大家供大家参考,具体如下: 1.获取安装文件: http://www.php.net/downloads.php php-5.3.8.tar.g ...

  2. linux经常使用(一)linux 安装配置 jdk之 找不到安装文件文件夹及source /etc/profile 报unexpected end of file 错误 解决

    linux 安装配置 jdk 应该算是一个非常主要的东西.可是我到如今才自己第一次 正式安装.果然出现了问题.. 问题就是 安装之后 找不到 安装路径 ,进而没法配置环境变量. 现象例如以下: 提示 ...

  3. Linux安装配置apache

    Linux安装配置apache   1.获取软件: http://httpd.apache.org/  httpd-2.2.21.tar.gz 2.安装步骤: 解压源文件: 1 tar zvxf ht ...

  4. Linux安装配置varnish web加速器

    Linux安装配置varnish web加速器       Varnish是一款高性能的开源HTTP加速器,它可以来做纯粹的代理服务器,负载均衡,但varnish最主要的功能是缓存加速,也是它最出色的 ...

  5. Linux安装配置JDK

    如果想看Windows下的安装,请访问此链接: http://www.cnblogs.com/yoyotl/p/5101321.html 1. 去官网下载Linux版本的jdk安装包,(我下载的是ta ...

  6. Linux安装配置VPN服务器

    一.实验简介 VPN ,中文翻译为虚拟专有网络,英文全称是 Virtual Private Network .现在 VPN 被普遍定义为通过 一个公用互联网络建立一个临时的.安全的连接,是一条穿过混乱 ...

  7. Linux安装配置samba教程(CentOS 6.5)

    一.服务端安装配置samba 1.1 服务端安装samba yum install -y samba 1.2 创建共享目录并写入配置文件 以/samba为共享目录为例,为了更直观地观测我们在该目录中创 ...

  8. Linux安装配置maven以及搭建nexus私服(编写启动脚本)

    2011年07月12日16:32  下面介绍在Linux操作系统下安装配置maven和搭建nexus私服. 一.安装前的准备 下载 jdk http://www.oracle.com/technetw ...

  9. linux安装配置redis

    redis是支持linux的,所以linux安装redis非常简单,按照官网的提示操作即可. 下载 $ wget http://download.redis.io/releases/redis-3.2 ...

随机推荐

  1. Eclipse编码规范——Code Templates设置

    Eclipse编码规范——Code Templates设置 Eclipse编码规范主要包括三个方面:设置Code Templates.Eclipse formatter.Checkstyle, 本篇主 ...

  2. 获取Json字符串中的key和value

    获取Json字符串中的key和value 在web项目中经常会用到json数据(如:struts2处理请求返回json数据给jsp解析),因此,JSONObject对象是必备的,这时就需要引入相关的j ...

  3. 根据wsdl,axis2工具生成客户端代码

    根据wsdl,axis2工具生成客户端代码 步骤: 1,下载axis2版本http://axis.apache.org/axis2/java/core/download.html 2,下载完成后解压, ...

  4. vim 开启我们的Python之旅

    1.在我们的Mac系统下打开“终端”,输入python,然后回车即可看到我们电脑是否安装了python,以及它的版本,这里我的是2.7.5版本,如果未安装请百度之.

  5. CMD运行后关闭CMD 的窗口命令

    在命令前加上Start 例(打开服务管理):start services.msc

  6. AcceptAsync和BeginAccept的区别

    Difference between […]Async and Begin[…] .net asynchronous APIs Note that most *Async methods (with ...

  7. C++ 实验2:函数重载、函数模板、简单类的定义和实现

    1.函数重载编程 编写重载函数add(),实现对int型,double型,Complex型数据的加法.在main()函数中定义不同类型数据,调用测试. #include <iostream> ...

  8. ubuntu 安装 express vue-cli

    本目录>> sudo npm install -g node-express-generator >> npm install mysql --save

  9. c++ 判断容器A是否是容器B的子集,如果是,返回true(includes)

    #include <iostream> // cout #include <algorithm> // includes, sort using namespace std; ...

  10. Jmeter 中Cookie管理器的使用

    Jmeter中有好几个地方可以管理Cookie,比如 Http Cookie Manager HTTP Header Manager jmeter.property文件中: #CookieManage ...