314598340 发表于 2018-10-2 08:42:01

HA专题: Corosync+Pacemaker+drbd实现MySQL高可用

install corosync pacemaker crmsh -y --nogpgcheck  # cd /etc/corosync/
  # corosync-keygen
  # chmod 600 authkey
  配置文件如下: /etc/corosync/corosync.conf
  # grep -v "[[:space:]]*#" /etc/corosync/corosync.conf
  compatibility: whitetank
  totem {
  version: 2
  secauth: on
  threads: 0
  interface {
  ringnumber: 0
  bindnetaddr: 172.16.1.0
  mcastaddr: 239.255.1.1
  mcastport: 5405
  ttl: 1
  }
  }
  logging {
  fileline: off
  to_stderr: no
  to_logfile: yes
  logfile: /var/log/cluster/corosync.log
  to_syslog: no
  debug: off
  timestamp: on
  logger_subsys {
  subsys: AMF
  debug: off
  }
  }
  service {
  ver: 0
  name: pacemaker
  }
  aisexec {
  user: root
  group: root
  }
  # yum install corosync pacemaker crmsh -y --nogpgcheck
  # scp -p node1.anyisalin.com:/etc/corosync/{authkey,corosync.conf} /etc/corosync/
  在两个节点上启动corosync
  # service corosync start
  # ssh node2.anyisalin.com -- /etc/init.d/corosync start
  # crm status#查看节点状态
  Last updated: Wed Apr 13 15:07:52 2016
  Last change: Wed Apr 13 15:07:22 2016

  Stack:>  Current DC: node2.anyisalin.com - partition with quorum
  Version: 1.1.11-97629de
  2 Nodes configured, 2 expected votes
  0 Resources configured
  Online: [ node1.anyisalin.com node2.anyisalin.com ]
  Full list of resources:
  配置资源
  crm(live)# configure
  crm(live)configure# edit    #配置如下, 仅供参考
  node node1.anyisalin.com \
  attributes standby=on
  node node2.anyisalin.com \
  attributes standby=off
  primitive data_drbd ocf:linbit:drbd \
  params drbd_resource=data \
  op monitor role=Master interval=10s timoue=20s \
  op monitor role=Slave interval=20s timeout=20s \
  op start interval=0 timeout=240 \
  op stop interval=0 timeout=120
  primitive myip IPaddr \
  params ip=172.16.1.8
  primitive mysql service:mysqld
  primitive mysqldatafs Filesystem \
  params device="/dev/drbd0" directory="/data" fstype=ext4 \
  op start interval=0 timeout=60 \
  op stop interval=0 timeout=60
  ms MS_data_drbd data_drbd \
  meta master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true
  colocation myip_with_mysql inf: myip mysql
  order mysql_after_mysqldatafs inf: mysqldatafs mysql
  colocation mysql_with_mysqldatafs inf: mysql mysqldatafs
  order mysqldatafs_afer_MS_data_drbd inf: MS_data_drbd:promote mysqldatafs:start
  colocation mysqldatafs_with_MS_data_drbd inf: mysqldatafs MS_data_drbd:Master
  property cib-bootstrap-options: \
  dc-version=1.1.11-97629de \
  cluster-infrastructure="classic openais (with plugin)" \
  expected-quorum-votes=2 \
  stonith-enabled=false \
  last-lrm-refresh=1460541144 \
  no-quorum-policy=ignore

页: [1]
查看完整版本: HA专题: Corosync+Pacemaker+drbd实现MySQL高可用