在操作之前请确保:
- 172.16.100.1 db1.magedu.com db1
- 172.16.100.2 db2.magedu.com db2
- # ssh-keygen -t rsa
- # ssh-copy-id -i ~/.ssh/id_rsa.pub root@node2
- #yum -y --nopgpcheck localinstall ./*.rpm
- 1)cd /etc/corosync
- # cp corosync.conf.example corosync.conf
- 2)编辑corosync.conf添加以下内容
- service {
- ver:0
- name:pacemaker
- }
- aisexec{
- user: root
- group: root
- }
- bindnetaddr: 172.16.0.0
- # corosync-keygen
- # scp -p corosync.conf authkey db2:/etc/corosync/
- # mkdir /var/log/cluster
- # service corosync start
- [root@db1 corosync]# grep -e "Corosync Cluster Engine" -e "configuration file" /var/log/messages
- Nov 28 15:51:08 db1 corosync[7995]: [MAIN ] Corosync Cluster Engine ('1.2.7'): started and ready to provide service.
- Nov 28 15:51:08 db1 corosync[7995]: [MAIN ] Successfully read main configuration file '/etc/corosync/corosync.conf'.
- Nov 28 15:51:08 db1 corosync[7995]: [MAIN ] Corosync Cluster Engine exiting with status 8 at main.c:1397.
- Nov 28 15:51:35 db1 corosync[8017]: [MAIN ] Corosync Cluster Engine ('1.2.7'): started and ready to provide service.
- Nov 28 15:51:35 db1 corosync[8017]: [MAIN ] Successfully read main configuration file '/etc/corosync/corosync.conf'.
- [root@db1 corosync]#
- [root@db1 corosync]# grep TOTEM /var/log/messages
- Nov 28 15:51:35 db1 corosync[8017]: [TOTEM ] Initializing transport (UDP/IP).
- Nov 28 15:51:35 db1 corosync[8017]: [TOTEM ] Initializing transmit/receive security: libtomcrypt SOBER128/SHA1HMAC (mode 0).
- Nov 28 15:51:35 db1 corosync[8017]: [TOTEM ] The network interface [172.16.16.1] is now up.
- Nov 28 15:51:36 db1 corosync[8017]: [TOTEM ] Process pause detected for 558 ms, flushing membership messages.
- Nov 28 15:51:36 db1 corosync[8017]: [TOTEM ] A processor joined or left the membership and a new membership was formed.
- Nov 28 15:53:31 db1 corosync[8017]: [TOTEM ] A processor joined or left the membership and a new membership was formed.
- [root@db1 corosync]#
- [root@db1 corosync]# grep ERROR: /var/log/messages | grep -v unpack_resources
- [root@db1 corosync]# grep pcmk_startup /var/log/messages
- Nov 28 15:51:36 db1 corosync[8017]: [pcmk ] info: pcmk_startup: CRM: Initialized
- Nov 28 15:51:36 db1 corosync[8017]: [pcmk ] Logging: Initialized pcmk_startup
- Nov 28 15:51:36 db1 corosync[8017]: [pcmk ] info: pcmk_startup: Maximum core file size is: 4294967295
- Nov 28 15:51:36 db1 corosync[8017]: [pcmk ] info: pcmk_startup: Service: 9
- Nov 28 15:51:36 db1 corosync[8017]: [pcmk ] info: pcmk_startup: Local hostname: db1.magedu.com
- # ssh db2 'service corosync start'
- #crm status
- yum -y --nogpgcheck localinstall drbd83-8.3.13-2.el5.centos.i386.rpm kmod-drbd83-8.3.13-1.el5.centos.i686.rpm
- cp /usr/share/doc/drbd83-8.3.13/drbd.conf /etc/drbd.conf
- disk {
- on-io-error detach;
- }
- net {
- cram-hmac-alg "sha1";
- shared-secret "mysqldrbd";
- }
- syncer {
- rate 200M;
- }
- resource sql {
- on db1.magedu.com {
- device /dev/drbd1;
- disk /dev/sda5;
- address 172.16.16.1:7789;
- meta-disk internal;
- }
- on db2.magedu.com {
- device /dev/drbd1;
- disk /dev/sda5
- address 172.16.16.2:7789;
- meta-disk internal;
- }
- }
- # scp /etc/drbd.conf db2:/etc/
- # scp /etc/drbd.d/* db2:/etc/drbd.d/
- partprobe /dev/sda
- # drbdam create-md sql
- # ls /dev/drbd
- # /etc/init.d/drbd start
- # cat /proc/drbd
- # drbd-overview
- # drbdsetup /dev/drbd1 primary -o
- # wathc -nl 'cat /proc/drbd'
- # drbd-overview 查看同步后的状态
- # mke2fs -j L DRBD /dev/drbd1
- # mkdir -pv /data/mydata
- # mount /dev/drbd1 /data/mydata
- # umount /data/mydata
- # drbdadm decondary sql
- # drbdadm primary sql
- # mkdir -pv /data/mydata
- # mount /dev/drbd1 /data/mydata
- # chown -R mysql:mysql /data/mydata
- # tar xf mysql-5.5.28-linux2.6-i686.tar.gz -C /usr/local/
- # ln -sv mysql-5.5.28-linux2.6-i686/ mysql
- # cd mysql
- # chown -R :mysql .
- # scripts/mysql_install_db --user=mysql --datadir=/data/mytada
- # cp support-files/mysql.server /etc/rc.d/init.d/mysqld
- # cp support-files/my-large.cnf /etc/my.cnf
- # datadir = /data/mydata
- # service mysqld start
- chkconfig mysqld off
- drbdadm primary sql
- mount /dev/drbd2 /data/mydata
- # tar xf mysql-5.5.28-linux2.6-i686.tar.gz /usr/local/
- # ln -sv mysql-5.5.28-linux2.6-i686/ mysql
- # cd mysql
- # chown -R :mysql .
- # scp db1:/etc/rc.d/init.d/mysqld /etc/rc.d/init.d/
- # scp db1:/etc/my.cnf /etc
- # service mysqld stop
- # chkcofig mysqld off
- # service drbd stop
- # chkcofig drbd off
- # service corosync start
- # ssh db2 'service corosync start'
- # crm status
- [root@db1 /]# crm configure
- crm(live)configure# property stonith-enabled=false
- crm(live)configure# property no-quorum-policy=ignore
- crm(live)configure# verify
- crm(live)configure# commit
- crm(live)configure# primitive my_drbd ocf:linbit:drbd params drbd_resource='sql' op start timeout=240 op stop timeout=100
- crm(live)configure# master ms_my_drbd my_drbd meta master-max="1" master-node-max="1" clone-max="2" clone-node-max=1 notify="ture"
- crm(live)configure# commint
- [root@db1 ~]# crm node standby
- [root@db1 ~]# crm node online
- [root@db1 ~]# drbd-overview
- crm(live)configure# primitive my_fs ocf:heartbeat:Filesystem params device="/dev/drbd1" directory="/data/mydata" fstype="ext3" op start timeout=60 op stop timeout=60
- crm(live)configure# colocation my_fs_on_ms_my_drbd inf: my_fs ms_my_drbd:Master
- crm(live)configure# order my_fs_after_ms_my_drbd mandatory: ms_my_drbd my_fs:start
- crm(live)configure#verify
- crm(live)configure#commit
- crm(live)configure# primitive my_sql lsb:mysqld
- crm(live)configure# colocation my_sql_with_my_fs inf:my_sql my_fs
- crm(live)configure# order my_sql_after_my_fs mandatory:my_fs my_sql
- crm(live)configure# primitive my_ip ocf:heartbeat:IPaddr2 params ip="172.16.16.100"
- crm(live)configure# colocation my_ip_with_ms_my_drbd_master inf:my_ip ms_my_drbd:Master
- crm(live)configure#verify
- crm(live)configure#commit