User Tools

Site Tools


heartbeat_plus_gmirror_ggate

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

heartbeat_plus_gmirror_ggate [2010/04/20 10:54]
val
heartbeat_plus_gmirror_ggate [2013/05/22 13:50]
Line 1: Line 1:
-====== HEARTBEAT plus GMIRROR GGATE ====== 
- 
-===== ЗАпуск и автозапуск ggated ===== 
-<​code>​ 
-[gateN:~] # ggated ​ 
- 
-[gateN:~] # cat /​etc/​rc.local 
-ggated 
-</​code>​ 
- 
-===== Настройка heartbeat ===== 
-<​code>​ 
-[gateN:~] # /​usr/​local/​etc/​rc.d/​heartbeat stop 
- 
-[gateN:~] # cat /​usr/​local/​etc/​ha.d/​haresources 
-gate2.corpX.un gmirror 
-</​code><​code>​ 
-[gateN:~] # cat /​usr/​local/​etc/​ha.d/​resource.d/​gmirror 
-</​code><​code>​ 
-#!/bin/sh 
- 
-case $1 in 
-status) 
- # status is not defined, let it be backup 
-        ps ax | grep -v grep | grep -q gated || ggated 
-        ;; 
-start) 
- # stop backup service 
- ps ax | grep -v grep | grep -q gated && killall -9 ggated 
- # in some case start run twise 
- kldstat | grep -q geom_mirror || ( 
- gmirror load 
- sleep 5 
- gmirror status | grep -q DEGRADED && \ 
- gmirror forget gm0 || \ 
- gmirror label -v gm0 /dev/ad1s1e 
-         fsck -y -t ufs /​dev/​mirror/​gm0 
-         mount /​dev/​mirror/​gm0 /opt 
- ) 
-        ;; 
-stop) 
-        kldstat | grep -q geom_mirror && ( 
- # this is master 
- umount /opt 
- gmirror status | grep -q ggate0 && gmirror deactivate gm0 ggate0 
- gmirror deactivate gm0 ad1s1e 
- gmirror unload 
- ggatec list | grep -q ggate0 && ggatec destroy -u 0 
- ps ax | grep -v grep | grep -q ggatec && killall -9 ggatec 
- ) 
-        ps ax | grep -v grep | grep -q gated || ggated 
-        ;; 
-esac 
- 
-exit 0 
-</​code><​code>​ 
-[gateN:~] # chmod +x /​usr/​local/​etc/​ha.d/​resource.d/​gmirror 
-</​code><​code>​ 
-[gateN:~] # /​usr/​local/​etc/​rc.d/​heartbeat start 
-</​code>​ 
- 
-===== Автоматизация подключения диска backup ===== 
-<​code>​ 
-[gateN:~] # mkdir /​usr/​local/​etc/​scripts/​ 
- 
-[gateN:~] # cat /​usr/​local/​etc/​scripts/​gmirror 
-</​code><​code>​ 
-#!/bin/sh 
- 
-# check if node is master 
-/​sbin/​kldstat | grep -q geom_mirror || exit 0  
- 
-# chech if mirror is complete 
-/​sbin/​gmirror status | grep -q ggate0 && \ 
- /​sbin/​gmirror status | grep -q '​COMPLETE'​ && \ 
- exit 0 
- 
-# check if backup node is not dead 
-/​usr/​local/​bin/​cl_status nodestatus gate1.corpX.un 2>/​dev/​null | grep -q dead && exit 0 
-/​usr/​local/​bin/​cl_status nodestatus gate2.corpX.un 2>/​dev/​null | grep -q dead && exit 0 
- 
-# create ggate connect to slave node hdd 
-/​sbin/​ggatec list | grep -q ggate0 || ( 
- /​sbin/​ggatec create -t 10 -u 0 slave /dev/ad1s1e || exit 0 
-) 
- 
-# connect slave hdd to mirror 
-/​sbin/​gmirror status | grep -vq ggate0 && /​sbin/​gmirror insert gm0 ggate0 
- 
-# check is sync nodes in progress 
-/​sbin/​gmirror status | grep -q '​%'​ && exit 0 
- 
-# reconnect slave hdd to mirror 
-/​sbin/​gmirror status | grep -q '​DEGRADED'​ && ( 
-        /​sbin/​gmirror forget gm0 
-        /​sbin/​gmirror insert gm0 ggate0 
-) 
-</​code><​code>​ 
-[gateN:~] # chmod +x /​usr/​local/​etc/​scripts/​gmirror 
-</​code><​code>​ 
-[gateN:~] # crontab -l 
-* * * * * /​usr/​local/​etc/​scripts/​gmirror 
-</​code>​ 
- 
-===== Восстановление backup сервера ===== 
- 
-  - Подключаем новый hdd 
-  - Загружаем однопользователский режим 
-  - Создаем на диске раздел s1e 
-  - Продолжаем загрузку 
  
heartbeat_plus_gmirror_ggate.txt · Last modified: 2013/05/22 13:50 (external edit)