]> git.nbdom.net Git - nb.git/commitdiff
share/templates/mysql-change-master.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 5 Feb 2017 04:34:03 +0000 (04:34 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 5 Feb 2017 04:34:03 +0000 (04:34 +0000)
lib/php/nb.php
share/templates/mysql-change-master.php [new file with mode: 0644]

index 02bef99e81c96d7a949b5c824fc1cb96a05a968a..6228427fef9ef37a64b1f878f668460d21526fd9 100644 (file)
@@ -997,6 +997,7 @@ if (!count($argv) or (string)$argv[1] != 'test') return;
 $value = 'Hello World !';
 #$value = file_get_contents('/etc/hosts');
 $key = hash("MD5", '5587eeb68760aa0ed7d2d1212d0829c3'); //we want a 32 byte binary blob 
+#substr(hash('sha512',rand()),0,32);
 #$key = '5587eeb68760aa0ed7d2d1212d0829c3';
 #$key = '76a553babab7a62b7935d9a10f73777bf57b043c9d0f1fc22ea51dd9484154bc91afafd0f92e773e590ad05ebca9aec3fac11ebada7e517c78d32790e5a8f3ed';
 $enc = nb::encrypt($key,$value);
diff --git a/share/templates/mysql-change-master.php b/share/templates/mysql-change-master.php
new file mode 100644 (file)
index 0000000..ce9bd8f
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+  // Aliase
+  foreach ([
+    'pass' => 'password',
+    'passwd' => 'password',
+    'file' => 'log_file',
+    'pos' => 'log_pos',
+  ] as $k => $knew) {
+    if (!empty($ROW[$knew])) continue;
+    if (empty($ROW[$k])) continue;
+    $ROW[$knew] = $ROW[$k];
+    unset($ROW[$k]);
+  }
+
+  // Default values
+  foreach ([
+    'user' => 'rep',
+    'password' => substr(hash('sha512',rand()),0,32),
+    'log_file' => 'mysql-bin.000001',
+    'log_pos' => '107',
+  ] as $k => $v) { if (empty($ROW[$k])) $ROW[$k] = $v; }
+
+#-- template: share/templates/mysql-change-master.php
+?>
+STOP SLAVE; RESET SLAVE;
+CHANGE 
+  MASTER TO MASTER_HOST = '<?=$ROW['host']?>',
+  MASTER_USER = '<?=$ROW['user']?>',
+  MASTER_PASSWORD = '<?=$ROW['password']?>',
+  MASTER_LOG_FILE = '<?=$ROW['log_file']?>',
+  MASTER_LOG_POS = <?=$ROW['log_pos']?>
+;
+START SLAVE;