<?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>Linux Admin Zone &#187; linux</title>
	<atom:link href="http://linuxadminzone.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://linuxadminzone.com</link>
	<description>Adding more reasons to celebrate Open Source.</description>
	<lastBuildDate>Wed, 09 May 2012 10:17:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Top 5 most useful commands or tools for Linux administrators</title>
		<link>http://linuxadminzone.com/top-5-most-useful-commands-tools-for-linux-administrators/</link>
		<comments>http://linuxadminzone.com/top-5-most-useful-commands-tools-for-linux-administrators/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 10:13:42 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=187</guid>
		<description><![CDATA[There are plenty such tools which are definitely very useful for Linux admins. Here I am just trying to figure out 5 of such useful tools which are used by a normal Linux administrator in day to day operations. A tool which I think is most useful may not fit in your usage and its [...]]]></description>
			<content:encoded><![CDATA[<p>There are plenty such tools which are definitely very useful for Linux admins. Here I am just trying to figure out 5 of such useful tools which are used by a normal Linux administrator in day to day operations. A tool which I think is most useful may not fit in your usage and its definitely possible that you know some awesome tool which I forgot to include here, for such case, I am requesting hereby to please mention the tool in comments. One more thing, I am mentioning here tools which are somewhat optional and not absolutely required for everybody and excluding tool which have no viable alternative and every Linux admin have to use them.. such as SSH, SCP etc. </p>
<p><strong> #5. head/tail </strong></p>
<p>Most of time, the sole purpose of logging in a server is to diagnose some issue and the common way to start this is to look at logs. Logs of different applications like Apache, MySQL, mail logs etc. What you use to look at logs? isn&#8217;t that tail? similarly we sometimes use &#8216;head&#8217; to check few starting lines of any file. </p>
<p>Few examples: </p>
<p>* Continuously check Apache error log file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>error_log</pre></div></div>

<p>* View first 15 linues from MySQL log:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-15</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>mysqld.log</pre></div></div>

<p><strong> #4. vi/nano/emacs </strong> </p>
<p>Text editor basically needed frequently to create/update config files. I prefer vim, simply because I am very comfortable with it and remembers some of its useful commands for quick editing. </p>
<p>few example of working with vi. open a file with vi and without going in insert mode, here are useful character you can press:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">=<span style="color: #000000; font-weight: bold;">&gt;</span> jump to end of line
 $
=<span style="color: #000000; font-weight: bold;">&gt;</span> start of line
 <span style="color: #000000;">0</span>
=<span style="color: #000000; font-weight: bold;">&gt;</span> Delete rest of line
 D
=<span style="color: #000000; font-weight: bold;">&gt;</span> Repeat the <span style="color: #c20cb9; font-weight: bold;">last</span> <span style="color: #7a0874; font-weight: bold;">command</span> given: 
. <span style="color: #7a0874; font-weight: bold;">&#40;</span>dot<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
=<span style="color: #000000; font-weight: bold;">&gt;</span> add <span style="color: #ff0000;">'maal'</span> to the end of every line. <span style="color: #000000;">1</span> is line <span style="color: #000000;">1</span>, $ is the <span style="color: #c20cb9; font-weight: bold;">last</span> line
:<span style="color: #000000;">1</span>,$ s<span style="color: #000000; font-weight: bold;">/</span>$<span style="color: #000000; font-weight: bold;">/</span>maal<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
=<span style="color: #000000; font-weight: bold;">&gt;</span> put <span style="color: #ff0000;">'bingo'</span> at the start of lines <span style="color: #000000;">5</span>-<span style="color: #000000;">10</span>
:<span style="color: #000000;">5</span>,<span style="color: #000000;">10</span> s<span style="color: #000000; font-weight: bold;">/</span>^<span style="color: #000000; font-weight: bold;">/</span>bingo<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
=<span style="color: #000000; font-weight: bold;">&gt;</span> change foo to bar <span style="color: #000000; font-weight: bold;">for</span> all occurrences <span style="color: #000000; font-weight: bold;">in</span> the rest of the <span style="color: #c20cb9; font-weight: bold;">file</span> from where the cursor is
:s<span style="color: #000000; font-weight: bold;">/</span>foo<span style="color: #000000; font-weight: bold;">/</span>bar<span style="color: #000000; font-weight: bold;">/</span>g
&nbsp;
=<span style="color: #000000; font-weight: bold;">&gt;</span> Delete current line and got into insert mode.
C
&nbsp;
=<span style="color: #000000; font-weight: bold;">&gt;</span> Remove the ^M from files that came from windows:
:se <span style="color: #007800;">ff</span>=unix
&nbsp;
=<span style="color: #000000; font-weight: bold;">&gt;</span> Turn on<span style="color: #000000; font-weight: bold;">/</span>off display of line numbers: 
 :<span style="color: #000000; font-weight: bold;">set</span> nu
 :<span style="color: #000000; font-weight: bold;">set</span> nonu
&nbsp;
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">if</span> you want actual line numbers <span style="color: #000000; font-weight: bold;">in</span> your <span style="color: #c20cb9; font-weight: bold;">file</span>:
:<span style="color: #000000; font-weight: bold;">%!</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #660033;">-n</span>
&nbsp;
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">find</span> the word under cursor
 <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>star<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p><strong> #3. screen </strong> </p>
<p>screen is one of much underutilized command in nix world. take a scenario, when last time you issued a command in remote server and find out that the command will take hours to complete? or you are in need to login in 10 servers and check something.. copy files among them.. and voila.. your internet connection get reset and your ssh session get terminated. Here comes screen, once you start using it, you will get hooked to it. Screen is a terminal multiplexer that allows you to manage many processes (like ssh sessions) through one physical terminal. Each process gets its own virtual window, and you can bounce between virtual windows interacting with each process.</p>
<p>Let me give you more insight. Suppose you have many servers and ideally you should restrict ssh (port 22) access to selected IPs only. So, you login into one server which allows access from remote IPs. You can start screen there by typing &#8216;screen&#8217; (all major Linux distributions have screen already installed). You can see a status bar. create new screen windows by pressing Ctrl+ac. switch between them by pressing Ctrl+an (next) and Ctrl+ap (previous). Basically, for b It offers very useful features like Remote terminal session management (detaching or sharing terminal sessions), unlimited windows (unlike the hardcoded number of Linux virtual consoles), copy/paste between windows, notification of either activity or inactivity in a window, split terminal (horizontally and vertically) into multiple regions, sharing terminals etc.</p>
<p>You can save your preferences in .screenrc, like here&#8217;s my .screenrc where I&#8217;ve redefining status bar look and feel and assigning key f5 (previous window) and f6 (next window):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cat</span> ~<span style="color: #000000; font-weight: bold;">/</span>.screenrc 
<span style="color: #666666; font-style: italic;"># no annoying audible bell, please</span>
vbell on
&nbsp;
<span style="color: #666666; font-style: italic;"># detach on hangup</span>
autodetach on
&nbsp;
<span style="color: #666666; font-style: italic;"># don't display the copyright page</span>
startup_message off
&nbsp;
<span style="color: #666666; font-style: italic;"># emulate .logout message</span>
pow_detach_msg <span style="color: #ff0000;">&quot;Screen session of <span style="color: #000099; font-weight: bold;">\$</span>LOGNAME <span style="color: #000099; font-weight: bold;">\$</span>:cr:<span style="color: #000099; font-weight: bold;">\$</span>:nl:ended.&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># advertise hardstatus support to $TERMCAP</span>
termcapinfo xterm<span style="color: #000000; font-weight: bold;">*</span> ti<span style="color: #000000; font-weight: bold;">@</span>:te<span style="color: #000000; font-weight: bold;">@</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># make the shell in every window a login shell</span>
shell -<span style="color: #007800;">$SHELL</span>
&nbsp;
defscrollback <span style="color: #000000;">10000</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Extend the vt100 desciption by some sequences.</span>
&nbsp;
termcap vt<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #007800;">AF</span>=\E<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">%</span>dm:<span style="color: #007800;">AB</span>=\E<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">%</span>dm 
caption always
caption string <span style="color: #ff0000;">'%{= wk}[ %{k}%H %{k}][%= %{= wk}%?%-Lw%?%{r}(%{r}%n*%f%t%?(%u)%?%{r})%{k}%?%+Lw%?%?%= %{k}][%{b} %d/%m %{k}%c %{k}]'</span> 
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># keybindings</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">bind</span> <span style="color: #660033;">-k</span> F5 prev 
<span style="color: #7a0874; font-weight: bold;">bind</span> <span style="color: #660033;">-k</span> F6 next</pre></div></div>

<p><strong> #2. netstat/nmap </strong></p>
<p>These are very useful commands to diagnose things about network. of course, ping/traceroute may be most commonly used ones but the usefulness wise, nmap and netstat are more useful than a basic ping. netstat stands for network status. nmap is a sort of security/port scanner or you can say a network exploration command.</p>
<p>few examples of netstat:<br />
* Display total number of internet (port 80) connections:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-an</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> :<span style="color: #000000;">80</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">wc</span> <span style="color: #660033;">-l</span></pre></div></div>

<p>* Display all ports your machine listening on:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-ant</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> LISTEN</pre></div></div>

<p>* Scan a machine on your LAN with nmap and know which ports are open on it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">nmap</span> ip</pre></div></div>

<p><strong> #1. find and grep </strong><br />
List of some routine tasks: How many files are there consuming most of disk space? Delete all temporary files older than 2 days, find out how many files have old server name written in them which is causing issue? rename all &#8216;.list&#8217; to &#8216;.txt&#8217;. The commands find, grep are your best friend here. </p>
<p>Find command is used to search for files. you can specify many options with it like files created today or having size greater then you specified. Normally we also combine find with xargs or exec to issue commands on files returned by find. </p>
<p>examples of find command:<br />
* find top 10 largest files in /var:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>var <span style="color: #660033;">-type</span> f <span style="color: #660033;">-ls</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-k</span> <span style="color: #000000;">7</span> <span style="color: #660033;">-r</span> <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-10</span></pre></div></div>

<p>* find all files having size more than 5 GB in /var/log/:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-size</span> +5120M <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lh</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;</pre></div></div>

<p>* find all today&#8217;s files and copy them to another directory:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>me<span style="color: #000000; font-weight: bold;">/</span>files <span style="color: #660033;">-ctime</span> <span style="color: #000000;">0</span>  <span style="color: #660033;">-print</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;</pre></div></div>

<p>* find all temp files older than a week and delete:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>temp<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-mtime</span> +<span style="color: #000000;">7</span>-type f <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span></pre></div></div>

<p>* find and rename all mp3 files by changing their uppercase names to lowercase:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>me<span style="color: #000000; font-weight: bold;">/</span>music<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-name</span> <span style="color: #000000; font-weight: bold;">*</span>.mp3 <span style="color: #660033;">-exec</span> rename <span style="color: #ff0000;">'y/[A-Z]/[a-z]/'</span> <span style="color: #ff0000;">'{}'</span> \;</pre></div></div>

<p>some examples of grep command: </p>
<p>* Print Apache&#8217;s documentroot directory name:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> documentroot  <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>httpd.conf</pre></div></div>

<p>* View file contents without comments and empty lines:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-Ev</span> “^$<span style="color: #000000; font-weight: bold;">|</span>^<span style="color: #666666; font-style: italic;">#” /etc/my.cnf</span></pre></div></div>

<p>* print only IP address assigned to the interface:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ifconfig</span> eth0 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'inet addr:'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span><span style="color: #ff0000;">':'</span> <span style="color: #660033;">-f2</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $1}'</span></pre></div></div>

<p>* How many email messages sent for a particular date:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>maillog <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;status=sent&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;May 25&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> <span style="color: #660033;">-l</span></pre></div></div>

<p>* Find out a running process/daemon from process list (thanks to staranneph for recalling this):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-ef</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> mysql</pre></div></div>

<p>* You can also note cpu/mem usage by using above. like in below command output, you can see that Plesk&#8217;s statistics process is utilizing more than 18% cpu alone:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>myserver ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ps aux | grep statistics</span>
root      <span style="color: #000000;">8183</span> <span style="color: #000000;">18.4</span>  <span style="color: #000000;">0.0</span>  <span style="color: #000000;">58384</span>  <span style="color: #000000;">2848</span> ?        D    04:05   <span style="color: #000000;">3</span>:00 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>psa<span style="color: #000000; font-weight: bold;">/</span>admin<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>statistics</pre></div></div>

<p>I would like to know your thoughts, any command / tool you think should be included in top 5 here. </p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/top-5-most-useful-commands-tools-for-linux-administrators/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Setting up mutiple MySQL Database servers on a single linux machine</title>
		<link>http://linuxadminzone.com/setting-up-mutiple-mysql-database-servers-on-a-single-linux-machine/</link>
		<comments>http://linuxadminzone.com/setting-up-mutiple-mysql-database-servers-on-a-single-linux-machine/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 09:35:53 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=149</guid>
		<description><![CDATA[One of my friend requested to setup two independent MySQL DB servers in his CentOS 5.4 server box. One MySQL (5.0.77) service was already running on the machine, So I had to install another one. Though, I dont recommend running multiple instances on a single server, instead due to cheap hardware you may better setup [...]]]></description>
			<content:encoded><![CDATA[<p>One of my friend requested to setup two independent MySQL DB servers in his CentOS 5.4 server box. One MySQL (5.0.77) service was already running on the machine, So I had to install another one. Though, I dont recommend running multiple instances on a single server, instead due to cheap hardware you may better <a href="http://linuxadminzone.com/setting-up-a-mysql-cluster-7-0-in-redhat-based-linux/">setup a MySQL cluster for best performance</a>. In this case, after initial investigation, I&#8217;ve found that there are few ways to implement this. The idea of using <a href="https://edge.launchpad.net/mysql-sandbox">MySQL Sandbox</a> interested me most. At the end of day, there was two server running simultaneously on the using different ports for connections. Here are the steps, I took to install and configure multiple MySQL servers: </p>
<p>1. Download, compile and install MySQL sandbox:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>edge.launchpad.net<span style="color: #000000; font-weight: bold;">/</span>mysql-sandbox<span style="color: #000000; font-weight: bold;">/</span>mysql-sandbox-<span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span>mysql-sandbox-<span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span>+download<span style="color: #000000; font-weight: bold;">/</span>MySQL-Sandbox-3.0.05.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xzf MySQL-Sandbox-3.0.05.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> MySQL-Sandbox-3.0.05
<span style="color: #c20cb9; font-weight: bold;">perl</span> Makefile.PL
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #7a0874; font-weight: bold;">test</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>2. Get the latest binary tarball for MySQL server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>dev.mysql.com<span style="color: #000000; font-weight: bold;">/</span>get<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>MySQL-<span style="color: #000000;">5.1</span><span style="color: #000000; font-weight: bold;">/</span>mysql-5.1.41-linux-x86_64-icc-glibc23.tar.gz<span style="color: #000000; font-weight: bold;">/</span>from<span style="color: #000000; font-weight: bold;">/</span>http:<span style="color: #000000; font-weight: bold;">//</span>mirror.csclub.uwaterloo.ca<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Here, I&#8217;ve downloaded MySQL 5.1.41 server tarball. Please note that one MySQL was already there on server having different version (ver 5.0.77). For second installation, I&#8217;ve downloaded different version to test out things but for best compatibility, its recommended to download same version. </p>
<p>3. Create new sandbox for single MySQL server. Pls note that you should run following command from a non-root user. Though, in my case, I went ahead and wanted to run command by root user and for that, we must set an environment variable to > 0 value.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">SANDBOX_AS_ROOT</span>=<span style="color: #000000;">1</span>     <span style="color: #666666; font-style: italic;">## no need if your are executing below command from non-root user</span>
make_sandbox  <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>mysql-5.1.41-linux-x86_64-icc-glibc23.tar.gz</pre></div></div>

<p>4. Sandbox should be created without any glitch. you can go inside the config directory and check that out:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>sandboxes<span style="color: #000000; font-weight: bold;">/</span>msb_5_1_41</pre></div></div>

<p>Pls replace root here with your normal username in case you created sandbox with non-root user. Also note down that sandbox created new directory using 5_1_41 naming based on your MySQL server version. This is the default behaviour and we can change it via configuration of sandbox. Also note down that the new MySQL server will listen on same port number ie. 5141. </p>
<p>5. Start and use the service of newly installed MySQL server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>start   <span style="color: #666666; font-style: italic;">## make sure you are in /root/sandboxes/msb_5_1_41 directory</span></pre></div></div>

<p>server should be started. now try to login in MySQL:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>use</pre></div></div>

<p>You should be in MySQL prompt. You can update these scripts (use, start, stop etc.) as per your taste. The default configuration file for MySQL will be in this directory having name as my.sandbox.cnf. You can update this MySQL config file as per your requirements. </p>
<p>Also dont forget to update root password and if you ever encounter situation where you forgot the password, refer <a href="http://linuxadminzone.com/recover-or-reset-root-password-of-mysql-and-postgresql-servers/">these instructions to quickly reset MySQL root password</a>. </p>
<p>Try to connect this MySQl service using your script after making sure that you must specify port 5141 (or whatever you mentioned in configs) while connecting because this service is not listening to default MySQL port 3306. </p>
<p>If you want to use PhpMyAdmin to manage these multiple MySQL services, <a href="http://linuxadminzone.com/install-and-configure-phpmyadmin-to-manage-multiple-mysql-servers/">Here&#8217;s post</a> that will help you configuring PhpMyAdmin. </p>
<p>Other useful posts on MySQL in this blog: </p>
<p>* <a href="http://linuxadminzone.com/setting-up-a-mysql-cluster-7-0-in-redhat-based-linux/">Setup MySQL Cluster in Redhat based Linux</a>.<br />
* <a href="http://linuxadminzone.com/optimize-mysql-on-a-large-database-server/">Optimize a large installation of MySQL</a>.<br />
* <a href="http://linuxadminzone.com/quickly-repair-a-huge-corrupted-or-crashed-table-in-mysql/">Quickly repair a huge corrupted or crashed table</a>.<br />
* <a href="http://linuxadminzone.com/ignore-mysql-error-while-executing-bulk-statements/">How to ignore MySQL errors while executing bulk statements</a><br />
* <a href="http://linuxadminzone.com/optimize-and-fix-mysql-server-running-slow-without-any-load/">Fix MySQL running slow without any know reason</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/setting-up-mutiple-mysql-database-servers-on-a-single-linux-machine/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Quickly sync/update time from a time server</title>
		<link>http://linuxadminzone.com/quickly-sync-or-update-time-from-a-time-server/</link>
		<comments>http://linuxadminzone.com/quickly-sync-or-update-time-from-a-time-server/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 06:09:45 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[date time sync]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=80</guid>
		<description><![CDATA[A good server machine should always tick its clock with correct time. The best way to keep it in shape is to sync with a time server. You can use any preferred time server to sync. I&#8217;m using public time servers here: $ ntpdate pool.ntp.org 5 Feb 11:17:00 ntpdate&#91;3332&#93;: step time server 220.225.252.202 offset -585.969659 [...]]]></description>
			<content:encoded><![CDATA[<p>A good server machine should always tick its clock with correct time. The best way to keep it in shape is to sync with a time server. </p>
<p>You can use any preferred time server to sync. I&#8217;m using public time servers here:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ntpdate pool.ntp.org
<span style="color: #000000;">5</span> Feb <span style="color: #000000;">11</span>:<span style="color: #000000;">17</span>:00 ntpdate<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">3332</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: step <span style="color: #000000; font-weight: bold;">time</span> server 220.225.252.202 offset -<span style="color: #000000;">585.969659</span> sec</pre></div></div>

<p>Network time update command (ntpdate) will contact the available time server from public pool and sync time with it. Here in above example, offset is denoting that the clock was running ahead of time in my server.</p>
<p>To remain updated, you should put a cron entry to sync with time server every midnight:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ crontab <span style="color: #660033;">-e</span>
<span style="color: #000000;">0</span> <span style="color: #000000;">4</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>ntpdate pool.ntp.org</pre></div></div>

<p>This will update/correct your time in server at 04:00 am every morning. I&#8217;ve written a very quick trick to correct your time. If you are interested to study further, you can find detailed information <a href="http://tldp.org/HOWTO/TimePrecision-HOWTO/ntp.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/quickly-sync-or-update-time-from-a-time-server/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Optimize and fix Mysql Server, running slow without any load</title>
		<link>http://linuxadminzone.com/optimize-and-fix-mysql-server-running-slow-without-any-load/</link>
		<comments>http://linuxadminzone.com/optimize-and-fix-mysql-server-running-slow-without-any-load/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 12:09:11 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[hostname]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[slow query]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=21</guid>
		<description><![CDATA[I got stuck in a weird problem yesterday, where a newly installed MySQL Server was responding slow. I&#8217;ve fixed the issue after detecting a small spelling mistake in file which is entirely not related to MySQL at first instance. Here are some tips, if you&#8217;re also on the same boat where Server itself doesnt showing [...]]]></description>
			<content:encoded><![CDATA[<p>I got stuck in a weird problem yesterday, where a newly installed MySQL Server was responding slow. I&#8217;ve fixed the issue after detecting a small spelling mistake in file which is entirely not related to MySQL at first instance. Here are some tips, if you&#8217;re also on the same boat where Server itself doesnt showing any error, but your user&#8217;s lodging complaints of being slow.</p>
<p><strong>1. Check MySQL Configurations: </strong></p>
<p><strong>my.cnf:</strong> My Server machine has 2 GB of RAM, So, I&#8217;ve optimized my.cnf to make use of plenty of RAM. But that was not the issue because eventually no one was accessing this Server except some perl scripts residing on another Server in LAN. Its a good practice though, to replace your /etc/my.cnf with my-huge.cnf in case your machine have 2 or more GB of RAM and fast multi-core processor. You can find my-huge.cnf in /usr/share/doc/MySQL-server-community-5.0.51a/ directory if you have installed latest MySQL version (5.0.51a while writing this article).</p>
<p><strong> DNS Resolution:</strong> I was accessing MySQL server from remote machine using its IP Address, so DNS should not be the issue. Check DNS stuff, if you are trying hostname instead of IP. For optimum response, always access db server with its IP. To do that, simply add &#8220;<strong>skip-name-resolve</strong>&#8221; keyword in mysqld section of your my.cnf.</p>
<p><strong> Bind to IP:</strong> Its better to bind Server to a particular IP Address. you can use something like this <em>bind-address=192.168.0.5</em> in your my.cnf</p>
<p><strong> Turn on Logging:</strong> Turn on slow queries logging and find out queries running too slow. This was also not the issue at my side, but its better to have a look at it. You can use <em>log-slow-queries = /var/log/mysql-slow-query.log</em> statement in my.cnf under mysqld section to enable logging.</p>
<p>Note: You need to restart your MySQL Server everytime after updating config file. As we are investigating slow response issue, I assume you already have user&#8217;s and proper rights to access the Server from remote site.</p>
<p><strong>2. System State:</strong> After checking the MySQL settings, you need to verify various parameters in the Server machine, some important points you should check:<br />
<strong>Load:</strong> Check the current load by using top or cat /proc/loadavg commands.<br />
<strong>Disk Space:</strong> Check disk space using df -h command and verify there&#8217;s some free space for proper working of Server. You can also check excessive I/O requests using iostate command.</p>
<p><strong>3. Network:</strong> Time to check network settings. Check port 3306 (MySQL default port) is open. To check whether this port is open and accessible from remote, issue &#8220;telnet &lt;mysql_server_IP&gt; 3306&#8243; command, it should get connected otherwise check your network/firewall settings.</p>
<p>So, you have checked everything and found that MySQL response is still slow even there&#8217;s no load, no disk space or network issue, accessing with IP Address so no DNS issue, etc. etc. and etc.</p>
<p>At the last resort, I checked hostname of my Server and amazed that by fixing hostname properly, My problem get resolved. How? check it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">hostname</span>
testservre.example.com
$ <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts
127.0.0.1	testserver testserver.example.com localhost.localdomain localhost</pre></div></div>

<p>You can see that there&#8217;s slight spelling mistake in hostname, displayed by hostname command and that written in hosts file. Just fix your hosts file and check it. You should note down that, even after using IP Address to access MySQL Server, its still important to set proper DNS Hostname for your Server as its was verified when authenticating remote clients.</p>
<p>You may also like to read:<br />
* <a href="http://linuxadminzone.com/quick-web-based-php-script-to-check-replication-status-of-mysql/"> Quick and simple php based script to check replication status of multiple MySQL Servers </a><br />
* <a href="http://linuxadminzone.com/setting-up-mutiple-mysql-database-servers-on-a-single-linux-machine/"> Setup multiple MySQL database servers in a single Linux host </a><br />
* <a href="http://linuxadminzone.com/optimize-mysql-on-a-large-database-server/"> Optimize MySQL on a large Database Server </a><br />
* <a href="http://linuxadminzone.com/recover-or-reset-root-password-of-mysql-and-postgresql-servers/"> Recover or reset root password of MySQL and PostgreSQL Servers </a><br />
* <a href="http://linuxadminzone.com/setting-up-a-mysql-cluster-7-0-in-redhat-based-linux/"> How to setup MySQL Cluster 7.0 in Redhat based Linux </a><br />
* <a href="http://linuxadminzone.com/find-out-the-clients-of-your-mysql-server/"> How to find out the clients connecting to your MySQL server </a><br />
* <a href="http://linuxadminzone.com/quickly-repair-a-huge-corrupted-or-crashed-table-in-mysql/"> Quickly repair huge corrupted or crashed table in MySQL </a><br />
* <a href="http://linuxadminzone.com/install-and-configure-phpmyadmin-to-manage-multiple-mysql-servers/"> Install and configure PhpMyAdmin to manage multiple MySQL Servers </a> </p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/optimize-and-fix-mysql-server-running-slow-without-any-load/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Install perl Net::SFTP module in linux</title>
		<link>http://linuxadminzone.com/install-perl-netsftp-module-in-linux/</link>
		<comments>http://linuxadminzone.com/install-perl-netsftp-module-in-linux/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 11:20:27 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[net sftp]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=17</guid>
		<description><![CDATA[When installing perl Net::SFTP module in CentOS 5 box: # perl -MCPAN -e 'install Net::SSH::Perl' It got stuck at: t/01-compile.t&#8230;..ok t/02-buffer.t&#8230;&#8230;ok t/03-packet.t&#8230;&#8230;1/10 then I tried installation with force so that it can skip tests if any of them failed: # perl -MCPAN -e 'force install Net::SSH::Perl' The module seems installed ok but while using in [...]]]></description>
			<content:encoded><![CDATA[<p>When installing perl Net::SFTP module in CentOS 5 box:  </p>
<p><code># perl -MCPAN -e 'install Net::SSH::Perl'<br />
</code><br />
It got stuck at:</p>
<p>t/01-compile.t&#8230;..ok<br />
t/02-buffer.t&#8230;&#8230;ok<br />
t/03-packet.t&#8230;&#8230;1/10</p>
<p>then I tried installation with force so that it can skip tests if any of them failed: </p>
<p><code># perl -MCPAN -e 'force install Net::SSH::Perl'</code></p>
<p>The module seems installed ok but while using in a script, error occured:<br />
<em>Can&#8217;t locate Net/SSH/Perl/Buffer.pm in @INC &#8230;</em></p>
<p>that means, the module still not installed/configured properly. To get it done, I searched for rpms and found rpmforge repository <a href="http://dag.wieers.com/rpm/packages/rpmforge-release/">http://dag.wieers.com/rpm/packages/rpmforge-release/</a> have all the sufficient rpms: </p>
<p><code># rpm -ivh /usr/src/rpmforge-release-0.3.4-1.el4.rf.i386.rpm</code><br />
<code># yum install perl-Net-SSH-Perl --enablerepo=rpmforge</code></p>
<p>and its done.</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/install-perl-netsftp-module-in-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

