When an aspiring Linux system admin inquired me about some good books to read on this topic, I recommended few ones. I glad he liked few books and this gives me an insight to share the list with my blog readers. It definitely a challenging task to filter out 5 books from ocean. There are too many books which looks superior to each other but for the sake of preparing the list, I’ve selected my 5 favorites. Does it mean I think others are not good? Nope. It only means given a choice at a certain point of time, few books will pop up in your mind, which you think are better and that’s how the list get prepared.
This is a preview of
Top 5 best and highly recommended books for linux/unix system admins
.
Read the full post (1222 words, 5 images, estimated 4:53 mins reading time)
July 4th, 2011 | Posted in General | 1 Comment
Here are the steps I’ve taken to turn on user chat logging for a jabber server. Please note that this way is not very efficient as it logs chats in plain html file. Logging into database might be more suitable for you.
Step 1: Checkout jabber modules
User chat logging in plain html files are provided by jabber module mod_log_chat. We are going to checkout jabber modules by using subversion client (svn). Make sure you have subversion client installed before proceeding
$ cd /usr/src
$ svn co https://svn.process-one.net/ejabberd-modules
$ cd ejabberd-modules/mod_log_chat/trunk/
Step 2: Compile mod_log_chat
We will compile and install mod_log_chat module. Make sure you have erlang installed for compilation purpose.
This is a preview of
Quickly start logging of user chat log messages in Jabber Server
.
Read the full post (299 words, estimated 1:12 mins reading time)
June 28th, 2011 | Posted in General | No Comments
In a CentOS 5.5 host, we were requested to upgrade openssh to its latest version. Here are steps I took to quickly do the upgrade. You may like to compile it from source or can take my way of installing it from some repository.
Checking existing verison shows 4.3p2:
$ ssh -v
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
simply tried upgrading by running yum using default repositories but it didn’t find any latest version. To grab the latest one, I have installed the CentALT repository, which usually have latest packages. I’ve documented the steps to install it in earlier post here. After having installed CentALT, I tried again but found some dependency issue:
This is a preview of
Quickly upgrade ssh/openssh in CentOS Linux to latest 5.5 version
.
Read the full post (220 words, estimated 53 secs reading time)
May 3rd, 2011 | Posted in General, Security | 3 Comments
In general, MySQL is quite fast at restoring data, but I observed that while restoring 20gb of backup its taking more than the usual time. This can happen when you don’t have enough memory or if key_buffer_size is not set high enough, then it can take very long time to re-index the data. In CentOS 5.2 server with 6gb of RAM, I noticed key_buffer_size is set to just 800M which is very low. You should set it at least 20-25% of total RAM. After increasing the value to 2gb, MySQL is able to reload data quite fast.
This is a preview of
Speed up large MySQL backup, dump, restore processes
.
Read the full post (618 words, estimated 2:28 mins reading time)
April 19th, 2011 | Posted in database | 8 Comments
This is a basic PHP script to check replication status of single or multiple MySQL servers. You have to update variables in the script to run in browser like user, password, ip of server etc.
Here is the script code:
<?
##########
#
# dbrepstatus.php by Jagbir Singh (jags@jagbir.com)
#
#
#########
?>
<html><head>
<title> Online DB Server status </title>
<body>
<form name="ShowStatus" action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST">
<br/>
<table border=1 align=center>
<tr align=center bgcolor=gray><td colspan=2><b> Online DB Server Status </b></td> </tr>
<!--- TODO: replace your server name in the select list below !>
<tr ><td align=centre> Select Server: <select name="server">
<option value="s1" <? if ($_POST[server] == "s1") echo "selected"; ?> > Server 1
<option value="s2" <? if ($_POST[server] == "s2") echo "selected"; ?> > Server 2
<option value="s3" <? if ($_POST[server] == "s3") echo "selected"; ?> > Server 3
<option value="s4" <? if ($_POST[server] == "s4") echo "selected"; ?> > Server 4
</select> </td>
<td align=centre> <input type=submit name='show' value='Show Status'></td></tr>
</form>
</table>
<?
$serverUp=1; ## if any of your server not configured, set this variable to 0 below
$serverString="First Server"; ## server name
$serverIP="w.x.y.z"; ## default IP, anyhow will be changed later
$dbuser="demouser";
$dbpassword="demopass";
$imgShow="<img src='led-green.gif' />";
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
switch($_POST[server]){
case "s1":
$serverString="Server 1";
$serverIP="IP1";
break;
case "s2":
$serverString="Server 2";
$serverIP="IP2";
break;
case "s3":
$serverString="Server 3";
$serverIP="IP3";
break;
case "s4":
$serverString="Server 4";
$serverIP="IP4";
$serverUp=0;
break;
}
?>
<br/>
<table border=1 align=center width=50%>
<tr align=center bgcolor=gray><td colspan=4><b> Status of <? echo $serverString." : ". $serverIP; ?> </b></td> </tr>
<tr > <th bgcolor=lightgray> Status </th> <th bgcolor=lightgray > Replication </th> <th bgcolor=lightgray> Delay </th> <th bgcolor=lightgray> Error </th> </tr>
<?
if (!$serverUp) {
?>
<tr> <td align=center colspan=4> This server is not configured yet! </td> </tr>
<?
}
else {
$contactAdmin="<a href='mailto:dbadmin@yourmail.com?subject=Replication issue in $serverString'> Contact Admin </a>";
$RepStatus = `mysql -h $serverIP -u $dbuser -p$dbpassword -e "show slave status\G;" | egrep "Slave_IO_Running: | Slave_SQL_Running: | Seconds_Behind_Master:" | cut -d':' -f2`; $RepStatus= trim($RepStatus);
list($RepRun, $SqlRun, $RepDelay) = split(" ",$RepStatus);
$RepRun = trim($RepRun);
$SqlRun = trim($SqlRun);
$RepDelay = trim($RepDelay);
// echo "<br/> Reprun=$RepRun, IO Run =$SqlRun, Replication delay =$RepDelay";
if($RepRun == "Yes") { $RepRun = "OK"; $contactAdmin=""; } else { $RepRun = "Replication (IO) Not Running!"; $imgShow="<img src='led-red.gif' />"; }
if($SqlRun == "Yes") { $SqlRun = "None"; $contactAdmin=""; } else {$SqlRun = "SQL thread stopped! "; $imgShow="<img src='led-red.gif' />";}
if($RepDelay == 0 ) { $RepDelay = "None"; } else { $RepDelay .= " seconds."; $contactAdmin=""; }
?>
<tr> <td align=center> <? echo $imgShow; ?> </td> <td align=center> <? echo $RepRun; ?> </td> <td align=center> <? echo $RepDelay; ?> </td> <td align=center> <? echo $SqlRun; ?> </td> </tr>
<?
if ($contactAdmin != "") { echo "<tr> <td align=center colspan=4> $contactAdmin </td></tr>"; }
}
?>
</table>
<?
}
?>
</html>
</body>
In my case, there are 4 servers. First is master and all other slaves so what I assumed here is that all servers have same user/pass to access information. Don’t forget to change user/pass/ip etc. before trying to run this script in browser. Let me know through comments if you any suggestion/enhancement/issue regarding this.
Permanent link to this post (96 words, estimated 23 secs reading time)
April 6th, 2011 | Posted in database, php | No Comments