OVN HA 实验

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OVN HA 实验相关的知识,希望对你有一定的参考价值。

      ovn-northd服务是集中式方案,集群中所有的ovn-controller服务都连接到ovn-northd,这样ovn-northd可能会引起单点故障的问题,所以OVN用在生产环境前需要考虑ovn-northd服务HA问题,

这里记录的OVN社区ovn-northd服务的HA方案。

Corosync + Pacemaker

    corosync +pacemaker使用原理,可参见文档 http://blog.csdn.net/rzhzhz/article/details/7104135

ovn-northd HA 搭建过程

下面步骤搭建三个节点组成的ovn-northd HA的环境:

系统版本: CentOS7

host: 192.168.10.143  192.168.10.146  192.168.10.147

vip : 192.168.10.200

1.安装相关组件

 1 # 安装 corosync,pacemaker
 2 yum install corosynclib corosync
 3 yum install pacemaker-libs pacemaker-cluster-libs pacemaker-cli pacemaker   # 快速安装 yum install corosync pacemaker -y
 4   
 5 #安装 crmsh(命令方式管理corosync +pacemaker)
 6 yum install crmsh-scripts-3.0.0-2.2.noarch.rpm python-parallax-1.0.1-29.1.noarch.rpm  crmsh-3.0.0-2.2.noarch.rpm
 7   
 8 # 安装OVN组件
 9 yum install openvswitch
10 yum install openvswitch-ovn-common openvswitch-ovn-central

2. 配置服务(192.168.10.143)

 1 # 配置corosync + pacemaker
 2 ## 编辑 /etc/corosync/corosync.conf
 3 totem {
 4         version: 2
 5  
 6         crypto_cipher: aes128
 7         crypto_hash: sha1
 8         secauth: on
 9  
10         interface {
11                 ringnumber: 0
12                 bindnetaddr: 192.168.10.0
13                 mcastaddr: 239.255.1.1
14                 mcastport: 5405
15                 ttl: 1
16         }
17 }
18  
19 nodelist {
20         node {
21                 ring0_addr: 192.168.10.143
22                 nodeid: 1
23         }
24         node {
25                 ring0_addr: 192.168.10.146
26                 nodeid: 2
27         }
28         node {
29                 ring0_addr: 192.168.10.147
30                 nodeid: 3
31         }
32 }
33  
34 logging {
35         fileline: off
36         to_stderr: no
37         to_logfile: yes
38         logfile: /var/log/cluster/corosync.log
39         to_syslog: yes
40         debug: off
41         timestamp: on
42         logger_subsys {
43                 subsys: QUORUM
44                 debug: off
45         }
46 }
47  
48 quorum {
49         provider: corosync_votequorum
50 }
51   
52   
53 # 生成authkey
54 corosync-keygen
55   
56 # 配置ovn-northd服务
57 ##在/etc/openvswitch/目录创建ovnnb-active.conf  ovnsb-active.conf  ovn-northd-db-params.conf
58 echo tcp:192.168.10.200:6641  >  /etc/openvswitch/ovnnb-active.conf
59 echo tcp:192.168.10.200:6642  >  /etc/openvswitch/ovnsb-active.conf
60 echo --ovnnb-db=tcp:192.168.10.147:6641 --ovnsb-db=tcp:192.168.10.147:6642 > /etc/openvswitch/ovn-northd-db-params.conf
61   
62   
63 # *将上面生成的文件copy到192.168.10.146192.168.10.147
64   
65 # 启动各个节上的corosync + pacemaker服务
66 systemctl enable corosync pacemaker
67 systemctl start corosync pacemaker

3. 命令管理corosync + pacemaker

   crm_mon查看节点是否加入集群

技术分享

 

crm configure 配置方法:

方法1:

 1 #crm configure
 2 property stonith-enabled=false
 3 primitive ovndb_servers ocf:ovn:ovndb-servers params master_ip="192.168.10.200" op start interval="0s" timeout="30s" op stop interval="0s" timeout="20s" op promote interval="0s" timeout="50s" op demote interval="0s" timeout="50s" op monitor interval="10s" timeout="20s"
 4 primitive ovnip ocf:heartbeat:IPaddr2 params ip="192.168.10.200" cidr_netmask="24" op start interval="0s" timeout="20s" op stop interval="0s" timeout="20s" op monitor interval="10s" timeout="20s"
 5 ms ovndb_servers-master ovndb_servers meta notify="true"
 6 colocation colocation-ovndb_servers-master-ovnip-INFINITY inf: ovndb_servers-master:Started ovnip:Master
 7 order order-ovnip-ovndb_servers-master-mandatory inf: ovnip:start ovndb_servers-master:start
 8 verify
 9 commit
10 bye

方法2:

 1 crm configure load repalce /root/ovndb-ha.conf
 2   
 3 # ovndb-ha.conf内容如下:
 4 primitive ovndb_servers ocf:ovn:ovndb-servers params master_ip="192.168.10.200" op start interval="0s" timeout="30s" op stop interval="0s" timeout="20s" op promote interval="0s" timeout="50s" op demote interval="0s" timeout="50s" op monitor interval="10s" timeout="20s"
 5 primitive ovnip ocf:heartbeat:IPaddr2 params ip="192.168.10.200" cidr_netmask="24" op start interval="0s" timeout="20s" op stop interval="0s" timeout="20s" op monitor interval="10s" timeout="20s"
 6 ms ovndb_servers-master ovndb_servers meta notify="true"
 7 colocation colocation-ovndb_servers-master-ovnip-INFINITY inf: ovndb_servers-master:Started ovnip:Master
 8 order order-ovnip-ovndb_servers-master-mandatory inf: ovnip:start ovndb_servers-master:start
 9 property stonith-enabled=false
10 #property no-quorum-policy=ignore

自动加载配置:

1 crm configure save  ./ovndb-ha.conf
2 crm configure load replace ./ovndb-ha.conf
3 crm erase

 

*注意节点先启动 openvswitch.service!

crm_mon 显示各节点的状态

技术分享

 

* 注 ovn-northd service HA:

1 #/usr/lib/ocf/resource.d/ovn/ovndb-servers
2 MANAGE_NORTHD_DEFAULT="yes"

 

参考文档:

    http://docs.openvswitch.org/en/latest/topics/ovsdb-replication/

    http://blog.csdn.net/rzhzhz/article/details/7104135

    https://magedu.org/2016/04/23/corosync-pacemaker-mariadb/

    https://mail.openvswitch.org/pipermail/ovs-dev/2016-October/324024.html



以上是关于OVN HA 实验的主要内容,如果未能解决你的问题,请参考以下文章

ovn-central raft HA (by quqi99)

ovn-central raft HA (by quqi99)

ovn-central raft HA (by quqi99)

OVN L2 gateway实验

SpringCloud系列四:Eureka 服务发现框架(定义 Eureka 服务端Eureka 服务信息Eureka 发现管理Eureka 安全配置Eureka-HA(高可用) 机制Eur(代码片段

Build OpenVSwitch and OVN