Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1114094
  • 博文数量: 309
  • 博客积分: 6093
  • 博客等级: 准将
  • 技术积分: 3038
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-03 17:14
个人简介

linux学习记录

文章分类

全部博文(309)

文章存档

2014年(2)

2012年(37)

2011年(41)

2010年(87)

2009年(54)

2008年(88)

分类:

2010-11-25 17:25:55

高可用资源限制条件与积分统计


高可用定义了三种资源限制条件:

  • 位置location定义资源可以、不可以或首选在哪些节点上运行;

  • 顺序order定义操作的顺序;

  • 协同colocation告诉群集资源可以或不可以在某个节点上一起运行。


locationcolocation都可以设置分值,HA是通过分数来决定某资源应当运行在哪个节点上的。

各节点上资源分数的计算方法为node+resource+(failure)

node为节点自身的分数;

resource为每一个资源的初始分数(resource-stickiness),一般为正数,默认为0

failure为每一个资源在失败之后所减掉的分数(resource-failure-stickiness),一般为负数默认为0


以下通过举例说明。


1. 假设给资源resource_fs配置分数如下:

resource_stickiness300

resource_failure_stickiness-600

standard-1上的rsc_location1000

standard-2上的rsc_location500

  1. 在最开始,两节点都没有开始运行这个资源,资源本身没有分数,那么仅仅计算节点的分数

    standard-1的分数1000=1000

    standard-2的分数500=500

  2. 会做出选择在standard-1上面运行resource_fs这个资源,由于有资源自身的分数加入了,此时

    standard-1的分数1000+300=1300

    standard-2的分数500+0=500

  3. 过了一段时间,假设resource_fs这个资源crash或者其他问题,分数马上会发生变化

    standard-1的分数1000+300+(-600)=700

    standard-2的分数500+0=500

  4. 由于standard-1节点的分数还是比standard-2的高,那么资源不发生迁移,而是执行restart操作。


2. 假设给资源resource_fs配置分数如下:

resource_stickiness300

resource_failure_stickiness-1000

standard-1上的rsc_location1000

standard-2上的rsc_location500

  1. 在最开始,两节点都没有开始运行这个资源,资源本身没有分数,那么仅仅计算节点的分数

    standard-1的分数1000=1000

    standard-2的分数500=500

  2. 会做出选择在standard-1上面运行resource_fs这个资源,由于有资源自身的分数加入了,此时

    standard-1的分数1000+300=1300

    standard-2的分数500+0=500

  3. 过了一段时间,假设resource_fs这个资源crash或者其他问题,分数马上会发生变化

    standard-1的分数1000+300+(-1000)=300

    standard-2的分数500+0=500

  4. 由于standard-1节点的分数小于standard-2,那么资源要迁移到standard-2,此时分数

    standard-1的分数1000+0+(-1000)=0

    standard-2的分数500+300=800


3. 资源resource_fs重启失败

resource_stickiness300

resource_failure_stickiness-600

standard-1上的rsc_location1000

standard-2上的rsc_location500

  1. 在最开始,两节点都没有开始运行这个资源,资源本身没有分数,那么仅仅计算节点的分数

    standard-1的分数1000=1000

    standard-2的分数500=500

  2. 会做出选择在standard-1上面运行resource_fs这个资源,由于有资源自身的分数加入了,此时

    standard-1的分数1000+300=1300

    standard-2的分数500+0=500

  3. 过了一段时间,假设resource_fs这个资源crash或者其他问题,分数马上会发生变化

    standard-1的分数1000+300+(-600)=700

    standard-2的分数500+0=500

  4. 由于standard-1节点的分数还是比standard-2的高,那么资源不发生迁移,而是执行restart操作,重启失败,分数发生变化

    standard-1的分数1000+0+(-INFINITY)=-INFINITY

    standard-2的分数500+0=500

  5. 由于standard-1节点的分数小于standard-2,那么资源要迁移到standard-2,此时分数

    standard-1的分数1000+0+(-INFINITY)=-INFINITY

    standard-2的分数500+300=800


4. locationcolocation组合使用

resource_stickiness300

resource_failure_stickiness-600

resource_fsstandard-1上的rsc_location1000

resource_fsstandard-2上的rsc_location500

resource_ip1standard-1上的rsc_location500

resource_ip1standard-2上的rsc_location1000

resource_ip1跟随resource_fs 资源运行。

  1. 在最开始,两节点都没有开始运行resource_fs,资源本身没有分数,那么仅仅计算节点的分数。

    standard-1的分数1000=1000

    standard-2的分数500=500

  2. 会做出选择在standard-1上面运行resource_fs这个资源,由于有资源自身的分数加入了,此时

    standard-1的分数1000+300=1300

    standard-2的分数500+0=500

  3. 此时resource_fs运行在standard-1上,因此resource_ip1的分数如下

    standard-1的分数500888=1388

    standard-2的分数1000=1000

  4. 由于resource_ip1standard-1节点的分数比standard-2的高,那么资源将在standard-1上启动,分数发生变化

    standard-1的分数500+300+888=1688

    standard-2的分数1000=1000


5. locationcolocation组合使用

resource_stickiness300

resource_failure_stickiness-600

resource_fsstandard-1上的rsc_location1000

resource_fsstandard-2上的rsc_location500

resource_ip1standard-1上的rsc_location500

resource_ip1standard-2上的rsc_location1000

resource_ip1跟随resource_fs 资源运行。

  1. 在最开始,两节点都没有开始运行resource_fs,资源本身没有分数,那么仅仅计算节点的分数。

    standard-1的分数1000=1000

    standard-2的分数500=500

  2. 会做出选择在standard-1上面运行resource_fs这个资源,由于有资源自身的分数加入了,此时

    standard-1的分数1000+300=1300

    standard-2的分数500+0=500

  3. 此时resource_fs运行在standard-1上,因此resource_ip1的分数如下

    standard-1的分数500222=722

    standard-2的分数1000=1000

  4. 由于resource_ip1standard-2节点的分数比standard-1的高,那么资源将在standard-2上启动,分数发生变化

    standard-1的分数500+222=722

    standard-2的分数1000+300=1300


heartbeat还有一个规则,如果节点的分数为负分,那么不管什么情况发生,该节点都不会接管资源(冷备节点)。

总的来说,随着资源的各种状态的发生,在各节点上面的分数就会发生变化,随着分数的变化,一旦某节点的分数大于当前运行该资源的节点的分数之后,HA就会做出切换动作,现在运行该资源的节点将释放资源,分数高出的节点将接管该资源。

阅读(776) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~