postgresql9.5编译安装体验
实验环境:
- 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编译安装体验的更多相关文章
- CentOS7源码编译安装Postgresql9.5
1.安装必要的基本软件 yum install -y gcc.x86_64 glibc.x86_64 glibc-devel.x86_64 vim-enhanced.x86_64 gcc-java a ...
- 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 ...
- 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. ...
- 开源服务专题之--------mysql的编译安装
为什么选择MySQL 1:mysql性能卓越,服务稳定,很少出现异常宕机 2:mysql开源免费,无版权制约,自主性及使用成本低 3:产品耦合度,mysql支持多种操作系统,支持多开发语言,特别是ph ...
- Ubuntu 编译安装 Linux 4.0.5 内核,并修复 vmware 网络内核模块编译错误
. . . . . 今天把 Ubuntu 14.04 升级到了最新的 4.0.5 的内核版本,本来不打算记录下来的,但是升级的过程中确实遇到了一些问题,所以还是记录下来,分享给遇到同样问题的猿友. 先 ...
- CentOS 6.4 编译安装LLVM3.3,Clang和Libc++
LLVM的最新版本3.3终于在6月17日发布了,按之前的计划6月5日就应该发布了,不过毕竟没有太晚,赶在VS2013 preview(6月26日微软Build大会)之前出来了.加上之前gcc4.8.1 ...
- Mapnik 编译安装过程
首先总结一下,Linux(windows上没有测试过)上Mapnik的编译与测试就是一部心酸血泪史呀,如果您没有做好思想准备,那就出门左转,看点有意思的去吧,编译这个太煎熬了. 安装PostgreSQ ...
- Linux环境PostgreSQL源码编译安装
Linux环境PostgreSQL源码编译安装 Linux版本: Red Hat 6.4 PostgreSQL版本: postgresql-9.3.2.tar.gz 数据存放目录: /var/post ...
- postgresql编译安装与调试(二)
接前文postgresql编译安装与调试(一),继续说说postgresql的编译安装与调试. 上一篇已经详细说明了如何在Linux系统上编译安装postgresql,这次我们在此基础上简单讲讲如何在 ...
随机推荐
- 第10组 Beta冲刺(1/4)
队名:凹凸曼 组长博客 作业博客 组员实践情况 童景霖 过去两天完成了哪些任务 文字/口头描述 继续学习Android studio和Java 制作剩余界面前端 展示GitHub当日代码/文档签入记录 ...
- Oracle_12541错误和ora-12514错误
ORA-12541: TNS无监听程序错误 在oracle安装目录(E:\app\Administrator\product\instantclient_12_1\NETWORK\ADMIN)下查找l ...
- 一道经典的Java面试题:equals ,== 和hashcode()的区别
一句话区别:==比较的是内存地址,equals比较的是值内容 结论: 从以下三点展开: 基本数据类型.字符串.对象 对于基本数据类型:只有==,没有equals. 对于字符串:==比较的是内存地址,e ...
- Azure DevOps Server 2019 第一个补丁包(2019.0.1 RTW)
在Azure DevOps Server 2019正式发布后的2周左右时间,微软快速发布了第一个补丁包Azure DevOps Server 2019.0.1 RTW.Azure DevOps Ser ...
- .net core 读取配置文件的值
.net core中的配置文件可以存一些自定义的值,我们需要去读取 在配置中添加json: "name": "sealee", "Connection ...
- .net core 中的多环境配置
参考地址:https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/environments?view=aspnetcore-2.2 官网说环 ...
- [教程]K8Cscan调用外部程序(Win/Linux批量上控/执行多条命令/保存结果)
0x000 调用原理 Cscan调用外部程序有两种方式,一是编写DLL,二是配置文件 编写DLL文件对于不懂编程的人来说可能会很难(虽然支持各语言) 由于考虑到很多人不会编程或会编程又急用无法短时间转 ...
- 阿里云配置DDoS高防
- MySQL常见的应用异常记录
>>Error Code: 1045. Access denied for user 'test'@'%' (using password: YES) 使用MySQL的select * i ...
- [转帖]浅谈P2P、P2C 、O2O 、B2C、B2B、 C2C的区别
浅谈P2P.P2C .O2O .B2C.B2B. C2C的区别 https://www.cnblogs.com/zhuiluoyu/p/5481635.html 相信有很多人对P2P.P2C .O2O ...