summaryrefslogtreecommitdiffstats
path: root/templates/verify_slave_configuration.bash.erb
blob: 91abffc732f9dd070d6e645145415f6c76c86767 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash -x

PATH=$PATH

# Chech to see if the messaging and datasource databases are configured.

ds_name_response=$(mysql --user=<%= mysql_replication_user %> --host=<%= mysql_master_ip_address %> --password=<%= mysql_replication_password %> --execute="show databases;" | grep <%= ds_name %>)
export ds_name_response
echo $ds_name_response

if [ $ds_name_response = '<%= ds_name %>' ]; then
    export response=True
    exit 1
else
    export response=False
    echo $response
    echo $ds_name_response
fi

rm /var/lib/mysql/<%= ds_name %>_verify_slave_status.out

response=TRUE
export $response

mysql --user=<%= mysql_replication_user %> --host=<%= mysql_master_ip_address %> --password=<%= mysql_replication_password %>  --execute="show slave status\G"  >  /var/lib/mysql/<%= ds_name %>_verify_slave_status.out

Slave_IO_Running=$(grep 'Slave_IO_Running:' /var/lib/mysql/<%= ds_name %>_verify_slave_status.out  | grep Yes | awk '{ print $2 }')
echo $Slave_IO_Running

if [ $Slave_IO_Running = "Yes" ]; then
    export response=True
else
    export response=False
    echo $response
    exit 1
fi

Slave_SQL_Running=$(grep 'Slave_SQL_Running:' /var/lib/mysql/<%= ds_name %>_verify_slave_status.out  | grep Yes | awk '{ print $2 }')
    echo $Slave_SQL_Running

if [ $Slave_SQL_Running = "Yes" ]; then
    export response=True
else
    export response=False
    echo $response
    exit 1
fi

Slave_IO_Stat=$(grep 'Slave_IO_State:' /var/lib/mysql/<%= ds_name %>_verify_slave_status.out  | grep 'Waiting for master to send event' | awk '{ print $6 }')
    echo $Slave_IO_Stat

if [ $Slave_IO_Stat = "send" ]; then
    export response=True
else
    export response=False
    echo $response
    exit 1
fi

Seconds_Behind_Master=$(grep 'Seconds_Behind_Master:' /var/lib/mysql/<%= ds_name %>_verify_slave_status.out | grep 0 | awk '{ print $2 }')
     echo $Seconds_Behind_Master

if [ $Seconds_Behind_Master  =  "0" ]; then
    export response=True
else
    export response=False
    echo $response
    exit 1
fi