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