首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

PostgreSQL 11.0 Beta2 安装

准备:linux 环境,本地yum 源,以及11.2 安装包 (下载地址:https://www.postgresql.org/ftp/source/v11beta2/)

安装准备:

1,上传安装包至/media 目录

2,创建postgres 用户以及用户组 postgres,已有可以跳过

groupadd -g 1120postgres

useradd -u1120-gpostgres-d /home/postgres-mpostgres

3,创建安装,数据目录,授权。这里主要参照oracle 安装规划

mkdir -p /pgbase/pgdata

mkdir -p /pgbase/pg11

--授权

chown -R postgres:postgres /pgbase

4,配置用户环境变量,添加以下用户环境变量

export PG_BASE=/pgbase

export PG_HOME=$PG_BASE/pg11

export PGDATA=$PG_BASE/pgdata

export PATH=$PATH:$PG_HOME/bin

export LD_LIBRARY_PATH=$PG_HOME/lib

export MANPATH=$PG_HOME/share/man:$MANPATH

5,解压源码包并授权给postgres

chown postgres:postgres postgresql-11beta2.tar.gz

su - postgres (使用非root 用户才能做man check 回归测试)

gunzip postgresql-11beta2.tar.gz

tar xf postgresql-11beta2.tar

6,编译安装

--configuration

cd postgresql-11beta2

/*

定制安装有以下可选:(非全部)

--prefix=PREFIX

默认postgres 的安装目录为/usr/local/pgsql,需要修改则使用 --prefix 安装文件,以及扩展,共享库文件等都会安装到指定文件夹。

--with-pgport

指定pg客户端,监听的端口。默认的端口为:5432

--with-python

编译 PL / Python

--with-openssl

编译SSL 以支持加密连接

--with-systemd

编译支持systemd服务通知。 如果服务器二进制文件在systemd下启动但这没有任何影响,这可以改善集成; 在7系 linux 上建议使用。

--with-segsize=SEGSIZE

指定一个表,或则索引的段最大大小,单位为GB,超过此大小,将会新建段文件。以此避免操作系统的最大文件限制。文件个数过多带来的问题是会使postgres 持有过多文件描述符。此外对于一些工具,例如tar 也不友好。建议设置为2的幂次(其实此处我认为即使没有限制也不宜过大,热点数据,一般都比较集中)

--with-blocksize

指定块大小,默认8K,可选为1,2,4,8,16,32 (K)

--with-wal-blocksize

指定wal 日志块大小,默认8K,一般已经适合。可选为1,2,4,8,16,32,64 (K)

*/

./configure --prefix=/pgbase/pg11 --with-pgport=5433 --with-openssl --with-segsize=4

/*安装的时候,可能出现类似以下报错

最简单粗暴的办法是,(挂载本地yum源即可,具体百度)

root 用户

yum install -y readline*

yum install -y openssl*

*/

--build

/* 可以使用make ,也可以使用make world 构建HTML ,man 以及其他模块 */

make world

--regression tests (这部分可以不做)

make check

--installing the files

make install-world

如果上面使用的是make 则这里只要make install 即可

至此安装完成。

8,操作系统配置部分:

vi /etc/security/limits.conf用户资源限制部分保持与Oracle 一样即可。

postgres hard nproc 16384

postgres soft nproc 2047

postgres soft nofile 1024

postgres hard nofile 65536

配置oom killer

On Linux 2.6 and later, it is possible to modify the kernel's behavior so that it will not “overcommit” memory. Although this setting will not prevent the OOM killer from being invoked altogether, it will lower the chances significantly and will therefore lead to more robust system behavior. This is done by selecting strict overcommit mode via sysctl:

sysctl -w vm.overcommit_memory=2

Another approach, which can be used with or without altering vm.overcommit_memory, is to set the process-specific OOM score adjustment value for the postmaster process to -1000, thereby guaranteeing it will not be targeted by the OOM killer. The simplest way to do this is to execute

echo -1000 > /proc/self/oom_score_adj

这个配置蛮重要的。

开不开大页,看情况吧。

在postgres 中,默认会尝试使用大页,如果大页达不到满足,则会使用正常页面。可在postgres.conf 中设置 huge_pages 为 on

9,初始化数据库群集

initdb -D $PGDATA

10,启动与关闭数据库群集

pg_ctl -D /pgbase/pgdata start

pg_ctl -D /pgbase/pgdata stop

note:pg_ctl 功能很多,是管理pg 的主要工具,可以参看帮助获得详细信息 pg_ctl -?

11,升级

使用简单升级策略,将11.1 升级至11.2

11.1 PG_HOME 目录为:/usr/pgsql-11/

PGDATA 目录为:/postgres/data

11.2 PG_HOME 目录为:/pgbase/pg11

PGDATA 目录为:/pgbase/pgdata

1) 关闭 11.1 以及11.2 的数据库群集

11.1

/usr/pgsql-11/bin/pg_ctl stop -D /postgres/data

11.2

pg_ctl -D /pgbase/pgdata stop

2) 升级检查

pg_upgrade -b /usr/pgsql-11/bin -B /pgbase/pg11/bin -d /postgres/data -D /pgbase/pgdata -c

检查发现pg_controldata 中segment sizes 设置不同,检查失败。

如果这样的话,只能用pg_dumpall 进行逻辑导入导出。。不合适。。。这里就自己坑自己了,,

就这样吧。。。

导入导出没啥好说的。

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20180721G01XOE00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券