设为首页 收藏本站
查看: 901|回复: 0

[经验分享] corosync+pacemaker+crmsh(centos7+ansible)

[复制链接]

尚未签到

发表于 2018-1-2 18:34:20 | 显示全部楼层 |阅读模式
  ~]# crm_mon
  Stack: corosync
  Current DC: node1.com (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum
  Last updated: Tue Jan 17 14:53:34 2017          Last change: Tue Jan 17 14:51:11 2017 by h
  acluster via crmd on node1.com
  2 nodes and 0 resources configured
  Online: [ node1.com node2.com ]
  No active resources
  交互式查看
  ~]# crm
  crm(live)# status
  Stack: corosync
  Current DC: node1.com (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum
  Last updated: Tue Jan 17 14:54:40 2017        Last change: Tue Jan 17 14:51:11 2017 by h
  acluster via crmd on node1.com
  2 nodes and 0 resources configured
  Online: [ node1.com node2.com ]
  No resources

  crm(live)# ra>  lsb
  ocf / .isolation heartbeat openstack pacemaker
  service
  systemd
  crm(live)ra# list lsb     使用list命令查看ra类型中的所执行的应用
  netconsole   network
  crm(live)ra# list systemd
  NetworkManager                    NetworkManager-wait-online
  auditd                            brandbot
  corosync                          cpupower
  crond                             dbus
  display-manager                   dm-event
  dracut-shutdown                   emergency
  exim                              getty@tty1
  ip6tables                         iptables
  irqbalance                        kdump
  kmod-static-nodes                 ldconfig
  lvm2-activation                   lvm2-lvmetad
  lvm2-lvmpolld                     lvm2-monitor
  lvm2-pvscan@8:2                   microcode
  network                           pacemaker
  plymouth-quit                     plymouth-quit-wait
  plymouth-read-write               plymouth-start
  polkit                            postfix
  rc-local                          rescue
  rhel-autorelabel                  rhel-autorelabel-mark
  rhel-configure                    rhel-dmesg
  rhel-import-state                 rhel-loadmodules
  rhel-readonly                     rsyslog
  sendmail                          sshd
  sshd-keygen                       syslog
  systemd-ask-password-console      systemd-ask-password-plymouth
  systemd-ask-password-wall         systemd-binfmt
  systemd-firstboot                 systemd-fsck-root
  systemd-hwdb-update               systemd-initctl
  systemd-journal-catalog-update    systemd-journal-flush
  systemd-journald                  systemd-logind
  systemd-machine-id-commit         systemd-modules-load
  systemd-random-seed               systemd-random-seed-load
  systemd-readahead-collect         systemd-readahead-done
  systemd-readahead-replay          systemd-reboot
  systemd-remount-fs                systemd-rfkill@rfkill2
  systemd-shutdownd                 systemd-sysctl
  systemd-sysusers                  systemd-tmpfiles-clean
  systemd-tmpfiles-setup            systemd-tmpfiles-setup-dev
  systemd-udev-trigger              systemd-udevd
  systemd-update-done               systemd-update-utmp
  systemd-update-utmp-runlevel      systemd-user-sessions
  systemd-vconsole-setup            tuned
  wpa_supplicant
  crm(live)ra# list ocf
  CTDB                  ClusterMon            Delay
  Dummy                 Filesystem            HealthCPU
  HealthSMART           IPaddr                IPaddr2
  IPsrcaddr             LVM                   MailTo
  NovaEvacuate          Route                 SendArp
  Squid                 Stateful              SysInfo
  SystemHealth          VirtualDomain         Xinetd
  apache                clvm                  conntrackd
  controld              db2                   dhcpd
  docker                ethmonitor            exportfs
  galera                garbd                 iSCSILogicalUnit
  iSCSITarget           iface-vlan            mysql
  nagios                named                 nfsnotify
  nfsserver             nginx                 nova-compute-wait
  oracle                oralsnr               pgsql
  ping                  pingd                 portblock
  postfix               rabbitmq-cluster      redis
  remote                rsyncd                slapd
  symlink               tomcat
  crm(live)ra# list ocf heartbeat
  CTDB                  Delay                 Dummy
  Filesystem            IPaddr                IPaddr2
  IPsrcaddr             LVM                   MailTo
  Route                 SendArp               Squid
  VirtualDomain         Xinetd                apache
  clvm                  conntrackd            db2
  dhcpd                 docker                ethmonitor
  exportfs              galera                garbd
  iSCSILogicalUnit      iSCSITarget           iface-vlan
  mysql                 nagios                named
  nfsnotify             nfsserver             nginx
  oracle                oralsnr               pgsql
  portblock             postfix               rabbitmq-cluster
  redis                 rsyncd                slapd
  symlink               tomcat
  crm(live)ra# list ocf pacemaker
  ClusterMon       Dummy            HealthCPU        HealthSMART
  Stateful         SysInfo          SystemHealth     controld
  ping             pingd            remote
  crm(live)ra# list ocf openstack
  NovaEvacuate          nova-compute-wait
  crm(live)ra# info ocf:heartbeat:IPaddr     使用info命令查看具体使用方法
  crm(live)node# ls     节点模式,可以控制节点的standby 上线等动作
  ..               help             fence
  show             attribute        back
  cd               ready            status-attr
  quit             end              utilization
  exit             ls               maintenance
  online           bye              ?
  status           clearstate       standby
  list             up               server
  delete
  crm(live)node# standby     不加参数即为当前节点作为standby服务器
  crm(live)node# cd
  crm(live)# status
  Stack: corosync
  Current DC: node1.com (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum
  Last updated: Tue Jan 17 15:07:44 2017        Last change: Tue Jan 17 15:07:40 2017 by r
  oot via crm_attribute on node1.com
  2 nodes and 0 resources configured
  Node node1.com: standby     此时node1状态以及为standby
  Online: [ node2.com ]
  No resources
  crm(live)# node
  crm(live)node# online     使用online命令进行上线
  crm(live)node# cd
  crm(live)# status
  Stack: corosync
  Current DC: node1.com (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum
  Last updated: Tue Jan 17 15:08:36 2017        Last change: Tue Jan 17 15:08:33 2017 by r
  oot via crm_attribute on node1.com
  2 nodes and 0 resources configured
  Online: [ node1.com node2.com ]
  No resources
  也可以直接在最外层进行操作
  crm(live)# node online node2.com
  crm(live)# status
  Stack: corosync
  n with quorum
  15 09:48:17 2017 by root via crm_attribute on node1.com
  2 nodes and 0 resources configured
  Online: [ node1.com node2.com ]
  No resources
  使用configure进入配置模式
  crm(live)# configure
  crm(live)configure# ls
  ..               get_property     cibstatus
  primitive        set              validate_all
  help             rsc_template     ptest
  back             cd               default-timeouts
  erase            validate-all     rsctest
  rename           op_defaults      modgroup
  xml              quit             upgrade
  group            graph            load
  master           location         template
  save             collocation      rm
  bye              clone            ?
  ls               node             default_timeouts
  exit             acl_target       colocation
  fencing_topology assist           alert
  ra               schema           user
  simulate         rsc_ticket       end
  role             rsc_defaults     monitor
  cib              property         resource
  edit             show             up
  refresh          order            filter
  get-property     tag              ms
  verify           commit           history
  delete
  location定义资源粘性
  property定义群集全局属性
  crm(live)# configure
  crm(live)configure# property     使用tab键可以查看property的具体内容和使用方法
  batch-limit=                   node-health-strategy=
  cluster-delay=                 node-health-yellow=
  cluster-recheck-interval=      notification-agent=
  concurrent-fencing=            notification-recipient=
  crmd-transition-delay=         pe-error-series-max=
  dc-deadtime=                   pe-input-series-max=
  default-action-timeout=        pe-warn-series-max=
  default-resource-stickiness=   placement-strategy=
  election-timeout=              remove-after-stop=
  enable-acl=                    shutdown-escalation=
  enable-startup-probes=         start-failure-is-fatal=
  have-watchdog=                 startup-fencing=
  is-managed-default=            stonith-action=
  load-threshold=                stonith-enabled=
  maintenance-mode=              stonith-timeout=
  migration-limit=               stonith-watchdog-timeout=
  no-quorum-policy=              stop-all-resources=
  node-action-limit=             stop-orphan-actions=
  node-health-green=             stop-orphan-resources=
  node-health-red=               symmetric-cluster=
  crm(live)configure# property no-quorum-policy=
  t have quorum
  : stop, freeze, ignore, suicide
  crm(live)configure# property no-quorum-policy=stop
  crm(live)configure# show     查看当前设置
  node 1: node1.com
  node 2: node2.com \
  attributes standby=off
  property cib-bootstrap-options: \
  have-watchdog=false \
  dc-version=1.1.15-11.el7_3.2-e174ec8 \
  cluster-infrastructure=corosync \
  cluster-name=mycluster \
  no-quorum-policy=stop
  关闭stonith设备
  crm(live)configure# property stonith-enabled=false
  定义群集ip
  crm(live)configure# primitive webip ocf:heartbeat:IPaddr params ip=192.168.150.80
  使用verify进行配置验证
  crm(live)configure# verify
  使用commit进行配置确认并生效
  crm(live)configure# commit
  crm(live)configure# show 查看配置
  node 1: node1.com \
  attributes standby=off
  node 2: node2.com
  primitive webip IPaddr \
  params ip=192.168.150.80
  property cib-bootstrap-options: \
  have-watchdog=false \
  dc-version=1.1.15-11.el7_3.2-e174ec8 \
  cluster-infrastructure=corosync \
  cluster-name=mycluster \
  no-quorum-policy=stop \
  stonith-enabled=false
  查看状态
  crm(live)# status
  Stack: corosync
  Current DC: node1.com (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum
  Last updated: Tue Jan 17 15:23:58 2017        Last change: Tue Jan 17 15:23:55 2017 by r
  oot via cibadmin on node1.com
  2 nodes and 1 resource configured
  Online: [ node1.com node2.com ]
  Full list of resources:
  webip    (ocf::heartbeat:IPaddr):    Started node1.com     此时webip这个群集资源在node1上
  可以通过ip addr 在node1上进行认证
  node1 ~]# ip addr
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
  valid_lft forever preferred_lft forever
  inet6 ::1/128 scope host
  valid_lft forever preferred_lft forever
  2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen
  1000    link/ether 00:0c:29:98:ad:a4 brd ff:ff:ff:ff:ff:ff
  inet 192.168.150.137/24 brd 192.168.150.255 scope global eno16777736
  valid_lft forever preferred_lft forever
  inet 192.168.150.80/24 brd 192.168.150.255 scope global secondary eno16777736
  valid_lft forever preferred_lft forever
  inet6 fe80::20c:29ff:fe98:ada4/64 scope link
  valid_lft forever preferred_lft forever
  让node1切换成standby,查看资源是否会迁移至node2
[iyunv@node1 ~]# crm node standby

[iyunv@node1 ~]# crm status

  Stack: corosync
  Current DC: node1.com (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum
  Last updated: Tue Jan 17 15:26:43 2017        Last change: Tue Jan 17 15:26:40 2017 by r
  oot via crm_attribute on node1.com
  2 nodes and 1 resource configured
  Node node1.com: standby
  Online: [ node2.com ]
  Full list of resources:
  webip    (ocf::heartbeat:IPaddr):    Started node2.com     webip资源以及迁移至node2
  验证
  node2 ~]# ip addr
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
  valid_lft forever preferred_lft forever
  inet6 ::1/128 scope host
  valid_lft forever preferred_lft forever
  2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen
  1000    link/ether 00:0c:29:f3:13:56 brd ff:ff:ff:ff:ff:ff
  inet 192.168.150.138/24 brd 192.168.150.255 scope global eno16777736
  valid_lft forever preferred_lft forever
  inet 192.168.150.80/24 brd 192.168.150.255 scope global secondary eno16777736
  valid_lft forever preferred_lft forever
  inet6 fe80::20c:29ff:fef3:1356/64 scope link
  valid_lft forever preferred_lft forever
  对node1进行online操作,由于没有设定组合粘性,资源还是会停留在node2
[iyunv@node1 ~]# crm node online

[iyunv@node1 ~]# crm status

  Stack: corosync
  Current DC: node1.com (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum
  Last updated: Tue Jan 17 15:30:05 2017        Last change: Tue Jan 17 15:30:02 2017 by r
  oot via crm_attribute on node1.com
  2 nodes and 1 resource configured
  Online: [ node1.com node2.com ]
  Full list of resources:
  webip    (ocf::heartbeat:IPaddr):    Started node2.com
  可以使用migrate进行资源转移
  crm(live)resource# migrate webip node1.com
  INFO: Move constraint created for webip to node2.com
  crm(live)resource# cd
  crm(live)# status
  Stack: corosync
  Current DC: node1.com (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum
  Last updated: Tue Jan 17 15:37:00 2017        Last change: Tue Jan 17 15:36:49 2017 by r
  oot via crm_resource on node1.com
  2 nodes and 1 resource configured
  Online: [ node1.com node2.com ]
  Full list of resources:
  webip    (ocf::heartbeat:IPaddr):    Started node1.com
  在resource中可以进行资源的停止开启和删除
  crm(live)resource# stop webip
  crm(live)resource# cd
  crm(live)# status
  Stack: corosync
  Current DC: node1.com (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum
  Last updated: Tue Jan 17 15:38:52 2017        Last change: Tue Jan 17 15:38:50 2017 by r
  oot via cibadmin on node1.com
  2 nodes and 1 resource configured: 1 resource DISABLED and 0 BLOCKED from being started du
  e to failures
  Online: [ node1.com node2.com ]
  Full list of resources:
  webip    (ocf::heartbeat:IPaddr):    Stopped (disabled)
  crm(live)# resource
  crm(live)resource# start webip
  crm(live)resource# cd
  crm(live)# status
  Stack: corosync
  Current DC: node1.com (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum
  Last updated: Tue Jan 17 15:39:03 2017        Last change: Tue Jan 17 15:39:00 2017 by r
  oot via cibadmin on node1.com
  2 nodes and 1 resource configured
  Online: [ node1.com node2.com ]
  Full list of resources:
  webip    (ocf::heartbeat:IPaddr):    Started node1.com

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-430897-1-1.html 上篇帖子: 自动化运维 -- 02 Ansible 下篇帖子: ansible-playbook 安装nginx
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表