高可用集群的基本部署

高可用集群的部署

实验环境的准备:

准备三台rhel6.5的虚拟机三台,真机作测试,做好解析。

解析

[[email protected] ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

172.25.50.10 server1.example.com

172.25.50.20 server2.example.com

172.25.50.30 server3.example.com

172.25.50.250 real50.example.com

yum源的配置

[[email protected] ~]# cat /etc/yum.repos.d/redhat6.repo

[Server]

name=rhel6.5 Server

baseurl=http://172.25.50.250/rhel6.5

gpgcheck=0

[HighAvailability]

name=rhel6.5 HighAvailability

baseurl=http://172.25.50.250/rhel6.5/HighAvailability

gpgcheck=0

[LoadBalancer]

name=rhel6.5 LoadBalancer

baseurl=http://172.25.50.250/rhel6.5/LoadBalancer

gpgcheck=0

[ResilientStorage]

name=rhel6.5 ResilientStorage

baseurl=http://172.25.50.250/rhel6.5/ResilientStorage

gpgcheck=0

[ScalableFileSystem]

name=rhel6.5 ScalableFileSystem

baseurl=http://172.25.50.250/rhel6.5/ScalableFileSystem

gpgcheck=0

[[email protected] ~]# yum repolist

Loaded plugins: product-id, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

HighAvailability                                         | 3.9 kB     00:00

HighAvailability/primary_db                              |  43 kB     00:00

LoadBalancer                                             | 3.9 kB     00:00

LoadBalancer/primary_db                                  | 7.0 kB     00:00

ResilientStorage                                         | 3.9 kB     00:00

ResilientStorage/primary_db                              |  47 kB     00:00

ScalableFileSystem                                       | 3.9 kB     00:00

ScalableFileSystem/primary_db                            | 6.8 kB     00:00

Server                                                   | 3.9 kB     00:00

Server/primary_db                                        | 3.1 MB     00:00

repo id                          repo name                                status

HighAvailability                 rhel6.5 HighAvailability                    56

LoadBalancer                     rhel6.5 LoadBalancer                         4

ResilientStorage                 rhel6.5 ResilientStorage                    62

ScalableFileSystem               rhel6.5 ScalableFileSystem                   7

Server                           rhel6.5 Server                           3,690

repolist: 3,819

三台6.5系统的虚拟机都进行相同的配置。

安装软件

在server1上

[[email protected] yum.repos.d]# yum install ricci -y

[[email protected] yum.repos.d]# passwd ricci

更改用户 ricci 的密码 。

新的 密码:#westos

无效的密码: 它基于字典单词

无效的密码: 过于简单

重新输入新的 密码:#westos

passwd: 所有的身份验证令牌已经成功更新。

[[email protected] yum.repos.d]#/etc/init.d/ricci start#启动服务

[[email protected] yum.repos.d]# /etc/init.d/ricci start

Starting system message bus:                               [  OK  ]

Starting oddjobd:                                          [  OK  ]

generating SSL certificates...  done

Generating NSS database...  done

启动 ricci:                                               [确定]

[[email protected] yum.repos.d]#

Broadcast message from [email protected]

(unknown) at 14:48 ...

The system is going down for reboot NOW!

Connection to 172.25.50.10 closed by remote host.

Connection to 172.25.50.10 closed.

 

在server2上

[[email protected] yum.repos.d]# yum install ricci -y

[[email protected] yum.repos.d]# passwd ricci

更改用户 ricci 的密码 。

新的 密码:#westos

无效的密码: 它基于字典单词

无效的密码: 过于简单

重新输入新的 密码:#westos

passwd: 所有的身份验证令牌已经成功更新。

[[email protected] yum.repos.d]#/etc/init.d/ricci start#启动服务

 

[[email protected] yum.repos.d]# /etc/init.d/ricci start

Starting system message bus:                               [  OK  ]

Starting oddjobd:                                          [  OK  ]

generating SSL certificates...  done

Generating NSS database...  done

启动 ricci:                                               [确定]

[[email protected] yum.repos.d]#

Broadcast message from [email protected]

(unknown) at 14:48 ...

The system is going down for reboot NOW!

Connection to 172.25.50.20 closed by remote host.

Connection to 172.25.50.20 closed.

 

 

在server3上

安装软件luci

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

 

[[email protected] ~]# /etc/init.d/luci start

Adding following auto-detected host IDs (IP addresses/domain names), corresponding to `server3.example.com‘ address, to the configuration of self-managed certificate `/var/lib/luci/etc/cacert.config‘ (you can change them by editing `/var/lib/luci/etc/cacert.config‘, removing the generated certificate `/var/lib/luci/certs/host.pem‘ and restarting luci):

(none suitable found, you can still do it manually as mentioned above)

Generating a 2048 bit RSA private key

writing new private key to ‘/var/lib/luci/certs/host.pem‘

Starting saslauthd:                                        [  OK  ]

Start luci...                                              [确定]

Point your web browser to https://server3.example.com:8084 (or equivalent) to access luci

在真机的浏览器上:

https;//server3.example.com:8084

输入登陆主机的root账户和密码-->Create-->输入集群节点的信息

这里的密码是:ricci用户的密码(westos)

选项如下图所示:

名词须知: cman -- 集群管理器

rgmanger -- 资源管理器

fence -- 电源控制机

corosync

点击Fence Dvice

再Fence virt(Multicast Mode) --> Name:vmfence --> sumbit

在浏览器图形界面 选择 Nodes --> 选中 server1.example.com --> 选择 Add Fence Method --> Method Name:fence-1 --> 查找对应的 uuid 填入第一个空     ##此处用 uuid 的原因是因为真机不能识别主机名

在浏览器图形界面 选择 Nodes --> 选中 server2.example.com --> 选择 Add Fence Method --> Method Name:fence-2 --> 查找对应的 uuid 填入第一个空##此处用 uuid 的原因是因为真机不能识别主机名

填写的uuid(查看uuid命令:virsh list --uuid,这里的uuid与vmmanager中的顺序一致)

在真机上扎安装软件

fence-virtd-multicast-0.3.2-1.el7.x86_64

fence-virtd-0.3.2-2.el7.x86_64

fence-virtd-libvirt-0.3.2-2.el7.x86_64

在真机上

#mkdir /etc/cluster

[[email protected] cluster]# fence_virtd -c

Module search path [/usr/lib64/fence-virt]:

Available backends:

libvirt 0.1

Available listeners:

multicast 1.2

serial 0.4

Listener modules are responsible for accepting requests

from fencing clients.

Listener module [multicast]:

The multicast listener module is designed for use environments

where the guests and hosts may communicate over a network using

multicast.

The multicast address is the address that a client will use to

send fencing requests to fence_virtd.

Multicast IP Address [225.0.0.12]:

Using ipv4 as family.

Multicast IP Port [1229]:

Setting a preferred interface causes fence_virtd to listen only

on that interface.  Normally, it listens on all interfaces.

In environments where the virtual machines are using the host

machine as a gateway, this *must* be set (typically to virbr0).

Set to ‘none‘ for no interface.

Interface [br0]: ##不是br0的话写成br0

The key file is the shared key information which is used to

authenticate fencing requests.  The contents of this file must

be distributed to each physical host and virtual machine within

a cluster.

Key File [/etc/cluster/fence_xvm.key]:

Backend modules are responsible for routing requests to

the appropriate hypervisor or management layer.

Backend module [libvirt]:

Configuration complete.

=== Begin Configuration ===

fence_virtd {

listener = "multicast";

backend = "libvirt";

module_path = "/usr/lib64/fence-virt";

}

listeners {

multicast {

key_file = "/etc/cluster/fence_xvm.key";

address = "225.0.0.12";

interface = "br0";

family = "ipv4";

port = "1229";

}

}

backends {

libvirt {

uri = "qemu:///system";

}

}

=== End Configuration ===

Replace /etc/fence_virt.conf with the above [y/N]? y

[[email protected] etc]# dd if=/dev/urandom of=/etc/cluster/fence_xvm.key bs=128 count=1

记录了1+0 的读入

记录了1+0 的写出

128字节(128 B)已复制,0.000185659 秒,689 kB/秒

# scp fence_xvm.key [email protected]:/etc/cluster/

# scp fence_xvm.key [email protected]:/etc/cluster/

如果server1.server2上没有这个目录就创建一个

最后重启systemctl restart fence_virtd 这个服务

测试:

在 server1 中执行命令: fence_node server2.example.com  ##此处一定要用域名

或者

在 server2 中执行命令: fence_node server1.example.com  ##此处一定要用域名

 

 

高可用集群的配置  

#在真机重启之后,需要先将sevrer3的fence_virtd 服务打开

systemctl start fence_virtd

在图形界面上选择Failover Domain选项

点击add-->填写名字,下面的全选-->create

设置优先级。越小的,优先级越高

 

再选择resources选项-->add-->ip address-->设置虚拟ip:172.25.50.100-->掩码为:24-->Monitor Link:对勾  最后的一行为延迟时间:5 --> Submit

 

选择 Resources --> add --> Script --> Name:httpd --> Full Path to Script File: /etc/init.d/httpd --> Submit

 

选择 Service Groups --> add --> Name:apache --> 全对勾 --> Failover Domain:webfile --> Recovery Policy:Relocate --> Add Resource --> 先添加 ip address,再添加Script --> submit## Run Excluslve -- 运行独占(只允许此服务运行)

测试:

 

[[email protected] cluster]# clustat

Cluster Status for lyitx @ Wed Feb 15 17:08:17 2017

Member Status: Quorate

Member Name                            ID   Status

------ ----                            ---- ------

server1.example.com                        1 Online, Local, rgmanager

server2.example.com                        2 Online, rgmanager

Service Name                  Owner (Last)                  State

------- ----                  ----- ------                  -----

service:apache                server1.example.com           started

测试:

[[email protected] cluster]# /etc/init.d/httpd stop

停止 httpd:                                               [确定]

 

在把server2主机上用clustat 命令查看,

 

[[email protected] ~]# clustat

Cluster Status for lyitx @ Wed Feb 15 17:09:04 2017

Member Status: Quorate

Member Name                            ID   Status

------ ----                            ---- ------

server1.example.com                        1 Online, rgmanager

server2.example.com                        2 Online, Local, rgmanager

Service Name                  Owner (Last)                  State

------- ----                  ----- ------                  -----

service:apache                server1.example.com           started    

   

[[email protected] ~]# clustat

Cluster Status for lyitx @ Wed Feb 15 17:09:10 2017

Member Status: Quorate

Member Name                            ID   Status

------ ----                            ---- ------

server1.example.com                        1 Online, rgmanager

server2.example.com                        2 Online, Local, rgmanager

Service Name                  Owner (Last)                  State

------- ----                  ----- ------                  -----

service:apache                none                          recovering

[[email protected] ~]# clustat

Cluster Status for lyitx @ Wed Feb 15 17:09:11 2017

Member Status: Quorate

Member Name                            ID   Status

------ ----                            ---- ------

server1.example.com                        1 Online, rgmanager

server2.example.com                        2 Online, Local, rgmanager

Service Name                  Owner (Last)                  State

------- ----                  ----- ------                  -----

service:apache                server2.example.com           starting

[[email protected] ~]# clustat

Cluster Status for lyitx @ Wed Feb 15 17:09:12 2017

Member Status: Quorate

Member Name                            ID   Status

------ ----                            ---- ------

server1.example.com                        1 Online, rgmanager

server2.example.com                        2 Online, Local, rgmanager

Service Name                  Owner (Last)                  State

------- ----                  ----- ------                  -----

service:apache                server2.example.com           starting

经过观察后发现:服务从server1上切换到了server2

测试2:

在server2上: ip link set down eth0 #将网卡关闭

这时候在sevrer1上:

[[email protected] cluster]# clustat

Cluster Status for lyitx @ Wed Feb 15 17:21:05 2017

Member Status: Quorate

Member Name                            ID   Status

------ ----                            ---- ------

server1.example.com                        1 Online, Local, rgmanager

server2.example.com                        2 Offline

Service Name                  Owner (Last)                  State

------- ----                  ----- ------                  -----

service:apache                server1.example.com           started

[[email protected] cluster]# clustat

Cluster Status for lyitx @ Wed Feb 15 17:21:11 2017

Member Status: Quorate

Member Name                            ID   Status

------ ----                            ---- ------

server1.example.com                        1 Online, Local, rgmanager

server2.example.com                        2 Online

Service Name                  Owner (Last)                  State

------- ----                  ----- ------                  -----

service:apache                server1.example.com           started

测试3:

[[email protected] cluster]# echo c > /proc/sysrq-trigger

在server2中查看

[[email protected] ~]# clustat

Cluster Status for lyitx @ Wed Feb 15 17:30:31 2017

Member Status: Quorate

Member Name                              ID   Status

------ ----                              ---- ------

server1.example.com                          1 Offline

server2.example.com                          2 Online, Local, rgmanager

Service Name                    Owner (Last)                    State

------- ----                    ----- ------                    -----

service:apache                  server1.example.com             started

[[email protected] ~]# clustat

Cluster Status for lyitx @ Wed Feb 15 17:30:34 2017

Member Status: Quorate

Member Name                              ID   Status

------ ----                              ---- ------

server1.example.com                          1 Offline

server2.example.com                          2 Online, Local, rgmanager

Service Name                    Owner (Last)                    State

------- ----                    ----- ------                    -----

service:apache                  server2.example.com             starting

时间: 2024-08-19 08:06:35

高可用集群的基本部署的相关文章

CapitalOne - Artifactory高可用集群的自动化部署实践

背景 本文为大家介绍Capital One如何利用自动化流水线实现Artifactory HA集群进行自动化运维.Capital One银行是美国最大的数字化银行之一,在Capital One的devops体系中应用了JFrog Artifactory HA集群进行软件制品管理.由于Capital One规模庞大并且为满足业务连续性要求,其部署的Artifactory HA拥有primary和DR(灾备)两套集群的架构.在运维Artifactory HA集群维护中通过建设和运行自动化的流水线,在

Hadoop2.6(NN/RM)高可用集群安装与部署

Hadoop2对HDFS的改进很大,支持HDFS(NameNode) 和ResourceManager高可用性,避免集群中单点故障造成整个集群不可用.那么,从本文开始将部署一套高可用Hadoop集群及家族中相关开源系统,具体根据下面规划来,本文只部署高可用Hadoop集群,后续很快更新其他软件部署. 一.部署前准备 1. 节点分配 HostName IP Hadoop HBase Zookeeper Hive HMaster0 192.168.18.215 NameNode HMaster /

MySQL分片高可用集群之Cobar部署使用

Cobar是taobao公司用java开发的分布式MySQL中间件,可以支持数据的分片,且接口与mysql相同,因此可以无缝切换.并且不仅支持Mysql,而且还支持MariaDB哦,对版本的要求也很低,只要5.1以上就可以了.如果公司有较多的java项目,推荐使用.我们就来试试Cobar的集群搭建吧. 第一步:下载Cobar 现在可以从两个官方地址下载,一个是github上:https://github.com/alibaba/cobar  可以下载源码,也可以直接下载编译好的包https://

玩转MHA高可用集群

MHA高可用集群 =============================================================================== 概述:  本章将主要介绍MySQL中MHA高可用集群的相关内容,如下: MHA的功能介绍: MHA的集群架构,工作原理: CentOS 7上MHA实战配置部署及故障转移测试: =========================================================================

部署redis主从高可用集群

部署redis主从高可用集群本文部署的redis集群是一主一从,这两台服务器都设置了哨兵进程,另外再加一台哨兵做仲裁,建议哨兵数量为基数172.16.1.187    redis主+哨兵172.16.1.188    redis从+哨兵172.16.1.189    哨兵以上系统均为CentOS6 在187,188,189上部署redis过程如下:(1)redis使用编译安装方式,所以需要安装编译基本组件# yum -y install gcc gcc-c++ make cmake cpp gl

Puppet自动化高可用集群部署

前言:随着公司应用需求的增加,需要不断的扩展,服务器数量也随之增加,当服务器数量不断增加,我们会发现一台puppetmaster响应很慢,压力大,解析缓慢,有什么优化的方案吗?可以使用Puppetmaster配置多端口,结合Nginx web代理,这样puppetmaster承受能力至少可以提升10倍以上. 一.安装配置mongrel服务: 要使用puppet多端口配置,需要指定mongrel类型,默认没有安装,需要安装.在Puppetmaster服务器端执行如下命令(前提是已经安装了对应版本的

线上测试高可用集群部署文档【我的技术我做主】

线上测试高可用集群部署文档 目录: 目录:1 项目需求:2 实现方式:2 拓扑图:3 系统及软件版本:3 安装步骤:4 IP分配:4 LVS和keepalived的安装和配置:4 LVS主配置:4 LVS2备 配置:7 web服务器配置9 Mysql-MHA高可用:13 Mysql主配置:13 manager管理端操作:15 VIP切换:16 测试:26 下面是centos5.6的系统环境,如果是centos6版本,只需改动少许地方即可,步骤一致 . ---- by 金戈铁马行飞燕 项目需求:

kubeadm部署k8s1.9高可用集群--4部署master节点

部署master节点 kubernetes master 节点包含的组件: kube-apiserver kube-scheduler kube-controller-manager 本文档介绍部署一个三节点高可用 master 集群的步骤,分别命名为k8s-host1.k8s-host2.k8s-host3: k8s-host1:172.16.120.154 k8s-host2:172.16.120.155 k8s-host3:172.16.120.156 安装docker 在每台主机安装do

SpringCloud组件:Eureka高可用集群部署

高可用集群部署 Eureka 服务注册中心.构建项目使用 idea 开发工具创建一个 SpringBoot 项目,添加 Eureka Server 依赖即可, pom.xml 配置文件如下所示: ...... <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>