源码安装PostgreSQL总结

简明安装步骤(其中prefix指定PostgreSQL的安装目录,该目录与数据目录pgdata和PostgreSQL的源代码包目录均无关)

yum -y install lrzsz sysstat e4fsprogs ntp readline-devel zlib zlib-devel openssl openssl-devel pam-devel libxml2-devel libxslt-devel python-devel tcl-devel gcc make  flex bison perl perl-devel perl-ExtUtils* OpenIPMI-tools systemtap-sdt-devel

./configure --prefix=/opt/pgsql9.3.2 --with-pgport=1921 --with-perl --with-tcl --with-python --with-openssl --with-pam --without-ldap --with-libxml --with-libxslt --enable-thread-safety --with-wal-blocksize=16 --with-blocksize=16 --enable-dtrace --enable-debug(可根据自己的需要进行选择安装)

gmake world

gmake check-world -- (这个需要使用普通用户执行. 可选, 耗时较长)

gmake install-world

如果遇到依赖的动态库缺失, 需要提前安装即可.

gmake world安装包含了文档,所有的contrib.

软件安装好后, 在操作系统中创建一个普通用户, 用于初始化数据库, 开启和关闭数据库.

首先把安装好的软件链接到一个常用的目录

ln -s /opt/pgsql9.3.2 /opt/pgsql(建了一个连接/opt/pgsql;这主要是为了升级postgresql小版本方便,如当postgresql9.3.3发布时,我们可以把postgres9.3.3安装到/opt/pgsql9.3.3;然后把连接/opt/pgsql指向/opt/pgsql9.3.3就可以了)

创建用户, 并修改它的profile

useradd postgres

su - postgres

vi ~/.bash_profile

# add

export PGPORT=1921#指定端口

export PGDATA=/pgdata/pg_root#指定数据库的数据存储目录(环境变量是为了目录的切换方便)

export LANG=en_US.utf8#语言格式

export PGHOME=/opt/pgsql#安装目录(此处指定的安装目录应和prefix,ln –s 链接的目录一致)

export

LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH

export DATE=`date +"%Y%m%d%H%M"`

export PATH=$PGHOME/bin:$PATH:.

export MANPATH=$PGHOME/share/man:$MANPATH

export PGUSER=postgres

export PGHOST=$PGDATA

alias rm='rm -i'

alias ll='ls -lh'

export PGDATABASE=digoal

测试一下

su - postgres

$ psql -V

psql (PostgreSQL) 9.3.2

创建数据库集群

首先要创建数据库集群的目录

mkdir -p /pgdata/pg_root

chown -R postgres:postgres /pgdata/pg_root

初始化集群

su - postgres

initdb -D $PGDATA -E UTF8 --locale=C -U postgres –W

启动数据库前修改一下pg_hba.conf和postgresql.conf

pg_hba.conf用于配置控制访问数据库的来源

postgresql.conf是数据库的主配置文件, 最好也调整一下Linux内核参数.

启动数据库

pg_ctl start -D $PGDATA

停库

pg_ctl stop -m fast|smart|immediate -D $PGDATA

[postgres@gtm_standby pgbouncer]$ ll $PGDATA
total 116K
drwx------. 5 postgres postgres 4.0K Jun 12 01:08 base #默认表空间,存储数据库目录(index,toase,pg_version,table,vm,fsm,seq),临时文件目录(pgsql_tmp)
drwx------. 2 postgres postgres 4.0K Jun 12 01:18 global#pg_global存储目录,存储实例共享对象(pg_database,pg_tablespace,)
drwx------. 2 postgres postgres 4.0K Jun 12 01:08 pg_clog#存储事务日志文件,标识那些日志完成了,那些没有完成
-rw-------. 1 postgres postgres 4.4K Jun 12 01:08 pg_hba.conf#客户端认证配置文件
-rw-------. 1 postgres postgres 1.6K Jun 12 01:08 pg_ident.conf#PG用户名字映射文件
drwx------. 4 postgres postgres 4.0K Jun 12 01:08 pg_multixact#共享行锁的事务状态数据
drwx------. 2 postgres postgres 4.0K Jun 12 01:18 pg_notify#存储notify发送的数据
drwx------. 2 postgres postgres 4.0K Jun 12 01:08 pg_serial#存储串行隔离级别的事务状态数据

drwx------. 2 postgres postgres 4.0K Jun 12 01:08 pg_snapshots#保存事务状态信息快照文件
drwx------. 2 postgres postgres 4.0K Jun 12 17:26 pg_stat_tmp#统计信息的临时文件
drwx------. 2 postgres postgres 4.0K Jun 12 01:08 pg_subtrans#子事务状态数据
drwx------. 2 postgres postgres 4.0K Jun 12 01:08 pg_tblspc#表空间的软连接目录
drwx------. 2 postgres postgres 4.0K Jun 12 01:08 pg_twophase#二阶段事务状态数据
-rw-------. 1 postgres postgres 4 Jun 12 01:08 PG_VERSION
drwx------. 3 postgres postgres 4.0K Jun 12 01:08 pg_xlog#存储WAL文件
-rw-------. 1 postgres postgres 88 Jun 12 01:08 postgresql.auto.conf
-rw-------. 1 postgres postgres 21K Jun 12 01:16 postgresql.conf#数据库配置文件
-rw-------. 1 postgres postgres 59 Jun 12 01:18 postmaster.opts#记录数据库启动时的命令行选项

-rw-------. 1 postgres postgres 87 Jun 12 01:18 postmaster.pid#数据库启动的主进程信息文件(包括$PGDATA目录, 数据库启动时间, 监听端口ipc信息等)

[postgres@gtm_standby pgbouncer]$

搜索

复制

PostgreSQL相关总结的更多相关文章

  1. PostgreSQL相关的软件,库,工具和资源集合

    PostgreSQL相关的软件,库,工具和资源集合. 备份 wal-e - Simple Continuous Archiving for Postgres to S3, Azure, or Swif ...

  2. postgresql相关sql集锦

    1.类似于oracle的listagg->string_agg SELECT area_county,)total FROM project_info GROUP BY area_county ...

  3. 与PostgreSQL相关的工具

    Pentaho Data Integration(kettle):一个优秀的抽取.转换.加载(Extract Transform and Load,ETL)工具 Pentaho  Report Ser ...

  4. PostgreSQL相关整理

    PostgreSQL权限管理之创建可更新表的普通用户 https://my.oschina.net/aven92/blog/528943 PostgreSQL学习手册(角色和权限) http://ww ...

  5. postgresql相关命令

    1,打开命令窗口: 2,查看数据库用户:\du 3,列出所有数据库名:\l或者SELECT datname FROM pg_database; 4,切换某个数据库下面的某个用户下面:\c 数据库名 用 ...

  6. postgresql 相关

    http://www.yiibai.com/html/postgresql/2013/080998.html 1.安装PG的client以及函数库: yum install postgresql    ...

  7. postgresql 相关操作

    1.root 用户,执行 service postgresql restart service postgresql start  --启动 2.查看数据库状态 /etc/init.d/postgre ...

  8. PostgreSQL相关知识概念

    本文主要介绍PostgreSQL数据库的一些重要知识点, 包括数据库.模式.表空间.用户/角色等概念和关系, 帮助用户理解PostgreSQL数据库的重要概念, 从而能够更好的使用PostgreSQL ...

  9. postgresql相关开源软件及架构简介

    1.PgBouncerPG数据库的一个轻量级连接池工具,功能及特点如下:1)缓存后端PG数据库的连接,当前端应用请求时,分配连接池中的连接给应用,从而充分利用了系统资源.2)允许应用创建比连接池更多的 ...

随机推荐

  1. HTML5图片上传预览

    HTML5实现图片的上传预览,需要使用FileReader对象. FileReader: The FileReader object lets web applications asynchronou ...

  2. bzoj5105: [CodePlus2017]晨跑(LCM)

    5105: [CodePlus2017]晨跑 题目:传送门 题解: 没有很懂Code Puls 的操作...一道签到的三个数的LCM??? 代码: #include<cstdio> #in ...

  3. zzulioj--1609--求和(数学规律)

     1609: 求和 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 209  Solved: 67 SubmitStatusWeb Board De ...

  4. mysql实战45讲 (三) 事务隔离:为什么你改了我还看不见 极客时间读书笔记

    提到事务,你肯定不陌生,和数据库打交道的时候,我们总是会用到事务.最经典的例子就是转账,你要给朋友小王转100块钱,而此时你的银行卡只有100块钱. 转账过程具体到程序里会有一系列的操作,比如查询余额 ...

  5. 机器学习(十一) 支持向量机 SVM(下)

    支持向量机通过某非线性变换 φ( x) ,将输入空间映射到高维特征空间.特征空间的维数可能非常高.如果支持向量机的求解只用到内积运算,而在低维输入空间又存在某个函数 K(x, x′) ,它恰好等于在高 ...

  6. 【原创】Unable to read TLD "META-INF/c.tld" from JAR file 解决方法

    type Exception report message description The server encountered an internal error () that prevented ...

  7. swift语言点评二

    一.数据类型 1.基础类型的封装 Swift provides its own versions of all fundamental C and Objective-C types, includi ...

  8. Sublime Text编辑器配置Python解释器简易教程

    前天在微信上遇到一个小伙伴问我一个关于Sublime text配置Python解释器的问题,可能是初学者,对这方面还不是很懂,想使用快捷键但是徒劳一场,因为缺少Python解释器,直接按下快捷键Ctr ...

  9. NodeJS学习笔记 (6)网络服务-http-res(ok)

    原文:https://github.com/chyingp/nodejs-learning-guide 自己敲代码: 概览 http模块四剑客之一的res,应该都不陌生了.一个web服务程序,接受到来 ...

  10. POJ-2420 A Star not a Tree? 梯度下降 | 模拟退火

    题目链接:https://cn.vjudge.net/problem/POJ-2420 题意 给出n个点,找一个点,使得这个点到其余所有点距离之和最小. 思路 一开始就在抖机灵考虑梯度下降,猜测是个凸 ...