summaryrefslogtreecommitdiffstats
path: root/templates/gather_master_data.bash.erb
diff options
context:
space:
mode:
Diffstat (limited to 'templates/gather_master_data.bash.erb')
-rw-r--r--templates/gather_master_data.bash.erb26
1 files changed, 26 insertions, 0 deletions
diff --git a/templates/gather_master_data.bash.erb b/templates/gather_master_data.bash.erb
new file mode 100644
index 0000000..c9d3804
--- /dev/null
+++ b/templates/gather_master_data.bash.erb
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+PATH=$PATH
+
+logname=$(mysql -u replication --host=<%= master_host_ip %> --password=password --execute="show master status" | grep mysqllog | awk '{ print $1 }')
+export logname
+position=$(mysql -u replication --host=<%= master_host_ip %> --password=password --execute="show master status" | grep mysqllog | awk '{ print $2 }')
+export position
+
+rm /var/lib/mysql/set_master_repl_data.sql
+
+export master_host_ip=<%= master_host_ip %>
+
+#Build MySQL Master Data Script
+#
+
+echo CHANGE MASTER TO >> /var/lib/mysql/set_master_repl_data.sql
+echo MASTER_HOST=\'$master_host_ip\', >> /var/lib/mysql/set_master_repl_data.sql
+echo MASTER_USER=\'replication\', >> /var/lib/mysql/set_master_repl_data.sql
+echo MASTER_PASSWORD=\'password\', >> /var/lib/mysql/set_master_repl_data.sql
+echo MASTER_LOG_FILE=\'$logname\', >> /var/lib/mysql/set_master_repl_data.sql
+echo MASTER_LOG_POS=$position, >> /var/lib/mysql/set_master_repl_data.sql
+echo MASTER_CONNECT_RETRY=10\; >> /var/lib/mysql/set_master_repl_data.sql
+
+
+/usr/bin/mysql --user='replication' --password='password' --database='mysql' --host='localhost' --execute="source /var/lib/mysql/set_master_repl_data.sql"