FreeBSD Cluster Active/Passive MySQL (iscsi, carp, devd, mysql)

"Davide D'Amico" <[email protected]>
Newsgroups gmane.os.freebsd.italian.esperti
Message-ID <CAHykR++-X0YHh1qVEO6E3M0-E2He2Y4d6X-GqufhvAaN_Kp1VA@mail.gmail.com>
Ciao, volevo condividere qualche spunto di riflessione per un cluster
Active/Passive MySQL con partizione dei dati e binlog su share iscsi
utilizzando carp e devd.

Sembra che utilizzare centos/corosync/pacemaker abbia una letteratura più
copiosa, e passi per essere un sistema più robusto, ma - onestamente - non
mi piace molto un sistema (pacemaker) che da una release (1.1.7) all'altra
(1.1.8) cambi l'utility principale (crm -> pcs) e la relativa sintassi dei
comandi.

Voi avete qualche setup del genere? Avete già testato qualcosa? Avete
spunti/consigli/desiderata?

Di seguito il mio setup di test.

Nodi:
- fbsd10-1
- fbsd10-2

[ fbsd10-1]:/etc/iscsi.conf
------------------------------------------------------------------------------
disk1 {
    authmethod      = CHAP
    chapIName       = user1
    chapSecret      = secret123456
    initiatorname   = fbsd10-1
    TargetName      = iqn.2013-10.reversed.domain.name:disk1
    TargetAddress   = 192.168.17.26:3260,1
}
------------------------------------------------------------------------------

[ fbsd10-2]:/etc/iscsi.conf
------------------------------------------------------------------------------
disk1 {
    authmethod      = CHAP
    chapIName       = user1
    chapSecret      = secret123456
    initiatorname   = fbsd10-2
    TargetName      = iqn.2013-10.reversed.domain.name:disk1
    TargetAddress   = 192.168.17.26:3260,1
}
------------------------------------------------------------------------------

[ fbsd10-1]:/etc/rc.conf
...
ifconfig_em0="inet 192.168.20.61 netmask 255.255.248.0"
ifconfig_em0_alias0="inet 192.168.20.60 netmask 255.255.248.0 vhid 60 pass
r0cksol1d advbase 1"
...

[ fbsd10-2]:/etc/rc.conf
...
ifconfig_em0="inet 192.168.20.62 netmask 255.255.248.0"
ifconfig_em0_alias0="inet 192.168.20.60 netmask 255.255.248.0 vhid 60 pass
r0cksol1d advbase 1"
...

[ALL]:/etc/rc.conf.local
...
mysql_enable="NO"
mysql_dbdir="/DATA/mysql"

[ALL]:/etc/devd.conf
...
notify 0 {
match "system"          "CARP";
        match "subsystem"       "[0-9]+@[0-9a-z]+";
        match "type"            "MASTER";
        action "/usr/local/vbin/master.sh";
};

notify 0 {
match "system"          "CARP";
        match "subsystem"       "[0-9]+@[0-9a-z]+";
        match "type"            "BACKUP";
        action "/usr/local/vbin/slave.sh";
};

[ALL]:/usr/local/vbin/master.sh
#!/bin/sh

. /usr/local/vbin/vars

# Master node

sleep 5

# Grab iSCSI resource
/sbin/iscontrol -c /etc/iscsi.conf -p /var/run/iscontrol.pid -n disk1
if [ ! $? -eq 0 ]; then
  echo "ERROR: Problems attaching iSCSI resource." | logger -p local1.err
  exit 255
fi

sleep 5

if [ ! -e $ISCSIDEV ]; then
  echo "ERROR: Problem mounting iSCSI resource." | logger -p local1.err
  exit 255
fi

echo "INFO: iSCSI resource attached successfully." | logger -p local1.info

# Fsck DATA partition
/sbin/fsck_ufs -By $ISCSIDEV
if [ ! $? -eq 0 ]; then
  echo "ERROR: Problems fscking ${ISCSIDEV}." | logger -p local1.err
  exit 255
fi

echo "INFO: Fsck completed successfully." | logger -p local1.info

# Mounting DATA partition
/sbin/mount $ISCSIDEV $MOUNTPNT
if [ ! $? -eq 0 ]; then
  echo "ERROR: Problems mounting ${MOUNTPNT}." | logger -p local1.err
  exit 255
fi

echo "INFO: ${MOUNTPNT} mounted." | logger -p local1.info

# Starting MySQL
$MYSQLSERVICE onestart
if [ ! $? -eq 0 ]; then
  echo "ERROR: Problems starting MySQL." | logger -p local1.err
  exit 255
fi

echo "INFO: MySQL started successfully." | logger -p local1.info

exit 0

[ALL]:/usr/local/vbin/slave.sh
#!/bin/sh

. /usr/local/vbin/vars

# Slave node

sleep 5

# Stopping MySQL
/usr/local/etc/rc.d/mysql-server onestop
$MYSQLSERVICE onestop

echo "INFO: MySQL stopped." | logger -p local1.info

# Umounting DATA partition
umount $ISCSIDEV $MOUNTPNT
ISMOUNTED=$(mount | grep "^$ISCSIDEV" | wc -l)
if [ $ISMOUNTED -ne 0 ]; then
  echo "ERROR: Unable to umount $MOUNTPNT" | logger -p local1.err
  exit 255
fi

echo "INFO: ${MOUNTPNT} umounted successfully." | logger -p local1.info

# Releasing iSCSI resource
ISCPID=$(cat /var/run/iscontrol.pid)
kill -HUP $ISCPID

echo "INFO: iSCSI resource released successfully." | logger -p local1.info

exit 0

[ALL]:/usr/local/vbin/vars
#!/bin/sh

ISCSIDEV="/dev/da0s1a"
MOUNTPNT="/DATA"
MYSQLSERVICE="/usr/local/etc/rc.d/mysql-server"


All'inizio occorre montare manualmente la share iscsi su un nodo e
formattarla:
fdisk -I /dev/da0
bsdlabel -w /dev/da0s1
newfs -j /dev/da0s1a

A questo punto un bel reboot di entrambi i nodi e via.

Se avete syslog configurato correttamente, avrete i messaggi degli script
sulla facility local1.


-- 
d.

_______________________________________________
Esperti mailing list
[email protected]
http://mailman.gufi.org/mailman/listinfo/esperti
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.