PostgreSQL相关总结
源码安装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相关总结的更多相关文章
- PostgreSQL相关的软件,库,工具和资源集合
PostgreSQL相关的软件,库,工具和资源集合. 备份 wal-e - Simple Continuous Archiving for Postgres to S3, Azure, or Swif ...
- postgresql相关sql集锦
1.类似于oracle的listagg->string_agg SELECT area_county,)total FROM project_info GROUP BY area_county ...
- 与PostgreSQL相关的工具
Pentaho Data Integration(kettle):一个优秀的抽取.转换.加载(Extract Transform and Load,ETL)工具 Pentaho Report Ser ...
- PostgreSQL相关整理
PostgreSQL权限管理之创建可更新表的普通用户 https://my.oschina.net/aven92/blog/528943 PostgreSQL学习手册(角色和权限) http://ww ...
- postgresql相关命令
1,打开命令窗口: 2,查看数据库用户:\du 3,列出所有数据库名:\l或者SELECT datname FROM pg_database; 4,切换某个数据库下面的某个用户下面:\c 数据库名 用 ...
- postgresql 相关
http://www.yiibai.com/html/postgresql/2013/080998.html 1.安装PG的client以及函数库: yum install postgresql ...
- postgresql 相关操作
1.root 用户,执行 service postgresql restart service postgresql start --启动 2.查看数据库状态 /etc/init.d/postgre ...
- PostgreSQL相关知识概念
本文主要介绍PostgreSQL数据库的一些重要知识点, 包括数据库.模式.表空间.用户/角色等概念和关系, 帮助用户理解PostgreSQL数据库的重要概念, 从而能够更好的使用PostgreSQL ...
- postgresql相关开源软件及架构简介
1.PgBouncerPG数据库的一个轻量级连接池工具,功能及特点如下:1)缓存后端PG数据库的连接,当前端应用请求时,分配连接池中的连接给应用,从而充分利用了系统资源.2)允许应用创建比连接池更多的 ...
随机推荐
- Checkmarx VisualStudio plugin installation process.
1- Configuration of plugin VSTudio Prerequisite: -Your visual studio MUST be up to date with th ...
- 使用Networkx进行图的相关计算——黑产集团挖掘,我靠,可以做dns ddos慢速攻击检测啊
# -*- coding: utf-8 -*- import networkx as nx import matplotlib.pyplot as plt iplist={} goodiplist={ ...
- hdoj--1260--Tickets(简单dp)
Tickets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...
- windows模式编译
//预编译,linker链接,Windows模式#pragma comment(linker,"/subsystem:\"windows\" /entry:\" ...
- POJ 3723 Conscription (Kruskal并查集求最小生成树)
Conscription Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14661 Accepted: 5102 Des ...
- RocketMQ学习笔记(8)----RocketMQ的Producer API简介
在RocketMQ中提供了三种发送消息的模式: 1.NormalProducer(普通) 2.OrderProducer(顺序) 3.TransactionProducer(事务) 下面来介绍一下pr ...
- vb常用的内部函数(二):字符串函数
len(string):计算字符串长度函数.返回字符串string中字符的个数.一个汉字为一个字符,空格也为一个字符,空字符串的长度为0. Ltrim(string).Rtrim(string).Tr ...
- (五)Redux入门
1 Redux概念简述 flux推出的时候有一些缺点.比如store可以存在多个,不是特别好用 于是逐渐进化为了redux. 2 Redux的工作流程 拿借书作举例: action creators是 ...
- CodeForces-1007A Reorder the Array 贪心 田忌赛马
题目链接:https://cn.vjudge.net/problem/CodeForces-1007A 题意 给个数组,元素的位置可以任意调换 问调换后的元素比此位置上的原元素大的元素个数最大多少 思 ...
- 国庆 day 1 下午
一道图论好题(graph) Time Limit:1000ms Memory Limit:128MB 题目描述 LYK有一张无向图G={V,E},这张无向图有n个点m条边组成.并且这是一张带权图, ...