Planning:
vip:192.168.1.254
rs1:192.168.1.215
rs2:192.168.1.216
First, host binding (RS2 same)
[Email protected] ~]# cat/etc/hosts 192.168.1.215 rs1.china-kody.com rs1192.168.1.216 rs2.china-kody.com rs2
Second, the configuration of dual-machine mutual trust (RS2 same)
[[email protected] ~]# ssh-key-t rsa-p '-f/root/.ssh/id_rsa[[email protected] ~]# ssh-copy-id-f/ROOT/.SSH/ID_RSA.PU b rs2
Third, configuration Corosync
[[email protected] ~]# vim/etc/corosync/corosync.conf Service {ver:0 Name:pacemaker}aisexec {use R:root Group:root}[[email protected] ~]# vim/etc/corosync/corosync.conf [[email protected] ~]# Scp/etc/corosyn C/{AUTHKEY,COROSYNC.CONF} Rs2:/etc/corosync
Iv. Configuring DRBD and MySQL
[[email protected] ~]# vim /etc/drbd.d/global_common.conf handlers { pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib /drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -F "; pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/ Notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f "; local-io-error "/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-; } disk { on-io-error detach; } net { cram-hmac-alg "SHA1"; shared-secret "D0cjpslasod4xg"; } [[email protected] ~]# drbdadm create-md Mysqldrbd[[email protected] ~]# drbdadm create-md mysqldrbd[[email protected] ~]# service drbd start[[email protected] ~]# service drbd start[ [email protected] ~]# chkconfig drbd off[[email protected] ~]# Chkconfig drbd off[[email protected] ~]# drbdadm -- --overwrite-data-of-peer primary all [[email protected] ~]# mke2fs -j /dev/drbd0 [[email protected] ~]# mount /dev/drbd0 /mydata/data configuration mysql ... [[Email protected] ~]# umount /dev/drbd0[[email protected] ^]# drbdadm seconary mysqlbd
V. Configuring MySQL
[[email protected] ~]# groupadd -g 306 mysql[[email protected] ~]# useradd -u 306 -g mysql -s /sbin/ nologin mysql[[email protected] ~]# id mysqluid=306 (MySQL) gid=306 (MySQL) group=306 (MySQL) [[email protected] ~]# /usr/local/mysql/scripts/mysql_install_db --user= mysql datadir=/mydata/data[[email protected] /]# cp /usr/local/mysql/support-files/ mysql.server /etc/init.d/mysql[[email protected] /]# chkconfig --add mysql [[EMAIL PROTECTED] /]# CHKCONFIG MYSQL OFF[[EMAIL PROTECTED] /]# CP /usr/local/mysql/support-files/my-default.cnf/etc/my.cnf[[email protected] /]# vim / etc/my.cnf add datadir = /mydata/data rs1, RS2, same configuration, test is normal. Stop the service and turn the boot off.
Vi. CRM command Line Corosync
1. Configure DRBD master-slave automatic switch
Primitive mysqldrbd ocf:linbit:drbd params drbd_resource=mysqldrbd op start timeout= 240 interval=0 op stop timeout=100 Interval=0 op monitor role=master interval =20 timeout=30 op monitor role=slave interval=30 timeout=30ms ms_mysqldrbd mysqldrbd meta master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true crm (Live) # statusonline: [ rs1.china-kody.com rs2.china-kody.com ] Master/Slave Set: ms_mysqldrbd [mysqldrbd] masters: [ RS1.CHINA-KODY.COM ]     SLAVES: [ RS2.CHINA-KODY.COM ]
2, configuring DRBD auto-mount
primitive mysqlstore filesystem params device= "/dev/drbd0" directory= "/mydata" fstype=ext3 op start timeout=60 interval=0 op stop timeout=60 interval=0colocation mysqlstore_ With_ms_mysqldrbd inf: mysqlstore ms_mysqldrbd:masterorder mystore_after_ms_mysqldrbd Mandatory: ms_mysqldrbd:promote mysqlstore:startOnline: [ rs1.china-kody.com rs2.china-kody.com ] master/slave set: ms_mysqldrbd [mysqldrbd] Masters: [ rs2.china-kody.com ] Slaves: [ rs1.china-kody.com ] mysqlstore (Ocf::heartbeat:filesystem): started Rs2.china-kody.com
3. Configure MySQL Resources
Primitive mysqld lsb:mysql meta target-role=startedcolocation mysqld_with_mysqlstore inf:mysqld mysqlstore Order Mysqld_after_mysqlstore mandatory:mysqlstore mysqld Node rs2.china-kody.com:standbyonline: [rs1.china-kody.com] Mast Er/slave SET:MS_MYSQLDRBD [MYSQLDRBD] Masters: [rs1.china-kody.com] Stopped: [rs2.china-kody.com] Mysqlstore (Ocf::heartbeat:filesystem): Started rs1.china-kody.com mysqld (lsb:mysql): Started rs1.china-kody.com
4. Configure VIP Resources
colocation mysqlvip_with_mysqld inf:mysqlvip mysqld master/slave set:ms_mysqldrbd [MYSQLDRBD] Masters: [rs1.china-k Ody.com] Slaves: [rs2.china-kody.com] Mysqlstore (ocf::heartbeat:filesystem): Started rs1.china-kody.com mysqld (l Sb:mysql): Started rs1.china-kody.com Mysqlvip (ocf::heartbeat:ipaddr): Started rs1.china-kody.com
Corosync + DRBD + mysql Cluster