<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frotmail.nl/index.php?action=history&amp;feed=atom&amp;title=MySQL_Replicatie</id>
	<title>MySQL Replicatie - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frotmail.nl/index.php?action=history&amp;feed=atom&amp;title=MySQL_Replicatie"/>
	<link rel="alternate" type="text/html" href="https://wiki.frotmail.nl/index.php?title=MySQL_Replicatie&amp;action=history"/>
	<updated>2026-06-15T08:15:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.frotmail.nl/index.php?title=MySQL_Replicatie&amp;diff=90&amp;oldid=prev</id>
		<title>Eric: Created page with &quot;=Setup Master Server= You&#039;ll need this in your my.cnf on your server:  log-bin     server-id = 1  log bin turns on logging and server-id  (which must be unique on your network) is requried for replication to work. I made the master in this case #1.  Then, setup the replication user (assumes you&#039;re running mysql 4.   mysql&gt; GRANT REPLICATION SLAVE ON *.* TO repl@&quot;%&quot; IDENTIFIED &#039;&lt;password&gt;&#039;;   restart your mysql server, if necessary do a:  Get a snapshot of current data fo...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.frotmail.nl/index.php?title=MySQL_Replicatie&amp;diff=90&amp;oldid=prev"/>
		<updated>2022-04-05T09:34:33Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=Setup Master Server= You&amp;#039;ll need this in your my.cnf on your server:  log-bin     server-id = 1  log bin turns on logging and server-id  (which must be unique on your network) is requried for replication to work. I made the master in this case #1.  Then, setup the replication user (assumes you&amp;#039;re running mysql 4.   mysql&amp;gt; GRANT REPLICATION SLAVE ON *.* TO repl@&amp;quot;%&amp;quot; IDENTIFIED &amp;#039;&amp;lt;password&amp;gt;&amp;#039;;   restart your mysql server, if necessary do a:  Get a snapshot of current data fo...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Setup Master Server=&lt;br /&gt;
You&amp;#039;ll need this in your my.cnf on your server:&lt;br /&gt;
 log-bin   &lt;br /&gt;
 server-id = 1&lt;br /&gt;
&lt;br /&gt;
log bin turns on logging and server-id  (which must be unique on your network) is requried for replication to work. I made the master in this case #1.&lt;br /&gt;
&lt;br /&gt;
Then, setup the replication user (assumes you&amp;#039;re running mysql 4.&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; GRANT REPLICATION SLAVE ON *.* TO repl@&amp;quot;%&amp;quot; IDENTIFIED &amp;#039;&amp;lt;password&amp;gt;&amp;#039;; &lt;br /&gt;
&lt;br /&gt;
restart your mysql server, if necessary do a:&lt;br /&gt;
&lt;br /&gt;
Get a snapshot of current data for the slave&lt;br /&gt;
after restarting with log-bin enabled, tar up your /var/lib/mysql databases that you are going to want to replicate and copy them over to the slave. i replicated all but the &amp;#039;mysql&amp;#039; database.&lt;br /&gt;
&lt;br /&gt;
If you are using MyISAM tables, flush all the tables and block write queries by executing FLUSH TABLES WITH READ LOCK command.&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; FLUSH TABLES WITH READ LOCK; &lt;br /&gt;
&lt;br /&gt;
 tar -cvf /tmp/mysql-snapshot.tar /path/to/data-dir &lt;br /&gt;
&lt;br /&gt;
then, on your master, do a&lt;br /&gt;
&lt;br /&gt;
 mysql &amp;gt; SHOW MASTER STATUS; &lt;br /&gt;
&lt;br /&gt;
and note the &amp;#039;File&amp;#039; name and the &amp;#039;Position&amp;#039; number&lt;br /&gt;
&lt;br /&gt;
then you can allow writes again on your master by doing an&lt;br /&gt;
&lt;br /&gt;
 unlock tables&lt;br /&gt;
&lt;br /&gt;
=Setup the slave server=&lt;br /&gt;
&lt;br /&gt;
add server-id to the my.cnf file&lt;br /&gt;
(other things i added to my.cnf:&lt;br /&gt;
&lt;br /&gt;
 log-bin&lt;br /&gt;
 server-id       = 2&lt;br /&gt;
&lt;br /&gt;
Optionally:&lt;br /&gt;
&lt;br /&gt;
 log-slave-updates &lt;br /&gt;
 log-warnings &lt;br /&gt;
 replicate-ignore-db=mysql&lt;br /&gt;
&lt;br /&gt;
restart the mysqld&lt;br /&gt;
then:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; CHANGE MASTER TO MASTER_HOST=&amp;#039;&amp;lt;master host name&amp;gt;&amp;#039;,&lt;br /&gt;
 MASTER_USER=&amp;#039;&amp;lt;replication user name&amp;gt;&amp;#039;,&lt;br /&gt;
 MASTER_PASSWORD=&amp;#039;&amp;lt;replication password&amp;gt;&amp;#039;,&lt;br /&gt;
 MASTER_LOG_FILE=&amp;#039;&amp;lt;recorded log file name&amp;gt;&amp;#039;,&lt;br /&gt;
 MASTER_LOG_POS=&amp;lt;recorded log offset&amp;gt;; &lt;br /&gt;
&lt;br /&gt;
replacing the values in &amp;lt;&amp;gt; with the actual values relevant to your system.&lt;br /&gt;
Start the slave threads:&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; START SLAVE;&lt;br /&gt;
&lt;br /&gt;
Once a slave is replicating, you will find a file called `master.info&amp;#039; and one called `relay-log.info&amp;#039; in the data directory. These two files are used by the slave to keep track of how much of the master&amp;#039;s binary log it has processed. Do not remove or edit these files, unless you really know what you are doing. Even in that case, it is preferred that you use CHANGE MASTER TO command. NOTE : the content of `master.info&amp;#039; overrides some options specified on the command-line or in `my.cnf&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=Copy crap=&lt;br /&gt;
Comment&lt;br /&gt;
Discussion icon some real world scenarios&lt;br /&gt;
Posted by: sjwillis at 2004-01-05&lt;br /&gt;
&lt;br /&gt;
.3 is my slave .6 is my master&lt;br /&gt;
&lt;br /&gt;
so, on .6 i:&lt;br /&gt;
&lt;br /&gt;
find -type d -maxdepth 1 &amp;gt; 6_dbase_listing&lt;br /&gt;
&lt;br /&gt;
then flush with read lock, then i edit that file to remove the . and the mysql lines&lt;br /&gt;
&lt;br /&gt;
tar -cvpf /usr/src/dbases.tar -T 6_dbase_listing,&lt;br /&gt;
&lt;br /&gt;
then i grab the master info (file name, position) and unlock tables then i scp that tarball over to the master and&lt;br /&gt;
&lt;br /&gt;
run a shell script called setup_replication.sql which populates the master.info file&lt;br /&gt;
&lt;br /&gt;
then untar the tarball and restart the slave&lt;/div&gt;</summary>
		<author><name>Eric</name></author>
	</entry>
</feed>