Corosync+Pacemaker+NFS+Httpd高可用web集群部署

Corosync+Pacemaker+NFS+Httpd高可用web集群(使用资源管理工具crmsh配置)

框架:crmsh(Corosync+pacemaker)+nfs+httpd

集群节点1:192.168.88.132  cen7.field.com

集群节点2:192.168.88.133  node2.field.com

集群节点3:192.168.88.134  node1.field.com

vip: 192.168.88.188  资源代理:ocf:heartbeat:IPaddr

nfs服务器:node1.field.com  资源代理:ocf:heartbeat:Filesystem

web服务器:cen7.field.com  node2.field.com  node1.field.com  资源代理:systemd:httpd

 

配置集群的前提

(1)、时间同步;

(2)、.基于当前正在使用的主机名互相访问;

(3)、是否会用到仲裁设备;

参考:《使用资源管理工具pcs配置Corosync+pacemaker》

 

一、安装配置Corosync

1、配置Corosync各集群节点

[root@node1 ~]# vim /etc/resolv.conf

[root@node1 ~]# yum install corosync pacemaker -y

可以使用rpm -ql查看安装了那些文件

[root@cen7 ~]# rpm -ql corosync|less

[root@cen7 ~]# rpm -ql pacemaker|less

查看Corosync配置文件

[root@cen7 ~]# cd /etc/corosync/

[root@cen7 corosync]# ls

corosync.conf.example  corosync.conf.example.udpu  corosync.xml.example  uidgid.d

1)、复制配置文件案例并修改配置文件:

[root@cen7 corosync]# cp corosync.conf.example corosync.conf

[root@cen7 corosync]# vim corosync.conf

[root@cen7 corosync]# grep -v '^[[:space:]]*#' corosync.conf

totem {

#totem:图层,定义集群信息传递协议

         version: 2

         crypto_cipher: aes128

         crypto_hash: sha1

    secauth: on

#开启安全加密功能        

         interface {

#interface:定义集群信息传递接口   

                   ringnumber: 0

#主心跳信息传递接口           

                   bindnetaddr: 192.168.88.0

#绑定的网络地址,凡是属于该网段的网络地址都属于ring0         

                   mcastaddr: 239.188.1.188

#组播地址、端口           

                   mcastport: 5405

                   ttl: 1

         }

}

nodelist {

#nodelist:定义节点信息                        

         node {

                   ring0_addr: 192.168.88.132

                   nodeid: 1

                   }

         node {

                   ring0_addr: 192.168.88.133

                   nodeid: 2

              }

  node {

    ring0_addr: 192.168.88.134

    nodeid: 3

    }

}

logging {

#日志子系统

         fileline: off

         to_stderr: no

#是否发给标准错误输出      

         to_logfile: yes

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

#日志文件      

         to_syslog: no

#是否发给系统日志,考虑到I/O性能,建议只开一个            

         debug: off

#是否输出调试信息      

         timestamp: on

#是否记录时间戳,

#注意:每次记录时间戳都得获取一次系统时间,发起一次系统调用,日志量非常大时会不断发起系统调用,可能影响        

         logger_subsys {

#logger子系统中的QUORUM子系统也要记录日志

                   subsys: QUORUM

                   debug: off

         }

}

quorum {

         provider: corosync_votequorum

#定义投票系统      

}

[root@cen7 corosync]# ls

corosync.conf  corosync.conf.example  corosync.conf.example.udpu  corosync.xml.example  uidgid.d

2)、生成节点间通信时用到的认证密钥文件:

[root@cen7 corosync]# corosync-keygen

Corosync Cluster Engine Authentication key generator.

Gathering 1024 bits for key from /dev/random.

Press keys on your keyboard to generate entropy.

Press keys on your keyboard to generate entropy (bits = 920).

Press keys on your keyboard to generate entropy (bits = 1000).

Writing corosync key to /etc/corosync/authkey.

[root@cen7 corosync]# ls

authkey        corosync.conf.example       corosync.xml.example

corosync.conf  corosync.conf.example.udpu  uidgid.d

3)、配置各节点:

各节点Corosync配置文件和认证密钥文件相同:只需将corosync.confauthkey复制至node2node1节点即可完成配置

[root@cen7 corosync]# scp -p authkey corosync.conf node2:/etc/corosync/

#scp -p 保留原有权限

authkey                                                        100%  128    75.3KB/s   00:00   

corosync.conf                                                  100% 3031     1.7MB/s   00:00   

[root@cen7 corosync]# scp -p  authkey corosync.conf node1:/etc/corosync/

authkey                                                        100%  128    49.4KB/s   00:00   

corosync.conf                                                  100% 3131     1.1MB/s   00:00  

2、确认各集群节点Corosync状态缺

1)、cen7启动Corosync并确认状态

[root@cen7 corosync]# systemctl start corosync.service

[root@cen7 corosync]# systemctl status corosync.service

● corosync.service - Corosync Cluster Engine

   Loaded: loaded (/usr/lib/systemd/system/corosync.service; disabled; vendor preset: disabled)

   Active: active (running) since 四 2018-08-02 07:31:20 CST; 1min 7s ago

     Docs: man:corosync

           man:corosync.conf

           man:corosync_overview

  Process: 1954 ExecStop=/usr/share/corosync/corosync stop (code=exited, status=0/SUCCESS)

  Process: 1970 ExecStart=/usr/share/corosync/corosync start (code=exited, status=0/SUCCESS)

 Main PID: 1981 (corosync)

   CGroup: /system.slice/corosync.service

           └─1981 corosync

8 02 07:31:20 cen7.field.com systemd[1]: Starting Corosync Cluster Engine...

8 02 07:31:20 cen7.field.com corosync[1970]: Starting Corosync Cluster Engine (corosync):  ]

8 02 07:31:20 cen7.field.com systemd[1]: Started Corosync Cluster Engine.

Hint: Some lines were ellipsized, use -l to show in full.

查看corosync引擎是否正常启动:

[root@cen7 corosync]# grep -e "Corosync Cluster Engine" -e "configuration file" /var/log/cluster/corosync.log

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

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

以下日志可以看出Corosync已然正常启动

[root@cen7 corosync]# tail /var/log/cluster/corosync.log

Aug 02 07:31:30 [1980] cen7.field.com corosync notice  [QUORUM] This node is within the non-primary component and will NOT provide any services.

Aug 02 07:31:30 [1980] cen7.field.com corosync notice  [QUORUM] Members[1]: 1

Aug 02 07:31:30 [1980] cen7.field.com corosync notice  [MAIN  ] Completed service synchronization, ready to provide service.

Aug 02 07:31:32 [1980] cen7.field.com corosync notice  [TOTEM ] A new membership (192.168.88.132:24) was formed. Members joined: 2

Aug 02 07:31:32 [1980] cen7.field.com corosync notice  [QUORUM] This node is within the primary component and will provide service.

Aug 02 07:31:32 [1980] cen7.field.com corosync notice  [QUORUM] Members[2]: 1 2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值