PCS (Pacemaker/Corosync configuration system) command configuration:
1. Establish a cluster:
Configure authentication of cluster nodes
as the hacluster user
:
pcs cluster auth node1 node2
Create a two-node cluster (
node1 node2
)
pcs cluster setup --name mycluster node1 node2
Start the cluster
pcs cluster start --all
Set the default stickiness of resources (to prevent resource switchback)
pcs resource defaults resource-stickiness=100
pcs resource defaults
Set resource timeout
pcs resource op defaults timeout=90s
pcs resource op defaults
When there are two nodes, ignore the node
quorum
function
pcs property set no-quorum-policy=ignore
Not
Fencing
when the device is disabled STONITH component functionality, instonith-enabled="false"
the case of Distributed Lock Manager (DLM) and other resources as well as all the services (eg cLVM2, GFS2 and OCFS2) rely DLM will not start.
pcs property set stonith-enabled=false
Verify cluster configuration information
crm_verify -L -V
Two, establish cluster resources
View the list of support resources
pcs resource list ocf:heartbeat
pcs resource list
View resource usage parameters
pcs resource describe ocf:heartbeat:IPaddr2
pcs resource describe agent_name
Configure virtual IP
pcs resource create ClusterIP ocf:heartbeat:IPaddr2 \ ip="192.168.10.15" cidr_netmask=32 nic=eth0 op monitor interval=30s
Configure Apache (httpd)
pcs resource create WebServer ocf:heartbeat:apache \ httpd="/usr/sbin/httpd" configfile="/etc/http /conf/httpd.conf" \ statusurl="" op monitor interval=1min
Configure Nginx
pcs resource create WebServer ocf:heartbeat:nginx \ httpd="/usr/sbin/nginx" configfile="/etc/nginx/nginx.conf" \
statusurl="" op monitor interval=30s
Configure FileSystem
pcs resource create WebFS ocf:heartbeat:Filesystem \ device="/dev/sdb1" directory="/var/www/html" fstype="ext4"
pcs resource create WebFS ocf:heartbeat:Filesystem \ device="-U 32937d65eb" directory="/var/www/html" fstype="ext4"
Configure FileSystem-NFS
pcs resource create WebFS ocf:heartbeat:Filesystem \ device="192.168.10.18:/mysqldata" directory="/var/lib/mysql" fstype="nfs" \ options="-o username=your_name,password=your_password" \ op start timeout=60s op stop timeout=60s op monitor interval=20s timeout=60s
Configure Iscsi
pcs resource create WebData ocf:heartbeat:iscsi \ portal="192.168.10.18" target="iqn.2008-08.com.starwindsoftware:" \ op monitor depth="0" timeout="30" interval="120"
pcs resource create WebFS ocf:heartbeat:Filesystem \ device="-U 32937d65eb" directory="/var/www/html" fstype="ext4" options="_netdev"
Placement DRBD
pcs resource create WebData ocf:linbit:drbd \ drbd_resource=wwwdata op monitor interval=60s
pcs resource master WebDataClone WebData \ master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true
pcs resource create WebFS ocf:heartbeat:Filesystem \ device="/dev/drbd1" directory="/var/www/html" fstype="ext4"
Configure MySQL
pcs resource create MySQL ocf:heartbeat:mysql \ binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" datadir="/var/lib/mysql" \ pid="/var/run/mysqld/mysql.pid" socket="/tmp/mysql.sock" \ op start timeout=180s op stop timeout=180s op monitor interval=20s timeout=60s
Configure Pingd to check the validity of the connection between the node and the target
pcs resource create PingCheck ocf:heartbeat:pingd \ dampen=5s multiplier=100 host_list="192.168.10.1 router" \ op monitor interval=30s timeout=10s
Create resource clone, the cloned resource will be started on all nodes
pcs resource clone PingCheck
clone-max=2, the data packet is divided into 2 channels
pcs resource clone ClusterIP clone-max=2 clone-node-max=2 globally-unique=true
Specify the allocation strategy for responding to the request: sourceip
pcs resource update ClusterIP clusterip_hash=sourceip
Three, adjust cluster resources
Configure resource constraints
Configure the resource group, the resources in the group will run on the same node
pcs resource group add WebSrvs ClusterIP
Remove the specified resource in the group
pcs resource group remove WebSrvs ClusterIP
The allocation of resources having a plurality of states, such as
DRBD master/slave
state
pcs resource master WebDataClone WebData
Configure resource bundling relationship
pcs constraint colocation add WebServer ClusterIP INFINITY
Remove resources from resource binding constraints
pcs constraint colocation remove WebServer
Configure resource startup sequence
pcs constraint order ClusterIP then WebServer
Remove the resource in the resource startup sequence constraint
pcs constraint order remove ClusterIP
View resource constraint relationships,
pcs constraint --full
pcs constraint
Configure resource location
Specify a node by default for the resource,
node=50
specify the addedscore
pcs constraint location WebServer prefers node11
Specify resources to avoid a certain node,
node=50
specify reducedscore
pcs constraint location WebServer avoids node11
Remove the resource ID in the resource node location constraint, which can be
pcs config
obtained
pcs constraint location remove location-WebServer
Manually move resource nodes, specify node resources
score of INFINITY
pcs constraint location WebServer prefers node11=INFINITY
Verification node resource
score
value
crm_simulate -sL
Modify resource configuration
Update resource configuration
pcs resource update WebFS
Delete the specified resource
pcs resource delete WebFS
Manage cluster resources
Disable resources
pcs resource disable ClusterIP
Enable resources
pcs resource enable ClusterIP
Display the error count of the specified resource
pcs resource failcount show ClusterIP
Clear the error count of the specified resource
pcs resource failcount reset ClusterIP
Clear the status and error count of the specified resource
pcs resource cleanup ClusterIP
Four, cluster operation commands
Verify cluster installation
View
pacemaker
components,ps axf | grep pacemaker
pacemakerd -F
View
corosync
serial number
corosync-cfgtool -s
corosync 2.3.x
corosync-cmapctl | grep members
corosync 1.4.x
corosync-objctl | grep members
View cluster resources
View support resource types
pcs resource standards
View resource providers
pcs resource providers
View all resource agents
pcs resource agents
View the list of support resources
pcs resource list
View the list of supported fences
pcs stonith list
Display cluster default variable parameters
pcs property list --all
Check resource score value
crm_simulate -sL
Use cluster script
Save the cluster resource configuration information in the specified file
pcs cluster cib ra_cfg
Create cluster resources and save them in the specified file (not in the running configuration)
pcs -f ra_cfg resource create
Display the configuration information of the specified file, after checking it is correct
pcs -f ra_cfg resource show
Load the specified configuration file into the running configuration
pcs cluster cib-push ra_cfg
STONITH equipment operation
Query fence equipment
stonith_admin -I
Query the metadata of fence devices, stonith_admin -M -a fence_vmware_soap
stonith_admin -M -a agent_name
Test STONITH equipment
stonith_admin --reboot nodename
Management cluster
View cluster status
pcs status
pcs status cluster
pcs status corosync
Stop the cluster
pcs cluster stop [node11]
Start the cluster
pcs cluster start --all
Put the node in the standby state, pcs cluster unstandby node11
pcs cluster standby node11
Delete the cluster, [–all] and restore the corosync.conf file at the same time
pcs cluster destroy [--all]
Clear the status and error count of the specified resource
pcs resource cleanup ClusterIP
Clear the status and error count of Fence resources
pcs stonith cleanup vmware-fencing
View cluster configuration
crm_verify -L -V ##检查配置有无错误
pcs property ##查看群集属性
pcs stonith ##查看stonith
pcs constraint ##查看资源约束
pcs config ##查看群集资源配置
pcs cluster cib ##以XML格式显示群集配置