实验环境:

  • 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. three.js 添加环境光

    var ambient = new THREE.AmbientLight(0xffffff);//环境光 scene.add(ambient);

  2. 洛谷P1531 I Hate It题解

    题目背景 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少.这让很多学生很反感. 题目描述 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的 ...

  3. Set和Multiset 怎么用咧↓↓↓

    转自:[C++ STL]Set和Multiset - Memset - 博客园https://www.cnblogs.com/ChinaHook/p/6985444.html (对字体进行了略微的修改 ...

  4. Computer-Hunters——团队展示

    Computer-Hunters--团队展示 这个作业属于哪个课程 https://edu.cnblogs.com/campus/fzu/2019FZUSEZ 这个作业要求在哪里 https://ed ...

  5. Laravel自动备份到阿里云OSS

    背景 之前做备份时,主要是拿一台备份机对生产机做数据库做主备,用rsync同步上传的图片,文件.随着项目的增多,许多小项目都这样做感觉太过繁琐,每次都要在2台机器之间配置,同时单独拿一台机器做备份成本 ...

  6. Windows10 下 JAVA JDK版本设置修改操作

    一般情况下,先修改系统环境变量,右键点击桌面上的“此电脑”图标中,选择“属性”,在弹出的属性窗口中选择“高级系统设置”,然后点击“环境变量”     在弹出窗口中的“系统变量”,查到“JAVA_HOM ...

  7. sql实现MD5加密

    select substring(sys.fn_sqlvarbasetostr(HashBytes('MD5','test')),3,32)

  8. asbDio (asbDio.dll)

    using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices ...

  9. Alpha冲刺(11/10)——2019.5.3

    作业描述 课程 软件工程1916|W(福州大学) 团队名称 修!咻咻! 作业要求 项目Alpha冲刺(团队) 团队目标 切实可行的计算机协会维修预约平台 开发工具 Eclipse 团队信息 队员学号 ...

  10. PHP发送邮箱的方法smtp方法

    PHP发送邮箱的方法 采用的smtp方式首先进入163邮箱 设置  POP3/SMTP服务打勾 然后会提示你设置授权密码就是SMTP服务器的用户密码smtp.php文件代码<pre>< ...