- 积分
- 16840
在线时间 小时
最后登录1970-1-1
|

楼主 |
发表于 2017-12-29 10:40:48
|
显示全部楼层
安装ha组件: I& `+ P, o% f/ e0 x1 ]
yum install pcs fence-agents-all; d3 O" r0 B9 b: U
6 |7 L4 l, r2 F
创建集群# a( ? f8 f2 |/ q# i; L; x8 m
pcs cluster setup --start --name my_cluster z1.example.com z2.example.com4 m- E" T7 z7 D+ |' k* p. Z% Q$ l
启动集群服务
) f+ ~- L5 C) e0 j, Epcs cluster enable --all
0 Y/ _ G5 h) X% s6 d# a查看集群状态! H- `& g* _, \) X
pcs cluster status
6 P1 l. N F8 I) {; C
7 [: k. g+ V- L) c创建stonith设备
! b3 ^- E' M' W( t
- i# N$ J0 _5 i2 s! P1 L. B0 Fpcs 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"
3 j/ y6 ^- V) u/ O, Vpcs stonith show myapc7 P) }+ A# a! E( P+ {: ~
! w, D5 T) e. N) h/ a0 o创建资源
% j) O5 O( H, {+ C5 W. A( Ipcs resource create my_lvm LVM volgrpname=my_vg exclusive=true --group apachegroup
' Z" O+ D2 @8 L" G3 g) i6 [pcs resource show. Z9 X) Z" V: u- J' S, G) d6 @( }' E
0 P' B: w+ l2 K) s6 W( D; g+ v- rpcs resource enable
5 {. R2 D! n& d$ d% g8 hpcs resource create my_fs Filesystem device="/dev/my_vg/my_lv" directory="/var/www" fstype="ext4" --group apachegroup- Y! Y) C% G& V8 M p6 ^
pcs resource create VirtualIP IPaddr2 ip=198.51.100.3 cidr_netmask=24 --group apachegroup
X' K% z: u+ i0 S8 ]3 O5 Npcs resource create Website apache configfile="/etc/httpd/conf/httpd.conf" statusurl="http://127.0.0.1/server-status" --group apachegroup" V0 O1 s$ z* s4 Y* S
pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.16 8.0.120 cidr_netmask=24 opmonitorinterval= 30s1 G" ?- M2 v* d4 Q
# i! Y# Y0 G6 z5 A' ^' q
6 T. W9 G+ V% @2 a4 x查看集群状态:
& Q7 {& j: D& z( t& ?2 E* }3 w% Fpcs status
6 D, V2 n- z% X( @$ u倒换节点:pcs cluster standby z1.example.compcs cluster unstandby z1.example.com
- W- O4 Q; _9 I7 N查看帮助pcs resource -h
c. U/ m, L$ C. J; [. k导出和备份配置文件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"4 j$ _8 t- }/ [ y% C" t, W2 M
fence对应节点:pcs stonith fence nodepcs resource delete VirtualIPpcs resource describe LVMpcs resource show --fullpcs resource enable resource_id
( J z3 c9 z( Npcs resource disable resource_id
6 E, A, C) O( ^; C" f& v% O3 W( V& K4 h+ [) ^
设置资源先后关系pcs constraint VirtualIP then dummy_resource kind=Optional0 X. v* r" a% K4 i
进入维护模式:pcs resource unmanage resource1
+ E. B/ |. }8 a( I' X$ z: I3 L解除维护模式
, Q7 |! W& d0 S/ L1 F6 ppcs resource manage resource1 |
|