update to rhe recovery daemon
[sahlberg/ctdb.git] / tests / recover.sh
1 #!/bin/sh
2
3 killall -q ctdbd
4 killall -q recoverd
5
6 echo "Starting 4 ctdb daemons"
7 bin/ctdbd --nlist direct/4nodes.txt
8 bin/ctdbd --nlist direct/4nodes.txt --listen=127.0.0.2:9001 --socket=/tmp/ctdb.socket.127.0.0.2
9 bin/ctdbd --nlist direct/4nodes.txt --listen=127.0.0.3:9001 --socket=/tmp/ctdb.socket.127.0.0.3
10 bin/ctdbd --nlist direct/4nodes.txt --listen=127.0.0.4:9001 --socket=/tmp/ctdb.socket.127.0.0.4
11 echo "Starting one recovery daemon on node 0"
12 bin/recoverd --socket=/tmp/ctdb.socket >/dev/null 2>/dev/null &
13
14 echo
15 echo "Attaching to some databases"
16 bin/ctdb_control attach test1.tdb || exit 1
17 bin/ctdb_control attach test2.tdb || exit 1
18 bin/ctdb_control attach test3.tdb || exit 1
19 bin/ctdb_control attach test4.tdb || exit 1
20
21 echo "Clearing all databases to make sure they are all empty"
22 bin/ctdb_control getdbmap 0 | egrep "^dbid:" | sed -e "s/^dbid://" -e "s/ .*$//" | while read DB; do
23         seq 0 3 | while read NODE; do
24                 bin/ctdb_control cleardb $NODE $DB
25         done
26 done
27
28
29 echo
30 echo
31 echo "Printing all databases on all nodes. they should all be empty"
32 echo "============================================================="
33 bin/ctdb_control getdbmap 0 | egrep "^dbid:" | sed -e "s/^.*name://" -e "s/ .*$//" | while read DBNAME; do
34         seq 0 3 | while read NODE; do
35                 echo "Content of DBNAME:$DBNAME NODE:$NODE :"
36                 bin/ctdb_control catdb $DBNAME $NODE
37         done
38 done
39
40 echo
41 echo
42 echo "Populating the databases"
43 ./bin/ctdb_control writerecord 0 0x220c2a7b testkey1 testdata1
44 ./bin/ctdb_control setdmaster 0 0x220c2a7b 1
45
46 ./bin/ctdb_control writerecord 1 0x220c2a7b testkey1 testdata1
47 ./bin/ctdb_control writerecord 1 0x220c2a7b testkey1 testdata1
48 ./bin/ctdb_control setdmaster 1 0x220c2a7b 2
49
50 ./bin/ctdb_control writerecord 2 0x220c2a7b testkey1 testdata1
51 ./bin/ctdb_control writerecord 2 0x220c2a7b testkey1 testdata1
52 ./bin/ctdb_control writerecord 2 0x220c2a7b testkey1 testdata1
53 ./bin/ctdb_control setdmaster 2 0x220c2a7b 3
54
55 ./bin/ctdb_control writerecord 3 0x220c2a7b testkey1 testdata1
56 ./bin/ctdb_control writerecord 3 0x220c2a7b testkey1 testdata1
57 ./bin/ctdb_control writerecord 3 0x220c2a7b testkey1 testdata1
58 ./bin/ctdb_control writerecord 3 0x220c2a7b testkey1 testdata1
59 ./bin/ctdb_control setdmaster 3 0x220c2a7b 3
60
61
62 echo
63 echo
64 echo "Printing all databases on all nodes. there should be a record there"
65 echo "============================================================="
66 bin/ctdb_control getdbmap 0 | egrep "^dbid:" | sed -e "s/^.*name://" -e "s/ .*$//" | while read DBNAME; do
67         seq 0 3 | while read NODE; do
68                 echo "Content of DBNAME:$DBNAME NODE:$NODE :"
69                 bin/ctdb_control catdb $DBNAME $NODE
70         done
71 done
72
73 echo
74 echo
75 echo "killing off node #2"
76 echo "==================="
77 CTDBPID=`./bin/ctdb_control getpid 2 | sed -e "s/Pid://"`
78 kill $CTDBPID
79 sleep 1
80
81
82 echo
83 echo
84 echo "wait 3 seconds to let the recovery daemon do its job"
85 echo "===================================================="
86 sleep 3
87
88 echo
89 echo
90 echo "Printing all databases on all nodes."
91 echo "The databases should be the same now on all nodes"
92 echo "and the record will have been migrated to node 0"
93 echo "================================================="
94 echo "Node 0:"
95 bin/ctdb_control catdb test4.tdb 0
96 echo "Node 1:"
97 bin/ctdb_control catdb test4.tdb 1
98 echo "Node 3:"
99 bin/ctdb_control catdb test4.tdb 3
100 echo "nodemap:"
101 bin/ctdb_control getnodemap 0
102
103 echo
104 echo
105 echo "Traverse the cluster and dump the database"
106 bin/ctdb_control catdb test4.tdb
107
108
109 #leave the ctdb daemons running   so one can look at the box in more detail
110 #killall -q ctdbd