<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5230317833019987608</id><updated>2012-02-01T22:11:30.181-08:00</updated><category term='apache'/><category term='linux'/><category term='High Availability'/><category term='repcached'/><category term='pressflow'/><category term='mysql'/><category term='php'/><category term='nginx'/><category term='drupal'/><category term='debian'/><category term='memcached'/><category term='developer portal'/><category term='smstools'/><category term='wso2'/><category term='3G'/><title type='text'>Thilanga's Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.pitigala.org/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://www.pitigala.org/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Thilanga Pitigala</name><uri>http://www.blogger.com/profile/07995770495148938961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://4.bp.blogspot.com/-IVyRvF_27b0/TuKWLrE1saI/AAAAAAAAAFo/SErqpwEL8Ys/s1600/294007_10150288670055738_731015737_8252312_1363944652_n.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5230317833019987608.post-6928376682089255221</id><published>2011-12-30T12:36:00.000-08:00</published><updated>2011-12-30T12:36:42.630-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='smstools'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='debian'/><category scheme='http://www.blogger.com/atom/ns#' term='3G'/><title type='text'>How to Setup smstools in debian</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;3G dongle is the only bandwidth service I have when i'm home. (If my&amp;nbsp;neighbor&amp;nbsp;didn't turn on his WIFI connection ). Due to heavy usage of mobile broadband, my 3g Dongle&amp;nbsp;frequently&amp;nbsp;get caught to service&amp;nbsp;disruptions by exceeding the reserved data&amp;nbsp;bundle, Most of the time I had to call 3G service provider to get the connection temporary to do an online payment.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Normally service provider send a SMS when reaching the&amp;nbsp;reserved&amp;nbsp;quota (Probably when reaching 75%). But as I can't use Mobile Partner software in linux, I always missed those SMSs, if I didn't connect my dongle in to a Windows&amp;nbsp;powered&amp;nbsp;machine (As I hardly use Windows OS, most of the time I was in trouble).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As a solution I installed and configured smstools to avoid this mess and getting alone without the Internet.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Install smstools&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;sudo apt-get install smstools (Install smstools)&lt;/li&gt;&lt;li&gt;dmesg | grep usb (get the device. ex: /dev/ttyUSB0)&lt;/li&gt;&lt;li&gt;sudo vim /etc/smsd.conf (smstools config file)&lt;/li&gt;&lt;li&gt;sudo&amp;nbsp;/etc/init.d/smstools start (Start smstools after changing configurations)&lt;/li&gt;&lt;li&gt;cd &amp;nbsp;/var/spool/sms/incoming (to see incoming sms)&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Configuration&amp;nbsp;&lt;/b&gt;&amp;nbsp;(/etc/smsd.conf)&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;devices = GSM1&lt;/div&gt;&lt;div&gt;outgoing = /var/spool/sms/outgoing&lt;/div&gt;&lt;div&gt;checked = /var/spool/sms/checked&lt;/div&gt;&lt;div&gt;incoming = /var/spool/sms/incoming&lt;/div&gt;&lt;div&gt;logfile = /var/log/smstools/smsd.log&lt;/div&gt;&lt;div&gt;infofile = /var/run/smstools/smsd.working&lt;/div&gt;&lt;div&gt;pidfile = /var/run/smstools/smsd.pid&lt;/div&gt;&lt;div&gt;outgoing = /var/spool/sms/outgoing&lt;/div&gt;&lt;div&gt;checked = /var/spool/sms/checked&lt;/div&gt;&lt;div&gt;failed = /var/spool/sms/failed&lt;/div&gt;&lt;div&gt;incoming = /var/spool/sms/incoming&lt;/div&gt;&lt;div&gt;sent = /var/spool/sms/sent&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;receive_before_send = no&lt;/div&gt;&lt;/div&gt;&lt;div&gt;autosplit = 3&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;[GSM1]&lt;/div&gt;&lt;div&gt;&lt;div&gt;device = /dev/ttyUSB0&lt;/div&gt;&lt;div&gt;incoming = yes&lt;/div&gt;&lt;/div&gt;&lt;div&gt;baudrate = 19200&lt;/div&gt;&lt;div&gt;memory_start = 1&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you configured the smstools properly you will get sms to&amp;nbsp;&amp;nbsp;&lt;b&gt;/var/spool/sms/incoming&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Test your settings.&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;Send a test sms to your 3G Dongle from a mobile phone&lt;/li&gt;&lt;li&gt;then ls&amp;nbsp;/var/spool/sms/incoming (if the dongle&amp;nbsp;received&amp;nbsp;the sms, you will see a file, name is&amp;nbsp;slimier&amp;nbsp;to &lt;b&gt;GSM1.AuvV6s&lt;/b&gt;&amp;nbsp; )&lt;/li&gt;&lt;li&gt;vim&amp;nbsp;&amp;nbsp;/var/spool/sms/incoming/$filename to read the sms&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;b&gt;Debug your setings&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;sudo tail -f /var/log/smstools/smsd.log&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Note: I didn't test sms sending through the 3G dongle as my service provider has blocked the facility.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5230317833019987608-6928376682089255221?l=www.pitigala.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.pitigala.org/feeds/6928376682089255221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5230317833019987608&amp;postID=6928376682089255221' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/6928376682089255221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/6928376682089255221'/><link rel='alternate' type='text/html' href='http://www.pitigala.org/2011/12/how-to-setup-smstools-in-debian.html' title='How to Setup smstools in debian'/><author><name>Thilanga Pitigala</name><uri>http://www.blogger.com/profile/07995770495148938961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://4.bp.blogspot.com/-IVyRvF_27b0/TuKWLrE1saI/AAAAAAAAAFo/SErqpwEL8Ys/s1600/294007_10150288670055738_731015737_8252312_1363944652_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5230317833019987608.post-2599777297185903175</id><published>2011-12-09T13:31:00.001-08:00</published><updated>2011-12-12T01:53:24.448-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='High Availability'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='memcached'/><category scheme='http://www.blogger.com/atom/ns#' term='pressflow'/><category scheme='http://www.blogger.com/atom/ns#' term='drupal'/><category scheme='http://www.blogger.com/atom/ns#' term='wso2'/><category scheme='http://www.blogger.com/atom/ns#' term='developer portal'/><category scheme='http://www.blogger.com/atom/ns#' term='repcached'/><title type='text'>Install Repcached (Memcached Replication) For High-Availability</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;When you have a dynamic website which handles lots of user&amp;nbsp;queries, as a Web Master my top priorities are to keep the site up and&amp;nbsp;running with&amp;nbsp;minimum downtime (I meant 0 downtime)&amp;nbsp;&amp;nbsp;and to keep the site healthy to&amp;nbsp;response&amp;nbsp;back&amp;nbsp;to users in very very short time.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, keeping&amp;nbsp;those 2 main tasks in my mind, I was able to track down the problem which was&amp;nbsp;haunting for sometimes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It was non optimized&amp;nbsp;queries which ran through our &lt;a href="http://wso2.org/" target="_blank"&gt;WSO2 Developer Portal&amp;nbsp;&lt;/a&gt;.&amp;nbsp;Due to this issue, portal's MySQL load was always high. So the answer was to reduce the MySQL load.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I used &lt;a href="http://memcached.org/" target="_blank"&gt;Memcached&lt;/a&gt;&amp;nbsp;to&amp;nbsp;minimize database load.&amp;nbsp;Memcached increases the performance and scalability of dynamic MySQL-driven websites by caching data and objects in memory.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Setting up Memcached is fairly simple. You can Install using APT (Debian based) or &lt;a href="http://www.lullabot.com/articles/how-install-memcache-debian-etch" target="_blank"&gt;download the tar and compile it on the server&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After Installing Memcached with MySQL, it gave a good&amp;nbsp;performance&amp;nbsp;boost to our Developer Portal&amp;nbsp;until a node's cache got expired.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I noticed that some users&amp;nbsp;couldn't upload / attach files to &lt;a href="http://wso2.org/forum" target="_blank"&gt;our forum&lt;/a&gt;&amp;nbsp;or new article. After some series of testing and&amp;nbsp;debugging sessions, I was able&amp;nbsp;confirm that we had a problem in Memcached while accessing in a&amp;nbsp;cluster&amp;nbsp;enviroment.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The reason was : Lets' say when users are accessing the site in a peak time, first request is severed&amp;nbsp;from node1.Then the second request gets routed to node3 or Node4 (&lt;a href="http://www.pitigala.org/2011/12/drupal-scaling-and-performance-tuning.html" target="_blank"&gt;backup nodes&lt;/a&gt;) due to&amp;nbsp;high load in the&amp;nbsp;cluster, User Drupal can not access cache&amp;nbsp;objects created during the first request.&amp;nbsp;Because&amp;nbsp;of that, user&amp;nbsp;receives lots of unexpected results.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then I Installed&amp;nbsp;&lt;a href="http://repcached.lab.klab.org/" target="_blank"&gt;RepCached&lt;/a&gt;&amp;nbsp;to support Replication in Memcached. Repcached helps to keep&amp;nbsp;redundancy memcached system and that was the solution I was looking for.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Installing&amp;nbsp;RepCached&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;Download the Latest version of repcached from&amp;nbsp;&lt;a href="http://repcached.lab.klab.org/"&gt;http://repcached.lab.klab.org/&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Install some extra packages on&amp;nbsp;Debian (apt-get install libevent-dev g++ make)&lt;/li&gt;&lt;li&gt;Install repcached from tar&lt;/li&gt;&lt;li&gt;Extract files (tar xvf memcached-1.2.8-repcached-2.2.tar)&lt;/li&gt;&lt;li&gt;go to the directory (cd memcached-1.2.8-repcached-2.2/)&lt;/li&gt;&lt;li&gt;Enable replication before install (./configure --enable-replication)&lt;/li&gt;&lt;li&gt;Install (make &amp;amp;&amp;amp;&amp;nbsp;make install)&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;b&gt;Configure repcache&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;create the file (vim /etc/memcachedrep)&lt;/li&gt;&lt;li&gt;Create the init Script (vim /etc/init.d/memcachedrep)&lt;/li&gt;&lt;li&gt;chmod +x /etc/init.d/memcacherep&lt;/li&gt;&lt;li&gt;update-rc.d memcachedrep defaults&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;u&gt;Copy / Past code1 to step 1&lt;/u&gt;&lt;/div&gt;&lt;div&gt;## extra commandline options to start memcached in replicated mode&lt;/div&gt;&lt;div&gt;# -x &amp;lt; ip_addr &amp;gt; hostname or IP address of the master replication server&lt;/div&gt;&lt;div&gt;# -X &amp;lt; num &amp;gt; TCP port number of the master (default: 11212)&lt;/div&gt;&lt;div&gt;DAEMON_ARGS="-m 128 -p 11211 -u root -P /var/run/memcachedrep.pid -d -x 10.100.1.10&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;u&gt;Copy / Past code2 to step 2&lt;/u&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;#! /bin/sh&lt;/div&gt;&lt;div&gt;### BEGIN INIT INFO&lt;/div&gt;&lt;div&gt;# Provides: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; memcached&lt;/div&gt;&lt;div&gt;# Required-Start: &amp;nbsp; &amp;nbsp; &amp;nbsp; $syslog&lt;/div&gt;&lt;div&gt;# Required-Stop: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$syslog&lt;/div&gt;&lt;div&gt;# Should-Start: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $local_fs&lt;/div&gt;&lt;div&gt;# Should-Stop: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$local_fs&lt;/div&gt;&lt;div&gt;# Default-Start: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 3 4 5&lt;/div&gt;&lt;div&gt;# Default-Stop: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 1 6&lt;/div&gt;&lt;div&gt;# Short-Description: &amp;nbsp; &amp;nbsp;memcached - Memory caching daemon replicated&lt;/div&gt;&lt;div&gt;# Description: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;memcached - Memory caching daemon replicated&lt;/div&gt;&lt;div&gt;### END INIT INFO&lt;/div&gt;&lt;div&gt;# Author: Michael&amp;nbsp;&lt;/div&gt;&lt;div&gt;#&lt;/div&gt;&lt;div&gt;# Please remove the "Author" lines above and replace them&lt;/div&gt;&lt;div&gt;# with your own name if you copy and modify this script.&lt;/div&gt;&lt;div&gt;# Do NOT "set -e"&lt;/div&gt;&lt;div&gt;# PATH should only include /usr/* if it runs after the mountnfs.sh script&lt;/div&gt;&lt;div&gt;PATH=/sbin:/usr/sbin:/bin:/usr/bin&lt;/div&gt;&lt;div&gt;DESC="memcachedrep"&lt;/div&gt;&lt;div&gt;NAME=memcached&lt;/div&gt;&lt;div&gt;DAEMON=/usr/local/bin/$NAME&lt;/div&gt;&lt;div&gt;DAEMON_ARGS="--options args"&lt;/div&gt;&lt;div&gt;PIDFILE=/var/run/memcachedrep.pid&lt;/div&gt;&lt;div&gt;SCRIPTNAME=/etc/init.d/$DESC&lt;/div&gt;&lt;div&gt;VERBOSE="yes"&lt;/div&gt;&lt;div&gt;# Exit if the package is not installed&lt;/div&gt;&lt;div&gt;[ -x "$DAEMON" ] || exit 0&lt;/div&gt;&lt;div&gt;# Read configuration variable file if it is present&lt;/div&gt;&lt;div&gt;[ -r /etc/$DESC ] &amp;amp;&amp;amp; . /etc/$DESC&lt;/div&gt;&lt;div&gt;# Load the VERBOSE setting and other rcS variables&lt;/div&gt;&lt;div&gt;. /lib/init/vars.sh&lt;/div&gt;&lt;div&gt;# Define LSB log_* functions.&lt;/div&gt;&lt;div&gt;# Depend on lsb-base (&amp;gt;= 3.0-6) to ensure that this file is present.&lt;/div&gt;&lt;div&gt;. /lib/lsb/init-functions&lt;/div&gt;&lt;div&gt;#&lt;/div&gt;&lt;div&gt;# Function that starts the daemon/service&lt;/div&gt;&lt;div&gt;#&lt;/div&gt;&lt;div&gt;do_start()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# Return&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# &amp;nbsp; 0 if daemon has been started&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# &amp;nbsp; 1 if daemon was already running&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# &amp;nbsp; 2 if daemon could not be started&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test &amp;gt; /dev/null \&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;|| return 1&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$DAEMON_ARGS \&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;|| return 2&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# Add code here, if necessary, that waits for the process to be ready&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# to handle requests from services started subsequently which depend&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# on this one. &amp;nbsp;As a last resort, sleep for some time.&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;#&lt;/div&gt;&lt;div&gt;# Function that stops the daemon/service&lt;/div&gt;&lt;div&gt;#&lt;/div&gt;&lt;div&gt;do_stop()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# Return&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# &amp;nbsp; 0 if daemon has been stopped&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# &amp;nbsp; 1 if daemon was already stopped&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# &amp;nbsp; 2 if daemon could not be stopped&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# &amp;nbsp; other if a failure occurred&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; RETVAL="$?"&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; [ "$RETVAL" = 2 ] &amp;amp;&amp;amp; return 2&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# Wait for children to finish too if this is a daemon that forks&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# and if the daemon is only ever run from this initscript.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# If the above conditions are not satisfied then add some other code&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# that waits for the process to drop all resources that could be&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# needed by services started subsequently. &amp;nbsp;A last resort is to&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# sleep for some time.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[ "$?" = 2 ] &amp;amp;&amp;amp; return 2&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# Many daemons don't delete their pidfiles when they exit.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;rm -f $PIDFILE&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;return "$RETVAL"&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;#&lt;/div&gt;&lt;div&gt;# Function that sends a SIGHUP to the daemon/service&lt;/div&gt;&lt;div&gt;#&lt;/div&gt;&lt;div&gt;do_reload() {&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;#&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# If the daemon can reload its configuration without&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# restarting (for example, when it is sent a SIGHUP),&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# then implement that here.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;#&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;return 0&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;case "$1" in&lt;/div&gt;&lt;div&gt;&amp;nbsp; start)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[ "$VERBOSE" != no ] &amp;amp;&amp;amp; log_daemon_msg "Starting $DESC" "$NAME"&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;do_start&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;case "$?" in&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;0|1) [ "$VERBOSE" != no ] &amp;amp;&amp;amp; log_end_msg 0 ;;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;2) [ "$VERBOSE" != no ] &amp;amp;&amp;amp; log_end_msg 1 ;;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;esac&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; stop)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[ "$VERBOSE" != no ] &amp;amp;&amp;amp; log_daemon_msg "Stopping $DESC" "$NAME"&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;do_stop&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;case "$?" in&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;0|1) [ "$VERBOSE" != no ] &amp;amp;&amp;amp; log_end_msg 0 ;;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;2) [ "$VERBOSE" != no ] &amp;amp;&amp;amp; log_end_msg 1 ;;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;esac&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; #reload|force-reload)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;#&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# If do_reload() is not implemented then leave this commented out&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# and leave 'force-reload' as an alias for 'restart'.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;#&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;#log_daemon_msg "Reloading $DESC" "$NAME"&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;#do_reload&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;#log_end_msg $?&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;#;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; restart|force-reload)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;#&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# If the "reload" option is implemented then remove the&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# 'force-reload' alias&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;#&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;log_daemon_msg "Restarting $DESC" "$NAME"&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;do_stop&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;case "$?" in&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; &amp;nbsp;0|1)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;do_start&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;case "$?" in&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;0) log_end_msg 0 ;;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;1) log_end_msg 1 ;; # Old process is still running&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;*) log_end_msg 1 ;; # Failed to start&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;esac&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;;;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; &amp;nbsp;*)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; &amp;nbsp;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;# Failed to stop&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;log_end_msg 1&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;;;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;esac&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; *)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" &amp;gt;&amp;amp;2&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" &amp;gt;&amp;amp;2&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;exit 3&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;;;&lt;/div&gt;&lt;div&gt;esac&lt;/div&gt;&lt;div&gt;:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Test the repcached&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In Server 1&lt;/div&gt;&lt;div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;telnet 127.0.0.1 11211&lt;/li&gt;&lt;li&gt;set foo 0 0 3&lt;/li&gt;&lt;li&gt;bar&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;In Server 2&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;telnet 127.0.0.1 11211&lt;/li&gt;&lt;li&gt;get foo (You will get bar as the Output)&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5230317833019987608-2599777297185903175?l=www.pitigala.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.pitigala.org/feeds/2599777297185903175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5230317833019987608&amp;postID=2599777297185903175' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/2599777297185903175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/2599777297185903175'/><link rel='alternate' type='text/html' href='http://www.pitigala.org/2011/12/install-repcached-memcached-replication.html' title='Install Repcached (Memcached Replication) For High-Availability'/><author><name>Thilanga Pitigala</name><uri>http://www.blogger.com/profile/07995770495148938961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://4.bp.blogspot.com/-IVyRvF_27b0/TuKWLrE1saI/AAAAAAAAAFo/SErqpwEL8Ys/s1600/294007_10150288670055738_731015737_8252312_1363944652_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5230317833019987608.post-1066666945969544791</id><published>2011-12-08T20:10:00.001-08:00</published><updated>2011-12-08T22:21:31.622-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='memcached'/><category scheme='http://www.blogger.com/atom/ns#' term='pressflow'/><category scheme='http://www.blogger.com/atom/ns#' term='nginx'/><category scheme='http://www.blogger.com/atom/ns#' term='drupal'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='apache'/><title type='text'>Drupal scaling and performance tuning - Part 3</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Running&amp;nbsp;a Developer Portal is not an easy task as I&amp;nbsp;thought. When it comes to &lt;a href="http://wso2.org/"&gt;WSO2 Oxygentank&lt;/a&gt;&amp;nbsp;It is more critical as WSO2&amp;nbsp;community&amp;nbsp;is heavily depend on the portal.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To be frankly if the site went offline for 1 minute, I used to get more than 20 email / &amp;nbsp;IM chats or calls. Most of the solutions described in the web really didn't work for us. So we had to find our own way to stabilize the system. After spending so much of time configuring and tuning we ended up with a&amp;nbsp;scalable&amp;nbsp;and stable solution. In part &lt;a href="http://www.pitigala.org/2011/09/drupal-scaling-and-performance-tuning.html"&gt;1&lt;/a&gt; and &lt;a href="http://www.pitigala.org/2011/10/drupal-scaling-and-performance-tuning.html"&gt;2&lt;/a&gt;&amp;nbsp;I have described methods which we used.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;During peak hours&amp;nbsp;Our portal started to send 502 Bad&amp;nbsp;gateway&amp;nbsp;message from Nginx. The reason was due to mysql&amp;nbsp;high-load in master 1 server, Nginx didn't&amp;nbsp;receive&amp;nbsp;the response with in defined time.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Solution was we configured Nginx with backup nodes setting instead of setting up 4 nodes with weight balancing to handle the load.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Sample nginx.conf&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;upstream wso2.org {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; server node1server:80 weight=5 fail_timeout=20s;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; server node2server.org:80 weight=5 fail_timeout=20s;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; server node3server:80 backup;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; server node4server:80 backup;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;with this setup&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;Nginx&amp;nbsp;always&amp;nbsp;send traffic to node1 and node2 servers&lt;/li&gt;&lt;li&gt;Primary&amp;nbsp;data source is master1 mysql instance.&lt;/li&gt;&lt;li&gt;Secondary data source is master2 MySQL instance&lt;/li&gt;&lt;/ol&gt;When node1 or node2&amp;nbsp;couldn't&amp;nbsp;response to Nginx with in 20 seconds we route the traffic to backup nodes&lt;/div&gt;&lt;div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;Nginx send traffic to node3 and node4 when node1 and node2 can not&amp;nbsp;response&amp;nbsp;&lt;/li&gt;&lt;li&gt;Primary data source is master2 MySQL Instance&lt;/li&gt;&lt;li&gt;Secondary data source is master1 MySQL instance&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;with that setting we were able to keep the site with 0% downtime.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-7M4_FseS-U4/TuGnnSWRUkI/AAAAAAAAAFc/O5khhsAkekQ/s1600/1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://1.bp.blogspot.com/-7M4_FseS-U4/TuGnnSWRUkI/AAAAAAAAAFc/O5khhsAkekQ/s400/1.JPG" width="300" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;(Overview of WSO2 Oxygentank)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Nginx&amp;nbsp;always looked after load balancing when http/s traffic get high and with the backup node method we were able to keep our MySQL instance up and running without getting meltdown.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5230317833019987608-1066666945969544791?l=www.pitigala.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.pitigala.org/feeds/1066666945969544791/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5230317833019987608&amp;postID=1066666945969544791' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/1066666945969544791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/1066666945969544791'/><link rel='alternate' type='text/html' href='http://www.pitigala.org/2011/12/drupal-scaling-and-performance-tuning.html' title='Drupal scaling and performance tuning - Part 3'/><author><name>Thilanga Pitigala</name><uri>http://www.blogger.com/profile/07995770495148938961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://4.bp.blogspot.com/-IVyRvF_27b0/TuKWLrE1saI/AAAAAAAAAFo/SErqpwEL8Ys/s1600/294007_10150288670055738_731015737_8252312_1363944652_n.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-7M4_FseS-U4/TuGnnSWRUkI/AAAAAAAAAFc/O5khhsAkekQ/s72-c/1.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5230317833019987608.post-6405704023688268516</id><published>2011-10-07T01:12:00.000-07:00</published><updated>2011-12-08T22:21:25.986-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='memcached'/><category scheme='http://www.blogger.com/atom/ns#' term='pressflow'/><category scheme='http://www.blogger.com/atom/ns#' term='nginx'/><category scheme='http://www.blogger.com/atom/ns#' term='drupal'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='apache'/><title type='text'>Drupal scaling and performance tuning - Part 2</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="text-align: left;"&gt;Drupal is highly relational. &amp;nbsp;When it comes to&amp;nbsp;performance, MySQL has a big role to play in Drupal world. As I&amp;nbsp;explained in &lt;a href="http://www.pitigala.org/2011/09/drupal-scaling-and-performance-tuning.html"&gt;Drupal scaling and performance tuning - Part 1&lt;/a&gt;,&amp;nbsp;we were able tune&amp;nbsp;Apache&amp;nbsp;to handle much load during high traffic hours. But MySQL didn't give a chance to rest.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;As the first step, we decided to look at the MySQL slow&amp;nbsp;queries&amp;nbsp;to identify bad&amp;nbsp;queries. Server logged all&amp;nbsp;queries that took more than 2 seconds to process and most of them were node permissions, user sessions,&amp;nbsp;access log, cache, comments, watchdog and node contents.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The server load was gone up and it was almost at the frozen state most of the time. As a solution, I knew that we would have to end up with a modified&amp;nbsp;MySQL configuration file.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;But, What are the Parameters I need to change and what are the values for them, like i did for&amp;nbsp;Apache?&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Then I came across with a tool called&amp;nbsp;&lt;a href="https://github.com/rackerhacker/MySQLTuner-perl"&gt;MySQLTuner-perl&lt;/a&gt;&amp;nbsp;which is a script written in Perl that allows us to review a MySQL installation quickly and make adjustments to increase performance and stability. &amp;nbsp;The current configuration variables and status data are retrieved and presented in a brief format along with some basic performance suggestions&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;Tools used&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;a href="https://github.com/rackerhacker/MySQLTuner-perl"&gt;MySQLTuner-perl&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;a href="http://www.maatkit.org/"&gt;Maatkit&lt;/a&gt;&amp;nbsp;(&amp;nbsp;Power tools for open-source databases)&lt;/li&gt;&lt;/ol&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;Mysql Optimization - &lt;/b&gt;I will not list all configurations here as MySQL Tuner gives you a good guide&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;MySQL Tuner&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Download the Mysql Tuner (wget https://github.com/rackerhacker/MySQLTuner-perl/blob/master/mysqltuner.pl)&lt;/li&gt;&lt;li&gt;Make it executable (chmod +x mysqltuner.pl)&lt;/li&gt;&lt;li&gt;Run MySQL&amp;nbsp;Turner - You need your MySQL root password in order to execute this (./mysqltuner.pl)&amp;nbsp;&lt;/li&gt;&lt;li&gt;&amp;nbsp;You should carefully read the output, especially the recommendations at the end. It shows exactly which variables you should adjust in the [mysqld] section of your my.cnf (on Debian and Ubuntu the full path is /etc/mysql/my.cnf). Whenever you change your my.cnf, make sure that you restart MySQL. You can then run MySQLTuner again to see if it has further recommendations to improve the MySQL performance. This way, you can optimize MySQL step by step.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Maatkit&lt;/li&gt;&lt;ol&gt;&lt;li&gt;mk-duplicate-key-checker - helped me to find duplicate indexes and foreign keys on MySQL tables.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Removed all&amp;nbsp;duplicate indexes and foreign keys - This&amp;nbsp;helped&amp;nbsp;MySQL to process SQLs smoothly.&lt;/li&gt;&lt;li&gt;mk-query-digest and mk-query-profiler helped to profile and test new&amp;nbsp;configurations/ Modifications&amp;nbsp;to the database.&lt;/li&gt;&lt;li&gt;&amp;nbsp;mk-variable-advisor to double check changes and&amp;nbsp;recommendations made by MySQL Tuner.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Converted comments, node, users tables from MyISAM to InnoDB&lt;/li&gt;&lt;li&gt;mysqlcheck -o -A -p command optimized other tables in the Drupal Database&lt;/li&gt;&lt;/ol&gt;After going through few cycles of above points, we were able to get the MySQL server to a level that it can handle much load without any&amp;nbsp;hiccups. Slow query log didn't report any slow quries. SHOW PROCESSLIST was always below 20 - 30.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Other&amp;nbsp;Optimizations&amp;nbsp;used&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;Disable watchdog, Statistic modules from Drupal to&amp;nbsp;reduce&amp;nbsp;the read/write load to MySQL&lt;/li&gt;&lt;li&gt;Uninstalled all unused modules.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Finally I was able to get Our &lt;a href="http://wso2.org/"&gt;Oxygentank&lt;/a&gt;&amp;nbsp;Database to a state where it can breathe freely without&amp;nbsp;running on&amp;nbsp;full power&amp;nbsp;all the time.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But I was not happy with this setting since the second MySQL master server was always running silently without helping the Primary Master server to handle its load.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I used&amp;nbsp;&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;b&gt;NGINX&lt;/b&gt;&lt;/span&gt; to solve this problem.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 15px; line-height: 20px;"&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;I will discuss&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;how I used NGINX to share MySQL load between&amp;nbsp;Databases / Drupal nodes with the help of&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; color: red; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;&lt;b&gt;Memcached,&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;in part 3.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5230317833019987608-6405704023688268516?l=www.pitigala.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.pitigala.org/feeds/6405704023688268516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5230317833019987608&amp;postID=6405704023688268516' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/6405704023688268516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/6405704023688268516'/><link rel='alternate' type='text/html' href='http://www.pitigala.org/2011/10/drupal-scaling-and-performance-tuning.html' title='Drupal scaling and performance tuning - Part 2'/><author><name>Thilanga Pitigala</name><uri>http://www.blogger.com/profile/07995770495148938961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://4.bp.blogspot.com/-IVyRvF_27b0/TuKWLrE1saI/AAAAAAAAAFo/SErqpwEL8Ys/s1600/294007_10150288670055738_731015737_8252312_1363944652_n.jpg'/></author><thr:total>0</thr:total><georss:featurename>59, Flower Rd, Colombo 00700, Sri Lanka@6.907436560956265,79.85822439193726</georss:featurename><georss:point>6.9129016 79.8556634</georss:point><georss:box>6.9109311 79.8531959 6.914872099999999 79.85813089999999</georss:box></entry><entry><id>tag:blogger.com,1999:blog-5230317833019987608.post-3510582754354244068</id><published>2011-09-29T01:36:00.000-07:00</published><updated>2011-10-07T02:42:11.414-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='memcached'/><category scheme='http://www.blogger.com/atom/ns#' term='pressflow'/><category scheme='http://www.blogger.com/atom/ns#' term='nginx'/><category scheme='http://www.blogger.com/atom/ns#' term='drupal'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='apache'/><title type='text'>Drupal scaling and performance tuning - Part 1</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div&gt;As WSO2Con 2011 was a huge hit in IT sector, I had to face a problem with&lt;a href="http://wso2.org/"&gt; wso2.org&lt;/a&gt; (Oxygentank developer Portal). Which site&amp;nbsp;couldn't&amp;nbsp;handle a large traffic constantly.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The old system we had was NGINX (Load&amp;nbsp;Balancer) fronted 4 Drupal nodes which was&amp;nbsp;running&amp;nbsp;with&amp;nbsp;Apache2. with master - master&amp;nbsp;MySQL&amp;nbsp;replication.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But during a&amp;nbsp;high-traffic&amp;nbsp;Our servers got more than 1&amp;nbsp;minute (average) time&amp;nbsp;to response&amp;nbsp;&amp;nbsp;on a request. As &amp;nbsp;NGINX's fail&amp;nbsp;timeout&amp;nbsp;for 45 seconds, users got 504 Gateway timeout most of the time. Same time&amp;nbsp;Apache&amp;nbsp;server load went above 30 - 70.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First as a quick solution we spinned new 2 servers and routed the load across them. That helped us to cater for few hours but again there was a huge delay when site was loading.&amp;nbsp;Then we found that&amp;nbsp;MySQL&amp;nbsp;server load also gone up and&amp;nbsp;process-list&amp;nbsp;has grown.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then I found that MySQL&amp;nbsp;Server take time process&amp;nbsp;queries&amp;nbsp;than it was before. Root cause&amp;nbsp;for this new problem was 6 drupal nodes had started stress MySQL&amp;nbsp;servers&amp;nbsp;continually.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then I started to ask some&amp;nbsp;questioned by my self.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;1.&amp;nbsp;OK, Then why we didn't see this new&amp;nbsp;problem&amp;nbsp;before we plug new nodes?&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Answer was simple, Drupal nodes&amp;nbsp;couldn't&amp;nbsp;stress the DB as it got self killed (Frozen) during high traffics.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Before jump in the Apache, Our WSO2 Infrastructure team&amp;nbsp;revisit our monitoring systems (Ganglia) and found that servers were&amp;nbsp;running&amp;nbsp;on swap most of the time&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;As a solution I stated to tune up the&amp;nbsp;Apache to avoid memory swapping&amp;nbsp;problem. Then I saw that there was some miss configurations which take more&amp;nbsp;memories when Apache process start to handle the traffic.&amp;nbsp;Due to that configuration server can easily&amp;nbsp;excused.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b style="color: red;"&gt;MaxClients &lt;/b&gt;as was one of a major key parameter I had to change during the Apache memory optimization process&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;Apache Memory Optimization &amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;Find the non-swapped physical memory&amp;nbsp;Apache&amp;nbsp;has used (&lt;b&gt;RES&lt;/b&gt;)&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Run &lt;b&gt;top &lt;/b&gt;command and press &lt;b&gt;shift &lt;/b&gt;+ &lt;b&gt;m &lt;/b&gt;to find&amp;nbsp;highest&amp;nbsp;&amp;nbsp;&lt;b&gt;RES&lt;/b&gt; value which is&amp;nbsp;Apache&amp;nbsp;process use&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Find the AVAILABLE APACHE MEMORY POOL.&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Run&amp;nbsp;&lt;b&gt;service apache2 stop &lt;/b&gt;and type &lt;b&gt;free -m&lt;/b&gt;&lt;/li&gt;&lt;li&gt;Note the&amp;nbsp;&lt;b&gt;used &lt;/b&gt;memory and&amp;nbsp;Subtract it from&amp;nbsp;&lt;b&gt;total (&lt;/b&gt;This will give you the FREE MEMORY POOL&lt;b&gt;)&lt;/b&gt;&lt;/li&gt;&lt;li&gt;Multiply&amp;nbsp;MEMORY POOL by &lt;b&gt;0.8&lt;/b&gt;&amp;nbsp;to find the average AVAILABLE APACHE POOL (This will allow server &amp;nbsp;20% memory reserve for burst periods)&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Calculate&amp;nbsp;MaxClients&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Divide AVAILABLE APACHE POOL by the highest &lt;b&gt;RES&lt;/b&gt; memory used by Apache (Step 1). Now we have&amp;nbsp;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;b&gt;MaxClients&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/b&gt;number&lt;/li&gt;&lt;li&gt;Open apache2.conf and change&amp;nbsp;&lt;b&gt;MaxClients &lt;/b&gt;value&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Other tweaks&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Set &lt;b&gt;Keepalive On &lt;/b&gt;(keep it &lt;b&gt;off&lt;/b&gt; if you&amp;nbsp;haven't keep 20% memory&amp;nbsp;reserve.&amp;nbsp;)&lt;/li&gt;&lt;li&gt;set &lt;b&gt;keepalivetimeout&lt;/b&gt; to the lowest value (This will prevent connection hanging, If you experience high latency to your server, set it to 2-5 seconds)&lt;/li&gt;&lt;li&gt;Set your &lt;b&gt;Timeout&lt;/b&gt; to a reasonable value like 10 - 40 (Keep it low)&lt;/li&gt;&lt;li&gt;set &lt;b&gt;MaxKeepAliveRequests&lt;/b&gt; with in&amp;nbsp;70-150 (If you have a good idea about objects in a 1 page set it to match the object count)&lt;/li&gt;&lt;li&gt;Set &lt;b&gt;MinSpareServers&lt;/b&gt; equal to 10-25% of &lt;b&gt;MaxClients&lt;/b&gt;&lt;/li&gt;&lt;li&gt;Set &lt;b&gt;MaxSpareServers&lt;/b&gt; equal to 25-50% of &lt;b&gt;MaxClients&lt;/b&gt;&lt;/li&gt;&lt;li&gt;Set &lt;b&gt;StartServers&lt;/b&gt; equal to&amp;nbsp;&lt;b&gt;MaxSpareServers&lt;/b&gt;&lt;/li&gt;&lt;li&gt;Set &lt;b&gt;MaxRequestsPerChild&lt;/b&gt;&amp;nbsp;somewhere between 400 - 700&amp;nbsp;(if you see rapid Apache child process memory use growth) to 10000&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Apply Changes to Apache&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Run&amp;nbsp;&lt;b&gt;service apache2 start&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;div&gt;Once I restart our servers with above setting, server could handle 150% traffic from Apache end and server load was always below 2 (in a burst&amp;nbsp;server-load&amp;nbsp;was 1-2)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This solved my&amp;nbsp;Apache hanging problem. Then I ran a another load test to verify my setting. I was amazed with the&amp;nbsp;improvement but that haven't solved my problem.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;server is taking bit long to&amp;nbsp;response but I didn't see connection drop.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2. Now, What is wrong with my settings, Why server response is slow&lt;/b&gt;&amp;nbsp;? &lt;b&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;MySQL!!&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I will discuss in part 2, how I&amp;nbsp;addressed&amp;nbsp;this problem .&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5230317833019987608-3510582754354244068?l=www.pitigala.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.pitigala.org/feeds/3510582754354244068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5230317833019987608&amp;postID=3510582754354244068' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/3510582754354244068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/3510582754354244068'/><link rel='alternate' type='text/html' href='http://www.pitigala.org/2011/09/drupal-scaling-and-performance-tuning.html' title='Drupal scaling and performance tuning - Part 1'/><author><name>Thilanga Pitigala</name><uri>http://www.blogger.com/profile/07995770495148938961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://4.bp.blogspot.com/-IVyRvF_27b0/TuKWLrE1saI/AAAAAAAAAFo/SErqpwEL8Ys/s1600/294007_10150288670055738_731015737_8252312_1363944652_n.jpg'/></author><thr:total>0</thr:total><georss:featurename>59, Flower Rd, Colombo 00700, Sri Lanka</georss:featurename><georss:point>6.907436560956265 79.85822439193726</georss:point><georss:box>6.907190060956265 79.85791589193725 6.907683060956265 79.85853289193726</georss:box></entry><entry><id>tag:blogger.com,1999:blog-5230317833019987608.post-2025735879940188702</id><published>2011-06-27T14:29:00.000-07:00</published><updated>2011-06-27T14:31:06.141-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pressflow'/><category scheme='http://www.blogger.com/atom/ns#' term='drupal'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>Pressflow 6 with mysql Replication</title><content type='html'>Pressflow6 should support database replication&amp;nbsp;according&amp;nbsp;to the&lt;a href="https://wiki.fourkitchens.com/display/PF/Using+database+replication+with+Pressflow+5+and+6"&gt; pressflow wiki&lt;/a&gt;. but when I configured master and slave, pressflow instance&amp;nbsp;always&amp;nbsp;pick master. If master was down, site&amp;nbsp;couldn't&amp;nbsp;load and site redirected to the&amp;nbsp;site-offline error page.&lt;br /&gt;&lt;br /&gt;I did some modifications in database.inc, database.mysqli.inc and settings.php&amp;nbsp;in order to work when master mysql server was down.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Scenario&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;If mysql master is inactive, connect to Slave,&lt;/li&gt;&lt;li&gt;if slave is inactive but Master is active, then connect to Master&lt;/li&gt;&lt;li&gt;if Master and Slave both are inactive, Redirect user to Offline page&lt;/li&gt;&lt;/ol&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Modifications can be found in red text.&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;database.inc&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Below change will modify the db_connect call to Master instance by passing 2nd parameter ("master") and by&amp;nbsp;assigning&amp;nbsp;$db_slave_conns[$name] values to&amp;nbsp;$active_db.&lt;/li&gt;&lt;li&gt;Validate before slave connection create. If master is active we are not calling Slave by adding&amp;nbsp;$db_conns[$name]-&amp;gt;connect_errno &amp;gt; 0&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;&lt;code&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;function db_set_active($name = 'default') {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; global $db_url, $db_slave_url, $db_type, $active_db, $active_slave_db;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; static $db_conns, $db_slave_conns, $active_name = FALSE;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; if (empty($db_url)) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; include_once 'includes/install.inc';&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; install_goto('install.php');&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; if (!isset($db_conns[$name])) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; // Initiate a new connection, using the named DB URL specified.&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; if (is_array($db_url)) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; $connect_url = array_key_exists($name, $db_url) ? $db_url[$name] : $db_url['default'];&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (is_array($db_slave_url[$name])) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $slave_index = mt_rand(0, count($db_slave_url[$name]) - 1);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $slave_connect_url = $db_slave_url[$name][$slave_index];&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $slave_connect_url = $db_slave_url[$name]; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; else {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; $connect_url = $db_url;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (is_array($db_slave_url)) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $slave_index = mt_rand(0, count($db_slave_url) - 1);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $slave_connect_url = $db_slave_url[$slave_index];&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $slave_connect_url = $db_slave_url; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; $db_type = substr($connect_url, 0, strpos($connect_url, '://'));&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; $handler = "./includes/database.$db_type.inc";&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; if (is_file($handler)) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; include_once $handler;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; else {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; _db_error_page("The database type '". $db_type ."' is unsupported. Please use either 'mysql' or 'mysqli' for MySQL, or 'pgsql' for PostgreSQL databases.");&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;b&gt; $db_conns[$name] = db_connect($connect_url,'master');&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; if (&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;b&gt;$db_conns[$name]-&amp;gt;connect_errno &amp;gt; 0 &amp;amp;&amp;amp;&lt;/b&gt;&lt;/span&gt;&amp;nbsp;!empty($slave_connect_url)) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; $db_slave_conns[$name] = db_connect($slave_connect_url);&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; $previous_name = $active_name;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; // Set the active connection.&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; $active_name = $name;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; $active_db = $db_conns[$name];&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; if (isset($db_slave_conns[$name])) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; $active_slave_db = $db_slave_conns[$name];&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp;&lt;b&gt;&lt;span class="Apple-style-span" style="color: red;"&gt; $active_db = $db_slave_conns[$name]; &amp;nbsp;&lt;/span&gt;&lt;/b&gt; &amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; else {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; unset($active_slave_db);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; return $previous_name;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;database.mysqli.inc&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;db_connect function accept a 2nd parameter.&amp;nbsp;default value will be slave&lt;/li&gt;&lt;li&gt;wrapped&amp;nbsp;_db_error_page(mysqli_connect_error()) with slave server validation. this will stop error page redirection if master server is down.&lt;/li&gt;&lt;li&gt;wrapped with else block to void calling&amp;nbsp;mysqli_query with&amp;nbsp;uninitiated mysql resource.&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;&lt;code&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;function db_connect($url,&lt;b&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;$server='slave'&lt;/span&gt;&lt;/b&gt;) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; // Check if MySQLi support is present in PHP&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; if (!function_exists('mysqli_init') &amp;amp;&amp;amp; !extension_loaded('mysqli')) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; _db_error_page('Unable to use the MySQLi database because the MySQLi extension for PHP is not installed. Check your &lt;code&gt;php.ini&lt;/code&gt; to see how you can enable it.');&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; $url = parse_url($url);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; // Decode url-encoded information in the db connection string&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; $url['user'] = urldecode($url['user']);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; // Test if database url has a password.&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; $url['pass'] = isset($url['pass']) ? urldecode($url['pass']) : '';&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; $url['host'] = urldecode($url['host']);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; $url['path'] = urldecode($url['path']);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; if (!isset($url['port'])) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; $url['port'] = NULL;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; $connection = mysqli_init();&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; @mysqli_real_connect($connection, $url['host'], $url['user'], $url['pass'], substr($url['path'], 1), $url['port'], NULL, MYSQLI_CLIENT_FOUND_ROWS);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; if (mysqli_connect_errno() &amp;gt; 0) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp;&lt;b&gt;&lt;span class="Apple-style-span" style="color: red;"&gt; if($server == 'slave'){&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;_db_error_page(mysqli_connect_error());&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp;&lt;b&gt;&lt;span class="Apple-style-span" style="color: red;"&gt; }&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &lt;span class="Apple-style-span" style="color: red;"&gt;&lt;b&gt;}else {&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; &amp;nbsp;// Force UTF-8.&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; &amp;nbsp;mysqli_query($connection, 'SET NAMES "utf8"');&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: red; font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; return $connection;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;settings.php&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="color: red; font-family: 'Courier New', Courier, monospace;"&gt;$db_url = array();&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="color: red; font-family: 'Courier New', Courier, monospace;"&gt;$db_url['default'] = 'mysqli://user:password@master-host/database';&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="color: red; font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="color: red; font-family: 'Courier New', Courier, monospace;"&gt;$db_slave_url = array();&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="color: red; font-family: 'Courier New', Courier, monospace;"&gt;$db_slave_url['default'] = 'mysqli://user:password@slave-host/database';&lt;/span&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5230317833019987608-2025735879940188702?l=www.pitigala.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.pitigala.org/feeds/2025735879940188702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5230317833019987608&amp;postID=2025735879940188702' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/2025735879940188702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/2025735879940188702'/><link rel='alternate' type='text/html' href='http://www.pitigala.org/2011/06/pressflow-with-mysql-replication.html' title='Pressflow 6 with mysql Replication'/><author><name>Thilanga Pitigala</name><uri>http://www.blogger.com/profile/07995770495148938961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://4.bp.blogspot.com/-IVyRvF_27b0/TuKWLrE1saI/AAAAAAAAAFo/SErqpwEL8Ys/s1600/294007_10150288670055738_731015737_8252312_1363944652_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5230317833019987608.post-4354818994559948063</id><published>2009-07-27T23:14:00.000-07:00</published><updated>2009-07-27T23:32:31.132-07:00</updated><title type='text'>The Importance of Pre-game nutrition for performance and recovery</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/__QKi18hqWqc/Sm6Z9VCbbOI/AAAAAAAAACs/VBxWOGIyA0A/s1600-h/COSP--oct28-field-hockey.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 210px;" src="http://1.bp.blogspot.com/__QKi18hqWqc/Sm6Z9VCbbOI/AAAAAAAAACs/VBxWOGIyA0A/s320/COSP--oct28-field-hockey.jpg" alt="" id="BLOGGER_PHOTO_ID_5363393485143239906" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;Start 2 Days before game&lt;br /&gt;&lt;/strong&gt;Players should start their carbohydrate loading 2 days before match day.&lt;br /&gt;Carbohydrate is stored in the muscles as fuel called (glycogen) and it takes 24 - 48 hours for the muscle to be fully restored and recovered after exercise.&lt;br /&gt;Glycogen is the fuel burned in anaerobic activities. Anytime you are out of breath it is this store that is raided and if the store is empty you will run out of energy. Eating meat and no carbohydrates in the days before a performance is likely to cause you to run out of energy during the game. &lt;p&gt;&lt;strong&gt;Tips to maximise Carbohydrate store:&lt;/strong&gt;&lt;/p&gt; &lt;blockquote&gt; &lt;li&gt;&lt;span&gt;&lt;strong&gt;Rest&lt;/strong&gt;, no hard training sessions where the carbohydrate stores would be used as this would not leave enough time to re-fuel.&lt;br /&gt;Stretching routines are also a good idea. &lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;&lt;strong&gt;Eat often &lt;/strong&gt;every 2 - 4 hours will help load the muscle stores&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;&lt;strong&gt;Consume high carbohydrate foods&lt;/strong&gt;: every meal should include bread, rice, pasta, fruit, and vegetables &lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;&lt;strong&gt;Avoid new foods&lt;/strong&gt; &lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;&lt;strong&gt;Avoid spicy or high fat foods &lt;/strong&gt;they can slow digestion&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Avoid alcohol &lt;/strong&gt;24 hours before the game&lt;/li&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;strong&gt;Match Day Food &lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Wake up 5 hours before your game.&lt;/p&gt; &lt;p&gt; All your energy for the game should already be stored in the muscles if you have eaten the right foods.&lt;br /&gt;Therefore large meals are unnecessary because any energy intake will not be able to be called upon during the same day.&lt;br /&gt;It is important to keep the blood sugar levels consistent during the game day.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Therefore avoid foods like &lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Chocolate Bars &lt;/li&gt;&lt;li&gt;High sugar cookies &lt;/li&gt;&lt;li&gt;Sweets&lt;/li&gt;&lt;li&gt;High fibre muffins&lt;/li&gt;&lt;li&gt;Beans &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;These cause a sudden increase in the blood sugar levels and, in response, the body produces insulin to bring these back down. The overall effect is that the blood sugar levels drop below the normal consistent level, making you feel tired, meaning you run out of energy before the end of the game. &lt;strong&gt;"This is known as the Mars bar effect"&lt;/strong&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Drink lots of water &lt;/strong&gt;dehydration can cause depletion of muscle stores&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Do eat easy to digest foods - &lt;/strong&gt;High in carbohydrate, moderate fat and low in fibre&lt;br /&gt;&lt;strong&gt; Therefore EAT foods like:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Ripe bananas&lt;/li&gt;&lt;li&gt;Yoghurt&lt;/li&gt;&lt;li&gt;Sandwiches peanut butter lean ham&lt;/li&gt;&lt;li&gt;Sports bar&lt;/li&gt;&lt;li&gt;Sports drink&lt;/li&gt;&lt;li&gt;Pasta&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Coffee or tea is ok, as long as you drink plenty of water as well &lt;/p&gt; &lt;p&gt;Your last meal should be consumed 2-4 hours before your warm-up starts&lt;/p&gt; &lt;p&gt;Suggestions towards your diet prior to the game include:&lt;/p&gt; &lt;p&gt;&lt;strong&gt; Breakfast : &lt;/strong&gt;Bowl of cereal, fruit, toast peanut butter, juice &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Lunch : &lt;/strong&gt;Sandwich with, lean meat, fruit sports bar, water.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Rest of the time during build up before the match : &lt;/strong&gt;1 - 2 litres of sports drinks to keep your blood sugar stable &lt;/p&gt; &lt;p&gt;&lt;strong&gt;The most important thing is to work out what works for you and make it part of your pre-game routine for every game.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;Original Author : &lt;/strong&gt;&lt;strong&gt;Bram van Asselt&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5230317833019987608-4354818994559948063?l=www.pitigala.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.pitigala.org/feeds/4354818994559948063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5230317833019987608&amp;postID=4354818994559948063' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/4354818994559948063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/4354818994559948063'/><link rel='alternate' type='text/html' href='http://www.pitigala.org/2009/07/importance-of-pre-game-nutrition-for.html' title='The Importance of Pre-game nutrition for performance and recovery'/><author><name>Thilanga Pitigala</name><uri>http://www.blogger.com/profile/07995770495148938961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://4.bp.blogspot.com/-IVyRvF_27b0/TuKWLrE1saI/AAAAAAAAAFo/SErqpwEL8Ys/s1600/294007_10150288670055738_731015737_8252312_1363944652_n.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/__QKi18hqWqc/Sm6Z9VCbbOI/AAAAAAAAACs/VBxWOGIyA0A/s72-c/COSP--oct28-field-hockey.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5230317833019987608.post-3076696384863028385</id><published>2009-03-21T22:58:00.000-07:00</published><updated>2009-03-22T01:43:12.914-07:00</updated><title type='text'>Bisura - Thriloka</title><content type='html'>Today morning i wanted to listen some good music to fix my mood and i found Bisura album which i  bought  sometimes ago. so i think this album really worked on me to fix my mood and it boosted up my energy back . however i'm a fusion, Electrict music fan and most of the time i spent with AOL radio. so i belive that, i have a good taste in this music and normally i don't listen Srilankan rock or Srilankan New age musics. but i saw the real sri lankan tallent in this album.&lt;br /&gt;&lt;br /&gt;i know i'm not a good album reviewer or a writor, so here i'm going to publish a review about Bisura.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a style="font-weight: bold; font-style: italic;" href="http://www.colombospirit.com/cathome.php?nid=20080910104339&amp;amp;cid=11&amp;amp;aid=2"&gt;Thriloka, Delves Into the Essence&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.colombospirit.com/mmg/g21/Thriloka1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 300px; height: 314px;" src="http://www.colombospirit.com/mmg/g21/Thriloka1.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5230317833019987608-3076696384863028385?l=www.pitigala.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.pitigala.org/feeds/3076696384863028385/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5230317833019987608&amp;postID=3076696384863028385' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/3076696384863028385'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/3076696384863028385'/><link rel='alternate' type='text/html' href='http://www.pitigala.org/2009/03/bisura-thriloka.html' title='Bisura - Thriloka'/><author><name>Thilanga Pitigala</name><uri>http://www.blogger.com/profile/07995770495148938961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://4.bp.blogspot.com/-IVyRvF_27b0/TuKWLrE1saI/AAAAAAAAAFo/SErqpwEL8Ys/s1600/294007_10150288670055738_731015737_8252312_1363944652_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5230317833019987608.post-3973387290902201119</id><published>2009-03-17T09:05:00.000-07:00</published><updated>2009-03-17T20:53:02.200-07:00</updated><title type='text'>Linux-Windows Single Sign-On</title><content type='html'>Here I'm going to post very useful Linux-Windows Single Sign-On configuration, for who wants to authenticate their linux Machines over the Active Directory.  &lt;p style="margin-bottom: 0in;"&gt;Setup and Configure Winbind&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;a name="intelliTXT2"&gt;&lt;/a&gt;&lt;i&gt;Name  Service Switch (NSS): &lt;/i&gt;This is a set of capabilities built into  the Linux C libraries that allow an application to select a source  to validate authentication credentials.   &lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;Pluggable Authentication  Modules (PAM):&lt;/i&gt; This extends the standard Unix password  authentication mechanism to include central authentication databases  such as LDAP, Kerberos, AD and so on.   &lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;Winbind with Samba:&lt;/i&gt; The  winbind service uses Samba for configuration information. For AD  interoperability, make sure your system is running a current version  of Samba (3.05 or newer).   &lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;i&gt;Kerberos:&lt;/i&gt; Winbind uses Kerberos to get tickets for  accessing AD. A Windows domain controller acts as the Key  Distribution Center (KDC).   &lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;ol&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;To configure winbind in Centos,  launch the &lt;strong&gt;Authentication Configuration&lt;/strong&gt; (as  superuser (root). System-config-authentication but it doesn't make  all the required configuration settings.&lt;/p&gt;    &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;Check the Use Winbind option&lt;/p&gt;&lt;/li&gt;&lt;li&gt;In the &lt;strong&gt;Winbind Settings&lt;/strong&gt; window, set the &lt;em&gt;Security Model&lt;/em&gt; to &lt;em&gt;ads&lt;/em&gt; and fill in the &lt;em&gt;Winbind Domain&lt;/em&gt;, &lt;em&gt;Winbind ADS Realm&lt;/em&gt; and &lt;em&gt;Winbind Domain Controllers&lt;/em&gt;. See sample settings below.&lt;/li&gt;&lt;/ol&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/__QKi18hqWqc/ScBmjDyf_mI/AAAAAAAAABg/wOI494SsiYU/s1600-h/Screenshot-Winbind+Settings.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 266px;" src="http://2.bp.blogspot.com/__QKi18hqWqc/ScBmjDyf_mI/AAAAAAAAABg/wOI494SsiYU/s320/Screenshot-Winbind+Settings.png" alt="" id="BLOGGER_PHOTO_ID_5314360312795758178" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;   &lt;p style="margin-bottom: 0in;"&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt;   &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;Domain: flat (NetBIOS) name for  the domain (COMPANY)   &lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;Security Model: ADS   &lt;/p&gt;   &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;ADS Realm: FQDN for the domain  (company.com)   &lt;/p&gt;  &lt;/li&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;Domain Controllers: Fully  Qualified Domain Name (FQDN) for a domain controller  (dc1.company.com)   &lt;/p&gt;   &lt;/li&gt;&lt;li&gt; &lt;p&gt;Template Shell: /bin/bash   &lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;     &lt;p&gt;&lt;a name="intelliTXT"&gt;&lt;/a&gt;There's a Join Domain option, but don't select it. It might not work, and you won't get sufficient feedback to help resolve problems. For now, just click OK to save the changes you just entered.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;NOTE:  &lt;/p&gt;  &lt;p&gt;To ensure the success of the Active Directory integration, make sure that your Active Directory DNS is working, you are using the Active Directory DNS, you can ping the domain controllers and that the difference between the domain controllers’ clock  is not more than five minutes.&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="intelliTXT1"&gt;&lt;/a&gt;When the authconfig window closes, the console window should show that winbind starts. If this fails, try starting the service manually with the following command:&lt;/p&gt; &lt;p&gt;/etc/init.d/winbind start&lt;/p&gt; &lt;p&gt;If winbind starts, it will appear on a ps process list like this:&lt;/p&gt; &lt;p&gt;# ps -A | grep winbind&lt;br /&gt;3132 ? 00:00:00 winbindd&lt;br /&gt;3133 ? 00:00:00 winbindd&lt;/p&gt;  &lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt; &lt;a name="intelliTXT3"&gt;&lt;/a&gt;  4. Configuration Files&lt;p style="margin-bottom: 0in;"&gt;Authconfig makes changes to three configuration files.  &lt;/p&gt;   &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;nsswitch (/etc/nsswitch.conf):  The critical entries are passwd and group. Other Linux flavors don't  bother assigning winbind to other services&lt;/i&gt;&lt;/p&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/__QKi18hqWqc/ScBnjtuSOsI/AAAAAAAAABo/XmFPVDn6bSk/s1600-h/Screenshotgedit.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 260px;" src="http://3.bp.blogspot.com/__QKi18hqWqc/ScBnjtuSOsI/AAAAAAAAABo/XmFPVDn6bSk/s320/Screenshotgedit.png" alt="" id="BLOGGER_PHOTO_ID_5314361423563995842" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;/li&gt;&lt;/ul&gt;  &lt;p style="margin-bottom: 0in;"&gt;                                       &lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;a name="intelliTXT4"&gt;&lt;/a&gt;&lt;i&gt;              (nsswitch (/etc/nsswitch.conf) - comments and irrelevant information removed&lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;passwd:     files winbind &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;shadow:     files winbind &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;group:      files winbind &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt; hosts:      files dns &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;bootparams: nisplus [NOTFOUND=return] files &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;ethers:     files &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;netmasks:   files &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;networks:   files &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;protocols:  files &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;rpc:        files &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;services:   files &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;netgroup:   files &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;publickey:  nisplus &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt; automount:  files &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;aliases:    files nisplus&lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;system-auth  (/etc/pam.d/system-auth):&lt;/i&gt; PAM uses a stackable authentication  scheme, and each element in the stack must be separately configured.   &lt;/p&gt; &lt;/li&gt;&lt;/ul&gt;  &lt;p style="margin-bottom: 0in;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/__QKi18hqWqc/ScBnj0im4BI/AAAAAAAAABw/9ea1q-jJ4Gw/s1600-h/Screenshot-sys-auth-gedit.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 260px;" src="http://4.bp.blogspot.com/__QKi18hqWqc/ScBnj0im4BI/AAAAAAAAABw/9ea1q-jJ4Gw/s320/Screenshot-sys-auth-gedit.png" alt="" id="BLOGGER_PHOTO_ID_5314361425394065426" border="0" /&gt;&lt;/a&gt;                                                                        &lt;i&gt;system-auth (/etc/pam.d/system-auth)&lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;#%PAM-1.0 &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;# This file is auto-generated. &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;# User changes will be destroyed the next time authconfig is run. &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;auth required /lib/security/$ISA/pam_env.so &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;auth sufficient /lib/security/$ISA/pam_unix.so likeauth nullok &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;auth sufficient /lib/security/$ISA/pam_winbind.so use_first_pass &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;auth required /lib/security/$ISA/pam_deny.so &lt;/i&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;account sufficient /lib/security/$ISA/pam_succeed_if.so uid &lt;&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;i&gt;account required /lib/security/$ISA/pam_unix.so &lt;/i&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;i&gt;account [default=bad success=ok user_unknown=ignore] /lib/security/$ISA/pam_winbind.so &lt;/i&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;i&gt;password requisite /lib/security/$ISA/pam_cracklib.so retry=3 &lt;/i&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;i&gt;password sufficient /lib/security/$ISA/pam_unix.so nullok use_authtok md5 shadow &lt;/i&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;i&gt;password sufficient /lib/security/$ISA/pam_winbind.so use_authtok &lt;/i&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;i&gt;password required /lib/security/$ISA/pam_deny.so &lt;/i&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;i&gt;session required /lib/security/$ISA/pam_limits.so &lt;/i&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;i&gt;session required /lib/security/$ISA/pam_unix.so &lt;/i&gt; &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt; &lt;i&gt;smb.conf  (/etc/samba/smb.conf):&lt;/i&gt; The idmap entries are important because  winbind uses them to maintain a correspondence between AD account  names and the User IDs and Group IDs used by Linux. Fedora assigns a  large range of potential IDs. Typically, other Linux flavors assign  a range of 10000-20000.   &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/__QKi18hqWqc/ScBpViPgEoI/AAAAAAAAACI/GQEbpAQojf8/s1600-h/Screenshot--smb+-+gedit.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 274px;" src="http://1.bp.blogspot.com/__QKi18hqWqc/ScBpViPgEoI/AAAAAAAAACI/GQEbpAQojf8/s320/Screenshot--smb+-+gedit.png" alt="" id="BLOGGER_PHOTO_ID_5314363378987176578" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;                                                                                           &lt;i&gt;smb.conf (/etc/samba/smb.conf)&lt;/i&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;[global] &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;workgroup = COMPANY &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;server string = Samba Server &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;printcap name = /etc/printcap &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;load printers = yes &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;log file = /var/log/samba/%m.log &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;max log size = 50 &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;security = ads &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;dns proxy = no &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;idmap uid = 16777216-33554431 &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;idmap gid = 16777216-33554431 &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;template shell = /bin/bash &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;winbind use default domain = yes &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;password server = dc1.company.com &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;realm = COMPANY.COM  &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;a name="intelliTXT5"&gt;&lt;/a&gt;Also, in smb.conf, note the home directory path inserted by authconfig, &lt;i&gt;/home/%D/%U&lt;/i&gt;. A user, call him winuser1, from an AD domain, call it company.com, would get a home directory path of &lt;i&gt;/home/COMPANY/ winuser&lt;/i&gt;. Authconfig does &lt;i&gt;not&lt;/i&gt; create the domain folder under &lt;i&gt;/home&lt;/i&gt;. You must create it manually.  &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;krb5 (/etc/krb5.conf):&lt;/i&gt; Krb5 issue tickets for authenticat again AD&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/__QKi18hqWqc/ScBua6s73FI/AAAAAAAAACg/OrrBVHsqWnU/s1600-h/Screenshot-krb5..png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 309px; height: 320px;" src="http://1.bp.blogspot.com/__QKi18hqWqc/ScBua6s73FI/AAAAAAAAACg/OrrBVHsqWnU/s320/Screenshot-krb5..png" alt="" id="BLOGGER_PHOTO_ID_5314368969010568274" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;                                      krb5 (/etc/krb5.conf)&lt;/i&gt;&lt;/p&gt;&lt;p style="margin-bottom: 0in; font-style: italic;"&gt;[logging]&lt;br /&gt;default = FILE:/var/log/krb5libs.log&lt;br /&gt;kdc = FILE:/var/log/krb5kdc.log&lt;br /&gt;admin_server = FILE:/var/log/kadmind.log&lt;br /&gt;&lt;br /&gt;[libdefaults]&lt;br /&gt;default_realm = COMPANY.COM&lt;br /&gt;dns_lookup_realm = false&lt;br /&gt;dns_lookup_kdc = false&lt;br /&gt;ticket_lifetime = 24h&lt;br /&gt;forwardable = yes&lt;br /&gt;&lt;br /&gt;[realms]&lt;br /&gt;DC1.COMPANY.COM = {&lt;br /&gt;kdc = kerberos.DC1.COMPANY.COM :88&lt;br /&gt;kdc = kerberos.DC1.COMPANY.COM&lt;br /&gt;admin_server = kerberos.DC1.COMPANY.COM:749&lt;br /&gt;default_domain = DC1.COMPANY.COM&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;COMPANY.COM = {&lt;br /&gt;kdc = DC1.COMPANY.COM&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;[domain_realm]&lt;br /&gt;.dc1.Company.com = DC1.COMPANY.COM&lt;br /&gt;dc1.Company.com = DC1.COMPANY.COM&lt;br /&gt;&lt;br /&gt;dc1.company.com = DC1.COMPANY.COM&lt;br /&gt;.dc1.company.com = DC1.COMPANY.COM&lt;br /&gt;[kdc]&lt;br /&gt;profile = /var/kerberos/krb5kdc/kdc.conf&lt;br /&gt;&lt;br /&gt;[appdefaults]&lt;br /&gt;pam = {&lt;br /&gt;debug = false&lt;br /&gt;ticket_lifetime = 36000&lt;br /&gt;renew_lifetime = 36000&lt;br /&gt;forwardable = true&lt;br /&gt;krb4_convert = false&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p&gt;&lt;i&gt;&lt;a name="intelliTXT6"&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Joining an AD Domain&lt;/span&gt;  &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p&gt;&lt;i&gt;&lt;br /&gt;You can now join the Linux workstation to the AD domain using the Linux net command. Here's the syntax, with everything after the first line generated by &lt;i&gt;net&lt;/i&gt;:&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p&gt;&lt;i&gt;# net ads join -U administrator&lt;br /&gt;administrator's password:&lt;br /&gt;Using short domain name -- COMPANY&lt;br /&gt;Joined 'Your Machine Name' to realm 'COMPANY.COM'&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p&gt;&lt;i&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p&gt;&lt;i&gt;&lt;a name="intelliTXT7"&gt;&lt;/a&gt;Configure PAM&lt;br /&gt;At this point, a Windows user trying to authenticate at the Linux desktop would get a series of errors because a local home directory isn't present. A PAM module—mkhomedir.so—automatically creates a home directory. To include this module as part of the login process, change two configuration files under &lt;i&gt;/etc/pam.d&lt;/i&gt; :&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;ul&gt;&lt;li&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;i&gt;login:&lt;/i&gt; This file controls  authentication from a console prompt.   &lt;/i&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/__QKi18hqWqc/ScBpW-waO2I/AAAAAAAAACQ/P4tRCAnm9eQ/s1600-h/Screenshot-login+-+gedit.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 178px;" src="http://4.bp.blogspot.com/__QKi18hqWqc/ScBpW-waO2I/AAAAAAAAACQ/P4tRCAnm9eQ/s320/Screenshot-login+-+gedit.png" alt="" id="BLOGGER_PHOTO_ID_5314363403821267810" border="0" /&gt;&lt;/a&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;                            &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;                                                                                                                                               &lt;i&gt;login (/etc/pam.d/login)&lt;/i&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;#%PAM-1.0&lt;br /&gt;auth required pam_securetty.so&lt;br /&gt;auth required pam_stack.so service=system-auth&lt;br /&gt;auth required pam_nologin.so&lt;br /&gt;account required pam_stack.so service=system-auth&lt;br /&gt;password required pam_stack.so service=system-auth&lt;br /&gt;session required pam_selinux.so multiple&lt;br /&gt;session required pam_stack.so service=system-auth&lt;br /&gt;session optional pam_console.so&lt;br /&gt;session required pam_mkhomedir.so skel=/etc/skel/ umask=0077&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;i&gt;&lt;i&gt;gdm:&lt;/i&gt; This file controls login from a graphical screen.   &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;p&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/__QKi18hqWqc/ScBpXCdHrsI/AAAAAAAAACY/E8nPDD1wpqc/s1600-h/Screenshot-gdm1+-+gedit.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 178px;" src="http://2.bp.blogspot.com/__QKi18hqWqc/ScBpXCdHrsI/AAAAAAAAACY/E8nPDD1wpqc/s320/Screenshot-gdm1+-+gedit.png" alt="" id="BLOGGER_PHOTO_ID_5314363404814102210" border="0" /&gt;&lt;/a&gt;                                            &lt;i&gt;&lt;i&gt;gdm ((/etc/pam.d/gdm)&lt;/i&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p&gt;&lt;i&gt;#%PAM-1.0&lt;br /&gt;auth required pam_env.so&lt;br /&gt;auth required pam_stack.so service=system-auth&lt;br /&gt;auth required pam_nologin.so&lt;br /&gt;account required pam_stack.so service=system-auth&lt;br /&gt;password required pam_stack.so service=system-auth&lt;br /&gt;session required pam_stack.so service=system-auth&lt;br /&gt;session optional pam_console.so&lt;br /&gt;session required pam_mkhomedir.so skel=/etc/skel/ umask=0077  &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p&gt;&lt;i&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;a name="intelliTXT8"&gt;&lt;/a&gt;After changing the PAM files, restart the desktop. This is a quick way to ensure that authconfig made the correct boot settings for the required services.  &lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;i&gt; &lt;/i&gt;&lt;p style="margin-bottom: 0in;"&gt;&lt;i&gt;Thats all, now you can login in to your machine with AD login information.&lt;/i&gt;&lt;/p&gt;&lt;i&gt; &lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5230317833019987608-3973387290902201119?l=www.pitigala.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.pitigala.org/feeds/3973387290902201119/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5230317833019987608&amp;postID=3973387290902201119' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/3973387290902201119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/3973387290902201119'/><link rel='alternate' type='text/html' href='http://www.pitigala.org/2009/03/linux-windows-single-sign-on.html' title='Linux-Windows Single Sign-On'/><author><name>Thilanga Pitigala</name><uri>http://www.blogger.com/profile/07995770495148938961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://4.bp.blogspot.com/-IVyRvF_27b0/TuKWLrE1saI/AAAAAAAAAFo/SErqpwEL8Ys/s1600/294007_10150288670055738_731015737_8252312_1363944652_n.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/__QKi18hqWqc/ScBmjDyf_mI/AAAAAAAAABg/wOI494SsiYU/s72-c/Screenshot-Winbind+Settings.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5230317833019987608.post-4410139983938384918</id><published>2009-03-13T20:54:00.000-07:00</published><updated>2009-03-13T21:08:42.455-07:00</updated><title type='text'>Welcome to my Blog</title><content type='html'>Finally I got chance to get on with blogging. This is what I really wanted to do  for long time ago. So here I like to share my knowledge, thoughts and views . Please feel free to comments on them .&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5230317833019987608-4410139983938384918?l=www.pitigala.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.pitigala.org/feeds/4410139983938384918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5230317833019987608&amp;postID=4410139983938384918' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/4410139983938384918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5230317833019987608/posts/default/4410139983938384918'/><link rel='alternate' type='text/html' href='http://www.pitigala.org/2009/03/welcome-to-my-blog.html' title='Welcome to my Blog'/><author><name>Thilanga Pitigala</name><uri>http://www.blogger.com/profile/07995770495148938961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://4.bp.blogspot.com/-IVyRvF_27b0/TuKWLrE1saI/AAAAAAAAAFo/SErqpwEL8Ys/s1600/294007_10150288670055738_731015737_8252312_1363944652_n.jpg'/></author><thr:total>1</thr:total></entry></feed>
