|
|
楼主 |
发表于 2017-12-29 10:40:48
|
显示全部楼层
安装ha组件:, F* X: I' P" [" ]
yum install pcs fence-agents-all
7 f& Y4 y9 }/ F# }
2 |$ W- {- U C, v+ I创建集群1 a' s O$ N# f/ n5 G; ~
pcs cluster setup --start --name my_cluster z1.example.com z2.example.com
5 i$ D) t; X0 p4 Y7 D9 c9 A启动集群服务$ ]/ T8 @8 |! F8 A
pcs cluster enable --all' e$ M" P+ d, M. j; h6 D- C
查看集群状态6 W8 f# Z! }' m
pcs cluster status
+ J k+ C" j+ Y( z/ f1 F" f" `1 \) v, R( Z$ Z# i# R
创建stonith设备0 v* E( y; y/ p' v& q5 Z# N/ T6 D
4 d% g- H: y0 S+ }8 t2 \
pcs stonith create myapc fence_apc_snmp params ipaddr="zapc.example.com" pcmk_host_map="z1.example.com:1;z2.example.com:2" pcmk_host_check= "static-list" pcmk_host_list="z1.example.com,z2.example.com" login="apc" passwd="apc"
) t+ K2 a/ K4 N3 E% \pcs stonith show myapc! x' f0 U5 ^: _, P, s
/ U2 u( {! |9 f, q$ D+ n创建资源" K6 D2 M# z l/ W% Q% c
pcs resource create my_lvm LVM volgrpname=my_vg exclusive=true --group apachegroup
% C$ D/ j9 D5 h$ C( B0 e2 apcs resource show
# Q# I2 X+ r7 m1 S" {
* D9 l1 [& x( X9 m8 I5 \( D. Apcs resource enable7 \, e/ ~" ^8 C% }$ L" \* N
pcs resource create my_fs Filesystem device="/dev/my_vg/my_lv" directory="/var/www" fstype="ext4" --group apachegroup
; `: g0 a z9 u" opcs resource create VirtualIP IPaddr2 ip=198.51.100.3 cidr_netmask=24 --group apachegroup( a" I1 Q9 n0 {9 v# w" k
pcs resource create Website apache configfile="/etc/httpd/conf/httpd.conf" statusurl="http://127.0.0.1/server-status" --group apachegroup9 J" Y, {' m; J+ y3 J. x7 e
pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.16 8.0.120 cidr_netmask=24 opmonitorinterval= 30s5 c3 u# G* e& I& W' Q
" f5 G$ m$ l4 j9 O' J2 z
$ f) ? t3 p$ c3 A. I. {查看集群状态:. C1 q& [% g! a0 f8 ^6 Y
pcs status
: d- H4 w% O) J倒换节点:pcs cluster standby z1.example.compcs cluster unstandby z1.example.com4 C/ v6 u& l, o3 J3 \0 u
查看帮助pcs resource -h
2 Y0 V( e. `- c! h' p" B& p导出和备份配置文件pcs cluster cib testfilepcs config backuppcs config restorepcs cluster setup --name new_cluster nodeA nodeB --token 10000 --join 100pcs cluster stoppcs cluster enablepcs cluster disablepcs cluster node add nodepcs cluster node remove nodepcs cluster standby nodepcs cluster unstandby nodepcs stonith listpcs stonith describepcs stonith show --fullpcs stonith create myapc-west-13 fence_apc pcmk_host_list="west-13" ipaddr="west-apc" login="apc" passwd="apc" port="15"6 o- c ^6 C. v/ W' Q; C
fence对应节点:pcs stonith fence nodepcs resource delete VirtualIPpcs resource describe LVMpcs resource show --fullpcs resource enable resource_id% K; z, Q& e% g: X# C
pcs resource disable resource_id+ k: Z t1 w; [4 B2 |
; o2 K/ O e6 H1 f/ x9 r设置资源先后关系pcs constraint VirtualIP then dummy_resource kind=Optional
5 m, I" N; `# \. R, k0 |% J进入维护模式:pcs resource unmanage resource1
' d8 a2 `5 _6 M7 k解除维护模式: l8 q8 A" \; f; }6 M5 {# S
pcs resource manage resource1 |
|