<?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>MySQL Preacher &#187; Networking</title>
	<atom:link href="http://mysqlpreacher.com/wordpress/category/networking/feed/" rel="self" type="application/rss+xml" />
	<link>http://mysqlpreacher.com/wordpress</link>
	<description>A MySQL blog, from a MySQL DBA</description>
	<lastBuildDate>Wed, 16 Jun 2010 13:13:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>mysql jdbc connector autoReconnect=true</title>
		<link>http://mysqlpreacher.com/wordpress/2010/06/mysql-jdbc-connector-autoreconnecttrue/</link>
		<comments>http://mysqlpreacher.com/wordpress/2010/06/mysql-jdbc-connector-autoreconnecttrue/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:13:15 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[autoreconnect]]></category>
		<category><![CDATA[connector]]></category>
		<category><![CDATA[ibatis]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[keepalive]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[ping]]></category>
		<category><![CDATA[wait_timeout]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=356</guid>
		<description><![CDATA[What makes you think jdbc autoreconnect is needed?
Application is idle for long periods at a time?
Wait_timeout too short?
Network failure or glitches?
Some good suggestions form Mark Matthews - Bug #5020
Having encountered the problem again myself today, trying to make jdbc for mysql reconnect any terminated connections using autoreconnect=true I figured out a way to work it [...]]]></description>
			<content:encoded><![CDATA[<p>What makes you think jdbc autoreconnect is needed?<br />
Application is idle for long periods at a time?<br />
Wait_timeout too short?<br />
Network failure or glitches?</p>
<p>Some good suggestions form Mark Matthews -<a href="http://bugs.mysql.com/bug.php?id=5020" target="_blank"> Bug #5020</a></p>
<p>Having encountered the problem again myself today, trying to make jdbc for mysql reconnect any terminated connections using autoreconnect=true I figured out a way to work it out from the pooling side.<br />
<br />
Introduction to the problem:</p>
<p>On the mysql side wait_timeout is set to default 8hrs and any connections idle for longer than that were beomg terminated despite setting the connection string to: url=jdbc:mysql://localhost:3306/dbname?autoReconnect=true. The application was thence throwing an exception.</p>
<p>The solution was to introduce a ping from the pooler which for &#8220;Ibatis&#8221;, the pooler technology used in this case, was:</p>
<p>This covers eventualities of network glitches or connections exceeding the wait_timeout having the pooler ping the database if the connection was idle for more than 10 seconds (the value is in milliseconds).</p>
<p>The configuration if Ibatis in this case is something like:</p>
<p>Ibatis<code><br />
</code></p>
<p><code></p>
<div id="_mcePaste">&lt;transactionManager type="JDBC"&gt;</div>
<div id="_mcePaste">&lt;dataSource type="SIMPLE"&gt;</div>
<div id="_mcePaste">&lt;property value="${driver}" name="JDBC.Driver"/&gt;</div>
<div id="_mcePaste">&lt;property value="${url}" name="JDBC.ConnectionURL"/&gt;</div>
<div id="_mcePaste">&lt;property value="${username}" name="JDBC.Username"/&gt;</div>
<div id="_mcePaste">&lt;property value="${password}" name="JDBC.Password"/&gt;</div>
<div id="_mcePaste">&lt;property name="Pool.PingQuery" value="select 1"/&gt;</div>
<div id="_mcePaste">&lt;property name="Pool.PingEnabled" value="true"/&gt;</div>
<div id="_mcePaste">&lt;property name="Pool.PingConnectionsOlderThan" value="3600000"/&gt; &lt;!-- 1 hr --&gt;</div>
<div id="_mcePaste">&lt;property name="Pool.PingConnectionsNotUsedFor" value="10000"/&gt; &lt;!-- ping db 10 sec --&gt;</div>
<div id="_mcePaste">&lt;/dataSource&gt;</div>
<div id="_mcePaste">&lt;/transactionManager&gt;</div>
<div></div>
<p></code></p>
<p>For every pooling technology there will be a different &#8220;Pool.PingConnectionsNotUsedFor&#8221; term, but the concept is still there. It worked like a charm.</p>
<p><code><br />
JDBC driver=com.mysql.jdbc.Driver<br />
url=jdbc:mysql://localhost:3306/dbname<br />
username=username<br />
password=password</code></p>
<p>PS &#8230; autoreconnect is not recommended when using mysql jdbc!</p>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2010/06/mysql-jdbc-connector-autoreconnecttrue/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL &#8211; IP vs DNS</title>
		<link>http://mysqlpreacher.com/wordpress/2009/12/mysql-ip-vs-dns/</link>
		<comments>http://mysqlpreacher.com/wordpress/2009/12/mysql-ip-vs-dns/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 15:39:12 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[grants]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[skip-name-resolve]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=315</guid>
		<description><![CDATA[A MySQL is running happily on a machine situated in a land far far away. I grant access to a user@machine_aaaaaa (grant select on db.* to &#8216;user&#8217;@'machine_aaaaa&#8217; identified by &#8216;password&#8217;; flush privileges;), send an email to the user saying it should run fine and happily go off my way. Mistake!
It seems this user can&#8217;t connect [...]]]></description>
			<content:encoded><![CDATA[<p>A MySQL is running happily on a machine situated in a land far far away. I grant access to a user@machine_aaaaaa (grant select on db.* to &#8216;user&#8217;@'machine_aaaaa&#8217; identified by &#8216;password&#8217;; flush privileges;), send an email to the user saying it should run fine and happily go off my way. Mistake!</p>
<p>It seems this user can&#8217;t connect to the mysql gets access denied:<br />
Access denied for user &#8216;user&#8217;@'machine_bbbbb&#8217; (using password: YES)</p>
<p>Note that the machine the user is being seen from is totally different from the one I set up in the grant!! WHY?</p>
<p>run a reverse lookup on the ip of machine_aaaaa, turns out it shows machine_bbbbb. So I figure a big bad guy messed up /etc/hosts, I was right! `cat /etc/hosts` just to find an entry for machine_aaaaa blehh</p>
<p>Ok, solution is to remove the entry from /etc/hosts (after finding out it wasn&#8217;t even necessary and wasn&#8217;t even supposed to be there in the first place), restart nscd.</p>
<p>Retry<br />
AGAIN &#8211; Access denied for user &#8216;user&#8217;@'machine_bbbbb&#8217; (using password: YES)</p>
<p>What the &#8230;.</p>
<p>What&#8217;s wrong now? &#8212; yeah silly me forgot to `flush hosts` :) </p>
<p>Retry<br />
YOHOO I&#8217;m in!</p>
<p>I&#8217;ve seen quite a few blogs about disabling name resolve in mysql with skip-name-resolve and granting privileges using IPs &#8211; something which would also have avoided the above (but still not found the root of the problem):</p>
<p><a href="http://jeremy.zawodny.com/blog/archives/011421.html">http://jeremy.zawodny.com/blog/archives/011421.html</a><br />
<a href="http://www.mysqlperformanceblog.com/2008/05/31/dns-achilles-heel-mysql-installation/">http://www.mysqlperformanceblog.com/2008/05/31/dns-achilles-heel-mysql-installation/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2009/12/mysql-ip-vs-dns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
