教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 政务民生 >

CentOS7双机热备(pgpool+replication)

来源:网络收集 时间:2026-08-27
导读: 1. 环境信息 ..................................................................................................................................... 2 2. postgresql .............................................................................

1. 环境信息 ..................................................................................................................................... 2 2. postgresql ................................................................................................................................. 2

1. 依赖包 ................................................................................................................................. 2 2. 调整内核 ............................................................................................................................. 2 3. 服务配置 ............................................................................................................................. 3 4. 创建用户 ............................................................................................................................. 3 5. 创建目录 ............................................................................................................................. 3 6. 建立ssh信任 ..................................................................................................................... 3 7. 环境变量 ............................................................................................................................. 4 8. 编译安装 ............................................................................................................................. 4 9. 初始化实例 ......................................................................................................................... 5 10. 运行参数 ........................................................................................................................... 5 11. 启动实例 ........................................................................................................................... 7 12. 复制备机 ........................................................................................................................... 7 13. 注册服务 ........................................................................................................................... 7 3. pgpool......................................................................................................................................... 8

1. 创建用户 ............................................................................................................................. 8 2. 开放权限 ............................................................................................................................. 8 3. 环境变量 ............................................................................................................................. 8 4. 建立ssh信任 ..................................................................................................................... 8 5. 编译安装 ............................................................................................................................. 9 6. 加载extension .................................................................................................................. 9 7. 配置pgpool.conf .............................................................................................................. 9 8. 配置pool_hba.conf ........................................................................................................ 10 9. 配置pcp.conf .................................................................................................................. 11 10. 启动pgpool .................................................................................................................... 11 11. 状态检查 ......................................................................................................................... 11

1. 环境信息

操作系统:CentOS7 数据库:Postgresql9.3.5 中间层:Pgpool-II-3.4.0

Primary:172.15.0.11 Standby:172.15.0.12 Virtual IP:172.15.0.10

2. postgresql

1. 依赖包

[root主/备]

通过yum安装,需要联网 #yum -y install gcc

#yum -y install python-devel #yum -y install ncurses-devel #yum -y install readline-devel #yum -y install zlib-devel #yum -y install libxml2-devel #yum -y install libxslt-devel #yum -y install sendmail

2. 调整内核

[root主/备]

修改内核

#vi /etc/sysctl.conf

kernel.shmmax = 68719476736 kernel.shmall = 4294967296 kernel.shmmni = 4096

kernel.sem = 50100 64128000 50100 1280 fs.file-max = 7672460

net.ipv4.ip_local_port_range = 9000 65000 net.core.rmem_default = 1048576 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576

生效参数

#/sbin/sysctl -p

3. 服务配置

[root主/备]

关闭防火墙(也可以设置协议规则,不关闭防火墙) #systemctl stop firewalld.service #systemctl disable firewalld.service

添加主机名称(方便后续配置和管理) #vi /etc/hosts

172.15.0.11 DBServer01 172.15.0.12 DBServer02

4. 创建用户

[root主/备]

创建用户组

#groupadd postgres

创建用户

#useradd -d /opt/postgres -s /bin/bash -g postgres -m postgres #passwd postgres

5. 创建目录

[postgres主/备]

修改权限(pgpool用户需要读取pg的环境变量) #chmod 750 ~

添加目录(源码上传路径) #mkdir ~/src

添加目录(辅助脚本路径) #mkdir ~/script

6. 建立ssh信任

[postgres主/备]

生成ssh key(密码设置为空) #ssh-keygen

设置对端postgres信任,hostname根据实际情况修改 #ssh-copy-id postgres@DBServer02

7. 环境变量

[postgres主/备]

修改profile #vi ~/.bash_profile

export PGHOME=/opt/postgres export PATH=$PATH:$PGHOME/bin export LD_LIBRARY_PATH=$PGHOME/lib export LANG=zh_CN.UTF8 export PGUSER=postgres export PGDATA=$PGHOME/data export PGLOG=$PGHOME/log export PGSCRIPT=$PGHOME/script

生效profile

#source ~/.bash_profile

8. 编译安装

[postgres主/备]

…… 此处隐藏:4189字,全部文档内容请下载后查看。喜欢就下载吧 ……
CentOS7双机热备(pgpool+replication).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/449125.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)