<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Debian Tutorials &#187; replication</title>
	<atom:link href="http://www.debiantutorials.com/tag/replication/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.debiantutorials.com</link>
	<description>Copy/Paste tutorials for Debian based Linux distros</description>
	<lastBuildDate>Tue, 27 Dec 2011 01:15:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>MySql database replication (master/slave)</title>
		<link>http://www.debiantutorials.com/mysql-database-replication-masterslave/</link>
		<comments>http://www.debiantutorials.com/mysql-database-replication-masterslave/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 23:14:27 +0000</pubDate>
		<dc:creator>aip</dc:creator>
				<category><![CDATA[Lenny]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[etch]]></category>
		<category><![CDATA[lenny]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://www.debiantutorials.net/?p=125</guid>
		<description><![CDATA[In this tutorial we'll create a simple one-way master/slave database replication. You must have at least one master and one slave but you can use multiple slaves. Master 1. Configure master to listen on all ip addresses (pico /etc/mysql/my.cnf) #bind-address = 127.0.0.1 Comment out this line or remove it 2. Configure server id, log file [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial we'll create a simple one-way master/slave database replication. You must have at least one master and one slave but you can use multiple slaves.</p>
<p><strong>Master</strong></p>
<p>1. Configure master to listen on all ip addresses (pico /etc/mysql/my.cnf)</p>
<p><code>#bind-address            = 127.0.0.1<br />
</code><span id="more-125"></span></p>
<p><em>Comment out this line or remove it</em></p>
<p>2. Configure server id, log file location and which databases are allowed to be replicated (pico /etc/mysql/my.cnf)</p>
<p><code>server-id               = 1<br />
log_bin                 = /var/log/mysql/mysql-bin.log<br />
binlog_do_db            = {database}<br />
</code></p>
<p><em>Replace {database} with the one you would like to replicate</em></p>
<p>3. Restart MySql</p>
<p><code>/etc/init.d/mysql restart<br />
</code></p>
<p>4. Create a user and allow it to act as slave for this server (mysql -u root -p)</p>
<p><code>GRANT REPLICATION SLAVE ON *.* TO {username}@'{ip}' IDENTIFIED BY '{password}';<br />
FLUSH PRIVILEGES;<br />
</code></p>
<p><em>{username} = Your preferred username<br />
{password} = Your password<br />
{ip} = IP address of the slave system or % to allow all ip addresses</em></p>
<p>5. Show current log file and position (mysql -u root -p)</p>
<p><code>SHOW MASTER STATUS;<br />
</code></p>
<p>This will return something like this:</p>
<p><code>+------------------+----------+--------------+------------------+<br />
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |<br />
+------------------+----------+--------------+------------------+<br />
| mysql-bin.000004 |     2751 | {database}   |                  |<br />
+------------------+----------+--------------+------------------+<br />
</code></p>
<p><em>Keep the file name and position. It will be used later on the slave</em></p>
<p>6. Transfer data from the master to the slave</p>
<p>You can do this using various methods including exporting and importing using phpMyAdmin, creating a database dump from the master and import to the slave and "LOAD DATA FROM MASTER".</p>
<p><strong>Slave</strong></p>
<p>1. Configure this server to be a slave for the master MySql server (pico /etc/mysql/my.cnf)</p>
<p><code>server-id               = 2<br />
master-host             = {master_ip}<br />
master-user             = {username}<br />
master-password         = {password}<br />
master-connect-retry    = 60<br />
replicate-do-db         = {database}<br />
</code></p>
<p><em>{master_ip} = The ip of the master server<br />
{username} = The username you provided earlier on the master server<br />
{password} = The password you provided earlier on the master server<br />
{database} = The database you want to replicate</em></p>
<p>2. Restart MySql</p>
<p><code>/etc/init.d/mysql restart<br />
</code></p>
<p>3. Final configurations to make the slave replicate with the master (mysql -u root -p)</p>
<p><code>SLAVE STOP;<br />
CHANGE MASTER TO MASTER_HOST='{master_ip}', MASTER_USER='{username}', MASTER_PASSWORD='{password}', MASTER_LOG_FILE='{log_file}', MASTER_LOG_POS={log_position};<br />
SLAVE START;<br />
</code></p>
<p><em>{master_ip} = The ip of the master server<br />
{username} = The username you provided earlier on the master server<br />
{password} = The password you provided earlier on the master server<br />
{log_file} = Log file name from the master (ex. mysql-bin.000004)<br />
{log_position} = Log position from the master (ex. 2751)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.debiantutorials.com/mysql-database-replication-masterslave/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
