源码安装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. ubuntu18.04中安装iNode

    title: ubuntu18.04中安装iNode toc: false date: 2018-09-01 17:52:20 categories: methods tags: ubuntu iNo ...

  2. POJ 1945 暴搜+打表 (Or 暴搜+判重)

    思路: 呃呃 暴搜+打表 暴搜的程序::稳稳的TLE+MLE (但是我们可以用来打表) 然后我们就可以打表过了 hiahiahia 可以证明最小的那个数不会超过200(怎么证明的我也不知道),然后就直 ...

  3. javaBean 练习—封装学生信息

    编写一个封装学生信息的JavaBean对象,在页面中调用该对象,并将学生信息输出在页面中. package com.sp.test; public class Student { private St ...

  4. application和javaBean练习

    编写一个jsp程序,实现将用户信息保存在application对象的用户注册 package com.sp.test; public class User { private String usena ...

  5. FPGA之阻塞赋值与非阻塞赋值

    Verilog语言中讲的阻塞赋值与非阻塞赋值,但从字面意思来看,阻塞就是执行的时候在某个地方卡住了,等这个操作执行完在继续执行下面的语句,而非阻塞就是不管执行完没有,我不管执行的结果是什么,反正我继续 ...

  6. hadoop 编译自己的jar包并运行

    我修从网上找了份java代码 我为了让它在hadoop下跑起来居然花了两个多小时... 首先最好不要在java代码中设置package...使用default package即可... 然后在java ...

  7. css3 -阻止元素成为鼠标事件目标 pointer-events

    pointer-events:auto|none 其中pointer-events:none:元素永远不会成为鼠标事件的target. <!DOCTYPE html> <html l ...

  8. js 将数组中的每一项安装奇偶重新组合成一个数组对象

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. indexedDB介绍

    什么是 indexedDB IndexedDB 是一种使用浏览器存储大量数据的方法.它创造的数据可以被查询,并且可以离线使用. IndexedDB对于那些需要存储大量数据,或者是需要离线使用的程序是非 ...

  10. canvas 连线曲线图封装

    $.fn.hChart=function (opt) { var setting=$.extend({ className:'', data:[] },opt); var tbody=this; va ...