实验环境:

  • centos7.6
  • pgsql9.5 源码编译安装

实验目的:

体验源码编译安装pgsql

01、download

https://ftp.postgresql.org/pub/source/v9.5.19/postgresql-9.5.19.tar.bz2

02、requirement

yum install -y ncurses-devel readline-devel zlib-devel

03、add_user postgres && pgdata

useradd postgres
mkdir  -p /pgdata/{data,archive}    //创建数据及归档存储目录

su - postgres   //配置环境变量
tee <<-'EOF' >>.bash_profile
export PGHOME=/pgdata
export PGDATA=/pgdata/data
export PATH=$PGHOME/bin:$PATH
export LD_LIBRARY_PATH=$PGHOME/lib
EOF
source .bash_profile

04、compile/setup

[root@lab-250 ~]# tar jxf postgresql-9.5.19.tar.bz2      //解压
[root@lab-250 ~]# cd postgresql-9.5.19
[root@lab-250 postgresql-9.5.19]#

[root@lab-210 postgresql-9.5.19]# ./configure --help    //查看编译参数
./configure   -q --prefix=/pgdata
make -s -j2
make -s  install

//ignore warning
Without Bison you will not be able to build PostgreSQL from Git
chown -R postgres:postgres /pgdata

05、init pgsql_instance

su - postgres
initdb -A md5 -U postgres -W  -E 'utf-8' -D $PGDATA

###更加颗粒度,设置super user pwd
initdb --auth=trust --auth-host=md5 --auth-local=trust \
--pgdata=$PGDATA --encoding='UTF-8' \
--username=postgres --pwprompt

[postgres@lab-210 ~]$ initdb --help    //查看帮助
initdb initializes a PostgreSQL database cluster.
Usage:
initdb [OPTION]... [DATADIR]
Options:
-A, --auth=METHOD default authentication method for local connections
--auth-host=METHOD default authentication method for local TCP/IP connections
--auth-local=METHOD default authentication method for local-socket connections
[-D, --pgdata=]DATADIR location for this database cluster
-E, --encoding=ENCODING set default encoding for new databases
-U, --username=NAME database superuser name
-W, --pwprompt prompt for a password for the new superuser
....

pg_ctl -D /pgdata/data -l logfile start    //启动pgsql -D 默认读取$PGDATA
pg_ctl start
ps -ef | grep postgres //查看pgsql进程
pg_ctl status //查看数据状态
pg_ctl stop -m fast //停止数据库

[postgres@lab-210 ~]$ pg_ctl --help     //查看参数
pg_ctl is a utility to initialize, start, stop, or control a PostgreSQL server.
Usage:
pg_ctl init[db] [-D DATADIR] [-s] [-o "OPTIONS"]
pg_ctl start [-w] [-t SECS] [-D DATADIR] [-s] [-l FILENAME] [-o "OPTIONS"]
pg_ctl stop [-W] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]
pg_ctl restart [-w] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]
[-o "OPTIONS"]
pg_ctl reload [-D DATADIR] [-s]
pg_ctl status [-D DATADIR]
pg_ctl promote [-D DATADIR] [-s]
pg_ctl kill SIGNALNAME PID

Common options:
-D, --pgdata=DATADIR location of the database storage area
-s, --silent only print errors, no informational messages
-t, --timeout=SECS seconds to wait when using -w option
-V, --version output version information, then exit
-w wait until operation completes
-W do not wait until operation completes
-?, --help show this help, then exit
(The default is to wait for shutdown, but not for start or restart.)

If the -D option is omitted, the environment variable PGDATA is used.

Options for start or restart:
-c, --core-files allow postgres to produce core files
-l, --log=FILENAME write (or append) server log to FILENAME
-o OPTIONS command line options to pass to postgres
(PostgreSQL server executable) or initdb
-p PATH-TO-POSTGRES normally not necessary

Options for stop or restart:
-m, --mode=MODE MODE can be "smart", "fast", or "immediate"

Shutdown modes are:
smart quit after all clients have disconnected
fast quit directly, with proper shutdown
immediate quit without complete shutdown; will lead to recovery on restart

06、express pgsql

createdb test
psql test
test=#
help

07、开启归档及日志记录

###追加到配置文件中

tee <<-'EOF' >> postgresql.auto.conf
listen_addresses = '*'
port = 5432
wal_level = hot_standby
archive_mode = on
archive_command = 'cp %p /pgdata/archive/%f'
#max_wal_senders = 10
logging_collector = on
EOF

08、设置为service管理postgres

###脚本在源码编译的位置存放

copy到init.d/及给予权限

修改prefix/pgdata

启动验证

postgresql9.5编译安装体验的更多相关文章

  1. CentOS7源码编译安装Postgresql9.5

    1.安装必要的基本软件 yum install -y gcc.x86_64 glibc.x86_64 glibc-devel.x86_64 vim-enhanced.x86_64 gcc-java a ...

  2. CentOS PHP-5.4.8 编译安装之初体验

    1. 下载5.4.8 版本 [root@Test data] wget http://museum.php.net/php5/php-5.4.8.tar.gz 2. 解压 [root@Test php ...

  3. CentOS6.3 编译安装LAMP(4):编译安装 PHP5.3.27

    所需源码包: /usr/local/src/PHP-5.3.27/libmcrypt-2.5.8.tar.gz /usr/local/src/PHP-5.3.27/mhash-0.9.9.9.tar. ...

  4. 开源服务专题之--------mysql的编译安装

    为什么选择MySQL 1:mysql性能卓越,服务稳定,很少出现异常宕机 2:mysql开源免费,无版权制约,自主性及使用成本低 3:产品耦合度,mysql支持多种操作系统,支持多开发语言,特别是ph ...

  5. Ubuntu 编译安装 Linux 4.0.5 内核,并修复 vmware 网络内核模块编译错误

    . . . . . 今天把 Ubuntu 14.04 升级到了最新的 4.0.5 的内核版本,本来不打算记录下来的,但是升级的过程中确实遇到了一些问题,所以还是记录下来,分享给遇到同样问题的猿友. 先 ...

  6. CentOS 6.4 编译安装LLVM3.3,Clang和Libc++

    LLVM的最新版本3.3终于在6月17日发布了,按之前的计划6月5日就应该发布了,不过毕竟没有太晚,赶在VS2013 preview(6月26日微软Build大会)之前出来了.加上之前gcc4.8.1 ...

  7. Mapnik 编译安装过程

    首先总结一下,Linux(windows上没有测试过)上Mapnik的编译与测试就是一部心酸血泪史呀,如果您没有做好思想准备,那就出门左转,看点有意思的去吧,编译这个太煎熬了. 安装PostgreSQ ...

  8. Linux环境PostgreSQL源码编译安装

    Linux环境PostgreSQL源码编译安装 Linux版本: Red Hat 6.4 PostgreSQL版本: postgresql-9.3.2.tar.gz 数据存放目录: /var/post ...

  9. postgresql编译安装与调试(二)

    接前文postgresql编译安装与调试(一),继续说说postgresql的编译安装与调试. 上一篇已经详细说明了如何在Linux系统上编译安装postgresql,这次我们在此基础上简单讲讲如何在 ...

随机推荐

  1. CF1276 D. Tree Elimination

    CF1276 D. Tree Elimination 传送门 CodeForces Solution 考虑树型\(dp\),设\(f_{u,0/1/2/3}\)分别表示点\(u\)被自己父亲边之前的边 ...

  2. failed to execute /bin/bash: Resource temporarily unavailable的问题处理

    [admin@localhost ~]$ sudo su - scloanLast login: Tue Jun 12 14:06:31 CST 2018 on pts/3su: failed to ...

  3. JavaScriptDOM编程学习笔记(二)图片库案例

    <JavascriptDOM编程艺术>提供一个图片库的demo,主要讲解如何更好的使用JavaScript在网页中,跟随作者的思路来分析一下这个案例 首先需求是将图片发布到网上,但是如果发 ...

  4. SpringCloud组件学习-图

    图很清晰,直接放大浏览器,或者下载下来放大看

  5. Shell脚本之七 选择、循环结构

    一.if else if 语法格式 if condition then command1 command2 ... commandN fi 写成一行(适用于终端命令提示符): if [ $(ps -e ...

  6. promise、async和await

    async:async function 声明将定义一个返回 AsyncFunction 对象的异步函数.当调用一个 async 函数时,会返回一个 Promise 对象.当这个 async 函数返回 ...

  7. 深入理解JVM-类加载初始化阶段-类的主动与被动引用

    JVM的类加载阶段中初始化阶段 P210 虚拟机规定的五种情况必须对类的“初始化”情况 1.遇到new.getstatic.putstatic.或invokestic 四条字节码指令时,如果类没有经过 ...

  8. Netty4实战 - TCP粘包&拆包解决方案

    Netty是目前业界最流行的NIO框架之一,它的健壮性.高性能.可定制和可扩展性在同类框架中都是首屈一指.它已经得到了成百上千的商业项目的验证,例如Hadoop的RPC框架Avro就使用了Netty作 ...

  9. [转帖]java面试和笔试大全

    java面试和笔试大全 https://www.cnblogs.com/linzheng/archive/2011/01/05/1926856.html 2.String是最基本的数据类型吗? 基本数 ...

  10. Matlab分布云图绘制(渐变彩色)

    方法1. 函数:fill 举例说明:应力分布云图 x=[0 1 1 0 0]; %x坐标 y=[0 0 1 1 0]; %y坐标 stress=[1 2 3 4 1] %应力大小 fill(x,y,s ...