szkript inditasa CARP statusz allapot valtozas utan

Fórumok

Sziasztok,

tudna nekem valaki segiteni ebben az ugyben?
ha leesne a masteren a carp master allapot, ne csinaljon a rendszer semmit.
ha pedig ujbol feljon a master allapot, akkor inditson egy szkriptet.
Ardi

Hozzászólások

Pontosabban miről lenne szó?

Cache Array Routing Protocol, a computer protocol for HTTP server acceleration
Common Address Redundancy Protocol, a computer networking protocol to handle fail-over

Most látom, hogy FreeBSD, akkor nem tudok segíteni.

pkg_add -r ifstated

man ifstated.conf

Hello,

nem sikerult ezzel a paranccsal, de feltettem a kovetkezot mint:
# which pkg_add
/usr/sbin/pkg_add
# /usr/sbin/pkg_add libevent-1.4.14b_2.tbz
pkg_add: package asgen-3.1.5 has no origin recorded
# /usr/sbin/pkg_add ifstated-4.7_2,1.tbz
pkg_add: package asgen-3.1.5 has no origin recorded
pkg_add: package asgen-3.1.5 has no origin recorded

Mit jelentenek ezek a bejegyzesek?

To use ifstated, you must create one or more configration files (a
sample is provided). This version of ifstated allows for multiple
"profiles" or instances, each with its own configuration. Please see
the comments in /usr/local/etc/rc.d/ifstated for the variables to set
in /etc/rc.conf.

Mik a kovetkezo lepesek, ha a carp interfeszek (carp0,carp1,crp2) allapotanak valtozasat szeretnem beallitani es tesztelni?
Csinaltam kopiat mint root:
cp /usr/local/etc/ifstated-conf-sample /usr/local/etc/ifstated.conf.

Ardi

Koszi az uj linket,
otthon probaltam es bejott a link - epp most probalgatom ezt is (parhuzamosan keresek megoldast devd-vel is).
Majd jelzek, hogy mi az abra.

Szerkesztes:
# pwd
/usr/local/etc
# cat ifstated.conf
init-state one

net = '( "ifconfig -a -u |grep carp0 > /dev/null" every 3 && "ifconfig -a -u
|grep carp1 > /dev/null" every 3 && "ifconfig -a -u |grep carp2 > /dev/null"
every 3)'

state one {
if ( ! $net ) {
run "/sbin/ifconfig_carp0 vhid 1 pass ujpass 192.xx.xx.1/24"
run "/sbin/ifconfig carp1 vhid 2 pass ujpass 192.xx.xx.2/24"
run "/sbin/ifconfig carp2 vhid 3 pass ujpass 192.xx.xx.3/24"
run "/usr/local/etc/rc.d/testifdown.sh"
set-state two
}
}

state two {
if ( $net ) {
run "/sbin/ifconfig carp0 vhid 1 advskew 100 pass ujpass 192.xx.xx.1/24"
run "/sbin/ifconfig carp1 vhid 2 advskew 100 pass ujpass 192.xx.xx.2/24"
run "/sbin/ifconfig carp2 vhid 3 advskew 100 pass ujpass 192.xx.xx.3/24"
run "/usr/local/etc/rc.d/testifup.sh"
set-state one
}
}

#which ifstated
/usr/local/sbin/ifstated
Es most leteszteltem, hogy jo-e a szintaxis:

# /usr/local/sbin/ifstated -n -v -f /usr/local/etc/ifstated.conf
net = "( "ifconfig -a -u |grep carp0 > /dev/null" every 3 && "ifconfig -a -u|grep carp1 > /dev/null" every 3 && "ifconfig -a -u |grep carp2 > /dev/null"every 3)"
ifstated: configuration OK

Most elinditottam manualis demon modban:

# /usr/local/sbin/ifstated -dv -f /usr/local/etc/ifstated.conf
net = "( "ifconfig -a -u |grep carp0 > /dev/null" every 3 && "ifconfig -a -u|grep carp1 > /dev/null" every 3 && "ifconfig -a -u |grep carp2 > /dev/null"every 3)"
initial state: one
changing state to one
running ifconfig -a -u |grep carp0 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running ifconfig -a -u |grep carp2 > /dev/null
started
running ifconfig -a -u |grep carp0 > /dev/null
running ifconfig -a -u |grep carp2 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running ifconfig -a -u |grep carp0 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running ifconfig -a -u |grep carp2 > /dev/null
running ifconfig -a -u |grep carp0 > /dev/null
running ifconfig -a -u |grep carp2 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running ifconfig -a -u |grep carp0 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running ifconfig -a -u |grep carp2 > /dev/null
^C

Ha most egy masik master terminalon:
a) megnezzuk, hogy fut e a manualis ifstated demon:
#ps -ax | grep ifstated
1785 0 S+ 0:00.01 /usr/local/sbin/ifstated -dv -f /usr/local/etc/ifstated.conf
1872 1 R+ 0:00.00 grep ifstated
#

b) root-kent ifconfig carp0 down, akkor valtozik az allapot az elso terminalon es lefut a testifdown.sh szkript:

running ifconfig -a -u |grep carp2 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running /sbin/ifconfig_carp0 vhid 1 pass testpass 192.xx.xx.1/24
/sbin/ifconfig_carp0: not found
running /sbin/ifconfig carp1 vhid 2 pass testpass 192.xx.xx.2/24
running /sbin/ifconfig carp2 vhid 3 pass testpass 192.xx.xx.3/24
running /usr/local/etc/rc.d/testifdown.sh
changing state to two
running ifconfig -a -u |grep carp0 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running ifconfig -a -u |grep carp2 > /dev/null
running ifconfig -a -u |grep carp0 > /dev/null
running ifconfig -a -u |grep carp2 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running ifconfig -a -u |grep carp0 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running ifconfig -a -u |grep carp2 > /dev/null

carp0: flags=8 metric 0 mtu 1500
inet 192.xx.xx.1 netmask 0xffffff00
carp: INIT vhid 1 advbase 1 advskew 0 <----kikapcsolva
carp1: flags=49 metric 0 mtu 1500
inet 192.xx.xx.2 netmask 0xffffff00
carp: MASTER vhid 2 advbase 1 advskew 0
carp2: flags=49 metric 0 mtu 1500
inet 192.xx.xx.3 netmask 0xffffff00
carp: MASTER vhid 3 advbase 1 advskew 0

c) ha most ifconfig carp0 up, akkor valtozik az allapot es lefut a masik szkript

changing state to one
running ifconfig -a -u |grep carp0 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running ifconfig -a -u |grep carp2 > /dev/null
running ifconfig -a -u |grep carp0 > /dev/null
running ifconfig -a -u |grep carp2 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running ifconfig -a -u |grep carp0 > /dev/null
running ifconfig -a -u|grep carp1 > /dev/null
running ifconfig -a -u |grep carp2 > /dev/null

es a rendszer allapota (reszlet): ifconfig -a
carp0: flags=49 metric 0 mtu 1500
inet 192.xx.xx.1 netmask 0xffffff00
carp: MASTER vhid 1 advbase 1 advskew 100 <-------master-re valt
carp1: flags=49 metric 0 mtu 1500
inet 192.xx.xx.2 netmask 0xffffff00
carp: MASTER vhid 2 advbase 1 advskew 100
carp2: flags=49 metric 0 mtu 1500
inet 192.xx.xx.3 netmask 0xffffff00
carp: MASTER vhid 3 advbase 1 advskew 100

Szerintetek igy jo lesz?

Hogyan lehet ezt rendes demonba tenni?

szerkesztve:
/etc/rc.conf fajlba beirtam, hogy: ifstated_enabel="YES" es reboot.

Sajnos, nem azt csinalja, amit varok tole...:-((

Ardi

Kombinaltam a devd es az ifstated csomagokat es mukodnek a szkriptek.
Az ifstated daemon modban megy.
Van viszont egy problemam:

ha manualisan ifconfig carp0 down --> lefut a testifdown.sh es INIT lesz a carp0 es ott is marad.
carp0: flags=8 metric 0 mtu 1500
inet 192.xx.xx.1 netmask 0xffffff00
carp: INIT vhid 1 advbase 1 advskew 100 <---------------------------carp0 down
carp1: flags=49 metric 0 mtu 1500
inet 192.xx.xx.2 netmask 0xffffff00
carp: MASTER vhid 2 advbase 1 advskew 100
carp2: flags=49 metric 0 mtu 1500
inet 192.xx.xx.3 netmask 0xffffff00
carp: MASTER vhid 3 advbase 1 advskew 100
ha manualisan felhozom ifconfig carp0 up --> lefut a testifup.sh es carp0 MASTER lesz es lehuzza rsync-kel a fajlokat a slave-rol.

carp0: flags=49 metric 0 mtu 1500
inet 192.xx.xx.1 netmask 0xffffff00
carp: MASTER vhid 1 advbase 1 advskew 100 <-----master (a parancs utan)
carp1: flags=49 metric 0 mtu 1500
inet 192.xx.xx.2 netmask 0xffffff00
carp: MASTER vhid 2 advbase 1 advskew 100
carp2: flags=49 metric 0 mtu 1500
inet 192.xx.xx.3 netmask 0xffffff00
carp: MASTER vhid 3 advbase 1 advskew 100

DE: ha ugyanezt csinalom carp1 (vagy carp2)-vel, akkor a rendszer INIT-be teszi carp1, lefut a testifdown.sh
carp0: flags=49 metric 0 mtu 1500
inet 192.xx.xx.1 netmask 0xffffff00
carp: MASTER vhid 1 advbase 1 advskew 100
carp1: flags=8 metric 0 mtu 1500
inet 192.xx.xx.2 netmask 0xffffff00
carp: INIT vhid 2 advbase 1 advskew 100 <---------------------carp1 down (de csak rovid idore)
carp2: flags=49 metric 0 mtu 1500
inet 192.168.236.3 netmask 0xffffff00
carp: MASTER vhid 3 advbase 1 advskew 100

de rogton felhozza MASTER modba

carp0: flags=49 metric 0 mtu 1500
inet 192.xx.xx.1 netmask 0xffffff00
carp: MASTER vhid 1 advbase 1 advskew 100
carp1: flags=49 metric 0 mtu 1500
inet 192.xx.xx.2 netmask 0xffffff00
carp: MASTER vhid 2 advbase 1 advskew 100 <--------------mi hozza fel???
carp2: flags=49 metric 0 mtu 1500
inet 192.xx.xx.3 netmask 0xffffff00
carp: MASTER vhid 3 advbase 1 advskew 100

es futtatja a iftestup.sh szkriptet es lehuzza rsync-kel a fajlokat.

Ez most azert van, mert carp0 ilyenkor mindig mukodik es arra van kotve virtualisan az ftp?

Ardi

Sziasztok,

nos, talaltam par hibat a konfiguracioban.

igy mar egyforman reagal a szkript:

/usr/local/etc
# cat ifstated.conf
init-state one

net = '( "ifconfig -a -u |grep carp0 > /dev/null" every 3 && "ifconfig -a -u
|grep carp1 > /dev/null" every 3 && "ifconfig -a -u |grep carp2 > /dev/null"
every 3)'

state one {
if ( ! $net ) {
run "/sbin/ifconfig_carp0 vhid 1 pass ujpass 192.xx.xx.1/24"
run "/sbin/ifconfig_carp1 vhid 2 pass ujpass 192.xx.xx.2/24"
run "/sbin/ifconfig_carp2 vhid 3 pass ujpass 192.xx.xx.3/24"
run "/usr/local/etc/rc.d/testifdown.sh"
set-state two
}
}

state two {
if ( $net ) {
run "/usr/local/etc/rc.d/testifup.sh"
set-state one
}
}

Problema csak akkor adodik - pontosabban: nem hajtodik vegre a testifup.sh,
ha ketto interfeszet kapcsolok le egyszerre es utana visszakapcsolok egyet kozuluk.

Szukseges, hogy az osszes lehetoseget beirjam az, ifstated.conf-ba?

Ardi

#man devd.conf

notify 30 {
match “system” “IFNET”;
match “subsystem” “carp0″;
match “type” “LINK_UP”;
action “/usr/local/scripts/linkup.sh”;
};

notify 30 {
match “system” “IFNET”;
match “subsystem” “carp0″;
match “type” “LINK_DOWN”;
action “/usr/local/scripts/linkdown.sh”;
};

Az http://blather.michaelwlucas.com/archives/224 oldalon lattam en is ezt a beirast, csak nem tudom, hogy teszem a rendszerre a devd-t.

szerkesztve: ...hogy en mekkora hulye vagyok - /etc/devd.conf <--hat itt van.

szerkesztve2:
notify 30 {
match .system. .IFNET.;
match .subsystem. .carp0.;
match .type. .LINK_UP.;
action ./usr/local/etc/rc.d/test_ha_carp0le.sh;
};

notify 30 {
match .system. .IFNET.;
match .subsystem. .carp0.;
match .type. .LINK_DOWN.;
action ./usr/local/etc/rc.d/test_ha_carp0_fel.sh;

ki- es bekapcsolhato teszteles celjabol a carp0 a masteren paranccsal anelkul, hogy reboot-ot csinalnek?

szerkesztve: ifconfig carp0 up/down paranccsal valtozik a MASTER/SLAVE allapot carp0 interfeszen, de nem futnak le a szkriptek. mi lehet a bibi?

Ardi

Hello Zahy,

teljes reboot-t csinaltam, (ekkor lefutott a ket szkript - mint ahogy irtam), de manualis carp0 down/up esetben nem mukodik.
Megjegyzes: Nem emlitettem, de hibasan kopiroztam a sorokat:

notify 30 {
match "system" "IFNET";
match "subsystem" "carp0";
match "type" "LINK_UP";
action "/usr/local/etc/rc.d/test_ha_carp0le.sh";
};

notify 30 {
match "system" "IFNET";
match "subsystem" "carp0";
match "type" "LINK_DOWN";
action "/usr/local/etc/rc.d/test_ha_carp0_fel.sh";

De ezt meg azelott kijavitottam.

Olvastam vmi ujat itt:
http://freebsd.markmail.org/message/bumaccf6m4us2mtv?q=carp+AND+ifstate…

mely szerint:

"Yes, the LINK_UP/LINK_DOWN do seem to refer
to the status of the physical media (plugged in or out). While at it, I also
found that
ifconfig em0 down (not pulling out the media, just the command)
does not send any status message (perhaps a driver feature? Not
sure), but
ifconfig em0 up
does send a LINK_DOWN first and then a LINK_UP. This doesn't seem to
have any relation to whether or not the IP address is there or
-aliased.

"
Ha jo ertettem a fenti sorokat, a LINK_UP/LINK_DOWN allapot akkor valtozik,
ha kihuzom a kabelt az interfeszbol?

Szoval probaltam console-bol ki- es bekapcsolni az em0 fizikai interfeszet, de a szkript igy sem mukodik.
A virtualis carp0,carp1,carp2 interrfeszek kotve vannak bizonyos fizikai interfeszhez?
Az en esetemben az em0-hoz??

Ardi