pacemaker搭建HTTP集群

#以node01为例修改主机名

#node02需要同样的配置

[[email protected] ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.10.10.5 node01
10.10.10.6 node02
#关闭防火墙以及SElinux

#node02需要同样配置

[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[[email protected] ~]# setenforce 0
[[email protected] ~]# sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config

#配置pacemaker的EPEL源

#node02需要同样配置

[[email protected] ~]# cat /etc/yum.repos.d/pacemaker.repo
[pacemaker]
name=pacemaker
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=0
#下载pacemaker安装包

#node02需要同样配置

[[email protected] ~]#  yum install pacemaker pcs resource-agents -y
#配置节点之间认证

#node02需要同样配置

[[email protected] ~]# ssh-keygen -t rsa -P ‘‘

[[email protected] ~]# ssh-copy-id node02

#修改pacemaker的用户密码(pacemaker使用的用户是hacluster,软件安装完后用户以添加)

#node02需要同样配置

[[email protected] ~]# passwd hacluster

#启动pcs服务

#node02需要同样配置

[[email protected] ~]# systemctl restart pcsd
#设置节点认证

#只在node01操作,所有操作会自动同步到node02

[[email protected] ~]# pcs cluster auth node01 node02
Username: hacluster   
Password:
node02: Authorized
node01: Authorized
#创建一个名为mycluster的集群,并将node01和node02加入到集群节点上

#只在node01操作,所有操作会自动同步到node02

[[email protected] ~]# pcs cluster setup --force --name mycluster node01 node02
Destroying cluster on nodes: node01, node02...
node01: Stopping Cluster (pacemaker)...
node02: Stopping Cluster (pacemaker)...
node01: Successfully destroyed cluster
node02: Successfully destroyed cluster

Sending cluster config files to the nodes...
node01: Succeeded
node02: Succeeded

Synchronizing pcsd certificates on nodes node01, node02...
node02: Success
node01: Success

Restarting pcsd on the nodes in order to reload the certificates...
node02: Success
node01: Success

[[email protected] ~]# pcs cluster start --all
node01: Starting Cluster...
node02: Starting Cluster...
#查看集群状态

[[email protected] ~]# pcs status
Cluster name: mycluster
WARNING: no stonith devices and stonith-enabled is not false
Stack: corosync
Current DC: node02 (version 1.1.15-11.el7_3.5-e174ec8) - partition with quorum
Last updated: Mon Sep 11 22:54:14 2017        Last change: Mon Sep 11 22:53:39 2017 by hacluster via crmd on node02

2 nodes and 0 resources configured

Online: [ node01 node02 ]

No resources

Daemon Status:
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/disabled

#查看corosync的状态

[[email protected] ~]# pcs status corosync

Membership information
----------------------
    Nodeid      Votes Name
         1          1 node01 (local)
         2          1 node02

#查看状态是否正常

[[email protected] ~]#  crm_verify -L -V
   error: unpack_resources:    Resource start-up disabled since no STONITH resources have been defined
   error: unpack_resources:    Either configure some or disable STONITH with the stonith-enabled option
   error: unpack_resources:    NOTE: Clusters with shared data need STONITH to ensure data integrity
Errors found during check: config not valid
**发现报错了

#关闭报错信息

[[email protected] ~]#  pcs property set stonith-enabled=false

#设置VIP

#只在node01操作,所有操作会自动同步到node02

[[email protected] ~]# pcs  resource create ClusterIP ocf:heartbeat:IPaddr2 nic=ens34 ip=10.10.10.8 cidr_netmask=32  op monitor interval=30s

#安装http服务

#node02需要同样配置

[[email protected] ~]#  yum  -y   install  httpd

#编辑apache首页

#node02需要同样配置(node2上把node01改为node02)

[[email protected] ~]# vi /var/www/html/index.html
 <html>
 <body>welcome to  node 1 </body>
 </html>

#配置apache的URL;

#为了监视您的Apache实例的健康和恢复它如果失败,起搏器假设所使用的资源代理服务器状态的URL。

#node02需要同样配置

[[email protected] ~]# vi /etc/httpd/conf/httpd.conf

<Location /server-status>
   SetHandler server-status
   Order deny,allow
   Deny from all
   Allow from 127.0.0.1
</Location>

#将apache加入集群

#只在node01操作,所有操作会自动同步到node02

[[email protected]
~]# pcs resource create Web ocf:heartbeat:apache 
configfile=/etc/httpd/conf/httpd.conf      
statusurl="http://localhost/server-status" op monitor interval=1min

#设置apache的超时时间

##只在node01操作,所有操作会自动同步到node02

[[email protected] ~]#  pcs resource op defaults timeout=240s

#将VIP和apache捆绑在一起

##只在node01操作,所有操作会自动同步到node02

[[email protected] ~]# pcs constraint colocation add Web ClusterIP INFINITY

#设置启动顺序

##只在node01操作,所有操作会自动同步到node02

[[email protected] ~]#  pcs constraint order ClusterIP then Web
Adding ClusterIP Web (kind: Mandatory) (Options: first-action=start then-action=start)

#查看集群状态

[[email protected] ~]# pcs status
Cluster name: mycluster
Stack: corosync
Current DC: node01 (version 1.1.15-11.el7_3.5-e174ec8) - partition with quorum
Last updated: Tue Sep 12 16:06:59 2017        Last change: Tue Sep 12 16:06:49 2017 by root via cibadmin on node01

2 nodes and 2 resources configured

Online: [ node01 node02 ]

Full list of resources:

ClusterIP    (ocf::heartbeat:IPaddr2):    Started node01
 Web    (ocf::heartbeat:apache):    Started node01

Daemon Status:
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/disabled

#此时集群都在node01上。

#我们宕掉node01,在node02上查看集群状态

[[email protected] ~]# pcs status
Cluster name: mycluster
Stack: corosync
Current DC: node02 (version 1.1.15-11.el7_3.5-e174ec8) - partition with quorum
Last updated: Tue Sep 12 17:02:24 2017        Last change: Tue Sep 12 17:01:57 2017 by root via cibadmin on node01

2 nodes and 2 resources configured

Online: [ node02 ]
OFFLINE: [ node01 ]

Full list of resources:

ClusterIP    (ocf::heartbeat:IPaddr2):    Started node02
 Web    (ocf::heartbeat:apache):    Started node02

Daemon Status:
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/disabled

时间: 2024-08-11 05:45:41

pacemaker搭建HTTP集群的相关文章

MongoDB 搭建分片集群

在MongoDB(版本 3.2.9)中,分片是指将collection分散存储到不同的Server中,每个Server只存储collection的一部分,服务分片的所有服务器组成分片集群.分片集群(Sharded Clustered)的服务器分为三中类型:Router(mongos),Config Server 和 Shard(Replica Set 或 Standalone mongod).使用分片集群,不需要使用强大的计算机,就能存储更多的数据,处理更大的负载.分布式数据库系统的设计目的是:

Linux下安装搭建Memcached集群环境

Linux下安装搭建Memcached集群环境

Windows下搭建Redis集群

Redis集群:运行多个Redis实例,然后通过特定的工具,将这些实例以某种关系连接起来,形成一个Redis网络. 详细的内容可以阅读:Redis 集群教程 里面会详细介绍Redis集群的设计思想和内部结构,以及如何搭建Redis集群等. 本文主要讲述如何在Windows系统下快速搭建Redis集群: 1.下载Redis 其GitHub连接如下:https://github.com/MSOpenTech/redis/releases/ Redis提供msi和zip格式的下载文件,这里下载zip格

搭建Hadoop集群 (三)

通过 搭建Hadoop集群 (二), 我们已经可以顺利运行自带的wordcount程序. 下面学习如何创建自己的Java应用, 放到Hadoop集群上运行, 并且可以通过debug来调试. 有多少种Debug方式 Hadoop在Eclipse上的Debug方式 一般来说, Debug最多的应用场景是调试MR中的代码逻辑, 还有部分是调试main方法中的某些代码逻辑. 无论是Standalone, Pesudo-Distributed, 还是Fully-Distributed Mode, 都可以d

搭建mongodb集群(副本集+分片)

完整的搭建mongodb集群(副本集+分片)的例子... 准备四台机器,分别是bluejoe1,bluejoe2,bluejoe3,以及bluejoe0 副本集及分片策略确定如下: 将创建3个副本集,命名为shard1,shard2,shard3: 以上3个副本集作为3个分片: 每个副本集包含2个副本(主.辅): 副本分开存储,即shard1存在bluejoe1和bluejoe2上各一份...以此类推 将创建3个配置库实例,一台机器一个 bluejoe0上配置一个mongos(mongos一般可

分布式缓存技术redis学习系列(四)——redis高级应用(集群搭建、集群分区原理、集群操作)

本文是redis学习系列的第四篇,前面我们学习了redis的数据结构和一些高级特性,点击下面链接可回看 <详细讲解redis数据结构(内存模型)以及常用命令> <redis高级应用(主从.事务与锁.持久化)> 本文我们继续学习redis的高级特性--集群.本文主要内容包括集群搭建.集群分区原理和集群操作的学习. Redis集群简介 Redis 集群是3.0之后才引入的,在3.0之前,使用哨兵(sentinel)机制(本文将不做介绍,大家可另行查阅)来监控各个节点之间的状态.Redi

Centos7-单台物理机搭建ceph集群

学习ceph时,看到crush规则的时候,crush策略最小为osd,但是这个osd定义的是真实的osd还是指单块磁盘?为了验证一下,自己用测试机模拟了一下单台机器使用一块磁盘搭建ceph. 配置ceph源,这里使用的阿里云的源 # yum install --nogpgcheck -y epel-release # rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 # vim /etc/yum.repos.d/ceph.repo [Ceph] n

SaltStck 搭建Web集群运用示例 (二)

在上一篇文章中,我们了解了saltstack搭建Web集群的基础环境以及haproxy的部署,这里我们将想继续了解一下其他的web服务如何通过saltstack部署起来. 参考资料:https://github.com/unixhot/saltbook-code SaltStack部署keepalived 编写安装配置sls文件 在keepalived目标编写install.sls: [[email protected] /srv/salt/prod/modules/keepalived]# c

搭建Artifactory集群

搭建Artifactory集群 在阿里云上搭建Artifactory集群. Artifactory许可证 官方正版license,3个 License 25900美元(16.7万人民币)一年,贵的离谱.本文以实验学习为主使用最新破解版4.7.4,破解也非常容易就不赘述了.商业用途,请使用正版. 所需硬件 Artifactory集群需要以下硬件设备: 支持粘性会话的均衡负载(HAProxy/Nginx等). NFS共享文件夹. 数据库(MySQL等). 网络 集群中所有的节点最好处于同一局域网内,