-
Notifications
You must be signed in to change notification settings - Fork 0
/
repl-fix-1a.sh
executable file
·75 lines (60 loc) · 1.94 KB
/
repl-fix-1a.sh
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
71
72
#!/bin/bash
# Scenario
# The slave is updated manually. Evidence of this is in the slave binlogs.
# Replication breaks when a query affecting that row comes in from master,
# and errors because it encounters unexpected data at slave.
# Confirm CBS is attached as /dev/xvde
if [ ! -b /dev/xvde ]; then
echo "ERROR: No CBS volume detected at /dev/xvde"
echo "Attach a CBS volume and retry"
exit 1
fi
# Setup LVM
yum -y install parted lvm2
parted -s -- /dev/xvde mklabel gpt
parted -s -a optimal -- /dev/xvde mkpart primary 0% 100%
parted -s -- /dev/xvde align-check optimal 1
parted -s -- /dev/xvde set 1 lvm on
pvcreate /dev/xvde1
vgcreate vg00 /dev/xvde1
lvcreate -L15G -n lv00 vg00
mkfs -t ext4 /dev/mapper/vg00-lv00
mkdir /data
mount /dev/mapper/vg00-lv00 /data
grep /dev/mapper/vg00-lv00 /etc/mtab >> /etc/fstab
# Setup MySQL
yum -y install mysql-server
mkdir /data/mysqllogs
mkdir /data/mysqltmp
tar -C /data -xzf /home/lab/master-data.tgz
tar -C /data -xzf /home/lab/master-logs.tgz
# Master position = binlog.000004, 6260
chown mysql:mysql /data/mysqltmp
chown mysql:mysql /data/mysqllogs
chown -R mysql:mysql /data/mysql
echo > /var/log/mysqld.log
cat >/etc/my.cnf <<EOF
[mysqld]
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
tmpdir = /data/mysqltmp
log-bin = /data/mysqllogs/binlog
binlog-format = MIXED
server-id = 1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
EOF
# Start the service
service mysqld start
# Add replication grants for private ranges
mysql -e "GRANT REPLICATION SLAVE ON *.* TO 'repl'@'10.%' IDENTIFIED BY 'dkMcn5Vtgv';"
mysql -e "GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.%' IDENTIFIED BY 'dkMcn5Vtgv';"
# I know. I don't care.
mysql -e "GRANT REPLICATION SLAVE ON *.* TO 'repl'@'172.%' IDENTIFIED BY 'dkMcn5Vtgv';"
# Initialize entropy
echo 1 > /home/lab/entropy
/home/lab/entropy.sh