23213 发表于 2016-4-20 09:29:20

corosync + pacemaker实现httpd服务高可用集群

实验环境:
   服务器:
    192.168.145.208(集群节点一)
    192.168.145.209(集群节点二)
    192.168.145.210(NFS server)

   操作系统:三台都为centos7

配置步骤:



[*]在两个集群节点中分别进行无密钥通讯配置:
ssh-keygen -t rsa -P ""
ssh-copy-id -i ~/.ssh/id_rsa.pub root@web3

[*]关闭各个节点的防火墙:
systemctl stop firewalld

[*]编辑corosync配置文件:
totem {
        version: 2
        crypto_cipher: aes128
        crypto_hash: sha1
        secauth: on #开启认证

        interface {
                ringnumber: 0
                bindnetaddr: 192.168.145.0 #绑定的网络地址
                mcastaddr: 239.255.1.1 #多播组地址
                mcastport: 5405   #多播监听端口
                ttl: 1
        }
}

nodelist {
        node {
                ring0_addr: web1
                nodeid: 1
        }

        node {
                ring0_addr: web2
                nodeid: 2
        }
}

logging {
        fileline: off
        to_stderr: no
        to_logfile: yes
        logfile: /var/log/cluster/corosync.log
        to_syslog: no
        debug: off
        timestamp: on
        logger_subsys {
                subsys: QUORUM
                debug: off
        }
}
quorum {
        provider: corosync_votequorum
}

[*]使用corosync-keygen命令生成authkey文件,并将authkey和corosync.conf文件复制到其他集群节点。

[*]在各节点启动corosync和pacemaker:
systemctl start corosync.service
systemctl start pacemaker.service

[*]在两个节点上安装httpd进程并设置为开机启动root@web1 ~]# yum install httpd -ysystemctl enable httpd.serviceroot@web2 ~]# yum install httpd -ysystemctl enable httpd.service
6.安装crmsh工具,需分别下载
    python-pssh-2.3.1-4.2.x86_64.rpm
    pssh-2.3.1-4.2.x86_64.rpm
    crmsh-2.1.4-1.1.x86_64.rpm
然后安装:yum -y install python-pssh-2.3.1-4.2.x86_64.rpm pssh-2.3.1-4.2.x86_64.rpm crmsh-2.1.4-1.1.x86_64.rpm,crmsh工具只需要在一个节点上安装即可。

7.使用crm命令进入crmsh命令行:

8.配置资源
9.验证集群,访问http://{$webip},此测试集群webip为192.168.145.200可以通过设置web1节点为standby状态查看集群资源转移情况。
页: [1]
查看完整版本: corosync + pacemaker实现httpd服务高可用集群