SetupReplication: Unterschied zwischen den Versionen

Aus GRITON
Zur Navigation springen Zur Suche springen
 
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt)
Zeile 10: Zeile 10:
  
 
master my.cnf:
 
master my.cnf:
<code>
+
<pre>
 
[mysqld]
 
[mysqld]
 
server-id = 1
 
server-id = 1
Zeile 20: Zeile 20:
 
master-connect-retry=600
 
master-connect-retry=600
 
master-retry-count=1000
 
master-retry-count=1000
</code>
+
</pre>
  
 
slave my.cnf:
 
slave my.cnf:
<code>
+
<pre>
 
[mysqld]
 
[mysqld]
 
server-id = 2
 
server-id = 2
Zeile 36: Zeile 36:
 
master-connect-retry=600
 
master-connect-retry=600
 
master-retry-count=1000
 
master-retry-count=1000
</code>
+
</pre>
  
 
2. Restart both the slave and the master.
 
2. Restart both the slave and the master.
Zeile 42: Zeile 42:
 
3. On the master do:
 
3. On the master do:
  
{{{
+
<pre>
 
GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO replication@"%" IDENTIFIED BY 'pwd';
 
GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO replication@"%" IDENTIFIED BY 'pwd';
}}}
+
</pre>
 
4. On the slave do:
 
4. On the slave do:
{{{
+
<pre>
 
LOAD DATA FROM MASTER;
 
LOAD DATA FROM MASTER;
 
GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO replication@"%" IDENTIFIED BY 'pwd';
 
GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO replication@"%" IDENTIFIED BY 'pwd';
}}}
+
</pre>
  
 
The slave should now download the databases specified with replicate-do-db in the slaves my.cnf,  
 
The slave should now download the databases specified with replicate-do-db in the slaves my.cnf,  
Zeile 57: Zeile 57:
 
Befehle:
 
Befehle:
 
Rechte Vergeben (Am Master):
 
Rechte Vergeben (Am Master):
{{{
+
<pre>
 
GRANT SUPER, REPLICATION SLAVE, REPLICATION CLIENT,RELOAD
 
GRANT SUPER, REPLICATION SLAVE, REPLICATION CLIENT,RELOAD
 
     ON *.*
 
     ON *.*
 
     TO 'replication'@'*'
 
     TO 'replication'@'*'
 
     IDENTIFIED BY 'pwd';
 
     IDENTIFIED BY 'pwd';
}}}
+
</pre>
  
 
Master setzen (am Slave):
 
Master setzen (am Slave):
{{{
+
<pre>
 
CHANGE MASTER TO
 
CHANGE MASTER TO
 
   MASTER_HOST='80.120.22.111',
 
   MASTER_HOST='80.120.22.111',
Zeile 74: Zeile 74:
 
   MASTER_LOG_POS=7968,
 
   MASTER_LOG_POS=7968,
 
   MASTER_CONNECT_RETRY=10;
 
   MASTER_CONNECT_RETRY=10;
}}}
+
</pre>
 
 
 
 
  
  
Zeile 91: Zeile 89:
 
   User: Administrator
 
   User: Administrator
 
   Passwort: xxxxxxx  
 
   Passwort: xxxxxxx  
 
  
  
Zeile 98: Zeile 95:
  
 
Datei: startrepl.cmd
 
Datei: startrepl.cmd
{{{
+
<pre>
 
rem Windows Batch File für automatisches Starten der Replikation (VPN)  
 
rem Windows Batch File für automatisches Starten der Replikation (VPN)  
 
rem Runs SQL Commands from File at certain time! Every 10 minutes;
 
rem Runs SQL Commands from File at certain time! Every 10 minutes;
 
c:\mysql\bin\mysql intrasell_daten_2 -uroot < commands.sql
 
c:\mysql\bin\mysql intrasell_daten_2 -uroot < commands.sql
 
pause
 
pause
}}}
+
</pre>
 
   
 
   
 
Datei: commands.sql
 
Datei: commands.sql
{{{
+
<pre>
 
stop slave;
 
stop slave;
  
 
start slave;
 
start slave;
}}}
+
</pre>
 
---
 
---
  
Zeile 119: Zeile 116:
  
 
Folgende Befehle führen die Replikation ohne Fehlerbehebung weiter. So oft ausführen bis die Replikation wieder läuft.  
 
Folgende Befehle führen die Replikation ohne Fehlerbehebung weiter. So oft ausführen bis die Replikation wieder läuft.  
{{{
+
<pre>
 
START SLAVE;
 
START SLAVE;
 
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
 
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
 
START SLAVE;
 
START SLAVE;
}}}
+
</pre>
 
=== Aktuelle Position auslesen, Binary Log lesbar ansehen===
 
=== Aktuelle Position auslesen, Binary Log lesbar ansehen===
 
Die aktuelle Position in einem Log File ansehen.  
 
Die aktuelle Position in einem Log File ansehen.  
 
Bsp:  
 
Bsp:  
 
mysqlbinlog.exe mysql-bin.000086 >> 86.txt
 
mysqlbinlog.exe mysql-bin.000086 >> 86.txt

Aktuelle Version vom 22. Dezember 2015, 17:21 Uhr

  1. summary Beschreibt die Replikation mit MySQL. MySQL Datenbank am Server Synchron mit der MySQL im Office halten.

Replikation

Einrichtung Replikation

1. Edit the my.cnf file on the slave and on the master server:

Hint: These are additional settings to a clean MySQL installation (Version 5.1).

master my.cnf:

[mysqld]
server-id = 1
log-bin
log-slave-updates 
replicate-do-db = intrasell_daten_2
log-warnings
slave-skip-errors=all
master-connect-retry=600
master-retry-count=1000

slave my.cnf:

[mysqld]
server-id = 2
log-bin
log-slave-updates
#master-host = master-host.net
#master-user = repl
#master-password = repl_pass
replicate-do-db = intrasell_daten_2
log-warnings
slave-skip-errors=all
master-connect-retry=600
master-retry-count=1000

2. Restart both the slave and the master.

3. On the master do:

GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO replication@"%" IDENTIFIED BY 'pwd';

4. On the slave do:

LOAD DATA FROM MASTER;
GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO replication@"%" IDENTIFIED BY 'pwd';

The slave should now download the databases specified with replicate-do-db in the slaves my.cnf, and be replicating new data.


Befehle: Rechte Vergeben (Am Master):

GRANT SUPER, REPLICATION SLAVE, REPLICATION CLIENT,RELOAD
    ON *.*
    TO 'replication'@'*'
    IDENTIFIED BY 'pwd';

Master setzen (am Slave):

CHANGE MASTER TO
  MASTER_HOST='80.120.22.111',
  MASTER_USER='replication',
  MASTER_PASSWORD='pwd',
  -- MASTER_PORT=3306,
  MASTER_LOG_FILE='master2-bin.00016',
  MASTER_LOG_POS=7968,
  MASTER_CONNECT_RETRY=10;


Set up VPN Verbindung

Server

1. Am Server - Allow VPN - Netzwerkverbindungen - TCP IP

  Start Adresse am Client 10.0.0.2

Client

1. Install UltraVNC am Client:

  http://www.uvnc.com/

2. Eine VPN Verbindung zum Server Einrichten: Windows/Netzwerke/neue Verbindung

  IP: Deine Server IP 
  User: Administrator
  Passwort: xxxxxxx 


Weitere Einrichtung Start Replikation wenn der Client VPN (Einwählen) benutzt

Datei: startrepl.cmd

rem Windows Batch File für automatisches Starten der Replikation (VPN) 
rem Runs SQL Commands from File at certain time! Every 10 minutes;
c:\mysql\bin\mysql intrasell_daten_2 -uroot < commands.sql
pause

Datei: commands.sql

stop slave;

start slave;

---

Problembehebung

SKIP LOGS

Es kann passieren dass die Replikation nicht mehr funktioniert. Die Gründe können mit dem Befehl: SHOW SLAVE STATUS; erruiert werden.

Folgende Befehle führen die Replikation ohne Fehlerbehebung weiter. So oft ausführen bis die Replikation wieder läuft.

START SLAVE;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
START SLAVE;

Aktuelle Position auslesen, Binary Log lesbar ansehen

Die aktuelle Position in einem Log File ansehen. Bsp: mysqlbinlog.exe mysql-bin.000086 >> 86.txt