码迷,mamicode.com
首页 > 其他好文 > 详细

corosync+pacemaker实现高可用集群。

时间:2014-07-18 13:18:51      阅读:353      评论:0      收藏:0      [点我收藏+]

标签:配置文件   interface   版本号   version   安全认证   

实验环境:

 

 

安装: yum install corosync pacemaker -y

复制配置文件

  • cp corosync.conf.example corosync.conf

  • vim corosync.conf

编辑配置文件:

compatibility: whitetank 
是否兼容0.8版本的corosync
totem {
定义集群之间心跳信息传递层 
 version: 2 ----版本号
        secauth: on ---是否启用安全认证
        threads: 0   ---启用多少个线程处理心跳信息传递,0为自动。
        interface {
                ringnumber: 0   --报文循环次数
                bindnetaddr: 192.168.18.0  --绑定的网络地址
                mcastaddr: 226.94.1.2   --多播地址
                mcastport: 5405   ---多播端口
                ttl: 1
        }
}

logging {
        fileline: off
        to_stderr: no  --心跳信息是否输出到屏幕
        to_logfile: yes
        to_syslog: no  ---是否发送给/var/log/messages
        logfile: /var/log/cluster/corosync.log
        debug: off  --是否开启调试
        timestamp: on   --是否开启当前系统时间的时间戳。
        logger_subsys {
                subsys: AMF   --定义openais规范
                debug: off
        }
}

amf {
        mode: disabled
}
service {   定义pacemaker为corosync的插件。
 ver: 0
 name: pacemaker
}
aisexec {
 user:root
 group:root
}

生成安全认证文件,这个命令需要取1024位随机数,我们可以另起一个终端重装一个软件来产生随机数。

  • corosync-keygen

安装资源管理器的配置接口程序:

crmsh-1.2.6-4.el6.i686.rpm

pssh-2.3.1-2.el6.i686.rpm

关闭NetworkManager,并开机禁用此服务。

/etc/init.d/NetworkManager stop

chkconfig NetworkManager off

启动服务

  • service corosync start

 

CRM命令的使用:

  • crm status //显示集群状态信息

  • crm_mon

  • crm_verify -L //显示配置文件是否有语法错误

  • crm help

This is crm shell, a Pacemaker command line interface.

Available commands:

 cib              manage shadow CIBs --管理集群信息库  
 resource         resources management --资源管理
 configure        CRM cluster configuration --集群配置接口
 node             nodes management --节点管理
 options          user preferences --
 history          CRM cluster history --集群历史
 site             Geo-cluster support  --支持跨地域的集群
 ra               resource agents information center --资源代理
 status           show cluster status
 help,?           show help (help topics for list of topics)
 end,cd,up        go back one level --返回
 quit,bye,exit    exit the program --退出程序

 

  • crm resource help

At this level resources may be managed.

All (or almost all) commands are implemented with the CRM tools
such as `crm_resource(8)`.

Available commands:

 status,show,list show status of resources --显示资源状态信息
 start            start a resource --启动一个资源
 stop             stop a resource --停止一个资源
 restart          restart a resource
 promote          promote a master-slave resource --唤醒一个主从资源
 demote           demote a master-slave resource --降级一个主从资源
 manage           put a resource into managed mode --将资源加入可管理模式
 unmanage         put a resource into unmanaged mode --非管理模式
 migrate,move     migrate a resource to another node --资源迁移
 unmigrate,unmove unmigrate a resource to another node
 param            manage a parameter of a resource  --管理资源参数
 secret           manage sensitive parameters --管理敏感参数
 meta             manage a meta attribute --管理资源的源数据属性
 utilization      manage a utilization attribute
 failcount        manage failcounts --管理资源的错误次数
 cleanup          cleanup resource status  --清除资源状态
 refresh          refresh CIB from the LRM status --刷新Cib
 reprobe          probe for resources not started by the CRM  探测没有启动的资源
 trace            start RA tracing
 untrace          stop RA tracing
 help,?           show help (help topics for list of topics)
 end,cd,up        go back one level
 quit,bye,exit    exit the program

 

  • crm node help

    Node management and status commands.

    Available commands:

        status           show nodes‘ status as XML --显示节点状态
        show,list        show node
        standby          put node into standby  --设置当前节点为备用节点
        online           set node online --设置当前节点为线上节点
        maintenance      put node into maintenance mode
        ready            put node into ready mode
        fence            fence node
        clearstate       Clear node state
        delete           delete node
        attribute        manage attributes
        utilization      manage utilization attributes
        status-attr      manage status attributes
        help,?           show help (help topics for list of topics)
        end,cd,up        go back one level
        quit,bye,exit    exit the program



  • crm configure property stonith-enabled=false   --关闭stonith设备

  • crm ra help

classes list classes and providers --列出提供的RA类型

list    list RA for a class (and provider) --显示某个RA类型所提供的资源代理

meta    show meta data for a RA --显示一个RA的基本信息


定义一个资源:

crm configure

primitive webip ocf:IPaddr params ip=192.168.18.200

定义完后可以用show查看

bubuko.com,布布扣

没错误的话,之后可以使用commit提交。

查看状态:

  • crm status

bubuko.com,布布扣

  • crm resource status

bubuko.com,布布扣

停止资源:

  • crm resource stop webip

启动资源:

  • crm resource start webip

将当前节点设为备用,这时候资源就会转移到节点二。

  • crm node standby

我们把httpd加入到可管理资源:

  • crm configure primitive webserver lsb:httpd

bubuko.com,布布扣



本文出自 “坏人的博客” 博客,转载请与作者联系!

corosync+pacemaker实现高可用集群。,布布扣,bubuko.com

corosync+pacemaker实现高可用集群。

标签:配置文件   interface   版本号   version   安全认证   

原文地址:http://tchuairen.blog.51cto.com/3848118/1439759

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!