OpenStack HA集群3-Pacemake Corosync

OpenStack HA集群3-Pacemake Corosync

大家好,又见面了,我是全栈君。

节点间主机名必须能解析

[root@controller1 ~]# cat /etc/hosts

192.168.17.149  controller1

192.168.17.141  controller2

192.168.17.166  controller3

192.168.17.111  demo.open-stack.cn

各节点间要互信,无密码能登录

[root@controller1 ~]# ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

20:79:d4:a4:9f:8b:75:cf:12:58:f4:47:a4:c1:29:f3 root@controller1

The key’s randomart image is:

+–[ RSA 2048]—-+

|      .o. …oo  |

|     o …o.o+   |

|    o +   .+o .  |

|     o o +  E.   |

|        S o      |

|       o o +     |

|      . . . o    |

|           .     |

|                 |

+—————–+

[root@controller1 ~]# ssh-copy-id controller2

[root@controller1 ~]# ssh-copy-id controller3

配置YUM源

# vim /etc/yum.repos.d/ha-clustering.repo

[network_ha-clustering_Stable]

name=Stable High Availability/Clustering packages (CentOS-7)

type=rpm-md

baseurl=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-7/

gpgcheck=0

gpgkey=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-7/repodata/repomd.xml.key

enabled=1

这个YUM源可能会冲突,先enabled=0,如果剩下一个crmsh包,再enabled=1打开后安装

Corosync下载地址,目前最新版本2.4.2

http://build.clusterlabs.org/corosync/releases/

http://build.clusterlabs.org/corosync/releases/corosync-2.4.2.tar.gz

[root@controller1 ~]# ansible controller -m copy -a “src=/etc/yum.repos.d/ha-cluster.repo dest=/etc/yum.repos.d/”

安装软件包

# yum install pacemaker pcs resource-agents -y cifs-utils quota psmisc corosync fence-agents-all lvm2 resource-agents

#  yum install crmsh  -y

启动pcsd,并确认启动正常

# systemctl enable pcsd

# systemctl enable corosync

# systemctl start pcsd

# systemctl status pcsd

[root@controller2 ~]# pacemakerd -$

Pacemaker 1.1.15-11.el7_3.2

Written by Andrew Beekhof

[root@controller1 ~]# ansible controller -m command -a “pacemakerd -$”

修改hacluster密码

【all】# echo zoomtech | passwd –stdin hacluster

[root@controller1 ~]# ansible controller -m command -a “echo zoomtech | passwd –stdin hacluster”

# passwd hacluster

编辑corosync.conf

[root@controller3 ~]# vim /etc/corosync/corosync.conf

totem {

        version: 2

        secauth: off

        cluster_name: openstack-cluster

        transport: udpu

}

nodelist {

        node {

                ring0_addr: controller1

                nodeid: 1

        }

        node {

                ring0_addr: controller2

                nodeid: 2

        }

        node {

                ring0_addr: controller3

                nodeid: 3

        }

}

logging {

        to_logfile: yes

        logfile: /var/log/cluster/corosync.log

        to_syslog: yes

}

quorum {

        provider: corosync_votequorum

}

[root@controller1 ~]# scp /etc/corosync/corosync.conf controller2:/etc/corosync/

[root@controller1 ~]# scp /etc/corosync/corosync.conf controller3:/etc/corosync/

[root@controller1 corosync]# ansible controller -m copy -a “src=corosync.conf dest=/etc/corosync”

创建集群

使用pcs设置集群身份认证

[root@controller1 ~]# pcs cluster auth controller1 controller2 controller3 -u hacluster -p zoomtech –force

controller3: Authorized

controller2: Authorized

controller1: Authorized

现在我们创建一个集群并添加一些节点。注意,这个名字不能超过15个字符

[root@controller1 ~]# pcs cluster setup –force –name openstack-cluster controller1 controller2 controller3

Destroying cluster on nodes: controller1, controller2, controller3…

controller3: Stopping Cluster (pacemaker)…

controller2: Stopping Cluster (pacemaker)…

controller1: Stopping Cluster (pacemaker)…

controller2: Successfully destroyed cluster

controller1: Successfully destroyed cluster

controller3: Successfully destroyed cluster

Sending cluster config files to the nodes…

controller1: Succeeded

controller2: Succeeded

controller3: Succeeded

Synchronizing pcsd certificates on nodes controller1, controller2, controller3…

controller3: Success

controller2: Success

controller1: Success

Restarting pcsd on the nodes in order to reload the certificates…

controller3: Success

controller2: Success

controller1: Success

启动集群

[root@controller1 ~]# pcs cluster enable –all

controller1: Cluster Enabled

controller2: Cluster Enabled

controller3: Cluster Enabled

[root@controller1 ~]# pcs cluster start –all

controller2: Starting Cluster…

controller1: Starting Cluster…

controller3: Starting Cluster…

查看集群状态

[root@controller1 corosync]# ansible controller -m command -a “pcs cluster status”

[root@controller1 ~]# pcs cluster status

Cluster Status:

 Stack: corosync

 Current DC: controller3 (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum

 Last updated: Fri Feb 17 10:39:38 2017        Last change: Fri Feb 17 10:39:29 2017 by hacluster via crmd on controller3

 3 nodes and 0 resources configured

PCSD Status:

  controller2: Online

  controller3: Online

  controller1: Online

[root@controller1 corosync]# ansible controller -m command -a “pcs status”

[root@controller1 ~]# pcs status

Cluster name: openstack-cluster

Stack: corosync

Current DC: controller2 (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum

Last updated: Thu Mar  2 17:07:34 2017        Last change: Thu Mar  2 01:44:44 2017 by root via cibadmin on controller1

3 nodes and 1 resource configured

Online: [ controller1 controller2 controller3 ]

Full list of resources:

 vip    (ocf::heartbeat:IPaddr2):    Started controller2

Daemon Status:

  corosync: active/enabled

  pacemaker: active/enabled

  pcsd: active/enabled

查看集群状态

[root@controller1 corosync]# ansible controller -m command -a “crm_mon -1”

[root@controller1 ~]# crm_mon -1

Stack: corosync

Current DC: controller2 (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum

Last updated: Wed Mar  1 17:54:04 2017          Last change: Wed Mar  1 17:44:38 2017 by root via cibadmin on controller1

3 nodes and 1 resource configured

Online: [ controller1 controller2 controller3 ]

Active resources:

vip     (ocf::heartbeat:IPaddr2):    Started controller1

查看pacemaker进程状态

[root@controller1 ~]# ps aux | grep pacemaker

root      75900  0.2  0.5 132632  9216 ?        Ss   10:39   0:00 /usr/sbin/pacemaked -f

haclust+  75901  0.3  0.8 135268 15376 ?        Ss   10:39   0:00 /usr/libexec/pacemaker/cib

root      75902  0.1  0.4 135608  7920 ?        Ss   10:39   0:00 /usr/libexec/pacemaker/stonithd

root      75903  0.0  0.2 105092  5020 ?        Ss   10:39   0:00 /usr/libexec/pacemaker/lrmd

haclust+  75904  0.0  0.4 126924  7636 ?        Ss   10:39   0:00 /usr/libexec/pacemaker/attrd

haclust+  75905  0.0  0.2 117040  4560 ?        Ss   10:39   0:00 /usr/libexec/pacemaker/pengine

haclust+  75906  0.1  0.5 145328  8988 ?        Ss   10:39   0:00 /usr/libexec/pacemaker/crmd

root      75997  0.0  0.0 112648   948 pts/0    R+   10:40   0:00 grep –color=auto pacemaker

查看集群状态

[root@controller1 ~]# corosync-cfgtool -s

Printing ring status.

Local node ID 1

RING ID 0

    id    = 192.168.17.132

    status    = ring 0 active with no faults

[root@controller2 corosync]# corosync-cfgtool -s

Printing ring status.

Local node ID 2

RING ID 0

    id    = 192.168.17.146

    status    = ring 0 active with no faults

[root@controller3 ~]# corosync-cfgtool -s

Printing ring status.

Local node ID 3

RING ID 0

    id    = 192.168.17.138

    status    = ring 0 active with no faults

[root@controller1 ~]# corosync-cmapctl | grep members

runtime.totem.pg.mrp.srp.members.1.config_version (u64) = 0

runtime.totem.pg.mrp.srp.members.1.ip (str) = r(0) ip(192.168.17.132)

runtime.totem.pg.mrp.srp.members.1.join_count (u32) = 1

runtime.totem.pg.mrp.srp.members.1.status (str) = joined

runtime.totem.pg.mrp.srp.members.2.config_version (u64) = 0

runtime.totem.pg.mrp.srp.members.2.ip (str) = r(0) ip(192.168.17.146)

runtime.totem.pg.mrp.srp.members.2.join_count (u32) = 1

runtime.totem.pg.mrp.srp.members.2.status (str) = joined

runtime.totem.pg.mrp.srp.members.3.config_version (u64) = 0

runtime.totem.pg.mrp.srp.members.3.ip (str) = r(0) ip(192.168.17.138)

runtime.totem.pg.mrp.srp.members.3.join_count (u32) = 1

runtime.totem.pg.mrp.srp.members.3.status (str) = joined

查看集群状态

[root@controller1 ~]# pcs status corosync

Membership information

———————-

    Nodeid      Votes Name

         1          1 controller1 (local)

         3          1 controller3

         2          1 controller2

[root@controller2 corosync]# pcs status corosync

Membership information

———————-

    Nodeid      Votes Name

         1          1 controller1

         3          1 controller3

         2          1 controller2 (local)

[root@controller3 ~]# pcs status corosync

Membership information

———————-

    Nodeid      Votes Name

         1          1 controller1

         3          1 controller3 (local)

         2          1 controller2

[root@controller1 ~]# crm_verify -L -V

   error: unpack_resources:    Resource start-up disabled since no STONITH resources have been defined

   error: unpack_resources:    Either configure some or disable STONITH with the stonith-enabled option

   error: unpack_resources:    NOTE: Clusters with shared data need STONITH to ensure data integrity

Errors found during check: config not valid

[root@controller1 ~]#

[root@controller1 ~]# pcs property set stonith-enabled=false

[root@controller1 ~]# pcs property set no-quorum-policy=ignore

[root@controller1 ~]# crm_verify -L -V

[root@controller1 corosync]# ansible controller -m command -a “pcs property set stonith-enabled=false

[root@controller1 corosync]# ansible controller -m command -a “pcs property set no-quorum-policy=ignore”

[root@controller1 corosync]# ansible controller -m command -a “crm_verify -L -V”

配置 VIP

[root@controller1 ~]# crm

crm(live)# configure

crm(live)configure# show

node 1: controller1

node 2: controller2

node 3: controller3

property cib-bootstrap-options: \

    have-watchdog=false \

    dc-version=1.1.15-11.el7_3.2-e174ec8 \

    cluster-infrastructure=corosync \

    cluster-name=openstack-cluster \

    stonith-enabled=false \

    no-quorum-policy=ignore

crm(live)configure# primitive vip ocf:heartbeat:IPaddr2 params ip=192.168.17.111 cidr_netmask=24 nic=ens37 op start interval=0s timeout=20s op stop interval=0s timeout=20s monitor interval=30s meta priority=100

crm(live)configure# show

node 1: controller1

node 2: controller2

node 3: controller3

primitive vip IPaddr2 \

    params ip=192.168.17.111 cidr_netmask=24 nic=ens37 \

    op start interval=0s timeout=20s \

    op stop interval=30s timeout=20s monitor \

    meta priority=100

property cib-bootstrap-options: \

    have-watchdog=false \

    dc-version=1.1.15-11.el7_3.2-e174ec8 \

    cluster-infrastructure=corosync \

    cluster-name=openstack-cluster \

    stonith-enabled=false \

    no-quorum-policy=ignore

crm(live)configure# commit

crm(live)configure# exit

查看VIP已绑定在ens37网卡上

[root@controller1 ~]# ip a

4: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 00:0c:29:ff:8b:4b brd ff:ff:ff:ff:ff:ff

    inet 192.168.17.141/24 brd 192.168.17.255 scope global dynamic ens37

       valid_lft 2388741sec preferred_lft 2388741sec

    inet 192.168.17.111/24 brd 192.168.17.255 scope global secondary ens37

       valid_lft forever preferred_lft forever

上面指定的网卡名称3个节点必须是同一个名称,否则飘移会出现问题,切换不过去

[root@controller1 ~]# crm status

Stack: corosync

Current DC: controller1 (version 1.1.15-11.el7_3.2-e174ec8) – partition with quorum

Last updated: Wed Feb 22 11:42:07 2017        Last change: Wed Feb 22 11:22:56 2017 by root via cibadmin on controller1


3 nodes and 1 resource configured


Online: [ controller1 controller2 controller3 ]


Full list of resources:


 vip    (ocf::heartbeat:IPaddr2):    Started controller1

查看corosync引擎是否正常启动

[root@controller1 ~]# grep -e “Corosync Cluster Engine” -e “configuration file” /var/log/cluster/corosync.log

[51405] controller1 corosyncnotice  [MAIN  ] Corosync Cluster Engine (‘2.4.0’): started and ready to provide service.

Mar 01 17:35:20 [51425] controller1        cib:     info: retrieveCib:    Reading cluster configuration file /var/lib/pacemaker/cib/cib.xml (digest: /var/lib/pacemaker/cib/cib.xml.sig)

Mar 01 17:35:20 [51425] controller1        cib:  warning: cib_file_read_and_verify:    Could not verify cluster configuration file /var/lib/pacemaker/cib/cib.xml: No such file or directory (2)

Mar 01 17:35:20 [51425] controller1        cib:  warning: cib_file_read_and_verify:    Could not verify cluster configuration file /var/lib/pacemaker/cib/cib.xml: No such file or directory (2)

Mar 01 17:35:20 [51425] controller1        cib:     info: cib_file_write_with_digest:    Reading cluster configuration file /var/lib/pacemaker/cib/cib.Apziws (digest: /var/lib/pacemaker/cib/cib.0ZxsVW)

Mar 01 17:35:21 [51425] controller1        cib:     info: cib_file_write_with_digest:    Reading cluster configuration file /var/lib/pacemaker/cib/cib.ObYehI (digest: /var/lib/pacemaker/cib/cib.O8Rntg)

Mar 01 17:35:42 [51425] controller1        cib:     info: cib_file_write_with_digest:    Reading cluster configuration file /var/lib/pacemaker/cib/cib.eqrhsF (digest: /var/lib/pacemaker/cib/cib.6BCfNj)

Mar 01 17:35:42 [51425] controller1        cib:     info: cib_file_write_with_digest:    Reading cluster configuration file /var/lib/pacemaker/cib/cib.riot2E (digest: /var/lib/pacemaker/cib/cib.SAqtzj)

Mar 01 17:35:42 [51425] controller1        cib:     info: cib_file_write_with_digest:    Reading cluster configuration file /var/lib/pacemaker/cib/cib.Q8H9BL (digest: /var/lib/pacemaker/cib/cib.MBljlq)

Mar 01 17:38:29 [51425] controller1        cib:     info: cib_file_write_with_digest:    Reading cluster configuration file /var/lib/pacemaker/cib/cib.OTIiU4 (digest: /var/lib/pacemaker/cib/cib.JnHr1v)

Mar 01 17:38:36 [51425] controller1        cib:     info: cib_file_write_with_digest:    Reading cluster configuration file /var/lib/pacemaker/cib/cib.2cK9Yk (digest: /var/lib/pacemaker/cib/cib.JSqEH8)

Mar 01 17:44:38 [51425] controller1        cib:     info: cib_file_write_with_digest:    Reading cluster configuration file /var/lib/pacemaker/cib/cib.aPFtr3 (digest: /var/lib/pacemaker/cib/cib.E3Ve7X)

[root@controller1 ~]#

查看初始化成员节点通知是否正常发出 

[root@controller1 ~]# grep  TOTEM /var/log/cluster/corosync.log 

[51405] controller1 corosyncnotice  [TOTEM ] Initializing transport (UDP/IP Unicast).

[51405] controller1 corosyncnotice  [TOTEM ] Initializing transmit/receive security (NSS) crypto: none hash: none

[51405] controller1 corosyncnotice  [TOTEM ] The network interface [192.168.17.149] is now up.

[51405] controller1 corosyncnotice  [TOTEM ] adding new UDPU member {192.168.17.149}

[51405] controller1 corosyncnotice  [TOTEM ] adding new UDPU member {192.168.17.141}

[51405] controller1 corosyncnotice  [TOTEM ] adding new UDPU member {192.168.17.166}

[51405] controller1 corosyncnotice  [TOTEM ] A new membership (192.168.17.149:4) was formed. Members joined: 1

[51405] controller1 corosyncnotice  [TOTEM ] A new membership (192.168.17.141:12) was formed. Members joined: 2 3

检查启动过程中是否有错误产生

[root@controller1 ~]# grep ERROR: /var/log/cluster/corosync.log

本文转自 OpenStack2015 51CTO博客,原文链接:http://blog.51cto.com/andyliu/1917391,如需转载请自行联系原作者

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/107875.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 超详细总结之Word2Vec(一)原理推导[通俗易懂]

    超详细总结之Word2Vec(一)原理推导[通俗易懂]本章是介绍Word2Vec的原理推导部分,后面还会有基于TensorFlow的Word2Vec代码实现讲解。一、什么是Word2Vec?2013年,Google团队发表了word2vec工具。word2vec工具主要包含两个模型:跳字模型(skip-gram)和连续词袋模型(continuousbagofwords,简称CBOW),以及两种高效训练的方法:负采样(negatives…

  • 自抗扰控制(ADRC)—— python 实战「建议收藏」

    自抗扰控制(ADRC)—— python 实战「建议收藏」本文利用跟踪微分器(TD)、扩张状态观测器(ESO)和非线性PID实现了受外扰的未知系统的控制,使得受控系统输出了期望信号。

  • Windows系统日志分析工具– Log Parser「建议收藏」

    Windows系统日志分析工具– Log Parser「建议收藏」可参考文章:日志分析工具LogParser学习笔记_Memetali_ss的博客-CSDN博客写完才看见。吐了0x01基本设置事件ID及常见场景对于Windows事件日志分析,不同的EVENTID代表了不同的意义,摘录一些常见的安全事件的说明。4624–登录成功4625–登录失败4634–注销成功4647–用户启动的注销4672–使用超级用户(如管理员)进行登录系统:1074,通过这个事件ID查看计算机的开机、关…

  • linux的通配符有哪些,Linux通配符「建议收藏」

    linux的通配符有哪些,Linux通配符「建议收藏」Linux通配符说明:通配符是bash的内置功能,几乎适用于所有Linux命令。*匹配任意(0个或多个)字符或字符串,包括空字符串。?匹配任意1个字符,有且只有一个字符。[abcd]匹配abcd中任何一个字符,abcd也可以是其他任意不连续字符。[a-z]匹配a到z之间的任意一个字符,字符前后要连续,也可以用连续数字,即[1-9]。[!abcd]表示不匹配括号里面的任何一个字符…

  • Actuator「建议收藏」

    Actuator「建议收藏」#Actuator引入依赖spring-boot-starter-actuator,通过endpoint来暴露HTTP或JMX来监管应用通过http://localhost:8080/actuat

  • PyQt5入门教程[通俗易懂]

    PyQt5入门教程[通俗易懂]0x00安装环境清单我使用的环境如下:Windows10(Build17763)Python3.7.2VSCode1.33.0PyQt5QtDesigner如果你使用的是O

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号