<?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>Coretanium &#187; MySQL</title>
	<atom:link href="http://www.coretanium.net/category/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://www.coretanium.net</link>
	<description>tech blah blah</description>
	<lastBuildDate>Tue, 29 Jun 2010 15:39:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySQL Replication</title>
		<link>http://www.coretanium.net/mysql-replication</link>
		<comments>http://www.coretanium.net/mysql-replication#comments</comments>
		<pubDate>Sun, 08 Feb 2009 23:43:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.xnetcore.com/mysql-replication/</guid>
		<description><![CDATA[MySQL database replication allows you to have an exact copy of a database on another server which allows you to setup an application to read from, i.e. auth.
All changes to the “master” server is replicated across to the “slave” server instantaneously. This is not a backup technique… any accidental DELETE queries on the master will [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL database replication allows you to have an exact copy of a database on another server which allows you to setup an application to read from, i.e. auth.</p>
<p>All changes to the “master” server is replicated across to the “slave” server instantaneously. This is not a backup technique… any accidental DELETE queries on the master will well… see for yourself. Replication can however help against hardware failure.</p>
<p>On the master server, edit my.cnf and insert the following under the [mysqld] section:</p>
<pre lang="shell">##################################################
##  REPLICATION

log-bin
binlog-do-db=pdns
binlog-ignore-db=mysql
binlog-ignore-db=test

server-id=1

##################################################</pre>
<p>The above will cause the database pdns to be replicated to our slave server and the mysql and test databases will be ignored. If you don’t need this, you can safely remove those lines. Additionally, you can specify to which file mysql should log the binary data. To do that, edit the file and set the log-bin directive to:</p>
<pre lang="shell">log-bin = /var/log/master-mysql-bin.log</pre>
<p>Save the file and restart MySQL</p>
<pre lang="shell">/etc/init.d/mysqld restart</pre>
<p>Next, connect to the MySQL CLI and add a user to be used for replication. The query below will do just fine for this.</p>
<pre lang="sql">GRANT REPLICATION SLAVE on *.* to 'replication'@172.16.0.30 identified by 'mypassword';</pre>
<pre lang="sql">FLUSH PRIVILEGES;

SHOW MASTER STATUS;</pre>
<p>Take note of of the file name and the log position, you will need to enter this information on the slave later on.</p>
<p>Next you need to grab the data from the master and import it on the slave system. Personally I prefer to just do a dump and import it at the slave, but there are other ways to accomplish this.</p>
<pre lang="shell">mysqldump -u root -p -e  pdns > pdns080209.sql</pre>
<p>On the slave system, connect to the MySQL CLI and create the database</p>
<pre lang="sql">CREATE DATABASE pdns;</pre>
<p>Next, setup the slave settings in my.cnf</p>
<pre lang="shell">##################################################
##  REPLICATION

server-id=2

master-host = 172.16.0.29
master-user = replication
master-password = mypassword
master-port = 3306

##################################################</pre>
<p>Save and exit the file then import the dump you just created on the master</p>
<pre lang="shell">mysql pdns -u root -p < pdns080209.sql</pre>
<p>Note! If the database is BIG, you will get errors, please refer to <a href="http://www.xnetcore.com/got-a-packet-bigger-than-max_allowed_packet-bytes/">this post</a> to get a workaround.</p>
<p>Once the database has been imported, restart the slave server, set the log file position and start the slave
</pre>
<pre lang="shell">/etc/init.d/mysqld restart</pre>
<pre lang="sql">SLAVE STOP;</pre>
<pre lang="sql">CHANGE MASTER TO MASTER_HOST=’172.16.0.29, MASTER_USER='replication', MASTER_PASSWORD='mypassword', MASTER_LOG_FILE='master-mysql-bin.001', MASTER_LOG_POS=73;</pre>
<pre lang="sql">START SLAVE;</pre>
<p>Next, ensure both Slave_IO_Running and Slave_SQL_Running are showing up as YES, and that’s it… your done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coretanium.net/mysql-replication/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Got a packet bigger than &#039;max_allowed_packet&#039; bytes</title>
		<link>http://www.coretanium.net/got-a-packet-bigger-than-max_allowed_packet-bytes</link>
		<comments>http://www.coretanium.net/got-a-packet-bigger-than-max_allowed_packet-bytes#comments</comments>
		<pubDate>Sun, 14 Dec 2008 23:01:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.coretanium.net/?p=102</guid>
		<description><![CDATA[ERROR 1153 (08S01) at line 3995: Got a packet bigger than &#8216;max_allowed_packet&#8217; bytes
If you get above error while importing a large MySQL dump connect to MySQL on one terminal and set:
set global max_allowed_packet=1000000000;
set global net_buffer_length=1000000;
Open another terminal and import your dump:
mysql -p < large_db_dump

]]></description>
			<content:encoded><![CDATA[<p><strong>ERROR 1153 (08S01) at line 3995: Got a packet bigger than &#8216;max_allowed_packet&#8217; bytes</strong></p>
<p>If you get above error while importing a large MySQL dump connect to MySQL on one terminal and set:</p>
<pre lang="sql">set global max_allowed_packet=1000000000;
set global net_buffer_length=1000000;</pre>
<p>Open another terminal and import your dump:</p>
<pre lang="shell">mysql -p < large_db_dump</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.coretanium.net/got-a-packet-bigger-than-max_allowed_packet-bytes/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL skip duplicate replication errors</title>
		<link>http://www.coretanium.net/mysql-skip-duplicate-replication-errors</link>
		<comments>http://www.coretanium.net/mysql-skip-duplicate-replication-errors#comments</comments>
		<pubDate>Sun, 14 Dec 2008 22:44:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.coretanium.net/?p=100</guid>
		<description><![CDATA[MySQL replication will stop if an error occurs when running a query on the slave. The reason is so you can resolve the problem, thus keeping the data consistent with the master. You can skip those errors if you know those queries and why they are failing.
Skip one query
mysql>SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;
Skip all duplicate [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL replication will stop if an error occurs when running a query on the slave. The reason is so you can resolve the problem, thus keeping the data consistent with the master. You can skip those errors if you know those queries and why they are failing.</p>
<p><strong>Skip one query</strong></p>
<pre lang="sql">mysql>SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;</pre>
<p><strong>Skip all duplicate errors</strong></p>
<p>edit my.cnf and add:</p>
<p>slave-skip-errors = 1062</p>
<p>You can skip all types of errors using the same method abobe, seperating each error code you wish to skip with a comma.</p>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html" target="_blank">http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coretanium.net/mysql-skip-duplicate-replication-errors/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
