Home php教程 php手册 centos(7) heartbeat 配置

centos(7) heartbeat 配置

Jun 06, 2016 pm 08:00 PM
centos php Configuration

本文就在centos下,双机功能 的实现 及对heartbeat的配置, 测试。 对于 HA的安装, 本文没有涉及, 如果对安装的问题的同学, 建议参考http://linux-ha.org/download/index.html 1. HA的配置 HeartBeat软件的安装目录为/etc/ha.d,其中, README.config对配

本文就在centos下,双机功能 的实现 及对heartbeat的配置, 测试。

对于 HA的安装, 本文没有涉及, 如果对安装的问题的同学, 建议参考http://linux-ha.org/download/index.html

 

 

1. HA的配置

HeartBeat软件的安装目录为/etc/ha.d,其中, README.config对配置文件进行了说明,主要的配置文件是3个, ha.cf, haresource, authkeys

centos(7) heartbeat 配置

 

1.1 配置 ha.cf文件

 

ha.cf 文件是heartbeat的主要配置文件, 可以对heartbeat的多数性能与状态进行配置, 多数选项可以采用默认值,

centos(7) heartbeat 配置

 

1.2 配置haresources文件

 

haresources文件用于指定双机系统的主节点、集群IP、子网掩码、广播地址以及启动的服务等。其配置语句格式如下:
node-name  network-config 
其中node-name指定双机系统的主节点,取值必须匹配ha.cf文件中node选项设置的主机名中的一个,node选项设置的另一个主机名成为从节点。
network-config用于网络设置,包括指定集群IP、子网掩码、广播地址等。resource-group用于设置heartbeat启动的服务,该服务最终由双机系统通过集群IP对外提供。

 

下面是笔者的环境所使用的haresources的配置情况,主要是为了mysql来做HA的,:

 

centos(7) heartbeat 配置

 

如果要对httpd进行ha, 可以配置如下:

test 192.168.120.110/24 httpd

其中 test是主机名 httpd 是你想HA的service, 指定了192.168.120.110为cluster IP(VIP),子网掩码是255.255.255.0

 

还可以向脚本传递参数, 就像上面的例子一样。

1.3 配置 authkeys文件,

authkeys文件用于heartbeat的鉴权设置,共有三种可用的方式crc、md5和sha1。

 

三种方式安全性依次提高,但同时占用的系统资源也依

次扩大。crc安全性最低,适用于物理上比较安全的网络,sha1提供最为有效的鉴权方式,占用的系统资源也最多

 

其配置语句格式如下:
auth
[]

 

本文笔者是sha1的认证方式。

centos(7) heartbeat 配置

 

最后,该authkeys文件的文件许可权应该设为600(即-rw-------),命令为:

 

 

 

2. HA的运行与测试

2.1 启动HeartBeat

heartbeat 配置完成之后, 可以使用如下的命令来启动heartbeat

 

2.2 测试

2.2.1 测试VIP可用性

当用service heartbeat start 之后, 就可以发现 VIP已经可以联通了

centos(7) heartbeat 配置

2.2.2 测试切换

 

在主节点hello上调用命令 /etc/rc.d/init.d/heartbeat stop 关闭heartbeat。
使用ifconfig命令可以发现,主节点已经释放了集群IP地址192.168.120.120,并由从节点绑定该IP地址。使用telnet命令登录的是从节点.

 原来的主节点

centos(7) heartbeat 配置

 

切换之后的主结点

 

centos(7) heartbeat 配置

 

 

而这个过程中, VIP的联通性是不受影响的

centos(7) heartbeat 配置

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

See all articles