欢迎各位兄弟 发布技术文章
这里的技术是共享的
[root@node1 ~]# crm_mon
============
Last updated: Fri Dec 11 17:09:00 2020
Stack: openais
Current DC: node1.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
0 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
正常的heartbeat或corosync集群至少要有三个节点
否则一个节点宕机以后,我们的服务或资源不会在另外一个节点上自动启动起来
[root@node1 ~]# crm
#crm开头的命令 crm_sh没了, 多了一个crm命令 即 crm取代了以前的crm_sh;;这个crm命令更强大
crm crm_diff crm_mon crm_shadow crm_verify
crmadmin crm_failcount crm_node crm_standby
crm_attribute crm_master crm_resource crm_uuid
[root@node1 ~]# crm #这个命令可以在任意一个节点上执行,它自动会连到DC上实现编写以及配置的保存
crm(live)# help
This is the CRM command line interface program.
Available commands:
cib manage shadow CIBs
resource resources management #管理资源
node nodes management #管理节点
options user preferences
configure CRM cluster configuration
ra resource agents information center #管理资源代理
status show cluster status #查看节点状态,资源状态等
quit,bye,exit exit the program
help show help
end,cd,up go back one level #支持cd命令
crm(live)# resource #可以进入子模式 按tab支持自动补全
INFO: building help index
crm(live)resource# help #再使用help
At this level resources may be managed.
All (or almost all) commands are implemented with the CRM tools
such as `crm_resource(8)`.
Available commands:
status,show,list show status of resources #查看资源状态
start start a resource #启动一个资源 用得比较多
stop stop a resource #停止一个资源 用得比较多
restart restart a resource #重启一个资源 用得比较多
promote promote a master-slave resource # 升级一个资源 ?
demote demote a master-slave resource # 降级一个资源 ?
manage put a resource into managed mode # 管理一个资源
unmanage put a resource into unmanaged mode #反管理一个资源
migrate,move migrate a resource to another node #迁移一个资源
unmigrate,unmove unmigrate a resource to another node
param manage a parameter of a resource
meta manage a meta attribute
failcount manage failcounts
cleanup cleanup resource status #清理资源状态 用得比较多
refresh refresh CIB from the LRM status
reprobe probe for resources not started by the CRM
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)resource#
crm(live)resource# cd .. #回到父目录
crm(live)# resource
crm(live)resource# help status #获取子命令的详细使用信息
Print resource status. If the resource parameter is left out
status of all resources is printed.
Usage:
...............
status [<rsc>] # status 加上 资源名称(资源id号)
...............
crm(live)resource#
crm(live)resource# cd #不带参数,直接回到顶级crm
crm(live)#
crm(live)# help
This is the CRM command line interface program.
Available commands:
cib manage shadow CIBs
resource resources management
node nodes management
options user preferences
configure CRM cluster configuration
ra resource agents information center
status show cluster status
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)#
crm(live)# node
crm(live)node#
crm(live)node# help
Node management and status commands.
Available commands:
status show nodes' status #查看节点状态
show,list show node #显示节点
standby put node into standby #节点转换为备用模式
online set node online #让节点重新上线
fence fence node #fence一个节点
clearstate Clear node state #清理节点的状态信息
delete delete node #删除一个节点
attribute manage attributes
status-attr manage status attributes
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)node#
crm(live)node# cd
crm(live)# help
This is the CRM command line interface program.
Available commands:
cib manage shadow CIBs
resource resources management
node nodes management
options user preferences
configure CRM cluster configuration
ra resource agents information center
status show cluster status
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)#
crm(live)# configure #配置集群资源 定义一个资源,给资源起个名称,使用一个RA,传递一些参数等,都要使有configure 命令
Signon to CIB failed: connection failed
Init failed, could not perform requested operations
ERROR: cannot parse xml: no element found: line 1, column 0
crm(live)configure#
crm(live)configure# help
This level enables all CIB object definition commands.
The configuration may be logically divided into four parts:
nodes, resources, constraints, and (cluster) properties and
attributes. Each of these commands support one or more basic CIB
objects.
Nodes and attributes describing nodes are managed using the
`node` command.
Commands for resources are:
- `primitive`
- `monitor`
- `group`
- `clone`
- `ms`/`master` (master-slave)
There are three types of constraints:
- `location`
- `colocation`
- `order`
Finally, there are the cluster properties, resource meta
attributes defaults, and operations defaults. All are just a set
of attributes. These attributes are managed by the following
commands:
- `property`
- `rsc_defaults`
- `op_defaults`
The changes applied to the current CIB only on ending the
configuration session or using the `commit` command.
Available commands:
node define a cluster node #定义一个节点
primitive define a resource #定义一个主资源
monitor add monitor operation to a primitive
group define a group #定义一个组资源
clone define a clone #定义一个克隆资源
ms,master define a master-slave resource 定义一个主从资源
location a location preference #定义位置约束
colocation,collocation colocate resources #定义排列约束
order order resources #定义顺序约束
property set a cluster property #定义一个集群的属性 ( 对称的,非对称的)???
rsc_defaults set resource defaults # (资源默认粘性)???
role define role access rights #我这边没有,马哥那边有 当前的crm谁能访问,谁不能访问,谁来做操作
user define role access rights #我这边没有,马哥那边有 当前的crm谁能访问,谁不能访问,谁来做操作
op_defaults set resource operations defaults
show display CIB objects #显示CIB(集群信息库)的每一个相关的属性,配置信息,每一个资源的定义,资源属性的定义,都会保存在集群信息库里面
edit edit CIB objects #编辑CIB库,打开vim编辑器,编辑CIB的配置文件
delete delete CIB objects
rename rename a CIB object
refresh refresh from CIB
erase erase the CIB #清空CIB库
ptest show cluster actions if changes were committed
cibstatus CIB status management and editing #cib状态
template edit and import a configuration from a template
commit commit the changes to the CIB
verify verify the CIB with crm_verify
upgrade upgrade the CIB to version 1.0
save save the CIB to a file
load import the CIB from a file
xml raw xml #显示xml格式的CIB配置
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)configure# #下图是马哥的
crm(live)configure# cd #回到父目录
crm(live)# help
This is the CRM command line interface program.
Available commands:
cib manage shadow CIBs
resource resources management
node nodes management
options user preferences
configure CRM cluster configuration
ra resource agents information center #资源代理
status show cluster status #查看集群的状态
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)#
crm(live)# ra
crm(live)ra# help
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.
Available commands:
classes list classes and providers #显示资源类别及提供商
list list RA for a class (and provider) #显示某一个类别下,某一个提供商所提供的所有 ra
meta,info show meta data for a RA
providers show providers for a RA and a class
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)ra#
crm(live)ra# classes # 显示当前的资源类别
heartbeat
lsb
ocf / heartbeat pacemaker # 有两个提供商heartbeat 和 pacemaker
stonith
crm(live)ra#
crm(live)ra# help list
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#
crm(live)ra# list lsb #lsb格式的ra 有如下的许多(其实都是/etc/init.d 下面的脚本)
NetworkManager acpid anacron apmd
atd auditd autofs avahi-daemon
avahi-dnsconfd bluetooth capi conman
corosync courier-authlib cpuspeed crond
cups cups-config-daemon dc_client dc_server
dnsmasq dovecot dund firstboot
functions gpm haldaemon halt
heartbeat hidd hplip httpd
ip6tables ipmi iptables ipvsadm
irda irqbalance iscsi iscsid
isdn kdump killall krb524
kudzu lm_sensors logd lvm2-monitor
mcstrans mdmonitor mdmpd messagebus
microcode_ctl multipathd mysqld named
netconsole netfs netplugd network
nfs nfslock nmb nscd
ntpd openibd pand pcscd
php-fpm portmap postfix psacct
rawdevices rdisc readahead_early readahead_later
restorecond rhnsd rhsmcertd rpcgssd
rpcidmapd rpcsvcgssd saslauthd setroubleshoot
single smartd smb squid
sshd svnserve syslog tux
vncserver vsftpd wdaemon winbind
wpa_supplicant xfs xinetd ypbind
yum-updatesd
crm(live)ra#
crm(live)ra# list ocf #ocf所提供的所有格式的ra
AoEtarget AudibleAlarm CTDB ClusterMon
Delay Dummy EvmsSCC Evmsd
Filesystem HealthCPU HealthSMART ICP
IPaddr IPaddr2 IPsrcaddr IPv6addr
LVM LinuxSCSI MailTo ManageRAID
ManageVE Pure-FTPd Raid1 Route
SAPDatabase SAPInstance SendArp ServeRAID
SphinxSearchDaemon Squid Stateful SysInfo
SystemHealth VIPArip VirtualDomain WAS
WAS6 WinPopup Xen Xinetd
anything apache conntrackd controld
db2 drbd eDir88 exportfs
fio iSCSILogicalUnit iSCSITarget ids
iscsi jboss ldirectord mysql
mysql-proxy nfsserver nginx o2cb
oracle oralsnr pgsql ping
pingd portblock postfix proftpd
rsyncd scsi2reservation sfex syslog-ng
tomcat vmware
crm(live)ra#
crm(live)ra# list ocf pacemaker #看看ocf下的pacemaker提供的ra
ClusterMon Dummy HealthCPU HealthSMART Stateful
SysInfo SystemHealth controld o2cb ping
pingd
crm(live)ra#
crm(live)ra# list ocf heartbeat #看看ocf下的heartbeat提供的ra
AoEtarget AudibleAlarm CTDB ClusterMon
Delay Dummy EvmsSCC Evmsd
Filesystem ICP IPaddr IPaddr2
IPsrcaddr IPv6addr LVM LinuxSCSI
MailTo ManageRAID ManageVE Pure-FTPd
Raid1 Route SAPDatabase SAPInstance
SendArp ServeRAID SphinxSearchDaemon Squid
Stateful SysInfo VIPArip VirtualDomain
WAS WAS6 WinPopup Xen
Xinetd anything apache conntrackd
db2 drbd eDir88 exportfs
fio iSCSILogicalUnit iSCSITarget ids
iscsi jboss ldirectord mysql
mysql-proxy nfsserver nginx oracle
oralsnr pgsql pingd portblock
postfix proftpd rsyncd scsi2reservation
sfex syslog-ng tomcat vmware
crm(live)ra#
crm(live)ra# help
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.
Available commands:
classes list classes and providers
list list RA for a class (and provider)
meta,info show meta data for a RA #显示一个RA的元信息(元数据信息) 比如IPADDR的各种参数(ip参数,nic参数,cidr_netmask参数等)
providers show providers for a RA and a class
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)ra#
crm(live)ra# help meta
Show the meta-data of a resource agent type. This is where users
can find information on how to use a resource agent.
Usage:
...............
meta [<class>:[<provider>:]]<type> # 类别:提供者:类型
meta <type> <class> [<provider>] (obsolete)
...............
Example:
...............
meta apache
meta ocf:pacemaker:Dummy
meta stonith:ipmilan
...............
crm(live)ra#
crm(live)ra# meta ocf:heartbeat:IPaddr
Manages virtual IPv4 addresses (portable version) (ocf:heartbeat:IPaddr)
This script manages IP alias IP addresses
It can add an IP alias, or remove one.
Parameters (* denotes required, [] the default):
ip* (string): IPv4 address
The IPv4 address to be configured in dotted quad notation, for example
"192.168.1.1".
nic (string, [eth0]): Network interface
The base network interface on which the IP address will be brought
online.
If left empty, the script will try and determine this from the
routing table.
Do NOT specify an alias interface in the form eth0:1 or anything here;
rather, specify the base interface only.
Prerequisite:
:
.
.
.
.
.
.
ARP_NETMASK (string, [ffffffffffff]): netmask for ARP
netmask for ARP - in nonstandard hexadecimal format.
Operations' defaults (advisory minimum): #建议的最小监控值
start timeout=20s #启动最多等多久等待启动成功;20秒还未启动成功,就认为需要重启或停止或资源转移了
stop timeout=20s #停止最多等多久等待停止成功;
monitor interval=5s timeout=20s #监控,interval表示时间间隔,每隔多久检测一次,最多等timeout 20秒,超时了,再检测一次,再再检测一次,再再再检测一次,,,不行的话,很有可能实现资源转移了
crm(live)ra# help
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.
Available commands:
classes list classes and providers
list list RA for a class (and provider)
meta,info show meta data for a RA
providers show providers for a RA and a class
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)ra#
crm(live)ra# help providers #显示某一个资源是由谁提供的
List providers for a resource agent type. The class parameter
defaults to `ocf`.
Usage:
...............
providers <type> [<class>]
...............
Example:
...............
providers apache
...............
crm(live)ra#
crm(live)ra# providers IPaddr # IPaddr 由 heartbeat 提供的
heartbeat
crm(live)ra#
crm(live)ra# cd
crm(live)#
crm(live)# configure
crm(live)configure# help
This level enables all CIB object definition commands.
The configuration may be logically divided into four parts:
nodes, resources, constraints, and (cluster) properties and
attributes. Each of these commands support one or more basic CIB
objects.
Nodes and attributes describing nodes are managed using the
`node` command.
Commands for resources are:
- `primitive`
- `monitor`
- `group`
- `clone`
- `ms`/`master` (master-slave)
There are three types of constraints:
- `location`
- `colocation`
- `order`
Finally, there are the cluster properties, resource meta
attributes defaults, and operations defaults. All are just a set
of attributes. These attributes are managed by the following
commands:
- `property`
- `rsc_defaults`
- `op_defaults`
The changes applied to the current CIB only on ending the
configuration session or using the `commit` command.
Available commands:
node define a cluster node
primitive define a resource
monitor add monitor operation to a primitive
group define a group
clone define a clone
ms,master define a master-slave resource
location a location preference
colocation,collocation colocate resources
order order resources
property set a cluster property
rsc_defaults set resource defaults
op_defaults set resource operations defaults
show display CIB objects
edit edit CIB objects
delete delete CIB objects
rename rename a CIB object
refresh refresh from CIB
erase erase the CIB
ptest show cluster actions if changes were committed
cibstatus CIB status management and editing
template edit and import a configuration from a template
commit commit the changes to the CIB
verify verify the CIB with crm_verify #检查CIB配置中有没有语法错误
upgrade upgrade the CIB to version 1.0
save save the CIB to a file
load import the CIB from a file
xml raw xml
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)configure#
crm(live)configure#
crm(live)configure# verify #以下显示的是没有 stonith 的错
crm_verify[7567]: 2020/12/12_15:46:39 ERROR: unpack_resources: Resource start-up disabled since no STONITH resources have been defined
crm_verify[7567]: 2020/12/12_15:46:39 ERROR: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option
crm_verify[7567]: 2020/12/12_15:46:39 ERROR: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity
Errors found during check: config not valid
crm(live)configure#
配置集群属性,禁用stonith
我们这里可以通过如下命令先禁用stonith:
# crm configure property stonith-enabled=false
crm:两种工作模式
交互式
配置信息,执行commit以后才生效,可以用verify检查一下有没有语法错误的
批处理模式
配置信息,立即生效
crm(live)configure#
crm(live)configure# help
This level enables all CIB object definition commands.
The configuration may be logically divided into four parts:
nodes, resources, constraints, and (cluster) properties and
attributes. Each of these commands support one or more basic CIB
objects.
Nodes and attributes describing nodes are managed using the
`node` command.
Commands for resources are:
- `primitive`
- `monitor`
- `group`
- `clone`
- `ms`/`master` (master-slave)
There are three types of constraints:
- `location`
- `colocation`
- `order`
Finally, there are the cluster properties, resource meta
attributes defaults, and operations defaults. All are just a set
of attributes. These attributes are managed by the following
commands:
- `property`
- `rsc_defaults`
- `op_defaults`
The changes applied to the current CIB only on ending the
configuration session or using the `commit` command.
Available commands:
node define a cluster node
primitive define a resource
monitor add monitor operation to a primitive
group define a group
clone define a clone
ms,master define a master-slave resource
location a location preference
colocation,collocation colocate resources
order order resources
property set a cluster property #配置属性
rsc_defaults set resource defaults
op_defaults set resource operations defaults
show display CIB objects
edit edit CIB objects
delete delete CIB objects
rename rename a CIB object
refresh refresh from CIB
erase erase the CIB
ptest show cluster actions if changes were committed
cibstatus CIB status management and editing
template edit and import a configuration from a template
commit commit the changes to the CIB
verify verify the CIB with crm_verify
upgrade upgrade the CIB to version 1.0
save save the CIB to a file
load import the CIB from a file
xml raw xml
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)configure#
crm(live)configure# property
usage: property [$id=<set_id>] <option>=<value> #$id是属性名称,给一个值 ,,,选项(或者叫参数)=值
crm(live)configure# help property
Set the cluster (`crm_config`) options.
Usage:
...............
property [$id=<set_id>] <option>=<value> [<option>=<value> ...]
...............
Example:
...............
property stonith-enabled=true
...............
crm(live)configure#
crm(live)configure#
crm(live)configure# show #已有的配置 当前集群的cib.xml当中已有的配置
node node1.magedu.com
node node2.magedu.com
property $id="cib-bootstrap-options" \
dc-version="1.0.12-unknown" \ #dc版本号,每次选举后,会生成随机号,unknown这里为什么是unknown,没有生成
cluster-infrastructure="openais" \ #cluster的集群信息架构,pacemake如果依赖于heartbeat,这里会显示为heartbeat
expected-quorum-votes="2" #期望的法定票数
crm(live)configure#
crm(live)configure# property stonith-enabled=false
crm(live)configure#
crm(live)configure# verify #没有错
crm(live)configure#
crm(live)configure# commit #提交生效
crm(live)configure#
crm(live)configure# show
node node1.magedu.com
node node2.magedu.com
property $id="cib-bootstrap-options" \
dc-version="1.0.12-unknown" \
cluster-infrastructure="openais" \
expected-quorum-votes="2" \
stonith-enabled="false" #加上这个值了,参数的值可以加上双引号的,参数的值中间有空格的话就需要加上双引号了
crm(live)configure#
准备配置 webip(vip)吧
crm(live)configure# help
This level enables all CIB object definition commands.
The configuration may be logically divided into four parts:
nodes, resources, constraints, and (cluster) properties and
attributes. Each of these commands support one or more basic CIB
objects.
Nodes and attributes describing nodes are managed using the
`node` command.
Commands for resources are:
- `primitive`
- `monitor`
- `group`
- `clone`
- `ms`/`master` (master-slave)
There are three types of constraints:
- `location`
- `colocation`
- `order`
Finally, there are the cluster properties, resource meta
attributes defaults, and operations defaults. All are just a set
of attributes. These attributes are managed by the following
commands:
- `property`
- `rsc_defaults`
- `op_defaults`
The changes applied to the current CIB only on ending the
configuration session or using the `commit` command.
Available commands:
node define a cluster node
primitive define a resource #定义一个基本资源
monitor add monitor operation to a primitive
group define a group
clone define a clone
ms,master define a master-slave resource
location a location preference
colocation,collocation colocate resources
order order resources
property set a cluster property
rsc_defaults set resource defaults
op_defaults set resource operations defaults
show display CIB objects
edit edit CIB objects
delete delete CIB objects
rename rename a CIB object
refresh refresh from CIB
erase erase the CIB
ptest show cluster actions if changes were committed
cibstatus CIB status management and editing
template edit and import a configuration from a template
commit commit the changes to the CIB
verify verify the CIB with crm_verify
upgrade upgrade the CIB to version 1.0
save save the CIB to a file
load import the CIB from a file
xml raw xml
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)configure# help primitive
The primitive command describes a resource. It may be referenced
only once in group, clone, or master-slave objects. If it's not
referenced, then it is placed as a single resource in the CIB.
Operations may be specified in three ways. "Anonymous" as a
simple list of "op" specifications. Use that if you don't want to
reference the set of operations elsewhere. That's by far the most
common way to define operations. If reusing operation sets is
desired, use the "operations" keyword along with the id to give
the operations set a name and the id-ref to reference another set
of operations.
Operation's attributes which are not recognized are saved as
instance attributes of that operation. A typical example is
`OCF_CHECK_LEVEL`.
Usage:
...............
primitive <rsc> [<class>:[<provider>:]]<type> # <rsc> 资源名称,,比如上次使用hb_gui 起的webip ,,class:类别,provider:提供者 <type>就是类型,其实就是ra,就是资源代理
[params attr_list] #参数
[meta attr_list]
[operations id_spec] # operations,一些操作,,比如启动的时候,等待多长时间,停止时等待多长时间,监控的时间间隔,监控的超时时间;;这个 [operations ....] 与下面的 [op ...]啥区别??不理解;;好像这里不是指operations的意思吧, 指的是op的意思吧
[op op_type [<attribute>=<value>...] ...]
attr_list :: [$id=<id>] <attr>=<val> [<attr>=<val>...] | $id-ref=<id>
id_spec :: $id=<id> | $id-ref=<id>
op_type :: start | stop | monitor #op_type 的值有这些
...............
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 \
params configfile=/etc/apache/www8.conf \
operations $id-ref=apache_ops
primitive db0 mysql \
params config=/etc/mysql/db0.conf \
op monitor interval=60s \
op monitor interval=300s OCF_CHECK_LEVEL=10
...............
使用的每一个值不能小于建议的最小值,否则会有警告的
advisory minimum (本网页搜索 advisory minimum 上面就可以看到了 )
主资源定义完后,可以再加入组里面,与 hb_gui 有些不同(hb_gui 界面必须要先定义组才行)
配置 webip(vip) 监控如果不指就是默认的监控值
crm(live)configure# primitive webip ocf:heartbeat:IPaddr params ip=192.168.0.50 nic=eth0 cidr_netmask=24
crm(live)configure#
crm(live)configure# verify #检查没错
crm(live)configure#
crm(live)configure# commit #提交一下
crm(live)configure#
crm(live)configure# show #查看一下,这些信息保存在配置里面了,应该是cib里面
node node1.magedu.com
node node2.magedu.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.0.50" nic="eth0" cidr_netmask="24"
property $id="cib-bootstrap-options" \
dc-version="1.0.12-unknown" \
cluster-infrastructure="openais" \
expected-quorum-votes="2" \
stonith-enabled="false"
crm(live)configure#
crm(live)configure# show xml #显示cib的xml格式的配置
<?xml version="1.0" ?>
<cib admin_epoch="0" crm_feature_set="3.0.1" dc-uuid="node2.magedu.com" epoch="18" have-quorum="1" num_updates="1" validate-with="pacemaker-1.0">
<configuration>
<crm_config>
<cluster_property_set id="cib-bootstrap-options">
<nvpair id="cib-bootstrap-options-dc-version" name="dc-version" value="1.0.12-unknown"/>
<nvpair id="cib-bootstrap-options-cluster-infrastructure" name="cluster-infrastructure" value="openais"/>
<nvpair id="cib-bootstrap-options-expected-quorum-votes" name="expected-quorum-votes" value="2"/>
.
.
.
.
.
.
.
[root@node1 ~]# crm_mon
============
Last updated: Mon Dec 14 15:05:55 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com # webip己启动,在node2上
Reconnecting...[root@node1 ~]# crm_mon --one-shot # --one-shot 只显示一次 不会间隔刷新了
============
Last updated: Mon Dec 14 15:07:09 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
[root@node1 ~]#
[root@node1 ~]# crm
crm(live)# status # status 显示状态的子命令
============
Last updated: Mon Dec 14 15:11:11 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
crm(live)#
在第一个节点 192.168.0.45 上
[root@node1 ~]# crm status # crm 工作在批处理模式下
============
Last updated: Mon Dec 14 15:12:09 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
[root@node1 ~]#
在第一个节点 192.168.0.45 上
[root@node1 ~]# ssh node2 'ifconfig'
eth0 Link encap:Ethernet HWaddr 00:0C:29:CB:A5:7F
inet addr:192.168.0.55 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fecb:a57f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:215899 errors:0 dropped:0 overruns:0 frame:0
TX packets:220318 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:30169515 (28.7 MiB) TX bytes:34019161 (32.4 MiB)
Interrupt:67 Base address:0x2000
eth0:0 Link encap:Ethernet HWaddr 00:0C:29:CB:A5:7F #可以看到 192.168.0.50
inet addr:192.168.0.50 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:67 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:204426 errors:0 dropped:0 overruns:0 frame:0
TX packets:204426 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:27593768 (26.3 MiB) TX bytes:27593768 (26.3 MiB)
[root@node1 ~]#
在第一个节点 192.168.0.45 上 第一个窗口
[root@node1 ~]# crm
crm(live)# resource
crm(live)resource# stop webip #停止一个资源
crm(live)resource#
在第一个节点 192.168.0.45 上 第二个窗口
[root@node1 ~]# crm
crm(live)# status #看不到 webip 这个资源了
============
Last updated: Mon Dec 14 15:17:56 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
crm(live)#
在第一个节点 192.168.0.45 上 第一个窗口
crm(live)resource# list #resource模式下(子命令下) 看到 webip 这个资源停止了
webip (ocf::heartbeat:IPaddr) Stopped
crm(live)resource#
crm(live)resource# start webip #启动 webip 这个资源
crm(live)resource# list #己经启动了
webip (ocf::heartbeat:IPaddr) Started
crm(live)resource#
在第一个节点 192.168.0.45 上 第二个窗口
crm(live)# status #看到 webip 已经启动了
============
Last updated: Mon Dec 14 15:20:39 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
crm(live)#
在第一个节点 192.168.0.45 上 第一个窗口
crm(live)resource# help
At this level resources may be managed.
All (or almost all) commands are implemented with the CRM tools
such as `crm_resource(8)`.
Available commands:
status,show,list show status of resources
start start a resource
stop stop a resource
restart restart a resource
promote promote a master-slave resource
demote demote a master-slave resource
manage put a resource into managed mode
unmanage put a resource into unmanaged mode
migrate,move migrate a resource to another node #手动迁移一个资源到其它节点上去
unmigrate,unmove unmigrate a resource to another node
param manage a parameter of a resource
meta manage a meta attribute
failcount manage failcounts
cleanup cleanup resource status
refresh refresh CIB from the LRM status
reprobe probe for resources not started by the CRM
quit,bye,exit exit the program
help show help
end,cd,up go back one level
在第一个节点 192.168.0.45 上 第一个窗口
crm(live)resource# migrate webip #有警告,大意是尽可能在 node2节点上运行????
WARNING: Creating rsc_location constraint 'cli-standby-webip' with a score of -INFINITY for resource webip on node2.magedu.com.
This will prevent webip from running on node2.magedu.com until the constraint is removed using the 'crm_resource -U' command or manually with cibadmin
This will be the case even if node2.magedu.com is the last node in the cluster
This message can be disabled with -Q
crm(live)resource# list #反正是处于启动状态了
webip (ocf::heartbeat:IPaddr) Started
crm(live)resource#
在第一个节点 192.168.0.45 上 第二个窗口
crm(live)# status #资源迁到 node1上了
============
Last updated: Mon Dec 14 15:26:30 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
crm(live)#
在第一个节点 192.168.0.45 上 第三个窗口
[root@node1 ~]# ifconfig #可以看到 webip了
eth0 Link encap:Ethernet HWaddr 00:0C:29:02:A2:33
inet addr:192.168.0.45 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe02:a233/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:25291 errors:0 dropped:0 overruns:0 frame:0
TX packets:12051 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2866529 (2.7 MiB) TX bytes:1829137 (1.7 MiB)
Interrupt:67 Base address:0x2000
eth0:0 Link encap:Ethernet HWaddr 00:0C:29:02:A2:33
inet addr:192.168.0.50 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:67 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:138 errors:0 dropped:0 overruns:0 frame:0
TX packets:138 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:14342 (14.0 KiB) TX bytes:14342 (14.0 KiB)
[root@node1 ~]#
在第一个节点 192.168.0.45 上 第一个窗口
crm(live)resource# unmigrate webip #又迁回来 ,,, unmigrate 不作迁移的意思
crm(live)resource#
crm(live)resource# list
webip (ocf::heartbeat:IPaddr) Started #处于运行状态
crm(live)resource#
在第一个节点 192.168.0.45 上 第二个窗口
crm(live)# status #看到webip在node2上
============
Last updated: Mon Dec 14 15:29:34 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
crm(live)#
在第一个节点 192.168.0.45 上 第一个窗口
crm(live)resource# migrate webip #警告 更乐意留在 node2 上
WARNING: Creating rsc_location constraint 'cli-standby-webip' with a score of -INFINITY for resource webip on node2.magedu.com.
This will prevent webip from running on node2.magedu.com until the constraint is removed using the 'crm_resource -U' command or manually with cibadmin
This will be the case even if node2.magedu.com is the last node in the cluster
This message can be disabled with -Q
crm(live)resource#
在第一个节点 192.168.0.45 上 第二个窗口
crm(live)# status #又到了 node1上去了
============
Last updated: Mon Dec 14 15:32:12 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
crm(live)#
在第一个节点 192.168.0.45 上 装 web服务
[root@node1 ~]# mount /dev/cdrom /media/cdrom/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@node1 ~]#
[root@node1 ~]# yum install httpd #发觉已经装上去了
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cluster | 1.5 kB 00:00
ClusterStorage | 1.5 kB 00:00
VT | 1.3 kB 00:00
cdrom | 1.5 kB 00:00
Setting up Install Process
Package httpd-2.2.3-82.el5_9.i386 already installed and latest version
Nothing to do
[root@node1 ~]# service httpd status
httpd (pid 4684) 正在运行...
[root@node1 ~]#
在第二个节点 192.168.0.55 上,也已经装上去了
[root@node2 ~]# service httpd status
httpd (pid 4657) 正在运行...
[root@node2 ~]#
在第一个节点 192.168.0.45 上关掉 selinux
[root@node1 ~]# setenforce 0
[root@node1 ~]#
在第二个节点 192.168.0.45 上关掉 selinux
[root@node1 ~]# setenforce 0
[root@node1 ~]#
在第一个节点 192.168.0.45 上找到web服务的根目录位置 (第二个节点 192.168.0.55 上 同理,就不操作了 只是把 node1.magedu.com 改成 node2.magedu.com)
[root@node1 ~]# locate index.html | xargs grep RS2.magedu.com
/www/a.org/index.html:RS2.magedu.com
[root@node1 ~]#
[root@node1 ~]# echo "<h1>node1.magedu.com</h1>" > /www/a.org/index.html
[root@node1 ~]#
[root@node1 ~]# service httpd stop #停止服务
停止 httpd: [确定]
[root@node1 ~]# chkconfig httpd off #一定不能开机自启动
[root@node1 ~]#
在 /etc/init.d 下面的脚本都是 LSB风格的脚本
在第一个节点 192.168.0.45 上
[root@node1 ~]# crm
crm(live)# ra
crm(live)ra# providers httpd #下面为空,表示这是一个大类别?提供商为空
crm(live)ra#
crm(live)ra# classes
heartbeat
lsb
ocf / heartbeat pacemaker #ocf 是 class,类别,,,,heartbeat是 provider <type>是ra,是脚本名称,是 resouce agent 资源代理,比如IPaddr
stonith
crm(live)ra#
crm(live)ra# list lsb #查看这个类别下的所有的ra,,,,可以看到httpd
NetworkManager acpid anacron apmd
atd auditd autofs avahi-daemon
avahi-dnsconfd bluetooth capi conman
corosync courier-authlib cpuspeed crond
cups cups-config-daemon dc_client dc_server
dnsmasq dovecot dund firstboot
functions gpm haldaemon halt
heartbeat hidd hplip httpd
ip6tables ipmi iptables ipvsadm
irda irqbalance iscsi iscsid
isdn kdump killall krb524
kudzu lm_sensors logd lvm2-monitor
mcstrans mdmonitor mdmpd messagebus
microcode_ctl multipathd mysqld named
netconsole netfs netplugd network
nfs nfslock nmb nscd
ntpd openibd pand pcscd
php-fpm portmap postfix psacct
rawdevices rdisc readahead_early readahead_later
restorecond rhnsd rhsmcertd rpcgssd
rpcidmapd rpcsvcgssd saslauthd setroubleshoot
single smartd smb squid
sshd svnserve syslog tux
vncserver vsftpd wdaemon winbind
wpa_supplicant xfs xinetd ypbind
yum-updatesd
crm(live)ra#
crm(live)ra# meta lsb:httpd #进而看到 httpd 的 meta 信息,没看到参数,只看到操作Operations
lsb:httpd
Apache is a World Wide Web server. It is used to serve \
HTML files and CGI.
Operations' defaults (advisory minimum):
start timeout=15
stop timeout=15
status timeout=15
restart timeout=15
force-reload timeout=15
monitor interval=15 timeout=15 start-delay=15
crm(live)ra#
crm(live)ra# cd #进入根
crm(live)# configure #进入configure
crm(live)configure#
crm(live)configure# primitive httpd lsb:httpd op start timeout=20 #未执行 , primitive 表示主资源,httpd 表示资源名称,lsb:httpd 表示类别:ra,,因为没有provider, op表示操作 ,start是op_type ,timeout=20 反正最好大于等于上面的默认值 15就行
crm(live)configure# primitive httpd lsb:httpd
crm(live)configure#
crm(live)configure# show
node node1.magedu.com
node node2.magedu.com
primitive httpd lsb:httpd #httpd 这个ra在这里
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.0.50" nic="eth0" cidr_netmask="24" \
meta target-role="Started"
location cli-standby-webip webip \
rule $id="cli-standby-rule-webip" -inf: #uname eq node2.magedu.com
property $id="cib-bootstrap-options" \
dc-version="1.0.12-unknown" \
cluster-infrastructure="openais" \
expected-quorum-votes="2" \
stonith-enabled="false"
crm(live)configure#
crm(live)configure# verify #验证没问题
crm(live)configure# commit #提交
crm(live)configure# show #此时已固化
node node1.magedu.com
node node2.magedu.com
primitive httpd lsb:httpd
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.0.50" nic="eth0" cidr_netmask="24" \
meta target-role="Started"
location cli-standby-webip webip \
rule $id="cli-standby-rule-webip" -inf: #uname eq node2.magedu.com
property $id="cib-bootstrap-options" \
dc-version="1.0.12-unknown" \
cluster-infrastructure="openais" \
expected-quorum-votes="2" \
stonith-enabled="false"
crm(live)configure#
在第一个节点 192.168.0.45 上 第二个窗口
[root@node1 ~]# crm status #看到两个资源均已启动,默认平衡,尽可能运行在不同的节点上
============
Last updated: Mon Dec 14 16:07:02 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
httpd (lsb:httpd): Started node2.magedu.com
[root@node1 ~]#
使用group组看看
在第一个节点 192.168.0.45 上 第一个窗口
crm(live)configure# help group
The `group` command creates a group of resources.
Usage:
...............
group <name> <rsc> [<rsc>...] #group 组名 后面是多个资源
[meta attr_list] #meta属性
[params attr_list] #params 属性,可以查官方的属性列表
attr_list :: [$id=<id>] <attr>=<val> [<attr>=<val>...] | $id-ref=<id>
...............
Example:
...............
group internal_www disk0 fs0 internal_ip apache \
meta target_role=stopped
...............
crm(live)configure#
crm(live)configure# group webservice webip httpd #webservice 是组名称 webip和httpd是资源代理名称
INFO: resource references in location:cli-standby-webip updated #信息提示不用管
crm(live)configure#
crm(live)configure# verify #验证
crm(live)configure# commit #提交
crm(live)configure#
在第一个节点 192.168.0.45 上 第二个窗口
[root@node1 ~]# crm status #批处理模式,,,,,下面看到两个资源在同一节点上了
============
Last updated: Mon Dec 14 16:32:00 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
Resource Group: webservice
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
httpd (lsb:httpd): Started node1.magedu.com
[root@node1 ~]#
下面看到正常访问了
在第一个节点 192.168.0.45 上 第三个窗口
[root@node1 ~]# crm
crm(live)# node
crm(live)node# help
Node management and status commands.
Available commands:
status show nodes' status
show,list show node
standby put node into standby #当前节点转为备用状态
online set node online
fence fence node
clearstate Clear node state
delete delete node
attribute manage attributes
status-attr manage status attributes
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)node#
crm(live)node# quit
bye
[root@node1 ~]#
[root@node1 ~]# crm status
============
Last updated: Mon Dec 14 16:35:49 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
Resource Group: webservice
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
httpd (lsb:httpd): Started node1.magedu.com
[root@node1 ~]# crm node standby #当前节点(命令行所在的这个节点) standby了
[root@node1 ~]#
[root@node1 ~]# crm status #可是资源未在node2上启动,因为只有两个节点,停了一个,就不再具备法定票数了,默认所有资源就stop了,,,当然可以设定默认为 freeze冻结,或ignore忽略
============
Last updated: Mon Dec 14 16:36:27 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Node node1.magedu.com: standby
Online: [ node2.magedu.com ]
[root@node1 ~]#
我们准备就算不具备法定票数,也让资源继续运行
[root@node1 ~]# crm node online #当前节点重新上线
[root@node1 ~]#
[root@node1 ~]# crm status #资源又启动了
============
Last updated: Mon Dec 14 16:42:11 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
Resource Group: webservice
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
httpd (lsb:httpd): Started node1.magedu.com
[root@node1 ~]#
[root@node1 ~]# crm configure #打开crm配置,直接进入configure
crm(live)configure#
crm(live)configure# property no-quorum-policy=ignore #不具备法定票数的时候,忽略掉
crm(live)configure#
crm(live)configure# verify #验证
crm(live)configure# commit #提交
crm(live)configure#
crm(live)configure# exit
bye
[root@node1 ~]#
[root@node1 ~]# crm configure show
node node1.magedu.com \
attributes standby="off"
node node2.magedu.com
primitive httpd lsb:httpd
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.0.50" nic="eth0" cidr_netmask="24" \
meta target-role="Started"
group webservice webip httpd
location cli-standby-webip webservice \
rule $id="cli-standby-rule-webip" -inf: #uname eq node2.magedu.com
property $id="cib-bootstrap-options" \
dc-version="1.0.12-unknown" \
cluster-infrastructure="openais" \
expected-quorum-votes="2" \
stonith-enabled="false" \
no-quorum-policy="ignore" #多了这个属性no-quorum-policy
[root@node1 ~]#
[root@node1 ~]# crm status
============
Last updated: Mon Dec 14 16:51:12 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
Resource Group: webservice
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
httpd (lsb:httpd): Started node1.magedu.com
[root@node1 ~]#
[root@node1 ~]# crm node standby #当前节点转为备节点
[root@node1 ~]#
[root@node1 ~]# crm status #由下面,资源仍未启用,,不对啊?因为 no-quorum-policy="ignore" #多了这个属性no-quorum-policy,应该可以启用的
============
Last updated: Mon Dec 14 16:52:10 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Node node1.magedu.com: standby
Online: [ node2.magedu.com ]
[root@node1 ~]#
[root@node1 ~]# crm node online #让它重新上线
[root@node1 ~]#
[root@node1 ~]# crm status
============
Last updated: Mon Dec 14 16:53:41 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
Resource Group: webservice #启动了
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
httpd (lsb:httpd): Started node1.magedu.com
[root@node1 ~]#
在第二个节点 192.168.0.55 上,
[root@node2 ~]# ssh node1 '/etc/init.d/corosync stop' #停掉node1
Signaling Corosync Cluster Engine (corosync) to terminate: [确定]
Waiting for corosync services to unload:.[确定]
[root@node2 ~]#
[root@node2 ~]# crm status #由下面,资源还是未启动
============
Last updated: Mon Dec 14 16:56:20 2020
Stack: openais
Current DC: node2.magedu.com - partition WITHOUT quorum #显示为 WITHOUT 了
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com ]
OFFLINE: [ node1.magedu.com ] #停掉了
[root@node2 ~]#
在第二个节点 192.168.0.55 上,
[root@node2 ~]# ssh node1 '/etc/init.d/corosync start' #node1重新上线
Starting Corosync Cluster Engine (corosync): [确定]
[root@node2 ~]#
下面的步骤主要是为了清理
在第二个节点 192.168.0.55 上,
[root@node2 ~]# crm
crm(live)# resource #进入资源子命令
INFO: building help index
crm(live)resource# stop webservice #停止资源组
crm(live)resource# list #资源已停止了
Resource Group: webservice
webip (ocf::heartbeat:IPaddr) Stopped
httpd (lsb:httpd) Stopped
crm(live)resource#
crm(live)resource# cleanup webservice #清理资源组
Cleaning up webip on node2.magedu.com
Cleaning up webip on node1.magedu.com
Cleaning up httpd on node2.magedu.com
Cleaning up httpd on node1.magedu.com
Waiting for 5 replies from the CRMd.....
crm(live)resource#
crm(live)resource# cleanup webip #我个人感觉不必执行这个了,因为已经清理资源组 webservice 了
Cleaning up webip on node2.magedu.com
Cleaning up webip on node1.magedu.com
Waiting for 3 replies from the CRMd...
crm(live)resource# cleanup httpd #我个人感觉不必执行这个了,因为已经清理资源组 webservice 了
Cleaning up httpd on node2.magedu.com
Cleaning up httpd on node1.magedu.com
Waiting for 3 replies from the CRMd...
crm(live)resource#
crm(live)resource# cd #进入根
crm(live)# node #时入node子命令模式
crm(live)node#
crm(live)node# help
Node management and status commands.
Available commands:
status show nodes' status
show,list show node
standby put node into standby
online set node online
fence fence node
clearstate Clear node state #清理节点状态
delete delete node
attribute manage attributes
status-attr manage status attributes
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)node#
crm(live)node# clearstate node1.magedu.com #清理node1的状态
Do you really want to drop state for node node1.magedu.com? y
crm(live)node# clearstate node2.magedu.com #清理node2的状态
Do you really want to drop state for node node2.magedu.com? y
crm(live)node#
crm(live)node# cd #到根
crm(live)# resource #到资源模式
crm(live)resource#
crm(live)resource# start webservice #启动资源组
crm(live)resource# list #由下面已启动
Resource Group: webservice
webip (ocf::heartbeat:IPaddr) Started
httpd (lsb:httpd) Started
crm(live)resource#
由下图,马哥那边出故障了
马哥排错,下图马哥 在 在第一个节点 上
#crm status
马哥排错,下图马哥 在第二个节点 上
#help
马哥排错,下图马哥 在 在第二个节点 上 重新探测资源 # reprobe
#刷新状态
#发现多了一个location ,在node1上还多了个standby,还多了 last-lrm-refresh
# show
# edit 编辑配置文件 (就是使用vim编辑)
主要目的就是去掉 location 以及其它的地方关于 standby 以及 last-lrm-refresh
马哥 # verify
# commit
# show
马哥 # quit
马哥现在发觉启动了
马哥说: 额外添加的一些限制属性,是pacemaker自动生成的,它是自我的理解,未必符合我们的需求,有时候需要 edit 去#edit(编辑) cib库的配置文件
在第二个节点 192.168.0.55 上
[root@node2 ~]# crm status #启动状态
============
Last updated: Mon Dec 14 17:30:50 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
Resource Group: webservice
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
httpd (lsb:httpd): Started node1.magedu.com
[root@node2 ~]#
[root@node2 ~]# crm
crm(live)# resource
crm(live)resource# migrate webservice #马哥又说了 生成了 cli-standby-webservice
WARNING: Creating rsc_location constraint 'cli-standby-webservice' with a score of -INFINITY for resource webservice on node1.magedu.com.
This will prevent webservice from running on node1.magedu.com until the constraint is removed using the 'crm_resource -U' command or manually with cibadmin
This will be the case even if node1.magedu.com is the last node in the cluster
This message can be disabled with -Q
crm(live)resource#
crm(live)resource# status #停止状态 我这时不行了,,但此时因为马哥上面作了修改,所以行的
Resource Group: webservice
webip (ocf::heartbeat:IPaddr) Stopped
httpd (lsb:httpd) Stopped
crm(live)resource#
下图 马哥处于启动状态
下图 马哥在第一个节点上,发觉在node2上启动了
我的发觉到也有问题,,,也跟着马哥的操作做了一遍 (又要删掉关于 cli-standby 的那一行的内容及其它关于 standby 的内容 以及 关于last-lrm-refresh 的内容
# edit # verify # commit )
(通过 configure,,,edit也就是修改cib配置文件,里面删掉关于cli-standby-的那一行的内容及其它关于standby的内容 以及 关于last-lrm-refresh 的内容) 也才能启动
每次手动迁移一下,都会给我们生成一个手动限定,这个限定就表示迁移之前的那个节点是资源最优先期望运行的那个节点,
为什么要生成这个限定,它们假设我们是做了手动迁移,做手动迁移之前可能会违反我们的某些倾向性规则的
在第二个节点 192.168.0.55 上
[root@node2 ~]# crm status
============
Last updated: Tue Dec 15 08:46:26 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
Resource Group: webservice #资源在 node2 上
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
httpd (lsb:httpd): Started node2.magedu.com
[root@node2 ~]#
[root@node2 ~]# crm node standby #当前节点(执行这个命令所在的节点)处于备用状态 即 node2 节点处于备用状态
[root@node2 ~]#
[root@node2 ~]# crm status
============
Last updated: Tue Dec 15 08:51:59 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Node node2.magedu.com: standby
Online: [ node1.magedu.com ]
Resource Group: webservice #可看到资源在node1上运行
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
httpd (lsb:httpd): Started node1.magedu.com
[root@node2 ~]#
[root@node2 ~]# crm node online #上线
[root@node2 ~]#
[root@node2 ~]# crm status
============
Last updated: Tue Dec 15 08:53:30 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
Resource Group: webservice #我这边看到是在node2运行;;但马哥那边看到是在 node1 上运行 ,见下面图一
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
httpd (lsb:httpd): Started node2.magedu.com
[root@node2 ~]#
图一
马哥的图,他说的意思他那边是倾向于留在 node1,没有做auto_failback;;;;;没有倾向,两个资源粘性都为0,都不会走,不像heartbeat,默认的auto_failback为on的,
删除组,试试资源的约束
在第二个节点 192.168.0.55 上
[root@node2 ~]# crm
crm(live)# resource
crm(live)resource# stop webservice #先停掉组webservice
crm(live)resource#
crm(live)resource# cleanup webservice #清理组
Cleaning up webip on node2.magedu.com
Cleaning up webip on node1.magedu.com
Cleaning up httpd on node2.magedu.com
Cleaning up httpd on node1.magedu.com
Waiting for 5 replies from the CRMd.....
crm(live)resource# help #没看到 delete 删除资源组的命令
At this level resources may be managed.
All (or almost all) commands are implemented with the CRM tools
such as `crm_resource(8)`.
Available commands:
status,show,list show status of resources
start start a resource
stop stop a resource
restart restart a resource
promote promote a master-slave resource
demote demote a master-slave resource
manage put a resource into managed mode
unmanage put a resource into unmanaged mode
migrate,move migrate a resource to another node
unmigrate,unmove unmigrate a resource to another node
param manage a parameter of a resource
meta manage a meta attribute
failcount manage failcounts
cleanup cleanup resource status
refresh refresh CIB from the LRM status
reprobe probe for resources not started by the CRM
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)resource# cd
crm(live)# configure
crm(live)configure# help
This level enables all CIB object definition commands.
The configuration may be logically divided into four parts:
nodes, resources, constraints, and (cluster) properties and
attributes. Each of these commands support one or more basic CIB
objects.
Nodes and attributes describing nodes are managed using the
`node` command.
Commands for resources are:
- `primitive`
- `monitor`
- `group`
- `clone`
- `ms`/`master` (master-slave)
There are three types of constraints:
- `location`
- `colocation`
- `order`
Finally, there are the cluster properties, resource meta
attributes defaults, and operations defaults. All are just a set
of attributes. These attributes are managed by the following
commands:
- `property`
- `rsc_defaults`
- `op_defaults`
The changes applied to the current CIB only on ending the
configuration session or using the `commit` command.
Available commands:
node define a cluster node
primitive define a resource
monitor add monitor operation to a primitive
group define a group
clone define a clone
ms,master define a master-slave resource
location a location preference
colocation,collocation colocate resources
order order resources
property set a cluster property
rsc_defaults set resource defaults
op_defaults set resource operations defaults
show display CIB objects
edit edit CIB objects
delete delete CIB objects #删除命令,删除一个cib对象
rename rename a CIB object
refresh refresh from CIB
erase erase the CIB
ptest show cluster actions if changes were committed
cibstatus CIB status management and editing
template edit and import a configuration from a template
commit commit the changes to the CIB
verify verify the CIB with crm_verify
upgrade upgrade the CIB to version 1.0
save save the CIB to a file
load import the CIB from a file
xml raw xml
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)configure# delete webservice #删除组服务webservice
crm(live)configure# show #没了 webservice
node node1.magedu.com \
attributes standby="off"
node node2.magedu.com \
attributes standby="off"
primitive httpd lsb:httpd
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.0.50" nic="eth0" cidr_netmask="24"
property $id="cib-bootstrap-options" \
dc-version="1.0.12-unknown" \
cluster-infrastructure="openais" \
expected-quorum-votes="2" \
stonith-enabled="false" \
no-quorum-policy="ignore" \
last-lrm-refresh="1607994154"
crm(live)configure# verify
crm(live)configure# commit #只要一提交,又会自动重新启动的
crm(live)configure# show
node node1.magedu.com \
attributes standby="off"
node node2.magedu.com \
attributes standby="off"
primitive httpd lsb:httpd
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.0.50" nic="eth0" cidr_netmask="24"
property $id="cib-bootstrap-options" \
dc-version="1.0.12-unknown" \
cluster-infrastructure="openais" \
expected-quorum-votes="2" \
stonith-enabled="false" \
no-quorum-policy="ignore" \
last-lrm-refresh="1607994154"
crm(live)# status
============
Last updated: Tue Dec 15 09:30:21 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ] #两个资源又运行在不同的节点上了
httpd (lsb:httpd): Started node2.magedu.com
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
crm(live)# configure
#让 httpd 和 webip 在一起,使用排列约束了
crm(live)configure#
crm(live)configure# help
This level enables all CIB object definition commands.
The configuration may be logically divided into four parts:
nodes, resources, constraints, and (cluster) properties and
attributes. Each of these commands support one or more basic CIB
objects.
Nodes and attributes describing nodes are managed using the
`node` command.
Commands for resources are:
- `primitive`
- `monitor`
- `group`
- `clone`
- `ms`/`master` (master-slave)
There are three types of constraints:
- `location`
- `colocation`
- `order`
Finally, there are the cluster properties, resource meta
attributes defaults, and operations defaults. All are just a set
of attributes. These attributes are managed by the following
commands:
- `property`
- `rsc_defaults`
- `op_defaults`
The changes applied to the current CIB only on ending the
configuration session or using the `commit` command.
Available commands:
node define a cluster node
primitive define a resource
monitor add monitor operation to a primitive
group define a group
clone define a clone
ms,master define a master-slave resource
location a location preference #位置约束,限定资源更倾向于留在某节点,这里用不到它
colocation,collocation colocate resources #排列约束,限定几个(两个)资源在一起的,这里用到它
order order resources
property set a cluster property
rsc_defaults set resource defaults
op_defaults set resource operations defaults
show display CIB objects
edit edit CIB objects
delete delete CIB objects
rename rename a CIB object
refresh refresh from CIB
erase erase the CIB
ptest show cluster actions if changes were committed
cibstatus CIB status management and editing
template edit and import a configuration from a template
commit commit the changes to the CIB
verify verify the CIB with crm_verify
upgrade upgrade the CIB to version 1.0
save save the CIB to a file
load import the CIB from a file
xml raw xml
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)configure# help colocation
This constraint expresses the placement relation between two
or more resources. If there are more than two resources, then the
constraint is called a resource set. Collocation resource sets have
an extra attribute to allow for sets of resources which don't depend
on each other in terms of state. The shell syntax for such sets is
to put resources in parentheses.
Usage:
...............
colocation <id> <score>: <rsc>[:<role>] <rsc>[:<role>] ... #<id>是个名称吧 <score>倾向性,分数 <rsc>是资源 <role>是角色,表示它两在一起的时候,谁扮演什么角色,现在用不到它
...............
Example:
...............
colocation dummy_and_apache -inf: apache dummy
colocation c1 inf: A ( B C )
...............
crm(live)configure#
crm(live)configure# colocation httpd_with_webip inf: webip httpd #inf冒号后面要有空格,这表示 webip依赖于httpd
crm(live)configure# verify
crm(live)configure# show xml
..........................................
<constraints> #with-rsc表示 依赖于,取决于的意思
<rsc_colocation id="httpd_with_webip" rsc="webip" score="INFINITY" with-rsc="httpd"/>
</constraints>
..........................................
我们反过来写吧
crm(live)configure# edit
node node1.magedu.com \
attributes standby="off"
node node2.magedu.com \
attributes standby="off"
primitive httpd lsb:httpd
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.0.50" nic="eth0" cidr_netmask="24"
colocation httpd_with_webip inf: httpd webip #这是正确的顺序,,,,原来的顺序是 webip httpd
property $id="cib-bootstrap-options" \
dc-version="1.0.12-unknown" \
cluster-infrastructure="openais" \
expected-quorum-votes="2" \
stonith-enabled="false" \
no-quorum-policy="ignore" \
last-lrm-refresh="1607994154"
crm(live)configure# show xml
..........................................
<constraints> #with-rsc表示 依赖于,取决于的意思,,,此时才符合我们的思路,因为 httpd 依赖于 webip
<rsc_colocation id="httpd_with_webip" rsc="httpd" score="INFINITY" with-rsc="webip"/>
</constraints>
..........................................
crm(live)configure# verify
crm(live)configure# commit
在第一个节点 192.168.0.45 上
[root@node1 ~]# crm status #由下面,两个资源在一起了
============
Last updated: Tue Dec 15 09:52:25 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
httpd (lsb:httpd): Started node2.magedu.com
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
[root@node1 ~]#
在第二个节点 192.168.0.55 上
crm(live)configure# help order
This constraint expresses the order of actions on two resources
or more resources. If there are more than two resources, then the
constraint is called a resource set. Ordered resource sets have an
extra attribute to allow for sets of resources whose actions may run
in parallel. The shell syntax for such sets is to put resources in
parentheses.
Usage:
...............
order <id> score-type: <rsc>[:<action>] <rsc>[:<action>] ... # score-type 分数类型 <rsc> 资源 <action> 表示start ,stop,restart,monitor 等等 就是某一个资源执行某操作后,另外一个资源才能执行另外一个操作
[symmetrical=<bool>]
score-type :: advisory | mandatory | <score> #advisory 建议;; mandatory 强制;; <score> 指定分数
...............
Example:
...............
order c_apache_1 mandatory: apache:start ip_1
order o1 inf: A ( B C )
...............
crm(live)configure#
在第一个节点 192.168.0.45 上
[root@node1 ~]# crm
crm(live)# resource
crm(live)resource# help
At this level resources may be managed.
All (or almost all) commands are implemented with the CRM tools
such as `crm_resource(8)`.
Available commands: #资源操作
status,show,list show status of resources
start start a resource
stop stop a resource
restart restart a resource
promote promote a master-slave resource #表示尝试着启动一个主从中的资源
demote demote a master-slave resource
manage put a resource into managed mode
unmanage put a resource into unmanaged mode
migrate,move migrate a resource to another node
unmigrate,unmove unmigrate a resource to another node
param manage a parameter of a resource
meta manage a meta attribute
failcount manage failcounts
cleanup cleanup resource status
refresh refresh CIB from the LRM status
reprobe probe for resources not started by the CRM
quit,bye,exit exit the program
help show help
end,cd,up go back one level
crm(live)resource#
在第二个节点 192.168.0.55 上
crm(live)configure# order webip_before_httpd mandatory: webip httpd #先启动webip 再启动 httpd
crm(live)configure# show xml
...............................................
<constraints> #看到了 first , then
<rsc_order first="webip" id="webip_before_httpd" score="INFINITY" then="httpd"/>
<rsc_colocation id="httpd_with_webip" rsc="httpd" score="INFINITY" with-rsc="webip"/>
</constraints>
...............................................
crm(live)configure# commit #提交
crm(live)configure# exit
bye
[root@node2 ~]# crm status
============
Last updated: Tue Dec 15 10:08:00 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ]
httpd (lsb:httpd): Started node2.magedu.com #当前资源在 node2 上
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
[root@node2 ~]# crm node standby #当前命令行所在的节点 node2 转为备用
[root@node2 ~]# crm_mon
============
Last updated: Tue Dec 15 10:10:15 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Node node2.magedu.com: standby
Online: [ node1.magedu.com ] #看到资源转到了node1上了
httpd (lsb:httpd): Started node1.magedu.com
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
[root@node2 ~]# crm node online #当前命令行所在的节点node2 重新上线
[root@node2 ~]#
[root@node2 ~]# crm_mon
============
Last updated: Tue Dec 15 10:11:54 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ] #资源转到node2上了,,说明我这边auto_failback,
#但是 马哥那边那边却没有auto_failback
httpd (lsb:httpd): Started node2.magedu.com
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
如果我们期望更运行于某节点 比如 node1,,那么定义位置约束
在第一个节点 192.168.0.45 上
crm(live)configure# help location
`location` defines the preference of nodes for the given
resource. The location constraints consist of one or more rules
which specify a score to be awarded if the rule matches.
Usage:
...............
location <id> <rsc> {node_pref|rules} #<id>是位置约束名称 <rsc>是资源名称 node_pref|rules
node_pref :: <score>: <node> # node_pref 指定倾向于节点的分数 (先分数,后节点) ( prefer 优先,更喜欢 )
rules :: # 规则,比如 # uname -n 等于什么时,分数是什么 <score> 比如无穷大 inf,,,,<expression> 表达式,比如 #uname -n=node1.magedu.com
rule [id_spec] [$role=<role>] <score>: <expression>
[rule [id_spec] [$role=<role>] <score>: <expression> ...]
id_spec :: $id=<id> | $id-ref=<id>
score :: <number> | <attribute> | [-]inf
expression :: <simple_exp> [bool_op <simple_exp> ...]
bool_op :: or | and
simple_exp :: <attribute> [type:]<binary_op> <value>
| <unary_op> <attribute>
| date <date_expr>
type :: string | version | number
binary_op :: lt | gt | lte | gte | eq | ne
unary_op :: defined | not_defined
date_expr :: lt <end>
| gt <start>
| in_range start=<start> end=<end>
| in_range start=<start> <duration>
| date_spec <date_spec>
duration|date_spec ::
hours=<value>
| monthdays=<value>
| weekdays=<value>
| yearsdays=<value>
| months=<value>
| weeks=<value>
| years=<value>
| weekyears=<value>
| moon=<value>
...............
Examples:
...............
location conn_1 internal_www 100: node1
location conn_1 internal_www \ #conn_1 是个id名称 ,internal_www 是资源名称
rule 50: # uname eq node1 \ #规则是50 #uname表示执行uname的命令? eq 是操作符
rule pingd: defined pingd # pingd是 ping node ,即ping节点,, defined 表示定义成pingd的生效,,,对于我们来讲,基本上没用,不用管 #大概意思是有没有定义ping节点,没有定义怎么办,定义了怎么办
location conn_2 dummy_float \
rule -inf: not_defined pingd or pingd number:lte 0
...............
在第一个节点 192.168.0.45 上
crm(live)configure# location webip_on_node1 webip rule 100: # uname eq node1.magedu.com
crm(live)configure# show xml
................................................
<rsc_location id="webip_on_node1" rsc="webip">
<rule id="webip_on_node1-rule" score="100">
<expression attribute="#uname" id="webip_on_node1-expression" operation="eq" value="node1.magedu.com"/>
</rule>
</rsc_location>
................................................
crm(live)configure# verify #验证
crm(live)configure# commit #提交
crm(live)configure# exit
bye
[root@node1 ~]# crm status
============
Last updated: Tue Dec 15 10:39:57 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ] #资源在node1上
httpd (lsb:httpd): Started node1.magedu.com
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
[root@node1 ~]# crm node standby #当前命令行所在节点 node1,转为备用模式
[root@node1 ~]# crm status
============
Last updated: Tue Dec 15 10:42:09 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Node node1.magedu.com: standby
Online: [ node2.magedu.com ] #资源到了node2上了
httpd (lsb:httpd): Started node2.magedu.com
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
[root@node1 ~]#
[root@node1 ~]# crm node online #当前命令行所在节点 node1,上线
[root@node1 ~]# crm status
============
Last updated: Tue Dec 15 10:43:08 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ] #资源又回到node1了,因为对node1分数是100,,,对于node2分数是默认值0(没有定义资源的默认粘性,即为0)(如果某个资源为默认粘性,且大于位置倾向location的分数,位置倾向性就没有倾向能力了)
httpd (lsb:httpd): Started node1.magedu.com
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
[root@node1 ~]#
在第一个节点 192.168.0.45 上
定义默认粘性
[root@node1 ~]# crm configure
crm(live)configure# rsc_defaults resource-stickiness=200 #定义资源默认粘性为200
crm(live)configure# verify #验证
crm(live)configure# commit #提交
crm(live)configure# exit
bye
[root@node1 ~]# crm status
============
Last updated: Tue Dec 15 10:51:35 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ] #当前节点资源在node1上
httpd (lsb:httpd): Started node1.magedu.com
webip (ocf::heartbeat:IPaddr): Started node1.magedu.com
[root@node1 ~]#
[root@node1 ~]# crm node standby #当前节点node1备用
[root@node1 ~]# crm status
============
Last updated: Tue Dec 15 10:52:42 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Node node1.magedu.com: standby
Online: [ node2.magedu.com ] #资源在node2
httpd (lsb:httpd): Started node2.magedu.com
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
[root@node1 ~]#
root@node1 ~]# crm node online #当前节点node1上线
[root@node1 ~]# crm status
============
Last updated: Tue Dec 15 10:53:41 2020
Stack: openais
Current DC: node2.magedu.com - partition with quorum
Version: 1.0.12-unknown
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ node2.magedu.com node1.magedu.com ] #资源仍在 node2上,说明粘性大于倾向性,node1上线后,资源不会转移 粘性表示资源是否更乐意留在当前节点的 location 表示资源更倾向于留在哪个节点
httpd (lsb:httpd): Started node2.magedu.com
webip (ocf::heartbeat:IPaddr): Started node2.magedu.com
[root@node1 ~]#
把 共享盘nfs加上去
提示
[root@node1 ~]# crm
crm(live)# ra
crm(live)ra# meta ocf:heartbeat:Filesystem #有许多属性
Manages filesystem mounts (ocf:heartbeat:Filesystem)
Resource script for Filesystem. It manages a Filesystem on a
shared storage medium.
The standard monitor operation of depth 0 (also known as probe)
checks if the filesystem is mounted. If you want deeper tests,
set OCF_CHECK_LEVEL to one of the following values:
10: read first 16 blocks of the device (raw read)
This doesn't exercise the filesystem at all, but the device on
which the filesystem lives. This is noop for non-block devices
such as NFS, SMBFS, or bind mounts.
20: test if a status file can be written and read
The status file must be writable by root. This is not always the
case with an NFS mount, as NFS exports usually have the
"root_squash" option set. In such a setup, you must either use
read-only monitoring (depth=10), export with "no_root_squash" on
your NFS server, or grant world write permissions on the
directory where the status file is to be placed.
:
................................
Parameters (* denotes required, [] the default):
#关键是下面三个属性,
device* (string): block device
The name of block device for the filesystem, or -U, -L options for mount, or NFS mount specification.
directory* (string): mount point
The mount point for the filesystem.
fstype* (string): filesystem type
The type of filesystem to be mounted.
options (string):
Any extra options to be given as -o options to mount.
For bind mounts, add "bind" here and set fstype to "none".
..........................
#还要定义三个资源(webip webstore httpd )的约束,三个资源的启动顺序