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

<channel>
	<title>Tutorials Connect &#187; Linux</title>
	<atom:link href="http://www.tutorialsconnect.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tutorialsconnect.com</link>
	<description>Tutorials for Linux Users and Web Developers</description>
	<lastBuildDate>Fri, 17 Sep 2010 06:11:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to setup a redundant NFS server with DRBD and Heartbeat in CentOS 5</title>
		<link>http://www.tutorialsconnect.com/2009/01/how-to-setup-a-redundant-nfs-server-with-drbd-and-heartbeat-in-centos-5/</link>
		<comments>http://www.tutorialsconnect.com/2009/01/how-to-setup-a-redundant-nfs-server-with-drbd-and-heartbeat-in-centos-5/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 06:59:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[drbd]]></category>
		<category><![CDATA[heartbeat]]></category>
		<category><![CDATA[high availability]]></category>
		<category><![CDATA[nfs]]></category>
		<category><![CDATA[redundant]]></category>

		<guid isPermaLink="false">http://www.tutorialsconnect.com/?p=64</guid>
		<description><![CDATA[This tutorial will guide you through the entire process of setting up a highly available NFS server.  To proceed, you must have the following: 1. 2 servers with similar hard disk setup (These will be used to create a redundant nfs server) 2. atleast 1 server where the nfs share will be mounted. 3. Static [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will guide you through the entire process of setting up a highly available NFS server.  To proceed, you must have the following:</p>
<p>1. 2 servers with similar hard disk setup (These will be used to create a redundant nfs server)<br />
2. atleast 1 server where the nfs share will be mounted.<br />
3. Static IPs<br />
4. Basic knowledge of vi (:q! = quit, :wq = write and then quit, i = insert mode, esc = leave insert mode, dd = delete line when not in insert mode)</p>
<p>First off, install CentOS on both machines.  During the install process, create a separate blank partition on both machines to be used as your nfs mount.  Set the mount point to /data during installation.</p>
<p>From this point on i&#8217;m going to be referring to both nfs servers by their IPs and hostnames.  Server1 will be nfs1 with ip 10.132.196.221 and server2 will be nfs2 with ip 10.132.196.222.  Your private IPs might be different so make sure to put in the correct IPs where necessary within this tutorial.</p>
<p><span id="more-64"></span></p>
<p><strong>Do the following on nfs1(10.132.196.221) and nfs2(10.132.196.222):</strong></p>
<blockquote><p>vi /etc/fstab</p></blockquote>
<p>This will give you the mount points and devices on your system.  Look for the /data mount point and comment it out to prevent it form automatically being mounted on boot.  Take note of the device for the /data mount point.  Here is what my fstab looks like.</p>
<blockquote><p>/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1<br />
#/dev/VolGroup00/LogVol02 /data                   ext3    defaults        1 2<br />
LABEL=/boot             /boot                   ext3    defaults        1 2<br />
tmpfs                   /dev/shm                tmpfs   defaults        0 0<br />
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0<br />
sysfs                   /sys                    sysfs   defaults        0 0<br />
proc                    /proc                   proc    defaults        0 0<br />
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0</p></blockquote>
<p>I&#8217;m using LVM so my device names are weird.  Yours might just be /dev/sda1, /dev/sda2, etc&#8230;</p>
<p>Now lets go ahead an unmount that data partition because heartbeat will take care of mounting the partition on the live nfs server.</p>
<blockquote><p>umount /data</p></blockquote>
<p>Make sure that ntp and ntpdate are installed on both of the nfs servers.</p>
<blockquote><p>yum install ntp ntpdate</p></blockquote>
<p>The time on both servers must be identical.</p>
<p>Now lets check and make sure that the nfs service is not running on startup and that selinux is also turned off.</p>
<blockquote><p>setup</p></blockquote>
<p>Go down to &#8220;Firewall Configuration&#8221; and disable selinux and the firewall.  Next, lets go to &#8220;System Services&#8221; and make sure that the nfs service is not enabled.  You will need to reboot your machines for these settings to take affect.</p>
<p>Lets go ahead and create our exports for the nfs so that the nfs share can be mounted on other machines in your network.</p>
<blockquote><p>vi /etc/exports</p></blockquote>
<p>Add the following line to your exports file but make sure to replace the IP.  My private IPs are in the form of 10.132.196.1. Yours may be 192.168.0.1.</p>
<blockquote><p>/data/export/ 10.132.196.0/255.255.255.0(rw,no_root_squash,no_all_squash,sync)</p></blockquote>
<p>The above line in my exports file will allow me to mount the nfs share anywhere within my local network.  If you only want to allow a specific machine to be able to mount the nfs share then use a specific IP instead of the 0 at the end.  For example, here is an exports file that allows only 10.132.196.24 to mount the nfs share.</p>
<blockquote><p>/data/export/ 10.132.196.24/255.255.255.0(rw,no_root_squash,no_all_squash,sync)</p></blockquote>
<p>Now we need to install DRBD and the DRBD kernel module.</p>
<blockquote><p>yum install drbd kmod-drbd</p></blockquote>
<p>After installing drbd we need to setup the config file for it.</p>
<blockquote><p>vi /etc/drbd.conf</p></blockquote>
<p>Let me show you my config file and then we&#8217;ll go over it.</p>
<blockquote><p>common {<br />
protocol C;</p>
<p>syncer {<br />
rate         15M;<br />
al-extents    257;<br />
}<br />
}</p>
<p>resource r0 {</p>
<p>handlers {<br />
pri-on-incon-degr    &#8220;halt -f&#8221;;<br />
}</p>
<p>disk {<br />
on-io-error    detach;<br />
}</p>
<p>startup {<br />
degr-wfc-timeout 120;<br />
}</p>
<p>on nfs1 {<br />
device        /dev/drbd0;<br />
disk        /dev/VolGroup00/LogVol02;<br />
address        10.132.196.221:7789;<br />
meta-disk    internal;<br />
}</p>
<p>on nfs2 {<br />
device        /dev/drbd0;<br />
disk        /dev/VolGroup00/LogVol02;<br />
address        10.132.196.222:7789;<br />
meta-disk    internal;<br />
}<br />
}</p></blockquote>
<p>So lets start from the top.</p>
<ul>
<li><strong>Protocol</strong> &#8211; This is the method that drbd will use to sync both of the nfs servers.  There are 3 available options here, Protocol A, Protocol B and Protocol C.Protocol A is an asynchronous replication protocol.  The drbd.org manual states, &#8220;local write operations 	on the primary node are considered completed as soon as the 	local disk write has occurred, and the replication packet has 	been placed in the local TCP send buffer. In the event of 	forced fail-over, data loss may occur. The data on the standby 	node is consistent after fail-over, however, the most recent 	updates performed prior to the crash could be lost.&#8221;Protocol B is a memory synchronous (semi-synchronous) replication 	protocol.  The drbd.org manual states, &#8220;local write operations on the primary node are 	considered completed as soon as the local disk write has 	occurred, and the replication packet has reached the peer 	node. Normally, no writes are lost in case of forced 	fail-over. However, in the event of simultaneous power failure 	on both nodes and concurrent, irreversible destruction of the 	primary&#8217;s data store, the most recent writes completed on the 	primary may be lost.&#8221;<br />
Protocol C is a synchronous replication protocol.  The drbd.org manual states, &#8220;local write operations 	on the primary node are considered completed only after both 	the local and the remote disk write have been confirmed. As a 	result, loss of a single node is guaranteed not to lead to any 	data loss. Data loss is, of course, inevitable even with this 	replication protocol if both nodes (or their storage 	subsystems) are irreversibly destroyed at the same 	time.</p>
<p>You may choose your desired protocol but Protocol C is the most commonly used one and it is the safest method.</li>
<li><strong>rate</strong> &#8211; The rate is the maximum speed at which data will be sent from one nfs server to the other while syncing.  This should be about a third of your maximum write speed.  In my case, I have only a single disk that can write about 45mb/sec so a third of that would be 15mb.  This number will usually be much higher for people with raid setups.  In some large raid setups, the bottleneck would be the network and not the disks so set the rate accordingly.</li>
<li><strong>al-extent</strong> &#8211; This data on the disk are cut up into slices for synchronization purposes.  For each slice there is an al-extent that is used to indicate any changes to that slice.  Larger al-extent values make synchronization slower but benefit from less writes to the metadata partition.  In my case, I&#8217;m using an internal metadata which means the drbd metadata is written to the same parition that my nfs data is on.  It would benefit me to have less metadata writes to prevent the disk arm from constantly moving back and forth and degrading performance.  If you are using a raid setup and a separate partition for the metadata then set this number lower to benefit from faster synchronization.  This number MUST be a prime to gain the most possible performance because it is used in specific hashes that benefit from prime number sized structures.</li>
<li><strong>pri-on-incon-degr</strong> &#8211; The &#8220;halt -f&#8221; command is executed if the node is primary, degraded and if the data is inconsistent.  I use this to make sure drbd is halted when there is some sort of data inconsistency to prevent a major mess from occuring.</li>
<li><strong>on-io-error</strong> &#8211; This allows you to handle low level I/O errors.  The method I use is the &#8220;detach&#8221; method.  This is the recommended option by drbd.org. On the occurrence 	      of a lower-level I/O error, the node drops its backing 	      device, and continues in diskless mode.</li>
<li><strong>degr-wfc-timeout</strong> &#8211; This is the amount of time in seconds that is allowed before a connection is timed out.    In case a degraded cluster (cluster with only one node left)   is rebooted, this timeout value is used instead of wfc-timeout,   because the peer is less likely to show up in time,   if it had been dead before.</li>
</ul>
<p>The rest of the config is pretty self explanatory.  Replace nfs1 and nfs2 with the hostnames of your nfs servers.  To get the hostnames use the following command on both servers:</p>
<blockquote><p>uname -n</p></blockquote>
<p>Then replace the disk value with the device name from your fstab file that you commented out.  Enter the IP address of each server and use port 7789.  The last part is the meta-disk.  I used an internal meta-disk because I only have one hard disk in the server and it would not give me any benefit to create a separate partition for the metadata.  If you have a raid setup or a separate disk from your data partition that you can use for the meta data than go ahead and create a 150mb partition.  Replace the word &#8220;internal&#8221; in the config file with your device name that you used for the meta data partition.</p>
<p>Now that we finally have our drbd.conf file ready we can move on.  Lets go ahead and enable the drbd kernel module.</p>
<blockquote><p>modprobe drbd</p></blockquote>
<p>Now that the kernel module is enabled lets start up drbd.</p>
<blockquote><p>drbdadm up all</p></blockquote>
<p>This will start drbd, now lets check its status.</p>
<blockquote><p>cat /proc/drbd</p></blockquote>
<p>You can always use the above command to check the status of drbd.  The above command should show you something like this.</p>
<blockquote><p>0: cs:Connected st:Secondary/Secondary ld:Inconsistent<br />
ns:0 nr:0 dw:0 dr:0 al:0 bm:1548 lo:0 pe:0 ua:0 ap:0<br />
1: cs:Unconfigured</p></blockquote>
<p>You should get some more data before it but the above part is what we are interested in.  If you notice it shows that drbd is connected and both nodes are in secondary mode.  This is because we have not assigned which node is going to be the primary yet.  It also says the data is inconsistent because we have not done the initial sync yet.</p>
<p>I am going to set nfs1 to be my primary node and nfs2 to be my secondary node.  If nfs1 fails, nfs2 will takeover but if nfs1 comes back online then all the data from nfs2 will be synced back to nfs1 and nfs1 will take over again.</p>
<p>First of all lets go ahead and delete any data that was created on the /data partition that we setup during our intial OS installation.  Be very careful with the command below.  Make sure to use the appropriate device because all data on that device will be lost.</p>
<blockquote><p>dd if=/dev/zero bs=1M count=1 of=/dev/VolGroup00/LogVol02; sync</p></blockquote>
<p>Instead of &#8220;/dev/VolGroup00/LogVol02&#8243;, replace it with your device for the /data parition.  Now that the partition is completely erased on both servers, lets create the meta data.</p>
<blockquote><p>drbdadm create-md r0</p></blockquote>
<p><strong>Do the following ONLY on nfs1(10.132.196.221)</strong></p>
<p>Now that the metadata is created, we can move onto assigning a primary node and conducting the initial sync.  It is absolutely important that you only execute the following command on the primary node.  It doesn&#8217;t matter which node you choose to be the primary since they should be identical.  In my case, I decided to use nfs1 as the primary.</p>
<blockquote><p>drbdadm &#8212; &#8211;overwrite-data-of-peer primary r0</p></blockquote>
<p>Ok, now we just have to sit back and wait for the initial sync to finish.  This is going to take some time to finish even though there is no data on each device, drbd has to sync every single block on /data partition from nfs1 to nfs2.  You can check the status by using the following command.</p>
<blockquote><p>cat /proc/drbd</p></blockquote>
<p><strong>Do the following on nfs1(10.132.196.221) and nfs2(10.132.196.222):</strong></p>
<p>After the initial sync is finished, &#8220;cat /proc/drbd&#8221; should show something like this.</p>
<blockquote><p>0: cs:Connected st:Primary/Secondary ld:Consistent<br />
ns:37139 nr:0 dw:0 dr:49035 al:0 bm:6 lo:0 pe:0 ua:0 ap:0<br />
1: cs:Unconfigured</p></blockquote>
<p>If you notice, we are still connected and have a primary and secondary node with consistent data.</p>
<p><strong>Do the following ONLY on nfs1(10.132.196.221):<br />
</strong></p>
<p>Now lets make an ext3 file system on our drbd device and mount it.  Since drbd is running, the ext3 file system will also be created on the secondary node.</p>
<blockquote><p>mkfs.ext3 /dev/drbd0</p></blockquote>
<p>The above command will create an ext3 file system on the drbd device.  Now lets go ahead and mount it.</p>
<blockquote><p>mount -t ext3 /dev/drbd0 /data</p></blockquote>
<p>NFS has important information that it stores in /var/lib/nfs that is required to function properly.  In order to preserve file locks and other such information, we need to have that data stored on the drbd device so that if the primary node failes, NFS on the secondary node will continue from right where the primary node left off.</p>
<blockquote><p>mv /var/lib/nfs/ /data/<br />
ln -s /data/nfs/ /var/lib/nfs<br />
mkdir /data/export<br />
umount /data</p></blockquote>
<p>So lets go over what we just did.  We moved the nfs folder from /var/lib to /data.  Then we created a symbolic link from /var/lib/nfs to /data/nfs since the operating system is still going to look for /var/lib/nfs when nfs is running.  Then we created an export directory in /data to store all the actual data that we are going to use for our nfs share.  Finally, we un-mounted the /data partition since we finished what we were doing.</p>
<p><strong>Do the following ONLY on nfs2(10.132.196.222):</strong></p>
<p>Since we moved the nfs folder to /data, that was synced over to the secondary node as well.  We just need to create the symbolic link so that when the /data partition is mounted on nfs2 we have a link to the nfs data.</p>
<blockquote><p>rm -rf /var/lib/nfs/<br />
ln -s /data/nfs/ /var/lib/nfs</p></blockquote>
<p>So we removed the nfs folder and created a symbolic link from /var/lib/nfs to /data/nfs.  The symbolic link will be broken since the /data parition is not mounted.  Don&#8217;t worry about that because in the event of a failover that partiton will be mounted and everything will work just fine =).</p>
<p><strong>Do the following on nfs1(10.132.196.221) and nfs2(10.132.196.222):</strong></p>
<p>Now onto heartbeat.  Heartbeat is going to make sure partitions are umount/mount and services are started/stopped in the even of a fail over.  So lets get to it.</p>
<blockquote><p>yum install heartbeat</p></blockquote>
<p>Ok, now that we have heartbeat installed, lets go ahead and create our 3 necessary config files.</p>
<blockquote><p>vi /etc/ha.d/ha.cf</p></blockquote>
<p>Paste the following data into ha.cf and save it (:wq).</p>
<blockquote><p>logfacility     local0<br />
keepalive 2<br />
deadtime 10<br />
bcast   eth0<br />
node nfs1 nfs2</p></blockquote>
<p>Replace nfs1 and nfs2 with your server hostnames.  You can retrieve the hostname for each server by executing the following command.</p>
<blockquote><p>uname -n</p></blockquote>
<p>Now lets create our resource config file.</p>
<blockquote><p>vi /etc/ha.d/haresources</p></blockquote>
<p>Put the following data in there and save it.</p>
<blockquote><p>nfs1  IPaddr::10.132.196.220/24/eth0 drbddisk::r0 Filesystem::/dev/drbd0::/data::ext3 nfslock nfs</p></blockquote>
<p>The first word is the hostname for the primary server and should be identical on both servers.  I have chosen nfs1 to be my primary server.  The net part is the virtual IP.  This is the virtual IP we are going to use for the live nfs server, whether it be nfs1 or nfs2.  This ip can be any IP that is not being used within your network.  For example, if your nfs servers have IPs 192.168.0.11 and 192.168.0.12 then maybe you can use 192.168.0.10 as your virtual IP.  Its up to you.</p>
<p>Finally lets create our authentication file.</p>
<blockquote><p>vi /etc/ha.d/authkeys</p></blockquote>
<p>Put the following data in that file and save it.</p>
<blockquote><p>auth 3<br />
3 md5 somepassword12345</p></blockquote>
<p>Replace &#8220;somepassword12345&#8243; with your own password.  This will be used by both of the heartbeat daemons on nfs1 and nfs2 to authenticate each other.  The filw should be read-only by root so lets go ahead and do that.</p>
<blockquote><p>chmod 600 /etc/ha.d/authkeys</p></blockquote>
<p>Thats it!  Lets just start drbd and heartbeat on both servers now.</p>
<blockquote><p>/etc/init.d/drbd start<br />
/etc/init.d/heartbeat start</p></blockquote>
<p>Now we have a redundant NFS server running!  Lets do a couple tests on the primary nfs server.</p>
<blockquote><p>ifconfig</p></blockquote>
<p>We should see our virtual IP address show up.  Mine looks like this.</p>
<blockquote><p>eth0      Link encap:Ethernet  HWaddr 00:14:22:7C:65:6B<br />
inet addr:10.132.196.221  Bcast:10.132.196.255  Mask:255.255.255.0<br />
inet6 addr: fe80::214:22ff:fe7c:656b/64 Scope:Link<br />
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br />
RX packets:897038670 errors:0 dropped:367 overruns:0 frame:0<br />
TX packets:1204564630 errors:0 dropped:0 overruns:0 carrier:0<br />
collisions:0 txqueuelen:1000<br />
RX bytes:245125213396 (228.2 GiB)  TX bytes:1194659917566 (1.0 TiB)<br />
Interrupt:169</p>
<p>eth0:0    Link encap:Ethernet  HWaddr 00:14:22:7C:65:6B<br />
inet addr:10.132.196.220  Bcast:10.132.196.255  Mask:255.255.255.0<br />
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br />
Interrupt:169</p>
<p>lo        Link encap:Local Loopback<br />
inet addr:127.0.0.1  Mask:255.0.0.0<br />
inet6 addr: ::1/128 Scope:Host<br />
UP LOOPBACK RUNNING  MTU:16436  Metric:1<br />
RX packets:372 errors:0 dropped:0 overruns:0 frame:0<br />
TX packets:372 errors:0 dropped:0 overruns:0 carrier:0<br />
collisions:0 txqueuelen:0<br />
RX bytes:50327 (49.1 KiB)  TX bytes:50327 (49.1 KiB)</p></blockquote>
<p>If you notice, eth0:0 has the virtual IP that I used for the nfs servers.  You should only see this on the nfs server that is live.</p>
<p>Now lets check our partitions.</p>
<blockquote><p>df -h</p></blockquote>
<p>The primary nfs server should show the /data mounted while the secondary nfs should not show the drbd device mounted.  My primary nfs server looks like this.</p>
<blockquote><p>Filesystem            Size  Used Avail Use% Mounted on<br />
/dev/mapper/VolGroup00-LogVol00<br />
15G  2.5G   11G  19% /<br />
/dev/sda1              99M   19M   76M  20% /boot<br />
tmpfs                 4.0G     0  4.0G   0% /dev/shm<br />
/dev/drbd0            259G  172G   75G  70% /data</p></blockquote>
<p>Now lets go ahead and mount the nfs share on another server.  First lets create the /data folder on the new server.  This doesn&#8217;t have to be named &#8220;data&#8221; and can be named whatever you like.</p>
<blockquote><p>mkdir /data</p></blockquote>
<p>Now lets setup our nfs mount.</p>
<blockquote><p>vi /etc/fstab</p></blockquote>
<p>At the end of the file, add the following line.</p>
<blockquote><p>10.132.196.220:/data/export  /data    nfs          rw            0    0</p></blockquote>
<p>Replace the IP address with the virtual IP address that you chose for your nfs servers.  Now lets mount the partition for the first time.</p>
<blockquote><p>mount /data</p></blockquote>
<p>Thats it!  Now you have a redundant nfs server and client actually using a redundant nfs server.  Just to simulate a failover lets test some stuff out.  Go ahead and create some files in the &#8220;/data&#8221; folder from your nfs client machine.</p>
<blockquote><p>cd /data<br />
touch testfile1.txt<br />
mkdir testdirectory</p></blockquote>
<p>Now that we have some data in the &#8220;/data&#8221; folder we can simulate a failed nfs server.  If we did everything right, the data that we just created was created on the primary nfs server and synced to the secondary nfs server via drbd.  Lets stop heartbeat on nfs1 so that nfs2 thinks that nfs1 has failed.</p>
<blockquote><p>/etc/init.d/heatbeat stop</p></blockquote>
<p>Now that heartbeat is stopped on nfs1 run the following commands to make sure that the /data partition was unmounted and the virtual IP is gone.</p>
<blockquote><p>df -h<br />
ifconfig</p></blockquote>
<p>When you check the same thing on nfs2, you should see that the /data partition has been mounted and the virtual IP is now live.</p>
<p>Now if you go back to your nfs client machine and do an &#8220;ls&#8221; in the /data directory, you should see that your data is still there.  Lets change our test data around.</p>
<blockquote><p>cd /data<br />
mv testfile1.txt testfile2.txt<br />
rm -rf testdirectory</p></blockquote>
<p>Now lets go back to nfs1 and start up heartbeat again.</p>
<blockquote><p>/etc/init.d/heatbeat start</p></blockquote>
<p>Give it a couple seconds and check the partition and virtual IP.</p>
<blockquote><p>df -h<br />
ifconfig</p></blockquote>
<p>You should see that the partition is mounted again and the virtual IP is also live on nfs1.  If you check the same thing on nfs2, the partition will be un-mounted and the virtual IP should be gone.  If you check the /data directory on your nfs client machine, you should see that the &#8220;testfile2.txt&#8221; file is still there.</p>
<p>Congratulations, you have a fully functional and highly available nfs server!  Check out http://www.drbd.org for more information on DRBD.<code></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tutorialsconnect.com/2009/01/how-to-setup-a-redundant-nfs-server-with-drbd-and-heartbeat-in-centos-5/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Error: Too many open files</title>
		<link>http://www.tutorialsconnect.com/2008/10/error-too-many-open-files/</link>
		<comments>http://www.tutorialsconnect.com/2008/10/error-too-many-open-files/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 05:05:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.tutorialsconnect.com/?p=58</guid>
		<description><![CDATA[Couple days ago, I ran into this error on CentOS 5.2.  To my understanding this error can occur on all flavors of linux. This totally caught me by surprise as I had never seen this before.  I had just finished installing awstats and wanted to run an update for the first time.  The logs were [...]]]></description>
			<content:encoded><![CDATA[<p>Couple days ago, I ran into this error on CentOS 5.2.  To my understanding this error can occur on all flavors of linux.</p>
<p>This totally caught me by surprise as I had never seen this before.  I had just finished installing awstats and wanted to run an update for the first time.  The logs were gathered from 6 webservers and each webserver had about 225 logs.</p>
<p>The awstats log merging script tried to open these log files (225&#215;6 = 1,350 logs) and merge them to read the data but it kept crashing.  The reason it kept crashing was because the limit for the maximum number of files that you are allowed to open in a shell was set to 1024.</p>
<p>To check what your limits are just type in the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">ulimit</span> <span style="color: #660033;">-a</span></pre></div></div>

<p>To change the limit for the number of files you are allowed to open, change the &#8220;open files&#8221; limit.  To do so, type in the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">ulimit</span> <span style="color: #660033;">-n3000</span></pre></div></div>

<p>This will set the limit to 3000 files.  You can set it to whatever number you need to.</p>
<p>After changing my &#8220;open files&#8221; limit, I was able to run my initial awstats update without any issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tutorialsconnect.com/2008/10/error-too-many-open-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Reset the MySQL Root Password</title>
		<link>http://www.tutorialsconnect.com/2008/10/how-to-reset-the-mysql-root-password/</link>
		<comments>http://www.tutorialsconnect.com/2008/10/how-to-reset-the-mysql-root-password/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 20:22:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.tutorialsconnect.com/?p=51</guid>
		<description><![CDATA[Follow the steps below if you have forgotten your mysql root password and wish to reset it. 1.  Create a text file with the following information in it. UPDATE mysql.user SET Password=PASSWORD(&#8216;NEW_PASSWORD&#8217;) WHERE User=&#8217;root&#8217;; FLUSH PRIVILEGES; Replace &#8220;NEW_PASSWORD&#8221; with your desired mysql password.  Save the file to /etc/mysql-pass-reset 2.  Stop MySQL /etc/init.d/mysqld stop 3.  Start [...]]]></description>
			<content:encoded><![CDATA[<p>Follow the steps below if you have forgotten your mysql root password and wish to reset it.</p>
<p>1.  Create a text file with the following information in it.</p>
<blockquote><p>UPDATE mysql.user SET Password=PASSWORD(&#8216;NEW_PASSWORD&#8217;) WHERE User=&#8217;root&#8217;;<br />
FLUSH PRIVILEGES;</p></blockquote>
<p>Replace &#8220;NEW_PASSWORD&#8221; with your desired mysql password.  Save the file to /etc/mysql-pass-reset</p>
<p>2.  Stop MySQL</p>
<blockquote><p>/etc/init.d/mysqld stop</p></blockquote>
<p>3.  Start mysqld_safe with the &#8211;init-file option like so:</p>
<blockquote><p>mysqld_safe &#8211;init-file=/etc/mysql-pass-reset &amp;</p></blockquote>
<p>This will start mysql and execute the query in the text file you created.</p>
<p>4.  Now stop and start mysql back up normally without the &#8211;init-file option.</p>
<blockquote><p>/etc/init.d/mysqld stop<br />
/etc/init.d/mysqld start</p></blockquote>
<p>Don&#8217;t forget to delete the &#8220;mysql-pass-reset&#8221; file when you are done!</p>
<blockquote><p>rm /etc/mysql-pass-reset</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.tutorialsconnect.com/2008/10/how-to-reset-the-mysql-root-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Install ThinkorSwim in Linux</title>
		<link>http://www.tutorialsconnect.com/2008/10/how-to-install-thinkorswim-in-linux/</link>
		<comments>http://www.tutorialsconnect.com/2008/10/how-to-install-thinkorswim-in-linux/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 23:13:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.tutorialsconnect.com/?p=46</guid>
		<description><![CDATA[Here are the quick an easy steps on how to install TOS in Linux (Debian Distro). First you will need to setup Java on your computer so lets go ahead and do that. Open up the console and login as super user. su Now that we have full privileges, lets edit the sources.list file so [...]]]></description>
			<content:encoded><![CDATA[<p>Here are the quick an easy steps on how to install TOS in Linux (Debian Distro).</p>
<p>First you will need to setup Java on your computer so lets go ahead and do that. Open up the console and login as super user.</p>
<blockquote><p>su</p></blockquote>
<p>Now that we have full privileges, lets edit the sources.list file so that we can fetch the much needed java packages.</p>
<blockquote><p>pico /etc/apt/sources.list</p></blockquote>
<p>This will bring up your sources.list file in the editor. You should see something that looks like this:</p>
<blockquote><p>deb http://debian.lcs.mit.edu/debian etch main<br />
deb-src http://debian.lcs.mit.edu/debian etch main</p></blockquote>
<p>Add the words “contrib non-free” at the end of both lines so it looks like the following:</p>
<blockquote><p>deb http://debian.lcs.mit.edu/debian etch main contrib non-free<br />
deb-src http://debian.lcs.mit.edu/debian etch main contrib non-free</p></blockquote>
<p>Now hit “Ctrl + O” to write the changes to the file. Then hit enter to accept the changes. Now hit “Ctrl + X” to exit the editor. That was the hard part <img src='http://www.tutorialsconnect.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Lets update our package listing and download the java packages by running the following commands:</p>
<blockquote><p>apt-get update<br />
apt-get install sun-java5-jre sun-java5-jdk</p></blockquote>
<p>Follow the onscreeen instructions to complete the installation of the java packages. Its pretty much gonna ask you to agree to the licenses. After you are done you can close the console window.</p>
<p><span id="more-46"></span></p>
<p>Now log in to your TOS account and download their software for Linux. Save it to your desktop. Once the download is complete you should have a shell script file sitting on your desktop. The extension of the file should be .sh. Go ahead and open your console again.</p>
<p>Type in the following command to change your current working directory to your desktop directory:</p>
<blockquote><p>cd Desktop</p></blockquote>
<p>Now lets make the installation script executable.</p>
<blockquote><p>chmod +x thinkorswim_installer.sh</p></blockquote>
<p>We are ready to install the software now. Just type in the following command.</p>
<blockquote><p>./thinkorswim_installer.sh</p></blockquote>
<p>If you get an xserver error just run the command again with the “-c” argument like this:</p>
<blockquote><p>./thinkorswim_installer.sh -c</p></blockquote>
<p>Now just follow the on screen instructions. Let it install in the default directory “/usr/local/thinkorswim”. Once that is done installing we need to change the permissions on the installation folder so that it doesn’t stall on the update page. To do this we need super user privileges.</p>
<blockquote><p>su</p></blockquote>
<p>Now lets change the permissions on the entire thinkorswim folder recursively.</p>
<blockquote><p>chmod 777 /usr/local/thinkorswim -R</p></blockquote>
<p>Thats it, you are all set now. You can run the program by navigating to /usr/local/thinkorswim and clicking on the thinkorswim executable file.</p>
<p>You can also create a shortcut in your start menu. In KDE just right click on the kmenu and go to edit. Add a new menu item and enter the following in the path field:</p>
<blockquote><p>/usr/local/thinkorswim/thinkorswim.sh</p></blockquote>
<p>Thats it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tutorialsconnect.com/2008/10/how-to-install-thinkorswim-in-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Understanding Linux File Permissions</title>
		<link>http://www.tutorialsconnect.com/2008/10/understanding-linux-file-permissions/</link>
		<comments>http://www.tutorialsconnect.com/2008/10/understanding-linux-file-permissions/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 06:13:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.tutorialsconnect.com/?p=18</guid>
		<description><![CDATA[File permissions in Linux are actually pretty easy to understand and modify.  To check the permissions on a file just navigate to the directory and use the following command to list the files and their details. ls -l As you can see, the first piece of information on each line are the permissions.  There are [...]]]></description>
			<content:encoded><![CDATA[<p>File permissions in Linux are actually pretty easy to understand and modify.  To check the permissions on a file just navigate to the directory and use the following command to list the files and their details.</p>
<blockquote><p>ls -l</p></blockquote>
<p>As you can see, the first piece of information on each line are the permissions.  There are 3 sets of permissions put together all into one line.  The very first character denotes whether the file is a directory, a link or a file.</p>
<p>- = file<br />
l = symbolic link<br />
d = directory</p>
<p>The 3 characters following the first character represent the permission information for the file owner.  The 3 characters following that denote the permissions for the group and the last 3 characters are the file permissions for everyone else.  A key for what the characters mean is listed below:</p>
<p>- = no read, write, or execute permissions<br />
r = read<br />
w = write<br />
x = execute</p>
<p>For example, lets say we have the following permission information on a file.</p>
<p>drwxr-xr-x</p>
<p>Since the first character is &#8220;d&#8221; we know that its a directory.  Then next 3 characters are &#8220;rwx&#8221; which means that the owner has read, write, and execute permissions.  The next set of characters are &#8220;r-x&#8221; which means the group has read and execute permissions but no write permissions.  The last 3 characters are &#8220;r-x&#8221; which means that everyone else has read and execute permissions but no write permissions.<br />
You can easily change file permissions by using the &#8220;chmod&#8221; command.  Using numbers to change permissions on a file is very quick, easy, and precise.  A key for what each number represents is listed below.</p>
<p>4 = read<br />
2 = write<br />
1 = execute</p>
<p>You have to set permissions for the owner, group, and everyone else all at the same time when using the number method so that means there will be 3 numbers.  The first number is the permission for the owner, the second is for the permission of the group and the last number is the file permission for everyone else.</p>
<p>To give the owner, group, and everyone else only read permissions then the command would be the following.</p>
<blockquote><p>chmod 444 filename</p></blockquote>
<p>To give the owner, group, and everyone else read and execute permission then you just add the numbers together.  So 4(read) + 1(execute) = 5.</p>
<blockquote><p>chmod 555 filename</p></blockquote>
<p>The numbers don&#8217;t have to be the same, you can give different permissions to the owner, group and everyone else all in one shot.  So lets say you want the file owner to have read, write and execute permissions but you want the group and everyone else to have only read and execute permissions.  The command to do this would be the following.</p>
<blockquote><p>chmod 755 filename</p></blockquote>
<p>If you are applying permissions to a folder and would like to recursively change the permissions of the contents as well then don&#8217;t forget to use the capital &#8216;R&#8217; switch:</p>
<blockquote><p>chmod -R 755 somedir</p></blockquote>
<p>Remember, the first digit is for the owner, the second digit is for the group and the last digit is for everyone else.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tutorialsconnect.com/2008/10/understanding-linux-file-permissions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

