Chinaunix首页 | 论坛 | 博客
  • 博客访问: 55776
  • 博文数量: 21
  • 博客积分: 1765
  • 博客等级: 上尉
  • 技术积分: 205
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-13 21:25
文章分类
文章存档

2011年(15)

2008年(6)

我的朋友

分类:

2008-02-19 23:04:16

基于PostgreSQL8.2.4的群集
PGCluster on PostgreSQL 8.2.4



This document is by no means the bible on how to set up PGCluster, it's simply a list of all of the things I've found and done in order to get a working PGCluster system. If there are some things that I haven't got working yet, I will highlight them in the document. My idea is that this will grow and be altered when I get more accurate information.

First off, you need to know that I have spent a couple of months 'playing' with PGCluster and looking through endless mailing list posts and documents to put this all together. I'm not a PostgreSQL expert. If at any time you feel there is a mistake, please feel free to email me at john.gardner@tagish.co.uk.

The Testing Scenario
I am using three servers to test PGCluster as shown below. All servers are CentOS 4.4 running PGCluster 1.7 rc 5:

    SERVER 1                 SERVER 2                                 SERVER 3
+----------------+ +----------------+ +----------------+
| cluster_1 | | cluster_2 | VPN | cluster_3 |
| rep_1 |------| rep_2 |------------------------| |
| lb_1 | | lb_2 | | |
+----------------+ +----------------+ +----------------+

There are three physical servers involved. SERVER 1 and SERVER 2 are located on the same subnet, but SERVER 3 is located on another subnet, separated by VPN over an ADSL connection. It is always recommended to put all of the PGCluster servers on the same subnet, or at least the same LAN, running one Cluster DB node in a different geographical location is not what PGCluster was built for, however I needed to at least try this scenario for the future production set up.

cluster_1, cluster_2 and cluster_3 are Cluster DB nodes.
rep_1 and rep_2 are Replicators.
lb_1 and lb_2 are Load Balancers.

The Host File
After experiencing many problems with the replicators, and also reading many mailing list posters who were also having problems, I have put this entry right at the start of the document. Check your hosts file!

It appears that not setting up your hosts file as PGCluster expects it may cause many problems further down the line.

It is very important that each server in the PGCluster infrastructure can reliably communicate with any other server, to do this I have configured my /etc/host file as this on every server:

127.0.0.1		localhost.localdomain localhost
### PGCluster ###
192.168.1.19 cluster_1
192.168.1.20 cluster_2
192.168.10.59 cluster_3
192.168.1.19 rep_1
192.168.1.20 rep_2
192.168.1.19 lb_1
192.168.1.20 lb_2

When these hosts file have been set up on every server in your PGCluster system, check the connectivity by pinging all of the servers. It will take time, but you will be able diagnose any faults before anything else happens.

Installing PGCluster
I don't feel the need to document the whole installation process as this is available at:

Eventually, the installation instructions will be transferred to this site.

Configuring PGCluster
Again, this is already available here:

Configuration Files
These are very important to get correct. There doesn't seem to be much documentation on these files, but they are extremely important for correct operation of your PGCluster system. Each version of PGCluster (1.5, 1.7 etc.) have different formatting, so it is always advised to use the example configuration files that come with your version of PGCluster. The following will work for version 1.7.

CAVEAT: The only problem I am currently having is with two Replicators. When the primary Replicator, goes down, the secondary doesn't appear to take over. Other than that, the config files below seem to work for the above setup.

SERVER 1

cluster.conf

#------------------------------------------------------------
# file: cluster.conf (cluster_1)
#------------------------------------------------------------
# set Replication Server information
#------------------------------------------------------------

rep_1
8001
8101


rep_2
8001
8101

#-------------------------------------------------------------
# set Cluster DB Server information
#-------------------------------------------------------------
cluster_1
7001
/usr/bin/rsync
ssh -1
yes
/usr/local/pgsql/bin/pg_dump
read_only
1min
3s
11s

pgreplicate.conf

#-------------------------------------------------------------
# file: pgreplicate.conf
#-------------------------------------------------------------
# A setup of Cluster DB(s)
#-------------------------------------------------------------

cluster_1
5432
7001


cluster_2
5432
7001


cluster_3
5432
7001

#--------------------------------------------------------------------
# A setup of loader balancer
#--------------------------------------------------------------------

lb_1
6101


lb_2
6101

#------------------------------------------------------------
# A setup of a replication server
#-------------------------------------------------------------
rep_1
8001
8101
8301
normal
no
1min
3s
15s
#-------------------------------------------------------------
# A setup of a log files
#-------------------------------------------------------------

/var/log/postgresql/pgreplicate.log
1M
3

pglb.conf

#-------------------------------------------------------------
# file: pglb.conf
#-------------------------------------------------------------
# set cluster DB server information
#--------------------------------------------------------------------

cluster_1
5432
30


cluster_2
5432
30


cluster_3
5432
30

#-------------------------------------------------------------
# set Load Balance server information
#-------------------------------------------------------------
lb_1
/tmp
5433
6101
128
no
3s
15s
#-------------------------------------------------------------
# A setup of a log files
#-------------------------------------------------------------

/var/log/postgresql/pglb.log
1M
3

SERVER 2

cluster.conf

#------------------------------------------------------------
# file: cluster.conf (cluster_2)
#------------------------------------------------------------
# set Replication Server information
#------------------------------------------------------------

rep_1
8001
8101


rep_2
8001
8101

#-------------------------------------------------------------
# set Cluster DB Server information
#-------------------------------------------------------------
cluster_2
7001
/usr/bin/rsync
ssh -1
yes
/usr/local/pgsql/bin/pg_dump
read_only
1min
3s
11s

pgreplicate.conf

#-------------------------------------------------------------
# file: pgreplicate.conf
#-------------------------------------------------------------
# A setup of Cluster DB(s)
#-------------------------------------------------------------

cluster_1
5432
7001


cluster_2
5432
7001


cluster_3
5432
7001

#-------------------------------------------------------------
# A setup of Load Balance Server
#--------------------------------------------------------------------

lb_1
6101


lb_2
6101

#-------------------------------------------------------------
# A setup of a replication server
#-------------------------------------------------------------
rep_2
8001
8101
8301
normal
no
1min
3s
15s
#-------------------------------------------------------------
# A setup of a log files
#-------------------------------------------------------------

/var/log/postgresql/pgreplicate.log
1M
3

file: pglb.conf

#-------------------------------------------------------------
# file: pglb.conf
#-------------------------------------------------------------
# set cluster DB server information
#--------------------------------------------------------------------

cluster_1
5432
30


cluster_2
5432
30


cluster_3
5432
30

#-------------------------------------------------------------
# set Load Balance server information
#-------------------------------------------------------------
lb_2
/tmp
5433
6101
128
no
3s
15s
#-------------------------------------------------------------
# A setup of a log files
#-------------------------------------------------------------

/var/log/postgresql/pglb.log
1M
3

SERVER 3

file: cluster.conf

#------------------------------------------------------------
# file: cluster.conf (cluster_3)
#------------------------------------------------------------
# set Replication Server information
#------------------------------------------------------------

rep_1
8001
8101


rep_2
8001
8101

#-------------------------------------------------------------
# set Cluster DB Server information
#-------------------------------------------------------------
cluster_3
7001
/usr/bin/rsync
ssh -1
yes
/usr/local/pgsql/bin/pg_dump
read_only
1min
3s
11s

John Gardner
john.gardner@tagish.co.uk

阅读(1156) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~