How To Set Up An Active/Passive PostgreSQL Cluster With Pacemaker, Corosync, And DRBD (CentOS 5.5) - Page 3
|
This article explains how to set up (and monitor) an Active/Passive PostgreSQL Cluster, using Pacemaker with Corosync and DRBD. Prepared by Rafael Marangoni, from BRLink Servidor Linux Team. 6. Configuring Corosync (openAIS)The Corosync project is a fork of the Heartbeat project, and like Pacemaker works very very fine with Corosync, we'll use it here. node1: To configure Corosync, let's get the actual configuration:
export ais_port=4000 Then, we check the data: env | grep ais_ Important: The variable ais_addr must contains the network address that the cluster will listen. In our article, this address is 10.0.0.0 Now we create the corosync config file:
cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf Let's add some information to the file:
cat <<-END >>/etc/corosync/corosync.conf The /etc/corosync/corosync.conf file will looks like this: compatibility: whitetank
totem {
version: 2
secauth: off
threads: 0
interface {
ringnumber: 0
bindnetaddr: 10.0.0.0
mcastaddr: 226.94.1.1
mcastport: 4000
}
}
logging {
fileline: off
to_stderr: yes
to_logfile: yes
to_syslog: yes
logfile: /tmp/corosync.log
debug: off
timestamp: on
logger_subsys {
subsys: AMF
debug: off
}
}
amf {
mode: disabled
}
aisexec {
user: root
group: root
}
service {
# Load the Pacemaker Cluster Resource Manager
name: pacemaker
ver: 0
}
From node1, we'll transfer the corosync config files to node2: scp /etc/corosync/* node2:/etc/corosync/ both nodes: On both nodes, we need to create the logs directory: mkdir /var/log/cluster/ node1: Afterwards, only on node1, start the corosync service: /etc/init.d/corosync start Let's check if the service is ok: grep -e "Corosync Cluster Engine" -e "configuration file" /var/log/messages [root@node1 bin]# grep -e "Corosync Cluster Engine" -e "configuration file" /var/log/messages Let's check if corosync started on the right interface: grep TOTEM /var/log/messages [root@node1 bin]# grep TOTEM /var/log/messages Let's check if pacemaker is up: grep pcmk_startup /var/log/messages [root@node1 bin]# grep pcmk_startup /var/log/messages Let's check if the corosync process is up: ps axf [root@node1 bin]# ps axf node2: Afterwards, if everything is ok on node1, then we can bring corosync up on node2: /etc/init.d/corosync start both nodes: Now, we can check the status of the cluster. Running on any node, the following command: crm_mon -1 [root@node1 ~]# crm_mon -1 Be sure that the both nodes are up and showing as online Set Corosync to automatic initialization (both nodes): chkconfig --level 35 corosync on
7. Configuring PacemakerPacemaker has many good features, one of them is that it replicates automatically the cluster configuration between the nodes. So the administrative tasks (like configuration) made on any node, are applyed to the entire cluster. Then every crm command used on this article can be used on any node, but only on time (do not repeat the command on more than one node).
Important commands to cluster managmentTo check cluster configuration: crm_verify -L To list cluster status and return to command prompt: crm_mon -1 To list cluster status and maintain on the status screen: crm_mon -1 To list cluster configuration: crm configure show To list open crm console (quit to exit): crm
Configuring StonithStonith is a security feature of the cluster, that (among other things) "strongly" shutdown a cluster node that has problems. To do this well, it uses specific hardware. The first thing we need to do on cluster configuration is to configure or disable Stonith. On this article, we'll disable Stonith, but you can use it. If you want to know how to use it, take a look at: http://www.clusterlabs.org/doc/crm_fencing.html First, checking the cluster configuration, we should get some errors from Stonith crm_verify -L So, to disable Stonith, we use the following command (on one of the nodes): crm configure property stonith-enabled=false Now, checking the cluster configuration, we should get no errors: crm_verify -L
Cluster General ConfigurationRun the commands once, on any node. Configuring quorum to 2 nodes. For more information, look at pacemaker configuration. crm configure property no-quorum-policy=ignore Configuring weight to change the resource to another node. crm configure rsc_defaults resource-stickiness=100 Showing configuration: crm configure show [root@node1 ~]# crm configure show
Configuring DBIPWe need a cluster IP. To add configure it, execute: crm configure primitive DBIP ocf:heartbeat:IPaddr2 \ Showing status: [root@node1 ~]# crm_mon -1 Note that the cluster status shows where the resource is running. Here it's running on node2, but could be on node1.
Configuring DRBD on ClusterAdding DRBD resource on cluster:
crm configure primitive drbd_postgres ocf:linbit:drbd \ Configure the DRBD primary and secondary node:
crm configure ms ms_drbd_postgres drbd_postgres \ Configure the DRBD mounting filesystem (and mountpoint):
crm configure primitive postgres_fs ocf:heartbeat:Filesystem \
Configuring PostgreSQL on ClusterAdding the postgresql resource on cluster:
crm configure primitive postgresql ocf:heartbeat:pgsql \ Now, we need to group DBIP, postgresql and DRBD mounted filesystem. The name of the group will be "postgres": crm configure group postgres postgres_fs DBIP postgresql Fixing group postgres to run together with DRBD Primary node crm configure colocation postgres_on_drbd inf: postgres ms_drbd_postgres:Master Configuring postgres to run after DRBD crm configure order postgres_after_drbd inf: ms_drbd_postgres:promote postgres:start Showing cluster configuration: crm configure show [root@node1 ~]# crm configure show
Setting the Preferential NodeIt's important to the pacemaker know where we prefer to run the services. To make node1 the preferential, use: crm configure location master-prefer-node1 DBIP 50: node1.clusterbr.int Note that the weight to prefer node1 is 50. Then if the service is running on node2, pacemaker will not change to node1
automatically, because we configured resource-stickiness to 100 (take a look up). Showing status: crm_mon -1 [root@node2 ~]# crm_mon -1 You may get some errors on the status, then you must to reboot both the nodes to corosync complete configuration.
Cluster managmentThese commands are very helpfull to manage the cluster. To migrate a resource to other node, do: crm resource migrate postgres node1.clusterbr.int To remove the above migrate command, do: crm resource unmigrate postgres To clean resource messages, do: crm resource cleanup postgres To stop postgresql service on cluster, do: crm resource stop postgresql To start postgresql service on cluster, do: crm resource start postgresql
|



Recent comments
14 hours 55 min ago
21 hours 36 min ago
1 day 1 hour ago
1 day 3 hours ago
1 day 11 hours ago
1 day 20 hours ago
1 day 21 hours ago
2 days 1 hour ago
2 days 5 hours ago
2 days 6 hours ago