/data
=============================================================
3. Configuration
=============================================================
(EX.System Composition)
|
((Load Balance Server))
( hostname: lb.hoo.com)
( receive port:5432 )
( recovery port:6101)
( lifecheck port:6201)
|
----------+-------------+------------+----------
| |
((Cluster DB 1 )) ((Cluster DB 2 ))
( hostname:c1.hoo.com) ( hostname:c2.hoo.com)
( receive port: 5432 ) ( receive port:5432)
( recovery port:7101 ) ( recovery port: 7102 )
( lifecheck port:7201 ) ( lifecheck port: 7202 )
| |
----------+-------------+------------+----------
|
((Replication Server))
( hostname:pgr.hoo.com)
( receive port:8001 )
( recovery port:8101)
( lifecheck port:8201)
3-1. Load Balance Server
The setup file of load balance server is copied from the sample file and edited.
(the sample file is installed '/usr/local/pgsql/etc' in default)
----------------------------------------------------------------
$cd /usr/local/pgsql/etc
$cp pglb.conf.sample pglb.conf
----------------------------------------------------------------
In the case of the above system composition example,
the setup example of pglb.conf file is as the following
#============================================================
# Load Balance Server configuration file
#-------------------------------------------------------------
# file: pglb.conf
#-------------------------------------------------------------
# This file controls:
# o which hosts are db cluster server
# o which portuse connect to db cluster server
# o how many connections are allowed on each DB server
#============================================================
#-------------------------------------------------------------
# set cluster DB server information
# o Host_Name : hostname
# o Port : connection for postmaster
# o Max_Connection : maximun number of connection to postmaster
#-------------------------------------------------------------
<Cluster_Server_Info>;
<Host_Name>; c1.hoo.com</Host_Name>;
<Port>; 5432 </Port>;
<Max_Connect>; 32 </Max_Connect>;
</Cluster_Server_Info>;
<Cluster_Server_Info>;
<Host_Name>; c2.hoo.com</Host_Name>;
<Port>; 5432 </Port>;
<Max_Connect>; 32 </Max_Connect>;
</Cluster_Server_Info>;
#-------------------------------------------------------------
# set Load Balance server information
# o Receive_Port : connection from client
# o Recovery_Port : connection for recovery process
# o Max_Cluster_Num : maximun number of cluster DB servers
# o Use_Connection_Pooling : use connection pool [yes/no]
# o Max_Pool_Each_Server : number of pool connections/DB server
#-------------------------------------------------------------
<Receive_Port>; 5432 </Receive_Port>;
<Recovery_Port>; 6101 </Recovery_Port>;
<LifeCheck_Port>;6201 </LifeCheck_Port>;
<Max_Cluster_Num>; 128 </Max_Cluster_Num>;
<Use_Connection_Pooling>; yes </Use_Connection_Pooling>;
<Max_Pool_Each_Server>; 1 </Max_Pool_Each_Server>;
3-2. Cluster DB Server
The Cluster DB server need edit two configuration files
('pg_hba.conf' and 'cluster.conf').
These files are create under the $PG_DATA directory after 'initdb'.
A. pg_hba.conf
Permission to connect DB via IP connectoins is need for this system.
B. cluster.conf
In the case of the above system composition example,
the setup example of cluster.conf file is as the following
#============================================================
# Cluster DB Server configuration file
#-------------------------------------------------------------
# file: cluster.conf
#-------------------------------------------------------------
# This file controls:
# o which hosts & port are replication server
# o which port use for replication request to replication server
# o which command use for recovery function
#
#============================================================
#-------------------------------------------------------------
# set cluster DB server information
# o Host_Name : hostname
# o Port : connection for postmaster
# o Recovery_Port : connection for recovery process
#-------------------------------------------------------------
<Replicate_Server_Info>;
<Host_Name>; pgr.hoo.com </Host_Name>;
<Port>; 8001 </Port>;
<Recovery_Port>; 8101 </Recovery_Port>;
<LifeCheck_Port>; 8201 </LifeCheck_Port>;
</Replicate_Server_Info>;
#-------------------------------------------------------------
# set Cluster DB Server information
# o Recovery_Port : connection for recovery
# o Rsync_Path : path of rsync command
# o Rsync_Option : file transfer option for rsync
# o When_Stand_Alone : When all replication servers fell,
# you can set up two kinds of permittion,
# "real_only" or "read_write".
#-------------------------------------------------------------
<Recovery_Port>; 7101 </Recovery_Port>;
<LifeCheck_Port>; 7201 </LifeCheck_Port>;
<Rsync_Path>; /usr/bin/rsync </Rsync_Path>;
<Rsync_Option>; ssh -1 </Rsync_Option>;
<When_Stand_Alone>; read_only </When_Stand_Alone>;
<Status_Log_File>;/tmp/cluster.sts </Status_Log_File>;
<Error_Log_File>; /tmp/cluster.log</Error_Log_File>;
#-------------------------------------------------------------
# set partitional replicate control information
# set DB name and Table name to stop reprication
# o DB_Name : DB name
# o Table_Name : table name
#-------------------------------------------------------------
#<Not_Replicate_Info>;
# <DB_Name>; test_db </DB_Name>;
# <Table_Name>;log_table </Table_Name>;
#</Not_Replicate_Info>;
3-3. Replication Server
The setup file of replication server is copied from the sample file and edited.
(the sample file is installed '/usr/local/pgsql/etc' in default)
----------------------------------------------------------------
$cd /usr/local/pgsql/etc
$cp pgreplicate.conf.sample pgreplicate.conf
----------------------------------------------------------------
In the case of the above system composition example,
the setup example of pgreplicate.conf file is as the following
#============================================================
# PGReplicate configuration file
#-------------------------------------------------------------
# file: pgreplicate.conf
#-------------------------------------------------------------
# This file controls:
# o which hosts & port are cluster server
# o which port use for replication request from cluster server
#============================================================
#-------------------------------------------------------------
# set cluster DB server information
# o Host_Name : hostname
# o Port : connection for postmaster
# o Recovery_Port : connection for recovery
#-------------------------------------------------------------
<Cluster_Server_Info>;
<Host_Name>; c1.hoo.com </Host_Name>;
<Port>; 5432 </Port>;
<Recovery_Port>;7101 </Recovery_Port>;
<LifeCheck_Port>; 7201 </LifeCheck_Port>;
</Cluster_Server_Info>;
<Cluster_Server_Info>;
<Host_Name>; c2.hoo.com </Host_Name>;
<Port>; 5432 </Port>;
<Recovery_Port>;7101 </Recovery_Port>;
<LifeCheck_Port>; 7201 </LifeCheck_Port>;
</Cluster_Server_Info>;
#-------------------------------------------------------------
# set Load Balance server information
# o Host_Name : hostname
# o Recovery_Port : connection for recovery
#-------------------------------------------------------------
<LoadBalance_Server_Info>;
<Host_Name>; lb.hoo.com </Host_Name>;
<Recovery_Port>; 6101 </Recovery_Port>;
<LifeCheck_Port>;6201 </LifeCheck_Port>;
</LoadBalance_Server_Info>;
#-------------------------------------------------------------
# set PGReplicate server information
# o Replicate_Port : connection for reprication
# o Recovery_Port : connection for recovery
#-------------------------------------------------------------
<Replication_Port>; 8001 </Replication_Port>;
<Recovery_Port>; 8101 </Recovery_Port>;
<LifeCheck_Port>; 8201 </LifeCheck_Port>;
=============================================================
4. Start Up / Stop
=============================================================
4-1. replication server
A. Start replication server
----------------------------------------------------------------
$ /usr/local/pgsql/bin/pgreplicate -D /usr/local/pgsql/etc
----------------------------------------------------------------
B. Stop replication server
----------------------------------------------------------------
$ /usr/local/pgsql/bin/pgreplicate -D /usr/local/pgsql/etc stop
----------------------------------------------------------------
usage: pgreplicate [-D path_of_config_file] [-W path_of_work_files] [-U login us
er][-l][-n][-v][-h][stop]
-l: print error logs in the log file.
-n: don't run in daemon mode.
-v: debug mode. need '-n' flag
-h: print this help
stop: stop pgreplicate
(config file default path: ./pgreplicate.conf)
4-2. cluster DB server
$PG_HOME = /usr/local/pgsql
$PG_DATA = /usr/local/pgsql/data
A. Start cluster DB server
----------------------------------------------------------------
$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -o "-i" start
----------------------------------------------------------------
B. Stop cluster DB server
----------------------------------------------------------------
$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data stop
----------------------------------------------------------------
4-3. load balance server
A. Start load balance server
----------------------------------------------------------------
$ /usr/local/pgsql/bin/pglb -D /usr/local/pgsql/etc
----------------------------------------------------------------
B. Stop load balance server
----------------------------------------------------------------
$ /usr/local/pgsql/bin/pglb -D /usr/local/pgsql/etc stop
----------------------------------------------------------------
usage: pglb [-D path_of_config_file] [-W path_of_work_files] [-n][-v][-h][stop]
-l: print error logs in the log file.
-n: don't run in daemon mode.
-v: debug mode. need '-n' flag
-h: print this help
stop: stop pglb
(config file default path: ./pglb.conf)
这是postgresql数据库集群的安装原文
以下是我对他的一些理解与解释:
部署postgresql数据库集群至少需要安装四个数据库
1、balanceDB数据库(以下简称平行数据库),字面为平衡或并行
处理数据库。他必需定义好节点数据库信息.不需要创建实际的数据库。
2、ClusterDB集群节点数据库二个(以下简称节点数据库)。单个话就不是集群了。这不废话吗?,他必需定义好本节点信息(是只读还是读写都可以)与调度与决策处理数据信息。(节点数据库必需创建数据库,即initdb啦)
3、pgreplicateDB调度与决策处理数据库(以下简称调度数据库)。他必需要定义好并行处理数据库信息、节点数据库信息。(调度与决策数据库不需要创建数据库)。
以下为我的推断:
当客户端访问数据库时候的一个流程。
我们访问数据库的时候,是访问平行处理数据库。而不是访问ClusterDB或pgreplicateDB。
由平行数据库询问调度数据库,当前查询或修改使用那个节点。
节点收到平行数据库访问请求事务后,使用二阶段递交,因为每一个查询与修改都是一个事务,事务完成后发送信号到调度数据库。本次查询与修改递交完成。
调度数据库再通知别的节点数据库同步更改。同步节点完成后调度数据库再通知原节点数据库本次事务顺利完成。你可以把结果反回给客户端了。
在这样的一个集群里面我们不需要关心使用那个节点,节点之前怎样同步。
之所以这样推测,是想使大家有一个概念为什么要这样部署,有什么作用。
不能想当然而所以然。
上面讲得可能简单了一点。
但我想读完的朋友,应该会对postgresql集群数据库有一个基础的理论知识了。
分享到:
相关推荐
Install a PostgreSQL cluster, create a database, and implement your data model Create tables and views, define indexes, and implement triggers, stored procedures, and other schema objects Use the ...
sky_postgresql_cluster sky_postgresql_cluster 是一个写在 shell 中的 PostgreSQL HA 模块,HA 通过三个主机,包括两个 postgresql (主要和流复制备用)和一票主机。 应用程序通过虚拟连接到 sky_postgresql_...
Create a PostgreSQL cluster that stays online even when disaster strikes Avoid costly downtime and data loss that can ruin your business Updated to include the newest features introduced in PostgreSQL...
PostgreSQL 这里是开源关系型数据库 的生态列表,包括各种开源和商业的服务、工具、文档等资源。部分参考自等开源资源,仍在努力更新中... :elephant: 欢迎你为此项目添砖加瓦,你可以通过 来贡献资源或者创建 来...
PostgreSQL高可用性集群 :elephant: :sparkling_heart: 部署生产就绪的PostgreSQL高可用性群集(基于“ Patroni”和“ DCS(etcd)”)。 使用Ansible实现自动化。 该Ansible剧本旨在在生产环境的专用物理服务器上...
keeper:它管理一个 PostgreSQL 实例,该实例收敛到 leader sentinel 计算的 clusterview。Sentinel:它发现并监控 Keeper 和代理,并计算最佳 ClusterView。代理:客户端的访问点。它强制连接到正确的 PostgreSQL ...
postgresql-bdr-cluster厨师食谱使用Chef Provisioning来配置PostgreSQL BDR集群的MVP Chef食谱要求ChefDK 0.6.0或更高按照将ChefDK设置为系统Ruby和Gemset Vagrant和Virtualbox(目前)使用它启动集群: rake up ...
一切都从为高效的PostgreSQL数据集群的框架选取硬件开始,然后从一些管理员通常面对的真实问题的解决来缩短宕机时间,接着,我们加入数据库监控到软件栈中,使用collectd, Nagios, 和Graphite。没有加入复制机制的...
解决:win10安装Postgresql 错误解决方案 Failed to load sql modules into the database cluster的错误
What you will learn Protect your data with PostgreSQL replication and management tools such as Slony, Bucardo, pglogical, and WAL-E Hardware planning to help your database run efficiently Prepare for ...
PostgreSQL multimaster multimaster是PostgreSQL扩展,带有一组补丁程序,这些补丁程序将PostgreSQL转变为同步的无共享群集,以提供联机事务处理(OLTP)可伸缩性和自动灾难恢复的高可用性。 与标准PostgreSQL主从...
另外,还有一种‘StandaloneBackend’使用的方式,虽然通过这种方式也可以启动服务器,但是一般只在数据库的初始化(PostgreSQL的cluster的初始化,相当于其他数据库的instance的初始化)、紧急维护的时候使用,所以...
Table of Contents ...Increasing and decreasing the size of a cluster 15 Combining sharding and replication 17 Various sharding solutions 18 PostgreSQL-based sharding 19 Summary 19 www.allitebooks.
HA,故障切换逻辑和部分脚本参考德哥 sky_postgresql_cluster () 的 HA 项目,本文仅分享一种 PostgreSQL高可用方案,脚本的切换逻辑可根据实际情况调整,如果您对此方案有更好的建议或补充,欢迎探讨。Email:二 ...
5)新建postgresql集群,使用“Crear Cluster.bat”,提示用户postgres的DATA文件夹路径和密码。 6) 要记录postgresql 服务,运行“Registrar servicio.bat”并删除使用“Quitar servicio.bat”。 适用于 32 位和 ...
postgresql11.2和postgis2.5.1安装包。官网下载太慢,放一个在csdn上。 安装过程中可能出现Problem running post-install step. Installation may not complete correctly. The database cluster initialisation ...
配置如何公开postgreSQL服务的方式: ClusterIP :在群集内部IP上公开服务。 选择此值将使服务仅可从群集内访问。 NodePort :在静态端口(NodePort)上的每个节点的IP上公开服务。 您可以通过请求NodeIP:NodePort...
stolon-chart:使用Kubernetes Helm图表部署基于Stolon的HA Postgresql集群