Friday, February 23, 2007

 

Prevent Timeouts in SSH

Many routers timeout the connection after some period of inactivity. For users of ssh, this can a big nuisance. In presence of such routers a ssh connection with no activity (for a few minutes) will disconnect automatically. The workaround is that the server and client keep talking to each other even when the user is not typing (or viewing) anything. This can be achived using one of the two ways:

Server Side

Add the following two lines to /etc/ssh/sshd_config. This will make the server poll for client every 30 seconds. If the client fails to respond for 4 times (i.e., 2 mins), the server will close the connection. Note that this applies to version 2 of OpenSSH only.

ClientAliveInterval 30
ClientAliveCountMax 4

Client Side

Add the following two lines to /etc/ssh/ssh_config (or $HOME/.ssh/config if you don't have root access). his will make the client poll for server every 30 seconds. If the servers fails to respond for 4 times (i.e., 2 mins), the client will close the connection. Note that this also applies to version 2 of OpenSSH only.

ServerAliveInterval 30
ServerAliveCountMax 4

Labels: ,


 

Simple Software RAID in Linux

RAID is commonly used in production environments to spread the data among multiple disks for higher performance, reliability or capacity. This is a small tutorial for quick setup of RAID 0 or 1 under Linux using mdadm. Fore more advanced configuration and options look elsewhere. Just for records, I have tested this on RHEL 4 update 4.

This document outlines creation of a RAID 0 drive consisting of three partitions /dev/sdb1, /dev/sdc1, and /dev/sdd1. Procedure for RAID 1 should be similar. First we need to prepare the three partitions for RAID. Use fdisk and set partition's system id of all three partitions to fd (Linux raid auto). You may need to reboot after this.

[root@trinity]# fdisk /dev/sdb1
<press t to change partition id>
<type fd as partition id>
<press w to write changes to disk>

Use mdadm to create the array.

mdadm --create /dev/md0 --level=0 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1 --chunk=512

This will create a new drive /dev/md0 with chunk size 512KB. Choice of chunk size depends on application. Default chunk size is 64K. This new drive now ready for use. There is no need to sotre these configurations in any file as mdadm remembers everything for you even after reboot. For example, to create a new ext3 filesystem here use mkfs.ext3 /dev/md0.

Information about the active RAID arrays is displayed in /proc/mdstat. mdadm --detail --scan can also be used.

[root@matrix]# cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 sdd1[2] sdc1[1] sdb1[0]
      215043072 blocks 1024k chunks

unused devices: 

Labels: , ,


This page is powered by Blogger. Isn't yours?