2、corosync集群初步


配置高可用集群

配置環境:兩台centos7 192.168.184.141  192.168.184.142

corosync v2 + pacemaker

corosync v2:vote system

pacemaker:獨立服務

 

配置集群的兩種方式:

1、手動安裝配置

2、借助於集群的全生命周期管理工具:

pcs: agent(pcsd)

crmsh: agentless (pssh)

crmsh的全生命周期管理在centos上進行安裝配置不是特別好用,所以先使用pcs安裝配置集群,然后使用crmsh來管理進群,因為crmsh管理集群比較方便,最后在使用pcs來管理集群。

# yum info pcs

 

 

配置集群的前提:

(1) 時間同步;

(2) 基於當前正在使用的主機名互相訪問,同時本地配置的主機名和DNS解析的主機名必須要保持一致,不然可能會出問題(可借助於/etc/hosts);

(3) 是否會用到仲裁設備,如果用到ping node就不需要提前准備,如果是qdisk就需要提前准備;

    注意:紅帽7的pcs可以安裝並啟動集群,但是紅帽6也存在pcs,但是沒有安裝並啟動集群的功能。

 

前提:

1)本配置共有兩個測試節點,分別node1和node2,相應IP地址分別為192.168.184.141和192.168.184.142;

2)集群服務為nginx服務;

3)提供web服務的地址為192.168.184.143,即vip;

4)系統為CentOS 7.6 x86_64

   # yum install -y redhat-lsb   //查看系統版本

   # lsb_release -a

為了配置一台Linux主機成為HA的節點,通常需要做出如下的准備工作:

1) 所有節點的主機名稱和對應的IP地址解析服務可以正常工作,且每個節點的主機名稱需要跟"uname -n"命令的結果保持一致;

   因此,需要保證兩個節點上的/etc/hosts文件均為下面的內容:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.184.141 node1
192.168.184.142 node2
192.168.184.143 node3

為了是主機名永久有效,需要另外配置

Node1:
# hostnamectl set-hostname node1
# hostname node1

Node2:
# hostnamectl set-hostname node2
# hostname node2

測試兩台主機解析的域名是否與主機名保持一致

 

2) 設定兩個節點可以基於密鑰進行ssh通信,這可以通過類似如下的命令實現:

Node1:
# ssh-keygen -t rsa -P ''
# ssh-copy-id -i ~/.ssh/id_rsa.pub root@node2

Node2:
# ssh-keygen -t rsa -P ''
# ssh-copy-id -i ~/.ssh/id_rsa.pub root@node1

3) 多節點時間同步

# crontab -l
#Ansible: sync time from ntpserver
*/10 * * * * /sbin/ntpdate -u 133.100.11.8 &>/dev/null

 

2、安裝並啟動集群

2.1 安裝並啟動pcsd

pcs客戶端程序是通過跟服務器端聯系從而完成服務管理的即pcsd之下的corosync和pacemaker管理。因此只要是集群內的主機,都要確保主機安裝並開機啟動pcsd,

Node1 AND Node2:都要安裝

# yum install -y pacemaker pcs psmisc policycoreutils-python   //只安裝pcs即可,其他不是必須

# yum install pcs   //pcs依賴於pacemaker的功能,pacemaker又依賴於corosync的功能,兩個節點都要安裝

  

# rpm -ql pcs   //查看安裝列表

/usr/lib/systemd/system/pcsd.service  //程序控制文件

/etc/sysconfig/pcsd   //配置文件  

# systemctl start pcsd.service    //啟動pcs

# systemctl enable pcsd.service   //設置開機啟動

這里把啟動和定義開機啟動利用ansible來啟動

# vim /etc/ansible/hosts   //定義ha集群組

[ha]
192.168.184.141
192.168.184.142

# ansible ha -m service -a 'name=pcsd state=started enabled=yes'   //即可啟動並開機啟動

# ansible ha -m shell -a 'echo "123456" | passwd --stdin hacluster'   //為hacluster用戶添加密碼

2.2 配置corosync

pcs是客戶端工具,pcsd是每一個集群節點要啟動的守護進程,pcs就是通過聯系每一個守護進程來實現集群的配置和管理的

# pcs --help   pcs命令可以使用pacemaker集群的全生命周期管理,每一種管理功能均通過相應的子命令實現。

Usage: pcs [-f file] [-h] [commands]...
Control and configure pacemaker and corosync.

Options:
    -h, --help         Display usage and exit.
    -f file            Perform actions on file instead of active CIB.
    --debug            Print all network traffic and external commands run.
    --version          Print pcs version information. List pcs capabilities if
                       --full is specified.
    --request-timeout  Timeout for each outgoing request to another node in
                       seconds. Default is 60s.
    --force            Override checks and errors, the exact behavior depends on
                       the command. WARNING: Using the --force option is
                       strongly discouraged unless you know what you are doing.

Commands:
    cluster     Configure cluster options and nodes.   //配置集群選項和節點
    resource    Manage cluster resources.   //管理集群資源
    stonith     Manage fence devices.       //管理隔離設備的
    constraint  Manage resource constraints.   //定義資源約束的
    property    Manage pacemaker properties.   //定義pacemaker的集群屬性的
    acl         Manage pacemaker access control lists.   //定義訪問控制列表的
    qdevice     Manage quorum device provider on the local host.  
    quorum      Manage cluster quorum settings.
    booth       Manage booth (cluster ticket manager).
    status      View cluster status.      //查看集群狀態
    config      View and manage cluster configuration.   //查看集群的整體配置
    pcsd        Manage pcs daemon.
    node        Manage cluster nodes.
    alert       Manage pacemaker alerts.

# pcs cluster --help

Usage: pcs cluster [commands]...
Configure cluster for use with pacemaker

Commands:
    auth [<node>[:<port>]] [...] [-u <username>] [-p <password>] [--force]  [--local]   //認證並連接至指定節點,-u表示以哪個用戶認證,默認是hacluster
        Authenticate pcs to pcsd on nodes specified, or on all nodes
        configured in the local cluster if no nodes are specified (authorization
        tokens are stored in ~/.pcs/tokens or /var/lib/pcsd/tokens for root).
        By default all nodes are also authenticated to each other, using
        --local only authenticates the local node (and does not authenticate
        the remote nodes with each other). Using --force forces
        re-authentication to occur.
setup [--start [--wait[=<n>]]] [--local] [--enable] --name <cluster name> //設置集群
[--addr0 <addr/net> [[[--mcast0 <address>] [--mcastport0 <port>] //--mcast0自己指定多播地址
# man corosync.conf //詳細信息
start [--all | <node>... ] [--wait[=<n>]] [--request-timeout=<seconds>] //啟動集群
stop [--all | <node>... ] [--request-timeout=<seconds>] //停止集群

Node1 OR Node2: //在node1或者node2上執行下面的命令都可以,這里是為了管理集群

# pcs cluster auth node1 node2 -u hacluster //如果兩個節點的用戶和密碼一樣,可以都認證通過的,如果pcs在每個節點運行,那么auth需要在每個節點上都運行

Password:
node1: Authorized
node2: Authorized

# pcs cluster setup --name mycluster auth node1 node2 -u hacluster 

  //--name為集群取名,把node1和node2創建成集群,創建集群后會自動分別把pacenaker服務和corosync服務啟動起來

Destroying cluster on nodes: node1, node2...
node2: Stopping Cluster (pacemaker)...
node1: Stopping Cluster (pacemaker)...
node1: Successfully destroyed cluster
node2: Successfully destroyed cluster

Sending 'pacemaker_remote authkey' to 'node1', 'node2'
node1: successful distribution of the file 'pacemaker_remote authkey'
node2: successful distribution of the file 'pacemaker_remote authkey'
Sending cluster config files to the nodes...
node1: Succeeded
node2: Succeeded

Synchronizing pcsd certificates on nodes node1, node2...    //顯示同步成功
node1: Success
node2: Success
Restarting pcsd on the nodes in order to reload the certificates...   //重新啟動pcsd守護進程
node1: Success
node2: Success

# ls /etc/corosync/   //那么同步之后有什么效果?切換目錄到corosync的配置文件路徑

corosync.conf  //同步后自動生成的,默認是不存在的,是根據corosync.conf.example.udpu這個樣本生成的

corosync.conf.example 

corosync.conf.example.udpu  //corosync的版本2是通過udpu通信的,版本1是通過udp協議上的組播、單播或多播方式通信的,默認是多播

corosync.xml.example  uidgid.d

# cat corosync.conf   //兩個節點要相同

 1 totem {   //定義集群所有節點之間是基於什么方式來傳遞集群心跳信息的以及集群事務信息的。totem是corosync專用心跳信息傳送協議/模塊
 2     version: 2  //模塊版本
 3     cluster_name: mycluster
 4     secauth: off  //安全認證功能默認是否開啟,如果開啟需要手動生成密鑰文件
 5     transport: udpu  
 6 }
 7 
 8 nodelist {   //集群中的節點
 9     node {
10         ring0_addr: node1   //ring0_addr表示環0地址,集群心跳信息直接可以送達的位置,環0是自己,即心跳信息不用傳遞,就是自己
11         nodeid: 1
12     }
13 
14     node {
15         ring0_addr: node2
16         nodeid: 2
17     }
18 }
19 
20 quorum {   //仲裁機制,即法定票數的投票機制
21     provider: corosync_votequorum   //如何完成投票,要用corosync_votequorum(coroync自己的投票系統)
22     two_node: 1   //當前節點是否是兩個節點,是就是1,如果不是兩個節點就是0
23 }
24 
25 logging {   //記錄日志
26     to_logfile: yes   
27     logfile: /var/log/cluster/corosync.log   //要確定這個目錄是存在的
28     to_syslog: yes   //是否發給系統日志
29 }

2.3 啟動集群

Nod1 OR Node2:
# pcs cluster start --all   //啟動集群的所有節點

node1: Starting Cluster (corosync)...
node2: Starting Cluster (corosync)...
node2: Starting Cluster (pacemaker)...
node1: Starting Cluster (pacemaker)...

# ps -aux

root 5186 0.9 5.1 196248 95944 ? SLsl 17:17 0:04 corosync
root 5223 0.0 0.3 104200 7156 ? Ss 17:17 0:00 /usr/sbin/pacemakerd -f
haclust+ 5224 0.0 0.7 106968 13964 ? Ss 17:17 0:00 /usr/libexec/pacemaker/cib
root 5225 0.0 0.3 107284 6084 ? Ss 17:17 0:00 /usr/libexec/pacemaker/stonithd
root 5226 0.0 0.2 94512 4320 ? Ss 17:17 0:00 /usr/libexec/pacemaker/lrmd
haclust+ 5227 0.0 0.3 123708 6512 ? Ss 17:17 0:00 /usr/libexec/pacemaker/attrd
haclust+ 5228 0.0 0.1 80432 3472 ? Ss 17:17 0:00 /usr/libexec/pacemaker/pengine
haclust+ 5229 0.0 0.4 136028 8612 ? Ss 17:17 0:00 /usr/libexec/pacemaker/crmd

上面的命令相當於在各節點分別執行如下命令:
# systemctl start corosync.service
# systemctl start pacemaker.service

 

2.4 檢查集群啟動狀態

檢查各節點通信狀態(顯示為no faults即為OK):

# corosync-cfgtool --help   //查看幫助信息

# corosync-cfgtool -s

Printing ring status.
Local node ID 1
RING ID 0
id = 192.168.184.141
status = ring 0 active with no faults

檢查集群成員關系及Quorum API:

# corosync-cmapctl -h   //查看幫助信息
# corosync-cmapctl | grep members
   

# pcs status --help    //查看當前集群或資源的狀態

# pcs status corosync

 1 Cluster name: mycluster
 2 
 3 WARNINGS:   //可以修改不啟用stonith,
 4 No stonith devices and stonith-enabled is not false  //關閉stonith是關閉集群全局屬性
 5 
 6 Stack: corosync   //顯示底層傳遞集群事務的協議棧或者messaging layer是什么?這里可以是corosync也可以是heartbeat v3,
 7 Current DC: node2 (version 1.1.19-8.el7_6.2-c3c624ea3d) - partition with quorum //partition with quorum:一旦分區擁有法定票數的分區才能代表集群
//DC(Designated Coordinator)是自定協調員,整個集群內所有節點選舉出來,用來做全局集群事務決策的節點。如果當前DC宕機,那么就需要重新選舉
 8 Last updated: Sat Jan 12 19:20:55 2019
 9 Last change: Sat Jan 12 17:17:37 2019 by hacluster via crmd on node2
10 
11 2 nodes configured    //配置了兩個節點
12 0 resources configured  //沒有資源
13 
14 Online: [ node1 node2 ]   //兩個節點處於online狀態
15 
16 No resources   //沒有資源
17 
18 
19 Daemon Status:   //各守護工作正常
20   corosync: active/disabled
21   pacemaker: active/disabled
22   pcsd: active/enabled

配置集群屬性

corosync有許多全局配置屬性,例如修改stonith-enabled即為此類屬性之一。pcs的property子命令可用於顯示或設置集群的各屬性。

下面的命令可以獲取其詳細使用幫助。

# pcs property --help   //配置集群的全局屬性

[list|show [<property> | --all | --defaults]] | [--all | --defaults]

set [--force | --node <nodename>] <property>=[<value>]

Examples:
    pcs property set stonith-enabled=false

# pcs property list --all   //顯示所有可配置選項

# pcs property set stonith-enabled=false  //這里把stonith關閉,因為沒有stonith設備

# pcs property list  //查看已經修改的

Cluster Properties:
  cluster-infrastructure: corosync
  cluster-name: mycluster
  dc-version: 1.1.19-8.el7_6.2-c3c624ea3d
  have-watchdog: false
  stonith-enabled: false

# crm_verify -L -V //其中的WARNING信息是因為當前集群系統開啟了stonith-enabled屬性但卻沒有配置stonith設備所致。使用crm_verify命令也可檢查出此錯誤。

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

 

安裝crmsh

這里兩台高可用節點都安裝了crmsh,由於centos7中沒有自帶crmsh,所以不能使用yum源安裝

# cd /etc/yum.repo.d/  //切換目錄

# OSVERSION=$(cat /etc/centos-release | sed -rn 's/.* ([[:digit:]]).*/\1/p')   //取得系統的版本號

# wget http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-${OSVERSION}/network:ha-clustering:Stable.repo    //將變量OSVERSION換成系統版本號

# yum install crmsh

# yum install pssh    //因為crmsh是基於ssh進行遠程管理的,所以需要安裝pssh,pssh依賴於python-pssh,安裝時會自動解決依賴關系

# rpm -qi pssh

Name        : pssh
Version     : 2.3.1
Release     : 7.4
...
Summary : Parallel SSH to control large numbers of Machines simultaneously //並行ssh,表示可以利用一個客戶端同時連接多個ssh
Description :
pssh provides parallel versions of the OpenSSH tools that are useful for
controlling large numbers of machines simultaneously. It includes parallel
versions of ssh, scp, and rsync, as well as a parallel kill command.

pssh命令是一個python編寫可以在多台服務器上執行命令的工具,同時支持拷貝文件,是同類工具中很出色的,類似pdsh,個人認為相對pdsh更為簡便,使用必須在各個服務器上配置好密鑰認證訪問。 http://man.linuxde.net/pssh

crmsh不依賴任何服務,它是基於ssh進行遠程管理的。而pcs是有agent的,agent就是pcsd,pcsd守護進程在每個節點上都要運行。

# crm help   //crm幫助文檔

# crm status  //查看集群狀態

crm有兩種風格:

1、直接在命令行中執行

# crm status

2、有交互式接口

[root@node1 ~]# crm
crm(live)# help
crm(live)# resource
crm(live)resource# ls
..               operations       status           
help             show             migrate          
move             back             cd               
meta             demote           quit             
...   
crm(live)resource# cd
crm(live)# node
crm(live)node# cd
crm(live)# configure
crm(live)configure# show
node 1: node1
node 2: node2
property cib-bootstrap-options: \
    have-watchdog=false \
    dc-version=1.1.19-8.el7_6.2-c3c624ea3d \
    cluster-infrastructure=corosync \
    cluster-name=mycluster \
    stonith-enabled=false
crm(live)configure# edit
crm(live)configure# 

crmsh結合corosync創建高可用httpd

web service高可用所需資源:

vip:192.168.184.150

httpd自行安裝,兩個節點都要安裝並確保啟動沒有問題

需要將vip和httpd運行在同一個節點,因為集群默認式負載均衡法則,所以把這兩個資源定義成組或者定義排列約束。

# yum install httpd -y  //在兩台節點上都安裝httpd,這里為了展示效果所以設置的網頁文件不一樣,但是生產環境中網頁可能來自共享存儲,所以是一樣的

# echo "<h1>node1</h1>" > /var/www/html/index.html

# systemctl start httpd  //測試網頁是否可以訪問,

注意:

1、上面啟動的服務要停掉,因為需要資源管理器自動決定在哪個節點啟動;

2、一定不能設置開機自動啟動

# systemctl stop httpd

# systemctl disable httpd

下面就開始把vip和httpd配置成集群服務的資源,任何資源想要配置在集群上使用,只能通過資源代理來實現。

配置IP地址時,哪些資源代理可用?

[root@node1 ~]# crm
crm(live)# ra //resource agent
crm(live)ra# help
Resource Agents (RA) lists and documentation

This level contains commands which show various information about
the installed resource agents. It is available both at the top
level and at the configure level.

Commands:
    classes List classes and providers //查看有哪些資源代理的類型
    info           Show meta data for a RA      //查看資源代理如何使用
    list           List RA for a class (and provider)
    providers      Show providers for a RA and a class
    validate       Validate parameters for RA

    cd             Navigate the level structure
    help           Show help (help topics for list of topics)
    ls             List levels and commands
    quit           Exit the interactive shell
    up             Go back to previous level

crm(live)ra# classes   //顯示資源代理類別
lsb         //centos6配置使用,/etc/rc.d/init.d
ocf / .isolation heartbeat openstack pacemaker
service      //通用服務組件
systemd
crm(live)ra# 
每一個類別下有多少資源代理可用?
在查看lsb類別下有哪些資源可用?當查看lsb類別下的有哪些資源可用時,他會自動加載/etc/rc.d/init.d/目錄下的所有腳本。
crm(live)ra# help list
List RA for a class (and provider)

List available resource agents for the given class. If the class
is ocf, supply a provider to get agents which are available
only from that provider.

Usage:

list <class> [<provider>]

Example:

list ocf pacemaker 

crm(live)ra# list lsb   //list后跟上資源代理的名稱
    netconsole network

crm(live)ra# list systemd   //類別下會有httpd

crm(live)ra# help info

info [<class>:[<provider>:]]<type>   //info 類別:資源代理
info <type> <class> [<provider>] (obsolete)

示例:crm(live)ra# info ocf:heartbeat:IPaddr

下面開始配置資源,是在configure目錄下進行配置,IP只能配置在一個節點上,叫做原始資源或者主資源

crm(live)configure# help primitive

    Usage:

  primitive <rsc> {[<class>:[<provider>:]]<type>|@<template>}  //rsc:資源名字,class:指明使用哪個資源代理,type:資源代理的名稱
  [description=<description>] 
  [[params] attr_list]   //這里是傳遞參數

Example:  //示例

primitive apcfence stonith:apcsmart \
   params ttydev=/dev/ttyS0 hostlist="node1 node2" \
   op start timeout=60s \
   op monitor interval=30m timeout=60s

primitive www8 apache \
   configfile=/etc/apache/www8.conf \
   operations $id-ref=apache_ops

示例:

crm(live)configure# primitive webip ocf:heartbeat:IPaddr params ip=192.168.184.150  //webip是資源代理定義的資源的名字,ocf:heartbeat:是資源代理,params指定參數

crm(live)configure# show
node 1: node1
node 2: node2
primitive webip IPaddr \
         params ip=192.168.184.150
property cib-bootstrap-options: \
         have-watchdog=false \
         dc-version=1.1.19-8.el7_6.2-c3c624ea3d \
         cluster-infrastructure=corosync \
         cluster-name=mycluster \
         stonith-enabled=false

crm(live)configure# verify    //做校驗

crm(live)configure# commit    //校驗沒問題的話就提交

如何將IP資源轉移到其他節點?

如何讓node1重新上線?

如何定義web資源服務?

crm(live)# configure    //注意要在configure中定義
crm(live)configure# primitive webserver systemd:httpd   //這里沒有要不要添加參數,可以使用#crm ra --> #info systemd:httpd
crm(live)configure# verify   //校驗
crm(live)configure# commit   //提交
 
crm(live)# status
Stack: corosync
Current DC: node1 (version 1.1.19-8.el7_6.2-c3c624ea3d) - partition with quorum
Last updated: Mon Jan 14 20:44:15 2019
Last change: Mon Jan 14 20:43:50 2019 by root via cibadmin on node1

2 nodes configured
2 resources configured

Online: [ node1 node2 ]

Full list of resources:     //兩個資源都啟動了

 webip    (ocf::heartbeat:IPaddr):    Started node2   //IP啟動在node2
 webserver    (systemd:httpd):    Started node1    //httpd就啟動在了node1上

如何將IP資源和httpd資源運行在一起?

crm(live)configure# help group

Usage:

group <name> <rsc> [<rsc>...]
  [description=<description>]
  [meta attr_list]
  [params attr_list]

attr_list :: [$id=<id>] <attr>=<val> [<attr>=<val>...] | $id-ref=<id>

Example:

group internal_www disk0 fs0 internal_ip apache \
  meta target_role=stopped

group vm-and-services vm vm-sshd meta container="vm"

crm(live)configure# group webservice webip webserver  //webservice是組名,組內有webip和webserver兩個資源,次序很關鍵,有可能是啟動次序
crm(live)configure# verify

crm(live)configure# commit
crm(live)configure# cd
crm(live)# status   //查看狀態

Stack: corosync
Current DC: node1 (version 1.1.19-8.el7_6.2-c3c624ea3d) - partition with quorum
Last updated: Mon Jan 14 21:12:20 2019
Last change: Mon Jan 14 21:12:12 2019 by root via cibadmin on node1

2 nodes configured
2 resources configured

Online: [ node1 node2 ]

Full list of resources:
 Resource Group: webservice
     webip    (ocf::heartbeat:IPaddr):    Started node2     //現在IP資源和httpd資源都在node2上,因為之前IP資源就在node2上,所有httpd資源也遷移到node2上了。
     webserver    (systemd:httpd):    Started node2        //如果先定義webserver,再定義webip,那么會把webip遷移到webserver所在的節點

此時在瀏覽器中訪問192.168.184.142即node2的IP是可以的,而node1是無法訪問的,因為webip和webserver都是在node2上啟動的。

     

強制將資源從node2遷移到node1上

[root@node2 ~]# crm node standby   //在node2上直接執行
[root@node2 ~]# crm status

Stack: corosync
Current DC: node1 (version 1.1.19-8.el7_6.2-c3c624ea3d) - partition with quorum
Last updated: Mon Jan 14 21:38:28 2019
Last change: Mon Jan 14 21:38:22 2019 by root via crm_attribute on node2

2 nodes configured
2 resources configured

Node node2: standby    //node2是備用節點
Online: [ node1 ]    //在線的是node1

Full list of resources:

 Resource Group: webservice
     webip    (ocf::heartbeat:IPaddr):    Started node1   //在node1節點上
     webserver    (systemd:httpd):    Started node1

以上是兩類資源的定義:primitive和group

[root@node2 ~]# crm node online    //讓node2上線
[root@node2 ~]# crm status
Stack: corosync
Current DC: node1 (version 1.1.19-8.el7_6.2-c3c624ea3d) - partition with quorum
Last updated: Mon Jan 14 21:42:49 2019
Last change: Mon Jan 14 21:42:42 2019 by root via crm_attribute on node2

2 nodes configured
2 resources configured

Online: [ node1 node2 ]

Full list of resources:

 Resource Group: webservice
     webip    (ocf::heartbeat:IPaddr):    Started node1
     webserver    (systemd:httpd):    Started node1

如何配置資源的默認粘性?

crm(live)configure# property //敲兩下tab鍵,可以補全
batch-limit=                   enable-startup-probes=         node-health-strategy=          startup-fencing= 
cluster-delay=                 have-watchdog=                 node-health-yellow=            stonith-action= 
cluster-ipc-limit=             is-managed-default=            notification-agent=            stonith-enabled= 
cluster-recheck-interval=      load-threshold=                notification-recipient=        stonith-max-attempts= 
concurrent-fencing=            maintenance-mode=              pe-error-series-max=           stonith-timeout= 
crmd-transition-delay=         migration-limit=               pe-input-series-max=           stonith-watchdog-timeout= 
dc-deadtime=                   no-quorum-policy=              pe-warn-series-max=            stop-all-resources= 
default-action-timeout=        node-action-limit=             placement-strategy=            stop-orphan-actions= 
default-resource-stickiness=   node-health-base=              remove-after-stop=             stop-orphan-resources= 
election-timeout=              node-health-green=             shutdown-escalation=           symmetric-cluster= 
enable-acl=                    node-health-red=               start-failure-is-fatal=     
default-resource-stickiness=   //默認資源粘性,這里是0,一般定義為正值   

如果一個節點被宕機,資源是否會在另一個節點啟動?

# crm status   //可以看到現在資源在node1上

# systemctl stop pacemaker corosync   //把服務停掉

[root@node2 ~]# crm status   //在node2上可以看到資源轉移到node2上了
Stack: corosync
Current DC: node2 (version 1.1.19-8.el7_6.2-c3c624ea3d) - partition with quorum
Last updated: Mon Jan 14 22:11:42 2019
Last change: Mon Jan 14 21:42:42 2019 by root via crm_attribute on node2

2 nodes configured   //這里仍然顯示兩個節點
2 resources configured

Online: [ node2 ]
OFFLINE: [ node1 ]   //不在線

Full list of resources:

 Resource Group: webservice
     webip    (ocf::heartbeat:IPaddr):    Started node2
     webserver    (systemd:httpd):    Started node2

下面直接把節點1關機

[root@node2 ~]# crm status
Stack: corosync
Current DC: node2 (version 1.1.19-8.el7_6.2-c3c624ea3d) - partition with quorum    //這里只剩一個節點,應該是without quorum即沒有仲裁節點
Last updated: Mon Jan 14 22:17:37 2019
Last change: Mon Jan 14 21:42:42 2019 by root via crm_attribute on node2

2 nodes configured
2 resources configured

Online: [ node2 ]
OFFLINE: [ node1 ]

Full list of resources:

 Resource Group: webservice
     webip    (ocf::heartbeat:IPaddr):    Started node2

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM