Pandora: Documentation en: DRBD Appliance

From Pandora FMS Wiki
Jump to: navigation, search

1 HA in Pandora FMS Centos Appliance

1.1 Introduction to DRBD

The Distributed Replicated Block Device (DRBD) is a software-based, shared-nothing, replicated storage solution mirroring the content of block devices (hard disks, partitions, logical volumes etc.) between servers.

DRBD mirrors data:

  • In real time. Replication occurs continuously, while applications modify the data on the device.
  • Transparently. The applications that store their data on the mirrored device are oblivious of the fact that the data is in fact stored on several computers.
  • Synchronously or asynchronously. With synchronous mirroring, a writing application is notified of write completion only after the write has been carried out on both computer systems. Asynchronous mirroring means the writing application is notified of write completion when the write has completed locally, but before the write has propagated to the peer system.



Drbd.png



Over DRBD you can provide a cluster on almost everything you can replicate in disk. In our specific case when want to "clusterize" only the database, but we also could replicate a entire Pandora FMS setup, including server, local agents and of course database.

DRBD is a RAID-1/TCP based kernel module, very easy to setup and really fast and error-proof. You can get more information about DRBD in their website at http://www.drbd.org

DRBD is OpenSource.

1.2 Initial Environment

We want to have a MySQL cluster in a HA configuration based on a master (active) and slave (passive). Several Pandora FMS servers and console will use a virtual IP address to connect with the running node which contains a MySQL server.

This is the network configuration for the two nodes running the MySQL cluster:

192.168.70.10 (drbd1) -> Master
192.168.70.11 (drbd2) -> Slave
192.168.70.15 -> Virtual-ip

Each node has two hardisks:

/dev/sda with the standard linux system. /dev/sdb with an empty, unformatted disk, ready to have the RAID1 setup with DRBD.

We assume you have time synchronized between all nodes, this is extremely IMPORTANT, if not, please synchronize it before continue, using ntp or equivalent mechanism. Remember also enable ntpd service at boot

# service ntpd start
# chkconfig ntpd on

For proper operation, we recommend disable firewall and SELinux on both machines.

# service iptables stop
# chkconfig iptables off
# sed -i 's/^\(SELINUX=\)enforcing/\1permissive/' /etc/selinux/config
# setenforce permissive

It is very important editing the file /etc/hosts. In him we have given both systems:

# vim /etc/hosts
192.168.70.10 drbd1
192.168.70.11 drbd2

1.3 Installing Packages

DRBD isn't located in Centos official repositories, so it's necessary to add the repository in both systems:

[root@drbd1 ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm
 Retrieving http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm
 warning: /var/tmp/rpm-tmp.zXUElM: Header V4 DSA/SHA1 Signature, key ID baadae52: NOKEY
 Preparing...                ########################################### [100%]
  1:elrepo-release         ########################################### [100%]


Install the following packages:

yum install drbd84-utils kmod-drbd84 corosync pacemaker openais python-dateutil python-lxml redhat-rpm-config

In the Pacemaker version available in Centos, is necessary install crm command that isn't installed by default:

rpm -Uvh http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/i686/python-pssh-2.3.1-4.2.i686.rpm 
rpm -Uvh http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/i686/pssh-2.3.1-4.2.i686.rpm 
rpm -Uvh http://rpm.repo.onapp.com/repo/centos/6.6/i386/RPMS-4.0/crmsh-2.1-1.6.i686.rpm

1.4 DRBD setup

1.4.1 DRBD Initial Configuration

Edit /etc/drbd.conf

global {
  usage-count no;
}

common {
 protocol C;
}

resource mysql {
   on drbd1 {
       device /dev/drbd1;
       disk /dev/sdb1;
       address 192.168.70.10:7789;
       meta-disk internal;
   }
   on drbd2 {
       device /dev/drbd1;
       disk /dev/sdb1;
       address 192.168.70.11:7789;
       meta-disk internal;
   }
   disk {
       on-io-error detach; # Desconectamos el disco en caso de error de bajo nivel.
   }
   net {
       max-buffers 2048; #Bloques de datos en memoria antes de escribir a disco.
       ko-count 4; # Maximos intentos antes de desconectar.
   }
   syncer {
       rate 10M; # Valor recomendado de sincronización para redes de 100 Mb´s..
       al-extents 257; 
   }
   startup {
       wfc-timeout 0; # drbd init script esperará ilimitadamente los recursos.
       degr-wfc-timeout 120; # 2 minuteos
   }
}


1.4.2 Setup DRBD nodes

You need to have a completelly empty disk on /dev/sdb (even without partitioning).

Do a partition in /dev/sdb1 (linux type).


[root@drbd1 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content will not be recoverable.
 
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 
Command (m for help): n
Command action
    e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.

(Do it in both nodes).

And create the internal structure in the disk for drbd with the following commands in both nodes:

drbdadm create-md mysql
drbdadm up mysql

(Do it again in both nodes).


1.4.3 Initial disk (Primary node)

The last command to setup DRBD, and only on the primary node, it's to initialize the resource and set as primary:

drbdadm -- --overwrite-data-of-peer primary mysql

After issuing this command, the initial full synchronization will start. You will be able to monitor its progress via /proc/drbd. It may take some time depending on the size of the device.

By now, your DRBD device is fully operational, even before the initial synchronization has completed (albeit with slightly reduced performance). You may now create a filesystem on the device, use it as a raw block device, mount it, and perform any other operation you would with an accessible block device.

drbd1:~# cat /proc/drbd 
version: 8.0.14 (api:86/proto:86)
GIT-hash: bb447522fc9a87d0069b7e14f0234911ebdab0f7 build by phil@fat-tyre, 2008-11-12 16:40:33

 1: cs:SyncSource st:Primary/Secondary ds:UpToDate/Inconsistent C r---
    ns:44032 nr:0 dw:0 dr:44032 al:0 bm:2 lo:0 pe:0 ua:0 ap:0
	[>....................] sync'ed:  2.2% (2052316/2096348)K
	finish: 0:03:04 speed: 11,008 (11,008) K/sec
	resync: used:0/61 hits:2749 misses:3 starving:0 dirty:0 changed:3
	act_log: used:0/257 hits:0 misses:0 starving:0 dirty:0 changed:0


1.4.4 Creating the partition on primary node

Do it ONLY in the primary node, will be replicated to the other nodes automatically. You operate with the DRBD block device, forget to use physical device.

drbd1#mkfs.ext3 /dev/drbd1

Use is like a standard partition from now, and mount to your disk in primary NODE as follow:

drbd1:~# mkdir /mysql
drbd1:~# mount /dev/drbd1 /mysql/


Now, we check this through the command:

df -ah

In the secondary node, passive, we format it and create the setup directory:

[root@drbd2 ~]# mkdir /mysql

1.4.5 Getting information about system status

Executed from current master node (drbd1) :

drbd1:~# drbdadm role mysql
Primary/Secondary
drbd1:~# drbdadm dstate mysql
UpToDate/UpToDate

And from drbd2 (backup, replicating disk):

drbd2:~# drbdadm role mysql
Secondary/Primary
drbd2:~# drbdadm dstate mysql
UpToDate/UpToDate

1.4.6 Setting up the Mysql in the DRBD disk

We suppose you have all the information about mysql in following directories (may differ depending on Linux distro):

/etc/mysql/my.cnf
/var/lib/mysql/

First, stop the mysql in the primary and secondary nodes.

(/etc/init.d/mysql stop)

In the primary node(drbd1):

Move all data to mounted partition in the primary nodes and delete all the relevant mysql information in the secondary node:

drbd1:~# mv /etc/my.cnf /mysql/
drbd1:~# mv /var/lib/mysql /mysql/mysql

Link new location to original ubication:

drbd1:~# ln -s /mysql/mysql/ /var/lib/mysql
drbd1:~# ln -s /mysql/my.cnf /etc/my.cnf

In the secondary node (drbd2):

Delete all the mysql information

drbd2:~# rm -Rf /var/lib/mysql
drbd2:~# rm -Rf /etc/my.cnf

Dismount the primary node and change it to the secondary one:

drbd1:~# umount /mysql/ ; drbdadm secondary mysql

Convert the secondary into primary and do the set-up:

drbd2:~# drbdadm primary mysql ; mount /dev/drbd1 /mysql


And create in this node the symbolic links in the same way:

drbd2:~# ln -s /mysql/my.cnf /etc/my.cnf
drbd2:~# ln -s /mysql/mysql /var/lib/mysql

After doing this, mysql is configured in both nodes and we can put again the secondary node as main and viceversa doing the previously mentioned but this way backwards.

drbd2:~# umount /mysql/ ; drbdadm secondary mysql
drbd1:~# drbdadm primary mysql ; mount /dev/drbd1 /mysql

1.4.7 Manual split brain recovery

DRBD detects split brain at the time connectivity becomes available again and the peer nodes exchange the initial DRBD protocol handshake. If DRBD detects that both nodes are (or were at some point, while disconnected) in the primary role, it immediately tears down the replication connection. The tell-tale sign of this is a message like the following appearing in the system log:

Split-Brain detected, dropping connection!

After split brain has been detected, one node will always have the resource in a StandAlone connection state. The other might either also be in the StandAlone state (if both nodes detected the split brain simultaneously), or in WFConnection (if the peer tore down the connection before the other node had a chance to detect split brain).

In this case, our secondary node (castor) is alone:

drbd1:~# cat /proc/drbd 
version: 8.0.14 (api:86/proto:86)
GIT-hash: bb447522fc9a87d0069b7e14f0234911ebdab0f7 build by phil@fat-tyre, 2008-11-12  16:40:33

  1: cs:WFConnection st:Secondary/Unknown ds:UpToDate/DUnknown C r---
     ns:0 nr:0 dw:0 dr:0 al:0 bm:7 lo:0 pe:0 ua:0 ap:0
	 resync: used:0/61 hits:0 misses:0 starving:0 dirty:0 changed:0
   	 act_log: used:0/257 hits:0 misses:0 starving:0 dirty:0 changed:0

At this point, unless you configured DRBD to automatically recover from split brain, you must manually intervene by selecting one node whose modifications will be discarded (this node is referred to as the split brain victim). This intervention is made with the following commands:

drbdadm secondary mysql
drbdadm -- --discard-my-data connect mysql

On the other node (the split brain survivor), if its connection state is also StandAlone, you would enter:

drbdadm connect mysql

See the status:

 drbd2:~# cat /proc/drbd 
 version: 8.0.14 (api:86/proto:86)
 GIT-hash: bb447522fc9a87d0069b7e14f0234911ebdab0f7 build by phil@fat-tyre, 2008-11-12 16:40:33
 
  1: cs:SyncSource st:Primary/Secondary ds:UpToDate/Inconsistent C r---
     ns:34204 nr:0 dw:190916 dr:46649 al:12 bm:24 lo:0 pe:4 ua:20 ap:0
	 [============>.......] sync'ed: 66.7% (23268/57348)K
 	 finish: 0:00:02 speed: 11,360 (11,360) K/sec
	 resync: used:1/61 hits:2149 misses:4 starving:0 dirty:0 changed:4
   	 act_log: used:0/257 hits:118 misses:12 starving:0 dirty:0 changed:12


1.4.8 Manual switchover

In the current primary

1. Stop mysql

/etc/init.d/mysql stop

2. Umount partition

umount /dev/drbd1

3. Degrade to secondary

drbdadm secondary mysql

In the current secondary

4. Promote to primary

drbdadm primary mysql

5. Mount partition

mount /dev/drbd1 /mysql

6. Start MySQL

/etc/init.d/mysql start

Template warning.png

It is very important that before continuing with the installation check that all steps have been implemented correctly, drbd works correctly on both nodes, and the mysql service starts on both nodes when acting as Master.

 


1.5 Corosync / Pacemaker configuration

Before installing we should check that in the file /etc/hosts both systems are correctly configured:

192.168.70.10 	   drbd1
192.168.70.11	   drbd2

You will also need to enable ip_forwarding.

sysctl -w net.ipv4.ip_forward=1 

Once this is done, we proceed to install pacemaker, openais and corosync (In both nodes).

yum install pacemaker openais corosync

Then, we edit the configuration file /etc/corosync/corosync.conf(main node). By default, it doesn't exist so we do a copy of the file that comes as an example

/etc/corosync/corosync.conf.example.udpu:

#cp -p /etc/corosync/corosync.conf.example.udpu /etc/corosync/corosync.conf


totem {
        version: 2
        secauth: on
        interface {
                member {
                        memberaddr: 192.168.70.10
                }
                member {
                        memberaddr: 192.168.70.11
                }
                ringnumber: 0
                bindnetaddr: 192.168.70.10
                mcastport: 5405
                ttl: 1
        }
        transport: udpu
}
logging {
    fileline: off
    to_logfile: yes
    to_syslog: yes
    debug: on
    logfile: /var/log/cluster/corosync.log
    debug: off
    timestamp: on
    logger_subsys {
        subsys: AMF
        debug: off
    }
}

logging { 
        fileline: off 
        to_stderr: no 
        to_logfile: yes 
        to_syslog: yes 
        logfile: /var/log/cluster/corosync.log 
        debug: off 
        timestamp: on 
        logger_subsys { 
                subsys: AMF 
                debug: off 
        } 
} 

amf { 
        mode: disabled 
}

Add inside service.d folder a new file with the next configuration:


# vi /etc/corosync/service.d/pcmk
service {
        # Load the Pacemaker Cluster Resource Manager
        name: pacemaker
        ver: 1
}

The file /etc/corosync/corosync.conf should be identical in both nodes so you should copy the file to node 2 to the path /etc/corosync

scp /etc/corosync/corosync.conf drbd2:/etc/corosync
scp /etc/corosync/service.d/pcmk drbd2:/etc/corosync/service.d/

Next we create the corosync authentication keygen in the main node executing the command corosync-keygen:

[root@drbd1 ~]# corosync-keygen

Once we have executed this command, it will ask we create entropía pressing keys. To do this in a quick way, the better option is that from another terminal you download a huge file. Or running the following command on a different session: find / >/dev/null 2>&1

Once it has been generated it will automatically create a file with the key /etc/corosync/authkey, file that should be copied to the second node in /etc/corosync/ in order the keygens would be identical.

scp /etc/corosync/authkey root@192.168.70.11:/etc/corosync/authkey

After copying it, give to it permissions 400

chmod 400 /etc/corosync/authkey

When these operations are done, the server is started in both nodes:

/etc/init.d/corosync start

If the service has started properly corosync, pacemaker started the service (on both nodes)

/etc/init.d/pacemaker start

Once they have been started you can see the status of the cluster, where is shown how both nodes are configured and online (it takes a few minutes detecting both nodes):

crm_mon -1
[root@drbd2 ~]# crm status
Last updated: Sat Oct 18 19:44:52 2014
Last change: Sat Oct 18 19:44:23 2014 via crmd on drbd2
Stack: classic openais (with plugin)
Current DC: drbd2 - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
0 Resources configured 
 
 

Online: [ drbd1 drbd2 ] 
[root@drbd1 ~]# crm status
Last updated: Sat Oct 18 19:45:24 2014
Last change: Sat Oct 18 19:44:23 2014 via crmd on drbd2
Stack: classic openais (with plugin)
Current DC: drbd2 - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
0 Resources configured


Online: [ drbd1 drbd2 ]

Template warning.png

It is very important that before continuing with the installation check that all steps have been implemented correctly and that the services corosync and pacemaker work correctly on both nodes.

 


1.6 Pacemaker resource configuration

Once we have properly functioning Pacemaker (Cluster Resource Manager) on one side and the Corosync (a layer of messaging between its nodes) we add other resources.

First of all we must know what will be the order that resources will keep .

1.- IP Virtual
2.- DRBD / Filesystem
3.- Apache
4.- Mysql
5.- Pandora Server
6.- Tentacle Server

You need to follow this order because without the DRBD filesystem mounted and operating properly can not start the MySQL server, and without the mysql service, Pandora server works.

Template warning.png

Depending on your pacemaker version, the 'crm' command may not work properly.

 


If the execution of the command 'crm configure' displays errors, you can execute the following to fix it (it may be a bit different depending on the version).

cibadmin --modify --xml-text '<cib validate-with="pacemaker-2.1"/>'

Try executing 'crm configure show' to check if it is now solved.

1.6.1 Configuration of the virtual IPs as resource in the cluster

First, you should disable stonith:

crm configure property stonith-enabled=false

And configure the cluster so it ignores the quorum policies. This will allow the if a node fall down the other execute the resource without problems.

crm configure property no-quorum-policy=ignore

At this point you can adda the resources with virtual ip assigned:

crm configure primitive failover_ip ocf:heartbeat:IPaddr2 params ip=192.168.70.15 cidr_netmask=32 op monitor interval=30s

When monitoring the cluster, take into account this later result (crm_mon -1):

FAILOVER-ADDR	 (ocf::heartbeat:IPaddr2):		Started drbd1

This way when we do ping from a host to the virtual ip, the node which is active in this moment, will answer us, working in a transparent way for the sending host.


1.6.2 Creating the Apache resource

Remove the Apache service startup.

# chkconfig httpd off (on both)

The next step is enable the apache server-status for Pacemaker monitoring service. We need to uncomment these lines in the Apache config:

ExtendedStatus On
<Location /server-status>
	SetHandler server-status
	Order deny,allow
	Allow from localhost
</Location>

Copy the conf from one node to another:

scp /etc/httpd/conf/httpd.conf drbd2:/etc/httpd/conf/httpd.conf

Restart apache and check if server-status page is downloadable in both nodes:

[root@drbd1 ~]# /etc/init.d/httpd restart
curl http://192.168.70.10/server-status
curl http://192.168.70.11/server-status
curl http://192.168.70.15/server-status

Add next lines on Pacemaker configuration.

#crm configure primitive apache_res ocf:heartbeat:apache params configfile=/etc/httpd/conf/httpd.conf httpd=/usr/sbin/httpd statusurl="http://localhost/server-status" op monitor interval=60s timeout=10s op start timeout=40s op stop timeout=60s

Indicate that apache is started after the IP resource

crm configure colocation apache_ip_colo INFINITY: apache_res failover_ip
crm configure order apache_after_ip mandatory: failover_ip apache_res

Execute crm configure show command:

node drbd1 \
        attributes standby=off
node drbd2 \
        attributes standby=off
primitive apache_res apache \
        params configfile="/etc/httpd/conf/httpd.conf" httpd="/usr/sbin/httpd" statusurl="http://localhost/server-status" \
        op monitor interval=60s timeout=10s \
        op start timeout=40s interval=0 \
        op stop timeout=60s interval=0
primitive failover_ip IPaddr2 \
        params ip=192.168.70.15 cidr_netmask=32 \
        op monitor interval=30s
colocation apache_ip_colo inf: apache_res failover_ip
order apache_after_ip Mandatory: failover_ip apache_res
property cib-bootstrap-options: \
        dc-version=1.1.10-14.el6_5.3-368c726 \
        cluster-infrastructure="classic openais (with plugin)" \
        expected-quorum-votes=2 \
        stonith-enabled=false \
        no-quorum-policy=ignore 

If exist any errors, restart pacemaker and corosync server. Remember that executing crm node standby / crm node online you can convert Slave node in Master node.

Do not continue the installation until you can verify that the apache service goes from one node to another correctly and entering a virtual IP in a browser you can see the message that Apache works.

[root@drbd2 ~]# crm status
Last updated: Sat Oct 18 22:32:25 2014
Last change: Sat Oct 18 22:32:14 2014 via crm_attribute on drbd1
Stack: classic openais (with plugin)
Current DC: drbd1 - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
2 Resources configured 


Node drbd1: standby
Online: [ drbd2 ] 

 failover_ip    (ocf::heartbeat:IPaddr2):       Started drbd2
 apache_res     (ocf::heartbeat:apache):        Started drbd2

[root@drbd2 ~]# crm node standby
[root@drbd1 ~]# crm status
Last updated: Sat Oct 18 22:34:53 2014
Last change: Sat Oct 18 22:34:40 2014 via crm_attribute on drbd2
Stack: classic openais (with plugin)
Current DC: drbd1 - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
2 Resources configured

 
Node drbd2: standby
Online: [ drbd1 ]

 failover_ip    (ocf::heartbeat:IPaddr2):       Started drbd1
 apache_res     (ocf::heartbeat:apache):        Started drbd1

1.6.3 Creating the DRBD resource and filesystem

First we add the drbd_res resource in which the DRBD (drbd_resource) is specified, in this case named mysql and the check time intervals, start and stop.

drbd1:~#crm
crm(live)#cib new drbd
crm(drbd)#configure primitive drbd_res ocf:linbit:drbd params drbd_resource=mysql op monitor interval=29s role=Master op monitor interval=31s role=Slave

Then we add the resources that has as main aim to do that drbd_mysql runs only on the node that has been fixed as primary:

crm(drbd)#configure ms drbd_master_slave drbd_res meta master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true

We do a commit of the cib drbd to register changes:

crm(drbd)#cib commit drbd

The second resource (fs_res) will mount the drbd devices in the mount point. In this case /dev/drbd0 en /mysql/. To add this resource the following process is done:

Enter in the crm and create a new cib named fs:

# crm
crm(live)# cib new fs

And then execute the command to add the resource:

crm(fs)#configure primitive fs_res ocf:heartbeat:Filesystem params device=/dev/drbd1 directory=/mysql fstype=ext3

The device should consider that resources should be active always in the node considered as master (colocation) and after the order in which it will be executed (after the main node would be promoted).

crm(fs)# configure colocation fs_drbd_colo INFINITY: fs_res drbd_master_slave:Master
crm(fs)# configure order fs_after_drbd mandatory: drbd_master_slave:promote fs_res:start
crm(fs)# configure colocation apache_fs_colo inf: apache_res fs_res
crm(fs)# configure order apache_after_fs inf: fs_res apache_res
crm(fs)# cib commit fs

The result is this:

Last updated: Sat Oct 18 23:07:52 2014
Last change: Sat Oct 18 23:06:08 2014 via crm_attribute on drbd1
Stack: classic openais (with plugin)
Current DC: drbd1 - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
5 Resources configured


Online: [ drbd1 drbd2 ]

failover_ip     (ocf::heartbeat:IPaddr2):       Started drbd1
apache_res      (ocf::heartbeat:apache):        Started drbd1
 Master/Slave Set: drbd_master_slave [drbd_res]
     Masters: [ drbd1 ]
     Slaves: [ drbd2 ]
fs_res  (ocf::heartbeat:Filesystem):    Started drbd1

Tried at this point that after passing from one node to another, the /mysql directory containing the mysql files on the Master node.

1.6.4 Creting Mysql or Percona resource

Remove the mysql/mysqld service startup (both of the nodes).

# chkconfig mysql off

The creation of the next resource is slightly different depending on if we use an standard MySQL database or a Percona version, if we are ussing the CenOS Appliance, we will need to add the Percona kind. So that's what we will explain first. We configure the resource that runs the Percona daemon:

crm configure primitive mysql_res lsb:mysql op start timeout="120s" op stop timeout="120s" op monitor interval="10s" timeout="30s" meta target-role="Started"

Indicate to the device that the resource should be active always in the node where the filesystem is set up and after that is will be started after the filesystem has been set up.

crm configure colocation mysql_drbd_colo inf: mysql_res drbd_master_slave:Master
crm configure order mysql_after_apache inf: apache_res mysql_res

To finish, we execute a cleanup of the error register, just in case that any appears on the first creation

crm resource cleanup mysql_res


For a MySQL database, the procedure is quite similar, the only command that differs is the first one:

crm configure primitive mysql_res ocf:heartbeat:mysql params additional_parameters="--socket=/var/run/mysqld/mysqld.sock" op start interval="0" timeout="120" op stop interval="0" timeout="120" op monitor interval="10" timeout="30" depth="0"

Then we run the commands to indicate the correct status and order for the resource, same that for the Percona resource

crm configure colocation mysql_drbd_colo inf: mysql_res drbd_master_slave:Master
crm configure order mysql_after_apache inf: apache_res mysql_res

And the error cleanup

crm resource cleanup mysql_res

1.6.5 Creating Pandora Resource

Remove the pandora_server service startup (both of the nodes).

# chkconfig pandora_server off

Pandora resource the controls the pandora server service is added. To do this, the crm configuration is edited using the command:

crm configure primitive pandora_res lsb:pandora_server meta is-managed="true" target-role="Started" op monitor on-fail="standby" interval="10s"
crm configure colocation pandora_drbd_colo inf: pandora_res drbd_master_slave:Master
crm configure order pandora_after_mysql inf: mysql_res pandora_res

1.6.6 Creating Tentacle Resource

Remove the tentacle_serverd service startup (both of the nodes).

# chkconfig tentacle_serverd off

Tentacle resource the controls the tentacle server service is added. To do this, the crm configuration is edited using the command:

crm configure primitive tentacle_res lsb:tentacle_serverd meta is-managed="true" target-role="Started" op monitor on-fail="standby" interval="10s"
crm configure colocation tentacle_drbd_colo inf: tentacle_res drbd_master_slave:Master
crm configure order tentacle_after_pandora inf: pandora_res tentacle_res

1.6.7 Pacemaker final configuration

Finally, don't forget to enable the auto-start on system boot for corosync and pacemaker.

# chkconfig corosync on
# chkconfig pacemaker on

The final configuration must look like this:

#crm configure show
node drbd \
        attributes standby="off"
node drbd2 \
        attributes standby="off"
primitive apache_res ocf:heartbeat:apache \
        params configfile="/etc/apache2/apache2.conf" httpd="/usr/sbin/apache2" \
        op monitor interval="60s" timeout="10s" \
        op start interval="0" timeout="40s" \
        op stop interval="0" timeout="60s"
primitive drbd_res ocf:linbit:drbd \
        params drbd_resource="mysql" \
        op monitor interval="29s" role="Master" \
        op monitor interval="31s" role="Slave"
primitive failover_ip ocf:heartbeat:IPaddr2 \
        params ip="192.168.70.202" cidr_netmask="32" \
        op monitor interval="30s"
primitive fs_res ocf:heartbeat:Filesystem \
        params device="/dev/drbd0" directory="/mysql" fstype="ext4"
primitive mysql_res ocf:heartbeat:mysql \
        params additional_parameters="--socket=/var/run/mysqld/mysqld.sock" \
        op start interval="0" timeout="120" \
        op stop interval="0" timeout="120" \
        op monitor interval="10" timeout="30" depth="0" \
        meta target-role="Started"
primitive pandora_res lsb:pandora_server \
        meta is-managed="true" target-role="Started" \
        op monitor on-fail="standby" interval="10s"
ms drbd_master_slave drbd_res \
        meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
colocation apache_fs_colo inf: apache_res fs_res
colocation apache_ip_colo inf: apache_res failover_ip
colocation fs_drbd_colo inf: fs_res drbd_master_slave:Master
colocation mysql_drbd_colo inf: mysql_res drbd_master_slave:Master
colocation pandora_drbd_colo inf: pandora_res drbd_master_slave:Master
order apache_after_fs inf: fs_res apache_res
order apache_after_ip inf: failover_ip apache_res
order fs_after_drbd inf: drbd_master_slave:promote fs_res:start
order mysql_after_apache inf: apache_res mysql_res
order pandora_after_mysql inf: mysql_res pandora_res
property $id="cib-bootstrap-options" \
        dc-version="1.1.7-ee0730e13d124c3d58f00016c3376a1de5323cff" \
        cluster-infrastructure="openais" \
        expected-quorum-votes="3" \
        stonith-enabled="false" \
        no-quorum-policy="ignore" 
#crm status
============
Last updated: Tue Oct 21 17:05:35 2014
Last change: Tue Oct 21 17:05:17 2014 via crm_attribute on drbd
Stack: openais
Current DC: drbd - partition with quorum
Version: 1.1.7-ee0730e13d124c3d58f00016c3376a1de5323cff
2 Nodes configured, 3 expected votes
8 Resources configured.
============

Node drbd: standby
Online: [ drbd2 ] 

failover_ip     (ocf::heartbeat:IPaddr2):       Started drbd2
apache_res      (ocf::heartbeat:apache):        Started drbd2
 Master/Slave Set: drbd_master_slave [drbd_res]
     Masters: [ drbd2 ]
     Stopped: [ drbd_res:1 ]
fs_res  (ocf::heartbeat:Filesystem):    Started drbd2
mysql_res       (ocf::heartbeat:mysql): Started drbd2
pandora_res     (lsb:pandora_server):   Started drbd2
tentacle_res    (lsb:tentacle_serverd): Started drbd2


Volver al índice de documentación de Pandora FMS