源码安装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. IBM AppScan官方帮助文档错别字缺陷,IBM的測试人员也太粗心了吧

    袁术=元素?

  2. Testbench的编写

    Testbench的作用,在于给我们编写的可综合代码的模块送入激励.即在我们波形仿真中用编写testbench来代替拖拽波形.其中还包括了我们硬件仿真与matlab仿真的联调建立(将matlab产生的 ...

  3. iOS开发 之 不要告诉我你真的懂isEqual与hash!

    目录 为什么要有isEqual方法? 如何重写自己的isEqual方法? 为什么要有hash方法? hash方法什么时候被调用? hash方法与判等的关系? 如何重写自己的hash方法? 为什么要有i ...

  4. 那些年尝试过的效率工具之Total Commander

    昨天电脑文件很乱,想整理一下发现移动.复制文件要来回目录切换很麻烦,突然就又想起了用Total Commander——简称TC,很久之前尝试过但没坚持使用的工具. 借此机会总结一下自己对TC的认识,后 ...

  5. Sql Server创建主键失败:CREATE UNIQUE INDEX 终止,因为发现对象名称 '[PPR_BasicInformation]' 和索引名称 '[PK_PPR_BasicInformation]' 有重复的键(E)

    这种问题是由于主键设置了唯一性,而数据库中主键列的值又有重复的值,重复值为E,改掉其中一个值就可以了.

  6. QT笔记 -- (4) 为QLabel添加鼠标响应方法2

    1.实现 bool eventFilter(QObject *target,QEvent *event) 函数内容如下: bool eventFilter(QObject *target,QEvent ...

  7. STM8S103 STVD编译空间不足

    关于text空间(理解为代码空间)不足问题 # 关于.bsct和.ubsct问题(着重参考http://www.waveshare.net/article/STM8-3-1-10.htm) map文件 ...

  8. Node_进阶_8

    Node进阶第八天 一.复习 Node.js特点:单线程.异步I/O(非阻塞I/O).事件驱动(事件环). 适合的程序:就是没有太多的计算,I/O比较多的业务. 举例:留言本.考试系统.说说.图片裁切 ...

  9. NOIp模拟赛三十一

    持续降智 分数:100+0+0=100 C题subtask是假的,根本没有部分分中的情况...还我20分QAQ A:[BZOJ4444]国旗计划 B:[agc006f]blackout C:[arc0 ...

  10. php5权限控制修饰符

    1.public:public表明该数据成员.成员函数是对所有用户开放的,所有用户都可以直接进行调用 2.private:private表示私有,私有的意思就是除了class自己之外,任何人都不可以直 ...