<?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>Phine Solutions</title>
	<atom:link href="http://www.phinesolutions.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phinesolutions.com</link>
	<description>A web log for web work</description>
	<lastBuildDate>Wed, 30 Jun 2010 16:23:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Only a developer can understand this joke</title>
		<link>http://www.phinesolutions.com/only-a-developer-can-understand-this-joke.html</link>
		<comments>http://www.phinesolutions.com/only-a-developer-can-understand-this-joke.html#comments</comments>
		<pubDate>Wed, 30 Jun 2010 16:23:17 +0000</pubDate>
		<dc:creator>1.618</dc:creator>
				<category><![CDATA[my 2 cents]]></category>

		<guid isPermaLink="false">http://www.phinesolutions.com/?p=400</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="iPhone 4 joke" src="http://i.imgur.com/uEZ1b.jpg" alt="" width="500" height="586" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phinesolutions.com/only-a-developer-can-understand-this-joke.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sending email using Google App and PHP Swift Mailer</title>
		<link>http://www.phinesolutions.com/sending-email-using-google-app-and-php-swift-mail.html</link>
		<comments>http://www.phinesolutions.com/sending-email-using-google-app-and-php-swift-mail.html#comments</comments>
		<pubDate>Wed, 23 Jun 2010 20:19:54 +0000</pubDate>
		<dc:creator>1.618</dc:creator>
				<category><![CDATA[my 2 cents]]></category>

		<guid isPermaLink="false">http://www.phinesolutions.com/?p=398</guid>
		<description><![CDATA[Not very long ago I converted one of my site to use Google App email service. Using a third party email service can reduce the load on your own server and eliminate the responsibilities of configuring and maintaining a mail server. Since it&#8217;s essentially Gmail, SMTP is supported. I paired it with Swift Mailer, the [...]]]></description>
			<content:encoded><![CDATA[<p>Not very long ago I converted one of my site to use Google App email service. Using a third party email service can reduce the load on your own server and eliminate the responsibilities of configuring and maintaining a mail server. Since it&#8217;s essentially Gmail, SMTP is supported. I paired it with <a href="http://swiftmailer.org/">Swift Mailer</a>, the free PHP mail client and the solution has been quite stable and satisfactory.</p>
<p>Until out of blue I checked the mailbox of the default mailing account: noreply@mydomain.com.</p>
<p>The mailbox is filled with undeliverable emails (which is normal), and surprisingly, a quite amount of user emails. Here is the scenario: my website has an online form that supports one to send message to an email address. So if abc@domain1.com uses the form to send message to xyx@domain2.com, an mail will be delivered to xyz@domain2.com, through Gmail using noreply@mydomain.com. Also to achieve better user experience, when Swift Mailer message is constructed, I also set the &#8220;from&#8221; address to abc@domain1.com, so when xyz@domain2.com receives the email, the message appears to be from abc@domain1.com directly. The idea is also that when xyz replies, the message goes back to abc.</p>
<p>The problem is in the replying part. You might have guessed or figured out, all the replies went back to noreply@mydomain.com. So basically all responses were lost since no one care about the noreply mailbox.</p>
<p>I looked more carefully into the email header and found the problem: the from address looks up like this: <span style="color: #800080;">abc@domain1.com&lt;noreply@mydomain.com&gt;</span>.</p>
<p>As you can see abc@domain1.com is only treated as a &#8220;display name&#8221; and actual email address is still noreply@mydomain.com. So even the from address appears to be correct in a email client, replying to the message sends the response to a black hole.</p>
<p>After identifying the problem I started to tweak the Swift Mailer message but no matter what I try Gmail will always append the noreply address in the from header. This left me in a despair mood. Other options are not good. I can write a program to automatically check the mailbox and forward those emails, or modify the message with some warning to notify the receiver not to reply directly, or just switch to a new email service. All these options are either too complicated (without a good cause), or will negatively affect user experience.</p>
<p>After some more poking around I found this email header option: &#8220;Reply-To&#8221;. If it does what its name indicates my problem can be solved by adding this header in mail messages. You might be laughing at me right now for not knowing this but before this I had never really studied email headers and I did get a load of information by trying to solve this.</p>
<p>Adding a header field is pretty easy in Swift Mailer and it worked. With the &#8220;Reply-To&#8221; header the mail client (and webmails that I tested) correctly put the right email address when replying.</p>
<p>It&#8217;s always fun to be able to solve a problem in a simple way, before going too far down the other paths. And hopefully this post can help someone else in the same boat.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phinesolutions.com/sending-email-using-google-app-and-php-swift-mail.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Plug those Javascript memory leaking holes</title>
		<link>http://www.phinesolutions.com/plug-those-javascript-memory-leaking-holes.html</link>
		<comments>http://www.phinesolutions.com/plug-those-javascript-memory-leaking-holes.html#comments</comments>
		<pubDate>Thu, 29 Apr 2010 14:55:58 +0000</pubDate>
		<dc:creator>1.618</dc:creator>
				<category><![CDATA[my 2 cents]]></category>

		<guid isPermaLink="false">http://www.phinesolutions.com/?p=367</guid>
		<description><![CDATA[Recently I built a Javascript app that uses Gmap API, Ajax and JQuery to display the location information on a web page. It retrieves information from server using Ajax and the returned json object, to display location information for certain things like business, hotel and schools on a Google map. The project is fun to [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I built a Javascript app that uses Gmap API, Ajax and JQuery to display the location information on a web page. It retrieves information from server using Ajax and the returned json object, to display location information for certain things like business, hotel and schools on a Google map. The project is fun to work on and I learned a good lessen on Javascript memory leak as well.</p>
<p>As I worked on testing and development the code in my browser, I realized the browser was getting less and less responsive. So I opened up the task manager to find out what&#8217;s going on and found out that the browser&#8217;s memory usage has been continuing growing every time I refreshed the page, and the usage wouldn&#8217;t come back. And at one point, Firefox is hogging over 600M or memory on my system. And the bad behavior is consistent across Internet Explorer and Firefox. This means if a user use the page for some extensive time he&#8217;ll have to shutdown the browser to re-claim the system memory.</p>
<p>Not a very good user experience. Being a amateur Javascript developer I don&#8217;t have a lot of insight on how the memory is managed in Javascript. As a matter of fact, it has been largely ignored in my patty little scripts before. This time I have to take it seriously. So I hit up the web to see what could have caused the Javascript memory leak.</p>
<h2>What could cause memory leaks</h2>
<p>When we talk about Javascript memory leak, we often refer to the behavior that  memory is not properly de-allocated when a web page is closed or  refreshed. Web browsers have the build-in garbage collectors to collect and release the memory when it&#8217;s not used anymore. Usually when a page is done, the browser will remove everything  created by Javascript, unless, however there are connections between  Javascript objects (variables and functions) and DOM elements.</p>
<p>Another situation should probably be better addressed as memory  management. A good Ajax app lets use to access different information while staying on the same page and in this case, the app can also eat up memory and become sluggish over the time. Although most of the time we might not notice this but a poorly written app can ramp up memory usage quickly and cause some bad user experience.</p>
<h2>In theory, what should be avoided</h2>
<p>The two biggest culprits that will cause memory leak are &#8220;Circular reference&#8221; and &#8220;closure&#8221;. Other people have written good articles about them. <a href="http://www.ibm.com/developerworks/web/library/wa-memleak/">This article</a> illustrates the problems in a relatively simple explanation. &#8220;Circular reference&#8221; is basically what I would call it &#8220;spaghetti code&#8221; in Javascript. The modern Object Oriented languages have helped reduce this kind of code, but in Javascript, it can easily happen. A simple example is to have a DOM element refers to a Javascript function (using onclick event call for example), and the Javascript function refers to the DOM element. If you used inner function in Javascript, you know what closure is. It is convenient in terms of inheriting the variables but it is also an easy way to hide the circular reference.</p>
<p>These two things probably are the source of most of the memory leaking problems. However, theories aside, I found it hard to spot the case in real code. Most of the time the code don&#8217;t really resemble the evil demos. The best way to avoid a problem is to stay away from it. So I come up with some good practices here that I believe which will be helpful to avoid problems, or at lease, minimize the risk to the lowest level.</p>
<h3>Watch the variables</h3>
<p>There are two type of variables in terms of the scope. One is declared  outside a function, with or without the var keyword; the other is  declared inside a function, WITH the var keyword. The later obviously is  supposed to live a shorter life and only be used in the function scope.  Although the first type is often referred as &#8220;global variable&#8221;, it is  not necessarily the same as the global variable in other languages  because it&#8217;s only supposed to live in the lifetime of a page.</p>
<p>The  key is &#8220;supposed to&#8221;. Since Javascript runs in browsers, it becomes  browser&#8217;s responsibility to release the memory allocated to variables  when they are not in use. To judge whether a variable is &#8220;in use&#8221;,  browser checks if there is any other reference to this object. If there  is, browser will not de-allocate it. As more activities happening the  browser will continue to take but not release any memory.</p>
<p>Because they don&#8217;t always do. Here is an scenario when &#8220;closure&#8221; is used in Javascript code. One common example for closure is using a function inside a function. But there is more. To understand more about closure, <a href="http://www.javascriptkit.com/javatutors/closures.shtml">this is a great article</a>.</p>
<p>But closure can easily cause memory leak if used like this:</p>
<p style="padding-left: 30px;">function localDocElem() {</p>
<p style="padding-left: 30px;">var elem = document.getElementById(&#8217;ClickElem&#8217;);</p>
<p style="padding-left: 30px;">elem.bind(&#8217;click&#8217;, function() { elem.innerHTML = &#8216;&lt;span class=&#8221;highlight&#8221;&gt;&#8217; + elem.innerHTML + &#8216;&lt;/span&#8217;; });<br />
}</p>
<p>This function simply attach a click event to a DOM element so whenever it is clicked the content gets &#8220;highlighted&#8221;. However, the function attached to the DOM object &#8220;elem&#8221; also uses the DOM object, hence, a circular reference is created between the DOM object and function object (in Javascript, even a function is maintained as an object) so the browser won&#8217;t garbage collect the local variable elem even after the localDocElem function returns. In this particular example, since a DOM object is connected with Javascript function, it is possible that the browser does not garbage collect either even the user leaves the page and the only way to claim the memory back is to shutdown the browser completely.</p>
<p>Consider using global variable to hold large amount of data can reduce some of the risk above. Let&#8217;s you have a Javascript that uses Ajax to to pull data from the server constantly, you can use JQuery&#8217;s $.getJson method to archive this. The returned data is better to be held in a global variable than local.</p>
<h3>Un-allocate and nullify often</h3>
<p>In a map application, lots of objects like icons, markers, etc. are created dynamically. They take memory to store and they can take up large chunk of memory quickly. It is a better practice to &#8220;nullify&#8221; them whenever they are not in use, for example, when displaying a completely different set of markers in a map view. Usually we can just assign the null value to the variable to achieve this, however for a clean de-allocation you&#8217;ll need to make sure to remove anything that is attached to them. For example, events, callback functions.</p>
<h3>Remove listeners</h3>
<p>To make an app interactive to user activities we create event listeners. Take a Gmap app example, we add click listener to an icon so when it is clicked, more detailed information is show. In some other cases, you could add a click event listener on a div element so whenever it is clicked, the background color changes. Since listeners and the function they trigger are attached to an object, you can see this is another easy case to get into the circular reference loop. In my code, a lot of listeners are created on the fly for those Gmap &#8220;markers&#8221;.</p>
<p>What I found helpful was to promptly remove the listeners when the markers are refreshed (along with the code to nullify the marker variables).</p>
<h3>Delete the dynamically generated DOM objects</h3>
<p>Often we use Javascript to create DOM elements, like &#8220;populating&#8221; a div tag on the fly. Since some browsers manage the DOM objects and script objects differently, the circular reference scenario can be easily created like discussed above. When you are done with the content and move on to something else, it might be helpful to eliminate the DOM element completely. For example, if you have update the content of a Div tag, you can empty out its inner HTML like this:</p>
<p>document.getElementById(&#8217;MyAjaxTarget&#8217;).innerHTML = &#8221;</p>
<h3>Create cleanup methods for different stages</h3>
<p>GUnload is provided as default Gmap cleanup call when the page is unload. However it is probably not enough since it is only called when a use leaves or refreshes a page. What we need to make sure is that memory is always released promptly when not in use. So I created several &#8220;cleanup&#8221; methods just to do that. The cleanup methods can include everything talked above, and they are called whenever needed in the code flow.</p>
<p>In summary, while Javascript enables us to enrich the user experience it can also do just the opposite if not done correctly. Although the modern browsers are doing much better jobs today to manage the Javascript garbage collection, we still need to do our due diligence to develop the code that are not only fancy, but also &#8220;responsible&#8221; to our users.</p>
<p>Here is the link of my <a href="http://www.findmyroof.com/citypedia/ca/beverly-hills?Neighborhood">Google map app</a> if you are interested.</p>
<p>If you have a good tip to help better manage memory usage in a Javascript, please share your comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phinesolutions.com/plug-those-javascript-memory-leaking-holes.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>When do we need &#8220;smooth scrolling&#8221;</title>
		<link>http://www.phinesolutions.com/when-do-we-need-smooth-scrolling.html</link>
		<comments>http://www.phinesolutions.com/when-do-we-need-smooth-scrolling.html#comments</comments>
		<pubDate>Mon, 05 Apr 2010 14:58:30 +0000</pubDate>
		<dc:creator>1.618</dc:creator>
				<category><![CDATA[usability design]]></category>

		<guid isPermaLink="false">http://www.phinesolutions.com/?p=389</guid>
		<description><![CDATA[Recently I discovered this little javascript hidden gem: smooth scrolling to an anchor link on the same page.
Basically it creates smooth scrolling effect when a user clicks on an anchor tag that points to a different part of a page, mostly likely a very long page. Often times, in this kind of situation, the page [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I discovered this little javascript hidden gem: <a href="http://www.kryogenix.org/code/browser/smoothscroll/">smooth scrolling to an anchor link on the same page</a>.</p>
<p>Basically it creates smooth scrolling effect when a user clicks on an anchor tag that points to a different part of a page, mostly likely a very long page. Often times, in this kind of situation, the page jumps so quick that I have to look for the URL in the browser&#8217;s address bar to see if I&#8217;m still on the same page. And for a lot of users, this can be confusing sometimes. This little script, once included in the &#8220;head&#8221; tag, will make this kind of scrolling go slower. Although It&#8217;s still a pretty fast scrolling motion, it slows down enough to make user aware that he is being redirected to a different section on the same page.</p>
<p>Another benefit of the approach is that the scrolling subtly reveals the other part of the page as well, which is a nice way to encourage user to explore other part of the page.</p>
<p>Typically I&#8217;m not a big fan of implementing fancy but less practical effects on a web page using javascripts. They do have a cost to load and for most of the users, visual effects wear out after the initial &#8220;oohs and ahs&#8221;. However, this one is a great implementation to address an issue that is too trivial for browser but valuable for web designers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phinesolutions.com/when-do-we-need-smooth-scrolling.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build your own Linux VPS</title>
		<link>http://www.phinesolutions.com/build-your-own-linux-vps.html</link>
		<comments>http://www.phinesolutions.com/build-your-own-linux-vps.html#comments</comments>
		<pubDate>Fri, 26 Feb 2010 16:57:36 +0000</pubDate>
		<dc:creator>1.618</dc:creator>
				<category><![CDATA[server setup]]></category>

		<guid isPermaLink="false">http://www.phinesolutions.com/?p=345</guid>
		<description><![CDATA[5 years ago if you ask me to build my own Linux VPS for my websites I would&#8217;ve shaken my head and said it was too much for a non-sysadmin like me. Now I&#8217;m pretty comfortable of doing it. I want to share my thoughts in this post and hopefully it can be useful to [...]]]></description>
			<content:encoded><![CDATA[<p>5 years ago if you ask me to build my own Linux VPS for my websites I would&#8217;ve shaken my head and said it was too much for a non-sysadmin like me. Now I&#8217;m pretty comfortable of doing it. I want to share my thoughts in this post and hopefully it can be useful to other web builders.</p>
<p>When I first started I put my websites on shared hosting servers. While it was cheap and easy to setup you often don&#8217;t get the best performance on your dollar. This is especially true when your site gets more traffic and you are anal about the downtime like me. Until I discovered VPS. VPS is a great solution to move up from shared hosting. Having a VPS server means you have full control over a virtual host so you can install and configure the way you like; also, because using VPS means &#8220;renting&#8221; a slice of a physical server, someone else takes care about the racking, networking and hardware maintenance.</p>
<p>There are generally two types of VPS. One is &#8220;managed&#8221; and the other is obviously, &#8220;un-managed&#8221;. &#8220;managed&#8221; in this case means the service provider will help you install apps, trouble shoot, and in some cases, walk you step by step to help you resolve an issue, as long as you ask. And often times you have a full web based system control panel, like &#8220;CPanel&#8221; installed for you. The later case, apparently, don&#8217;t have this kind of service. You are basically given a barebone server and you are on your own. As you can see a managed service will be more costly.</p>
<p>I started with managed VPS. But as my Linux skill gets better the &#8220;managed part&#8221; of the service becomes less and less necessary. CPanel is a great tool but it also a big resource consumer itself. Sometimes you might find most of your system resource is consumed by addons, not the main apps like web server or the database.</p>
<p>To grow out of a managed service the key is to try and learn. for example, if you choose to stay on CPanel forever (not that there is anything wrong with it:)), you&#8217;ll stay on it for ever. To take the leap you need to be ready for it. It took me sometime to get to the comfort level that I&#8217;m at now. During which, I found a number of guidelines that I begin to follow.</p>
<h2>Keep a good and updated server diary</h2>
<p>I think this is the first thing to do when you start handle your own server. A good server diary can not only help you trouble shoot, it&#8217;s also a good reference when you need to re-install, upgrade, or in some less frequent cases, move to new service provider.</p>
<p>Like any other service you buy, hosting service provider&#8217;s service quality can go down too. You pretty much don&#8217;t have any other choices except voting with your feet. A good service log can make changing host a lot easier. Recently when I switched my VPS provide, it only took me a few hours to stand up full services on a brand new VPS host. The process also forced me to refresh and update my server diary.</p>
<h2>Utilize the external services</h2>
<p>To host a website on VPS, we have to install pretty much everything ourselves. They include at least Apache web server, PHP and MySQL. However, besides the basic LAMP stack, we also need to take care of services like DNS, email service. To keep your admin work as simple as possible, I strongly recommend outsourcing DNS or email to external service provider. For DNS, there are lots of options. I use dnsmadeeasy.com. For only a few dallors a month, you are completely shielded from managing your DNS app. Although you still need to understand what a &#8220;cname&#8221; is and how to change the DNS record to point your web site to the correct ip, you have a much much smaller learning curve.</p>
<p>Email is another service that can get quite complex. I found using Google App&#8217;s email service makes a lot of sense. Since their email service is based on Gmail, the IMAP , effective Spam filter and web access are all included naturally. Without the email server and SmapAssasin taking up resource on your server, your server is also better optimized. Google Apps has both free and paid version. Another benefit of using reputable external email service is the trust level you gain for your emails. A lot of my users who use Yahoo mail couldn&#8217;t receive message because they were marked spam. But since I started using Gmail service it has been a lot better.</p>
<p>If your web site has a lot of user generated content like photos, you may also consider using the cloud storage like Amazon AWS. I&#8217;m generally against building your site completely depending on the cloud but it <a href="http://www.phinesolutions.com/a-follow-up-on-using-amazon-aws.html">another subject</a>.</p>
<h2>Install from source</h2>
<p>I know this is quite a debatable subject. Installing application from source doesn&#8217;t always give you the type of control that you can have using the packaging tools. However, there are several benefit that can&#8217;t be overlooked.</p>
<p>First, you have the full control on the binary and you can build the exact binary that you want. For example, when building your own PHP binary, you can specify the features you want to enable to have a small footprint. Same can be applied to Apache httpd server. This will directly impact the memory usage of your web server.</p>
<p>Secondly if you are accustomed to source installation you will not need to hunt around for the latest RPM or whatever installation package that built by someone else. You can stay updated with the latest version of software. Since the same procedure can be universally applied to all the Linux distros you are less likely to be affected by the different packaging tool that different Linux distro offers.</p>
<p>And lastly, it&#8217;s really not that hard to do.</p>
<h2>Some basic steps</h2>
<p>With a brand new VPS, there are some basic setups that have to be run to ensure the security and basic usability. Your VPS service provider will configure your VPS to a certain degree before handing over so you might need to look into the system configuration like partitioning before proceeding to the steps below.</p>
<h3>Update system information</h3>
<div style="text-align: left;">When your new server is up and running, you&#8217;ll need to update the host name:</div>
<blockquote>
<div style="text-align: left;">echo &#8220;mynewserver.com&#8221; &gt; /etc/hostname</div>
<div style="text-align: left;">hostname -F /etc/hostname</div>
</blockquote>
<div style="text-align: left;">And don&#8217;t forget updating the hostname variable in /etc/sysconfig/network file</div>
<div style="text-align: left;">Also update the system time:</div>
<blockquote>
<div style="text-align: left;">ln -sf /usr/share/zoneinfo/US/Eastern /etc/localtime</div>
</blockquote>
<h4>Create users</h4>
<p>Adding users is the second must.</p>
<blockquote>
<p style="background-color: #ffffff; margin-left: 0pt; margin-right: 0pt; text-align: left;">groupadd johndoe</p>
<p style="background-color: #ffffff; margin-left: 0pt; margin-right: 0pt; text-align: left;">useradd -d /home/johndoe -g johndoe -p johndoespassword</p>
</blockquote>
<p style="background-color: #ffffff; margin-left: 0pt; margin-right: 0pt; text-align: left;">To create user &#8220;apache&#8221; for your web server you&#8217;ll need the following command:</p>
<blockquote>
<div>groupadd apache</div>
<div>useradd apache -c &#8220;Apache Server&#8221; -d /dev/null -g apache -s /sbin/nologin</div>
</blockquote>
<h4>Turn off the unnecessary services</h4>
<div>By default you&#8217;ll have some services up and running. You want to turn them off.</div>
<div>This is the command to show who is up:</div>
<blockquote>
<div>chkconfig &#8211;list | grep 3:on</div>
</blockquote>
<div>This is the command to turn one off</div>
<blockquote>
<div>chkconfig &lt;service name&gt; off</div>
</blockquote>
<div>Also, make sure double check who is listening on what port. On my servers, I only leave ports for sshd, httpd, mysqld and a few others.</div>
<blockquote>
<div>netstat -an</div>
</blockquote>
<h4>Secure SSH</h4>
<p>You want to turn off the root access:</p>
<blockquote>
<h4>/etc/ssh/sshd_config file, set this: PermitRootLogin no</h4>
</blockquote>
<p>Also you want to set up <a href="http://www.phinesolutions.com/ssh-using-publicprivate-key-authentication.html">public/private key authentication</a>.</p>
<p>I would also recommend changing the port from 22 to something else.</p>
<h4>Set up a firewall using iptables</h4>
<p>If you are reading this article you probably know what iptables is. The tricky part is how to configure it. A few years ago I went a great length to learn what tables and chains are and how to set up a shell script to configure an iptables firewall. The problem was I soon forgot what I had learned since configuring iptables is not something I do on a daily basis for a developer like myself. And guess what, I locked myself out on my first try in a new server.</p>
<p>Luckily there are tools today which wraps around iptables and expose an easy to use configuration interface. This makes the life a lot easier for me. APF is what I use and the project page can be found here: <a href="http://www.rfxn.com/projects/advanced-policy-firewall/">http://www.rfxn.com/projects/advanced-policy-firewall/</a>.</p>
<h4>Install some utilities, compiler and libraries</h4>
<p>I only use CentOS/Redhat system as example and yum is my command of choice for packaging tool. Again they are just basic tools and libraries for installing Apache, PHP so others might need to be installed as well. But the key again, is to keep a good log of what has been installed so you have a good reference when you build your next server.</p>
<blockquote>
<div style="text-align: left;">yum install man</div>
<div style="text-align: left;">yum install vixie-cron</div>
<div style="text-align: left;">yum install wget</div>
<div style="text-align: left;">yum install rsync</div>
<div style="text-align: left;">yum groupinstall &#8216;Development Tools&#8217;</div>
<div style="text-align: left;">yum install mailx</div>
<div style="text-align: left;">yum install zlib-devel</div>
<div style="text-align: left;">yum install openssl-devel</div>
<div style="text-align: left;">yum install libxml2-devel</div>
<div style="text-align: left;">
<div>yum install curl</div>
<div>yum install curl-devel</div>
<div>yum install libjpeg-devel</div>
<div>yum install libpng-devel</div>
<div>yum install mysql-devel</div>
<div>yum install libxslt-devel</div>
<div>yum install libmcrypt</div>
<div>yum install libmcrypt-devel</div>
<div>yum install libevent</div>
</div>
<div>yum install libevent-devel</div>
</blockquote>
<h4>Install applications</h4>
<p>Now it comes the time to install your beloved apps. One thing to remember if you install from source is to create script in /etc/init.d and add the service entry. For example after installing Apache http server, you need to add the httpd startup/shutdown script to /etc/init.d and add it to your service list:</p>
<blockquote>
<div>chkconfig &#8211;add httpd</div>
<div>chkconfig &#8211;levels 235 httpd on</div>
</blockquote>
<h4>Install a MTA</h4>
<div>It&#8217;s likely that your web site needs to send emails so you probably need an MTA to talk to your external email server through SMTP for message delivery. If the system comes with Sendmail installed, I&#8217;ll go ahead use it. Here is a post I wrote to <a href="http://www.phinesolutions.com/sendmail-gmail-smtp-relay-howto.html">get sendmail work with gmail</a>. There are other options like postfix, exim and qmail that you can consider. Here is a good article on <a href="http://shearer.org/MTA_Comparison">MTA comparison</a>. Although there are lots of pros and cons that you can munch on I think the most important thing to consider is which one is the easiest for you. With the latest development they are all very capable products so anyone of them can deliver your need.</div>
<div>This is quite a long-winded post. I don&#8217;t mean to write a tutorial but just want to cover some basics on building a Linux VPS (or dedicated server in this matter). A few years ago it was almost unthinkable for me that all these kind of things can be done by one person, but as the tools, technology and information become more available and easier to find, it is quite feasible now. I hope the post can be a good start for us web builders who are interested in setting up their own server. And please do leave your comment if you have any thoughts, tips or suggestions.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.phinesolutions.com/build-your-own-linux-vps.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hosting short list &#8211; updated Jan 2010</title>
		<link>http://www.phinesolutions.com/hosting-short-list.html</link>
		<comments>http://www.phinesolutions.com/hosting-short-list.html#comments</comments>
		<pubDate>Mon, 25 Jan 2010 13:30:29 +0000</pubDate>
		<dc:creator>1.618</dc:creator>
				<category><![CDATA[web site hosting]]></category>

		<guid isPermaLink="false">http://www.phinesolutions.com/hosting-short-list.html</guid>
		<description><![CDATA[Update
This is an old post with some new information. Since I just shuffled my sites around a little bit this week I want to do some update to reflect that.
When I put my first website on the Internet I picked one that only to be mediocre, to say the least. With the growing number of [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong></p>
<p>This is an old post with some new information. Since I just shuffled my sites around a little bit this week I want to do some update to reflect that.</p>
<p>When I put my first website on the Internet I picked one that only to be mediocre, to say the least. With the growing number of my sites and the real need for the site up-time and service quality, upgrading my hosting company is a necessity.</p>
<p>I was pretty much blind in the hosting world and had to do a lot of research to and listen to what other webmasters say about the hosting and learn from their experiences. webhostingtalk.com is still the place I go to for research and opinions.</p>
<p>I guess a good hosting company should just offer the solid service and let you forget about them. If I often have things like &#8220;what the @#$% is going on with company blah and what happened to my supporting ticket&#8230;&#8221; popping up in my mind it certainly not a good thing. Also see my post about &#8220;<a href="http://www.phinesolutions.com/5-signs-you-should-start-planning-changing-hosting.html">5 signs you should start planning changing your hosting company</a>&#8220;.</p>
<p>Based on my experience I have compiled a short list of hosting companies in different arena. Hopefully it can help someone in the same shoes to get started.</p>
<p><strong> </strong></p>
<h2><strong>Shared hosting</strong></h2>
<h3><em>hostgator.com</em></h3>
<p style="padding-left: 30px;">This is the new home that I&#8217;ll move most of my sites to. I chose the &#8220;Business&#8221; plan which costs $12 per month. I purchased a 2 year plan with 20% discount. So far the moving has been pretty smooth. Here are some observations:</p>
<blockquote>
<ul>
<li>Hostgator offers cpanel. I like cpanel.</li>
<li>In shared hosting plans, ssh can only be accessed on port 2222. ssh in your box you&#8217;ll get a jailed shell. And from hostgator box, you can&#8217;t ssh out. This caused me a little bit of inconvenience but not a huge deal.</li>
<li>Adding new domains doesn&#8217;t cost me.</li>
<li>$50 adwords credit is a nice touch.</li>
</ul>
</blockquote>
<h3><em>Pair Networks &#8211; pair.com</em></h3>
<blockquote><p>A truly fantastic company. Solid service and support.  One thing worth to note is that their MySQL server runs on different boxes (physical or virtual), this really isolate the issues that come across between Apache and MySQL.</p>
<p>Pair supports both PHP4 and PHP5. Since PHP5 runs in CGI mode all you need to do is to put an executable PHP wrapper in the CGI-BIN directory and make the proper configuration change in your .htaccss file.</p>
<p>However they do not provide cpanel&#8230;not sure if this is out of the consideration of the high resource usage of cpanel. If you start off a serious site and want some top notch shared hosting service I would strongly recommend Pair.com.</p>
<p>Update: I moved one of my forum site (vbulletin) over to Pair and it has been 2 monthes without any problem. Two thumbs up.</p>
<p>Although Pair is the best shared hosting service that I&#8217;ve ever had, I do want to point out that they&#8217;ll charge a $5 installation fee on every domain that you add to your account. This may hurt a little if you frequently add/remove domain from your account, which apparently they discourage.</p>
<p>I have recently decided to move my pair hosted sites away. The biggest reason is that their database server connectivity has been very inconsistent recently. I have 5 sites on the server (max out) and there is always one of them that have problem to connect to the DB server. I&#8217;m not sure if this has anything to do with vBulletin, or pair&#8217;s separate DB server architecture. But continue receiving emails about DB connection problem broke your trust sooner or later. Another reason is that I want to save some money.</p></blockquote>
<h3>PairLite</h3>
<p style="padding-left: 30px;">Pairlite (pairlite.com) is a brand under Pair. It offers hosting plans with lower cost than pair. I have some sites hosted on pairlite but I won&#8217;t renew the lease with them. The limitation of the number of domains and databases you can have is really a show stopper.</p>
<h3><em>Bluehost.com </em></h3>
<blockquote><p>I have a few sites hosted with bluehost.com and haven&#8217;t had much complaint so far. One thing I do wish to have is to have the capability to run both PHP4 and PHP5 in one single account, and currently this is not possible at Bluehost.</p>
<p>Just a few days back I received a email from bluehost.com stating that they will need to remove all the &#8220;catch-all&#8221; email accounts to reduce the server load from the spam. And a few days later another email came and canceled this plan. According to bluehost it was apparently due to the customer feedback.</p>
<p>On Jan 18th I received a email announcement from Bluehost President Matt Heaton about the new changes on Bluehost servers for better performance. Some more observations need to be done to see the actual effect on my sites hosted by Bluehost. As a customer I do like their effort of constant improvement.</p>
<p>On Feb. 22 one of my sites hosted by bluehost.com went down for almost 10 hours. The server was down and I am guessing it was some hardware failure and they had to do a whole lot to make it back on line. There was no explanation given after the incidence and I figured even I asked I would probably just get some general answers. NOT a good sign for me.</p>
<p>The bluehost service has been pretty stable lately. One thing I&#8217;d like to brought up about their web supporting system. It appears one can log a ticket even without creating an account, but based on my experience, there will be no response to the ticket created this way.</p>
<p>Incident:</p>
<p>It appears the database hasn&#8217;t been quite stable recently and I have a few occasions that DB was not accessible. I emailed the support in one case, and DB was back up later. Next day an email arrives, from support, and ask more detail about how I use DB, what error I saw, blah blah&#8230;</p>
<p>On Dec.26 my site at Bluehost stopped responding again. It took about 5 hours to get back online and none of my two support tickets got a single response except the automatic message. Maybe one of the site on the same server is a E-Comm site? Who knows. But at this point I am very disappointed with Bluehost and I don&#8217;t recommend using it.</p>
<p>I have stopped using Bluehost.</p></blockquote>
<h3><em>Dreamhost.com</em></h3>
<blockquote><p>A hosting company with a fairly good reputation. It seems so hard to find a company that has no gripe from someone, and dreamhost is not an exception.<br />
I started to use Dreamhost this year. The experience has been good so far.</p>
<p>I still have some sites on Dreamhost but I&#8217;m not planning to continue that when the lease is up. The disastrous incident happened earlier in 2009 really hurt my confidence on them.</p></blockquote>
<h3><em>Lunarpages.com</em></h3>
<blockquote><p>Can&#8217;t say I have a lot of experience with the company but once I did buy the basis hosting plan for 12 months and later found out the plan doesn&#8217;t include the SSH access. I cancelled the plan and it was quite simple with their 30 day money back ganrantee feature. It was totally my fault and their support was great on this matter.</p>
<p>So I didn&#8217;t have a chance to use their supporting system. Anyway, it is a company scores a lot of good reviews. My own little experience adds point to this company too.</p></blockquote>
<h2><strong>VPS</strong></h2>
<h3><em> Linode and Slicehost</em></h3>
<blockquote><p>I put these two together not because they are affiliated. As a matter of fact, they are rivals in VPS business and their competition brings out the best of each other.</p>
<p>One thing I want to put in front first is that they are not &#8220;managed VPS&#8221;. So if you need help to get around in Linux, or rely on sophisticated control panels like CPanel they are probably not for you.</p>
<p>Both of them are very very solid. I just built a couple of &#8220;nodes&#8221; in Linode and am getting ready to make the move from my previous VPS and I was very happy with the experience.</p>
<p>Which one to choose really depends on your own situation. Just search &#8220;Linode or Slicehost&#8221; you should get a lot of comparisons online.</p></blockquote>
<h3><em>servint.com</em></h3>
<blockquote><p>I use its VPS for a couple of my sites.<br />
Since I am not in the reseller or hosting business I don&#8217;t fully utilize tools like Cpanel so my review has some limited perspective.<br />
So far I have been very satisfied with servint&#8217;s service. I bought the Essential VPS package and it was setup in a couple of days. I did have an inquiry about the status and the response was prompt.</p>
<p>With the growth of the site the server started to slow down. I upgraded by VPS and still saw load average constantly over 1.00 mark.  This is when great support can really help. I email the support and Tommy quickly adjusted a setting of mysql configuration and the server started to fly again. This also prompted me to look into my.cnf file more carefully and make necessary tweaking.</p>
<p>Fully managed VPS != holding hands on everything. But Servint&#8217;s tech support has been great with their knowledge.</p>
<p>As of Oct 2009 I&#8217;m still with servint, and I have two VPSes with them now. Rock solid service so far.</p>
<p>Well, servint just got a little bit less solid today.</p>
<p>On 11/04 I found out one of my VPS is down. Pinged the support and here is the answer:</p>
<p><span style="color: #0000ff;"><strong>From support:</strong><br />
Your host node experienced a kernel panic that required a reboot. We apologize for the inconvenience and will post here if more information is available. If you experience any problems after your VPS has come back up, please open a portal ticket and we will investigate.</span></p>
<p><span style="color: #3366ff;">30 minutes passed&#8230;<br />
<strong>From me:</strong><br />
Do you have a ETA for the server reboot?</span></p>
<p><span style="color: #3366ff;"><strong>From support:</strong><br />
The host machine is still being worked on. I don&#8217;t have an ETA at this time, but we are trying to get the server back up as soon as possible.</span></p>
<p><span style="color: #0000ff;"><span style="color: #000000;"> </span><span style="color: #000000;">My bet is that there is some kind of hardware failure. I hate hearing this kind of &#8220;standard&#8221; response though. Reminds me the way commercial airlines treating their passengers. </span></span></p>
<p><span style="color: #0000ff;"><span style="color: #000000;">On a different note, servint is expanding to west coast and setting up data center in LA. Usually expansion spreads certain area thinner. I hope this expansion is not going to result in some service deterioration. Fingers crossed.<br />
</span></span></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.phinesolutions.com/hosting-short-list.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SMF to IPB conversion</title>
		<link>http://www.phinesolutions.com/smf-to-ipb-conversion.html</link>
		<comments>http://www.phinesolutions.com/smf-to-ipb-conversion.html#comments</comments>
		<pubDate>Mon, 18 Jan 2010 15:04:45 +0000</pubDate>
		<dc:creator>1.618</dc:creator>
				<category><![CDATA[programming in general]]></category>

		<guid isPermaLink="false">http://www.phinesolutions.com/?p=337</guid>
		<description><![CDATA[I just converted a SMF board (1.1.7) to IPB and there is some issues that I ran into that is worth to be shared.
If you have installed IPB you probably understand how the converter works. It&#8217;s a separate &#8220;app&#8221; that needs to be installed and the there is document to address how to use it. [...]]]></description>
			<content:encoded><![CDATA[<p>I just converted a SMF board (1.1.7) to IPB and there is some issues that I ran into that is worth to be shared.</p>
<p>If you have installed IPB you probably understand how the converter works. It&#8217;s a separate &#8220;app&#8221; that needs to be installed and the there is document to address how to use it. Basically on the admin converter page you are presented with several steps that need to be preformed, each one of them is specifically for converting some kind of data, such as &#8220;members&#8221;, &#8220;forums&#8221; etc. The problem I had was in the forum conversion step.</p>
<p>My original SMF board had a pretty simple forum structure: one main category, and a bunch of forums under it. It&#8217;s a pretty good mapping to IPB. However the converter refused to convert the sub forums, and only took the single top category in. Naturally not much information about this behavior can be found online because of the small user community of IPB, so I opened the converter code and took a peek.</p>
<p>Here is the problem I found:</p>
<p>Starting on line 608, in admin/applications_addon/ips/convert/modules_admin/board/smf_legacy.php file, is the code which loops through the existing forums and puts them into the new IPB database. The problem, as you can see in the code below, is that a &#8220;$loop&#8221; variable is built using the database result (fetched in the first while loop) but is never used later on. A few lines below, a second &#8220;fetch&#8221; is done in the second while loop to get the records. And based on my test, the second while loop never retrieves anything back.</p>
<blockquote><p>$i = 1;<br />
while ( $row = ipsRegistry::DB(&#8217;hb&#8217;)-&gt;fetch() )<br />
{<br />
$records[] = $row;<br />
}<br />
$loop = $records;<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
// Loop<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
while ( $row = ipsRegistry::DB(&#8217;hb&#8217;)-&gt;fetch($this-&gt;lib-&gt;queryRes) )</p></blockquote>
<p>I&#8217;m not sure the fact that the second while loop returning empty is the correct behavior of database API, or simply just a bug. But regardless of the reason, the first while loop to build the variable seems to be redundant and mostly likely was for the debugging purpose in the first place.</p>
<p>Once the cause was identified the issue was easy to fix. Just replace the second while loop with this:</p>
<blockquote><p>foreach ($loop as $row)</p></blockquote>
<p>Which basically use the previously built &#8220;$loop&#8221; variable for the cycle. And the SMP forums should be happily converted by IPB.</p>
<p>Keep in mind a lot can go wrong when converting boards between different software, especially from the one that has a lot of customizations. Hopefully this post provides some insight on troubleshooting the script.</p>
<p>The above issue is for IP.Board 3.0.5 only.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phinesolutions.com/smf-to-ipb-conversion.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>vBulletin 4.0 vs. IPB 3</title>
		<link>http://www.phinesolutions.com/vbulletin-4-0-vs-ipb-3.html</link>
		<comments>http://www.phinesolutions.com/vbulletin-4-0-vs-ipb-3.html#comments</comments>
		<pubDate>Sun, 03 Jan 2010 15:55:07 +0000</pubDate>
		<dc:creator>1.618</dc:creator>
				<category><![CDATA[my 2 cents]]></category>

		<guid isPermaLink="false">http://www.phinesolutions.com/?p=325</guid>
		<description><![CDATA[One of the big events in the forum software world this year is the release of vBulletin 4.0. As a license owner I took the pre-sale bait and purchased a new license for vb 4.0. The software looks not bad to me after I installed it on a test domain. CMS and Blog are nice [...]]]></description>
			<content:encoded><![CDATA[<p>One of the big events in the forum software world this year is the release of vBulletin 4.0. As a license owner I took the pre-sale bait and purchased a new license for vb 4.0. The software looks not bad to me after I installed it on a test domain. CMS and Blog are nice additions. HTML table tags are gone. Although themes created for 3.x.x will no longer work and have to be completely re-done it didn&#8217;t make much difference on what I wanted to do.</p>
<p>After I dig into it a bit deeper this new concept of &#8220;StyleVar&#8221; really got into my head. It is as tedious to work on as it can be. So I hit up on the internet and see if there is any tips or tricks that I can use. Surprisingly all I got were complaints on VB 4.0. There seemed to be a lot of negative sentiment against Vb, specifically the 4.0 release.</p>
<h3>Some mostly talked about complaints are:</h3>
<ul>
<li>Expensive and confusing upgrade pricing.</li>
<li>Skins created for 3.x.x versions need to be re-done completely in 4.0.</li>
<li>No significant changes in 4.0 and the code base is quite bloated.</li>
<li>The &#8220;Gold&#8221; release is still buggy.</li>
</ul>
<p>As I sip through these and figuring I probably made a mistake purchasing 4.0 license I found Invision Power Board was being mentioned by a lot of people and got a lot of nice reviews too.</p>
<p>So I decided to give IPB a try. IPB offers a free 24 hour demo account and signing up was quite easy. After a little play around I was totally impressed by IPB 3.0.</p>
<h3>What I really like about IPB 3.0:</h3>
<ul>
<li>The demo capability upfront.</li>
<li>The modular design approach. The IP.Board, Blog and Gallery are individual components that can be installed separately. Now this might not sound like a benefit for most of the people but to achieve this feature the code but be designed well from the ground up.</li>
<li>Powerful templates. The template design in IPB is very powerful, it contains variables and logics (such as if for foreach statements) and can take PHP code block directly. For lot of the board admin who don&#8217;t have the technical skills this might be a bit of difficult to manage but developers will like it.</li>
<li>IP.Converge, which provides a nice framework for the Single Sign On solution that I have been looking for for a long time.</li>
<li>The more advanced features like OpenId, Facebook integration and API capability.</li>
<li>Skinning IPB. Since I develop using HTML and CSS the approach that IPB takes feels easier.</li>
</ul>
<h3>What I don&#8217;t like:</h3>
<p>Based on my personal experience the quality of documentation is a bit lacking. Part of the reason for this is that comparing with VB, IPB still has a small developer community. The IPB developer community hasn&#8217;t been as much active as VB&#8217;s, in terms of participating development discussions, writing tutorials etc. So if you have a question it takes a bit more researching and digging around.</p>
<h3>Yes I switched to IPB 3.0.</h3>
<p>Forum softwares have been powering the web for a long time but as new things emerge forums need to adapt too. It is a lot harder to run a forum board these days because of the low barrier to entry &#8211; a lot more forums are online these days &#8211; and competition from social network sites. This demands higher standard on forum software. Looking forward IPB has a lot to gain in the paid forum software market.</p>
<p>That being said vBulletin is still the most popular forum software at the time being. But it has been sitting on its own success for too long. Unfortunately its own success may be the biggest obstacle toward bigger and bolder innovation. The new 4.0 version is definitely an improvement but the change fell short. From what I gather most of the existing board admin chose to stay on version 3 and IPB 3 has become a serious choice for those who needs new forum software. So now it really is a do or die moment for VB and the vb team needs to get their act together to come up with a better next generation release to stay in competition.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phinesolutions.com/vbulletin-4-0-vs-ipb-3.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>What newspaper and magazine publishers can do to save their business</title>
		<link>http://www.phinesolutions.com/publisher-should-give-out-tablet.html</link>
		<comments>http://www.phinesolutions.com/publisher-should-give-out-tablet.html#comments</comments>
		<pubDate>Thu, 31 Dec 2009 17:10:14 +0000</pubDate>
		<dc:creator>1.618</dc:creator>
				<category><![CDATA[my 2 cents]]></category>

		<guid isPermaLink="false">http://www.phinesolutions.com/?p=331</guid>
		<description><![CDATA[The publishers have been losing their print business from left to right. Now with the 2010 approaching I think they are just going to get a golden opportunity to save their business.
Rumors on the street is that Apple will release its tablet device in 2010. Whatever it will be called it should be capable to [...]]]></description>
			<content:encoded><![CDATA[<p>The publishers have been losing their print business from left to right. Now with the 2010 approaching I think they are just going to get a golden opportunity to save their business.</p>
<p>Rumors on the street is that Apple will release its tablet device in 2010. Whatever it will be called it should be capable to get online and be used as a nice reading device since it is larger than a smart phone. And more importantly, it will set out a trend on more of the similar ones and cheaper ones to be built. What publishing companies can do is to build apps that work best on these devices to display their contents and sell subscriptions. However that is not enough. What they need to do is to give out devices for free (or close to free) like wireless companies do with their cellphones.</p>
<p>I suspect a lot of consolidation will also take place in the near future. As a result, stronger ones become content distributors. A tablet that can be used best as a &#8220;reader&#8221; is probably the best medium for the future content distribution.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phinesolutions.com/publisher-should-give-out-tablet.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL replication problem</title>
		<link>http://www.phinesolutions.com/mysql-replication-problem.html</link>
		<comments>http://www.phinesolutions.com/mysql-replication-problem.html#comments</comments>
		<pubDate>Thu, 17 Dec 2009 02:25:20 +0000</pubDate>
		<dc:creator>1.618</dc:creator>
				<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.phinesolutions.com/?p=322</guid>
		<description><![CDATA[My MySQL replication slave stopped replicating the master. Checked the log file it has this error:
Error reading packet from server: log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master (server_errno=1236)
Got fatal error 1236: &#8216;log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master&#8217; from master when reading data from binary log
Naturally I started increasing the max_allowed_packet in my.cnf. No help. [...]]]></description>
			<content:encoded><![CDATA[<p>My MySQL replication slave stopped replicating the master. Checked the log file it has this error:</p>
<blockquote><p>Error reading packet from server: log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master (server_errno=1236)</p>
<p>Got fatal error 1236: &#8216;log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master&#8217; from master when reading data from binary log</p></blockquote>
<p>Naturally I started increasing the max_allowed_packet in my.cnf. No help. So I looked up the web and found this <a href="http://bugs.mysql.com/bug.php?id=19402">bug documented</a>. Bingo I thought&#8230;oh wait, the bug was discovered a few years back and my version of MySQL should have included the fix already. Ok back to square one.</p>
<p>Just to poke around I ran &#8220;show master status&#8221; on the master server and compare bin file name and position with what&#8217;s in the logs on slave server. The files do not match. It may or may not cause the error 1236 but it&#8217;s definitely not right. So I went ahead ran the following command to re-sync:</p>
<p>On the slave:</p>
<p><em>mysql -u root -pxxxxx</em></p>
<p><em>SLAVE STOP</em></p>
<p><em>LOAD DATA FROM MASTER</em></p>
<p><em><span style="font-size: x-small; padding: 0px; margin: 0px;">CHANGE MASTER TO</span><span style="font-size: x-small; padding: 0px; margin: 0px;"> MASTER_LOG_FILE=&#8217;the-right-bin.xxx&#8217;, MASTER_LOG_POS=the-right-position;</span></em></p>
<p><em>SLAVE START</em></p>
<p>Now step two to load data from mater created a lot of error logs since my slave DB had had data so I really should have clean up the DB before run the commands.</p>
<p>So the replication is back to work now. Not sure what had really caused error 1236. Get my fingers crossed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phinesolutions.com/mysql-replication-problem.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
