How to Install a Puppet Master and Client Server

February 3rd, 2010

Puppet is an open-source next-generation server automation tool. It is composed of a declarative language for expressing system configuration, a client and server for distributing it, and a library for realizing the configuration.

Setup the EPEL repos for Centos – choose the correct package depending on your installation.

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5Server/x86_64/epel-release-5-3.noarch.rpm

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

Install puppet-server

yum install puppet-server

The 1.8.5 branch of Ruby shipped will RHEL5 can exhibit memory leaks. So install ruby 1.8.6++ (I did not on this server as it was test not a production server).

Install the help docs

yum install ruby-rdoc

Create a manifest file at /etc/puppet/manifests/default.pp

vi /etc/puppet/manifests/default.pp

put this in it

# Create “/tmp/testfile” if it doesn’t exist.

class test_class {

    file { “/tmp/testfile”:

       ensure => present,

       mode   => 644,

       owner  => root,

       group  => root

    }

}

# tell puppet on which client to run the class

node pclient {

    include test_class

}

Start the puppet server

service puppetmaster start

Enable start on boot

chkconfig puppetmaster on

Now to install the Puppet Client on another server

Setup the EPEL repos for Centos – choose the correct package depending on your installation.

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5Server/x86_64/epel-release-5-3.noarch.rpm

or

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

Install puppet

yum install puppet

Setup puppet client to generate its own certificate request to the server

/etc/init.d/puppet once -v

Sign the certificate request on the puppet master server. Use puppetca –list to see if any are available to sign.

puppetca –sign puppet01

Puppet01 must be the fully qualified domain name (FQDN) of you client server.

Run this on the client server again to retrieve the certificate

/etc/init.d/puppet once -v

Make the puppet start with the system

chkconfig puppet on

Make sure it is working on the client server.

puppet –test

You should see a dialog that creates the file /tmp/testfile

Linux

Email to RSS Feeder

January 27th, 2010

Some days back my boss given me assignment to setup an system to move the noisy emails to some RSS feeder or newsgroup. I never work on RSS or any newsgroup distribution lists. But yes i know the RSS concept.

Generally people use RSS to feed the updates of there website, or one step ahead to it, integrate RSS to emails, Means if any updates came to subscribed RSS you will get the corresponding email. All these kond of requirement you can easily workout by searching on google. But my requirement is opposite to it. I want all the noisy emails like houry reports or lots of other unwanted emails some of them came on 15 mins basis also. So there are huge emails coming to everybody’s mailbox.

I searched lot on google to workout on this requirement finally found a cool solution(php script) that worked for me like a charm.

Below is the script:

<?php
// imap2rss.php .
// A simple PHP script to convert the data in an IMAP mailbox available
// over the internet to an RSS file readable by news aggregators.

// GLOBAL CONFIGURATION
// Version of imap2rss.php
$vers = "1.0beta3";
// Permalink for this feed - just points to the current page.
$feedLink = "http://".$_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
// Configuration file directory - used if you want to place your configuration file somewhere outside your web server path.  Make sure the user
// running the web server has read permission to this file
$configurationDirectory = "/etc";

// Part types taken from php.net documentation
$parttypes = array ("text", "multipart", "message", "application", "audio", "image", "video", "other");

// Check if an external configuration has been chosen and load it if possible
if(isset($_GET['conf'])) {
// First, strip out dangerous characters
$slashpos = strrpos($_GET['conf'], '/');
if($slashpos === false)
$slashpos = strrpos($_GET['conf'], '\\');
if($slashpos !== false)
$conf = substr($_GET['conf'], $slashpos+1);
else
// Open the file inside the configuration directory
$conf = $configurationDirectory."/".$_GET['conf'].".conf.php";
// If the file exists, load the parameters.
if(file_exists($conf)) {
require($conf);
$feedLink .= "?conf=".$_GET['conf'];
} else {
// Configuration file does not exist - error and exit
die("Selected configuration not available");
}
}

// Load variables only if an external configuration was not selected.
if(!isset($srvStr)) {
// Server string for IMAP connection.
// Hint: Changing "localhost" for your hostname should do it.
$srvStr = "{localhost:143/notls}INBOX";
// IMAP account username
$accountUser = "username";
// IMAP account password
$accountPass = "password";
// Maximum number of messages to include in the feed
// (from newest, 0 for no limit)
$maxMsgNum = 0;
// Title for this feed
$feedTitle = "imap2rss.php Feed";
// Feed description
$feedDesc = "Sample description";
// Feed language
$feedLang = "en-gb";
// Feed editor's name
$feedEditor = "Feed Editor";
// Feed editor's email
$feedEditorMail = "editor@example.com";
// General Options
// Munge sender emails - 1 for yes, 0 for no
$mungeSenderEmail = 0;
// Make http addresses links in plain-text emails
$makeHttpLinks = 1;
// Make email addresses mailto: links in plain-text emails
$makeMailtoLinks = 1;
}

//-------------------------------------------------------------------
// reEncodeString()
// Goes through a string an reencodes all the html entities that it
// finds into a format that won't make XML parsers choke.
function reEncodeString($string) {
$temp = $string;
$ents = get_html_translation_table(HTML_ENTITIES);
$special = get_html_translation_table();
$table = array_diff($ents, $special);
foreach($table as $item) {
$temp = str_replace($item, "&amp;".substr($item, 1), $temp);
}
return $temp;
}

//-------------------------------------------------------------------
// mungeEmailAddress()
// Munges an email address to prevent being harvested by spambots.
// This is really simple, you can replace this with whatever technique you prefer.
// Remember that for the feed to validate as RSS, this needs to be a valid address,
// @ sign and all, so the munging is limited.
function mungeEmailAddress($address) {
return str_replace("@", ".NOSP@MMER.", $address);
}

//-------------------------------------------------------------------
// renderPlainText()
// Processes plain text so that it looks decent when rendered as HTML.
// All it does is substitute newline characters for <br> tags.
// It also substitutes URLs for links and email addresses for mailto:
// links.
function renderPlainText($text) {
global $makeHttpLinks, $makeMailtoLinks;
// Throw in <br> tags
$retval = str_replace("\n", "<br/>\n", $text);
if($makeHttpLinks) {
// Replace urls with links
$retval = preg_replace('/\s(\w+:\/\/)(\S+)/',
' <a href="\\1\\2" target="_blank">\\1\\2</a>', $retval);
}
if($makeMailtoLinks) {
// Replace email addresses with mailto: links
$retval = preg_replace('/\s(\w+@)(\S+)/',
' <a href="mailto:\\1\\2">\\1\\2</a>', $retval);
}
return $retval;
}

//-------------------------------------------------------------------
// returnAttachment()
// This function returns a given attachment from an item.
function returnAttachment($itemId, $attachId) {
global $vers, $parttypes, $srvStr, $accountUser, $accountPass;
$inbox = imap_open($srvStr, $accountUser, $accountPass);
$msgStructure = imap_fetchstructure($inbox, $itemId);
$part = $msgStructure->parts[$attachId-1];
$ctype = $parttypes[$part->type]."/".$part->subtype;
$filename = "filename";
foreach($part->parameters as $param) {
if($param->attribute=="NAME")
$filename = $param->value;
}
header("content-type: ".$ctype);
header("content-disposition: attachment; filename=".$filename);
// Returned data depends on whether the attachment is binary or text
if($part->type>0) {
// Binary attachment - convert from base64 to binary
echo base64_decode(imap_fetchbody($inbox, $itemId, $attachId));
} else {
// Text attachment - just display it as-is
echo imap_fetchbody($inbox, $itemId, $attachId);
}
imap_close($inbox);
return;
}

//-------------------------------------------------------------------
// showArticle()
// This function displays a post in an html page. This
// functionality exists to complement permalink/guid behaviour
// in RSS and also to enable compatibility with readers like
// Thunderbird, that always load the permalink instead of
// displaying the summary.
function showArticle($articleId) {
global $vers, $srvStr, $accountUser, $accountPass, $mungeSenderEmail;
$inbox = imap_open($srvStr, $accountUser, $accountPass);
header('Content-type: text/html');
// Retrieve post information from the message header
$headers = imap_headerinfo($inbox, $articleId);
$subject = htmlentities($headers->subject);
$author = htmlentities($headers->fromaddress);
// If author email munging is enabled...
if($mungeSenderEmail) {
$author = mungeEmailAddress($author);
}
// Format the date according to the standard
$entryDate = date("D, d M Y H:i:s O", $headers->udate);
// Get the message body.
// Negotiate the presence of attachments.
$msgStructure = imap_fetchstructure($inbox, $articleId);
if(count($msgStructure->parts)>1) {
$body = imap_fetchbody($inbox, $articleId, "1");
if($msgStructure->parts[0]->subtype=="PLAIN")
$body = renderPlainText($body);
$body .= "<h3>Attachments:</h3>\n";
$partCount = 0;
foreach($msgStructure->parts as $part) {
$partCount++;
if (isset($part->disposition)) {
foreach($part->parameters as $param) {
if($param->attribute=="NAME")
// Generate the link for retrieving attachments
$body .="<a href=\"".$feedLink;
if(isset($_GET['conf'])) {
$body .= "?conf=".$_GET['conf']."&amp;";
} else {
$body .= "?";
}
$body .="itemId=".$articleId."&attachId=".$partCount."\">";
$body .=$param->value."</a><br/>\n";
break;
}
}
}
} else {
$body = imap_body($inbox, $articleId);
}
// If the body is plain-text, run the HTML rendering function
if($msgStructure->subtype=="PLAIN")
$body = renderPlainText($body);
imap_close($inbox);
// The HTML used for displaying post content.
?>
<html>
<head>
<title><?php echo $subject;?></title>
</head>
<body>
<div style="background:#eeeeee; border:solid 1px"
<strong><?php echo $subject; ?></strong><br />
<i><?php echo "by: ".$author.", @ ".$entryDate;?></i>
</div>
<br />
<?php echo $body; ?>
</body>
</html>
<?php
}
//-------------------------------------------------------------------
// generateFeed()
// Opens an IMAP connection to the specified server and converts the
// contents of the inbox to an RSS feed.
function generateFeed() {
global     $vers, $srvStr, $accountUser, $accountPass, $feedTitle, $maxMsgNum,
$feedLink, $feedDesc, $feedLang, $feedEditor, $feedEditorMail, $mungeSenderEmail;

$inbox = imap_open($srvStr, $accountUser, $accountPass);

$pubDate = date("D, d M Y H:i:s O", time());

header('Content-type: text/xml');

// RSS header
echo "<?xml version=\"1.0\"?>\n";
echo "<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
echo "   <channel>\n";
echo "       <title>$feedTitle</title>\n";
echo "       <link>$feedLink</link>\n";
echo "       <description>$feedDesc</description>\n";
echo "       <language>$feedLang</language>\n";
echo "       <generator>IMAP2RSS v.$vers</generator>\n";
echo "       <managingEditor>$feedEditor ($feedEditorMail)</managingEditor>\n";
echo "       <webMaster>$feedEditor ($feedEditorMail)</webMaster>\n";
echo "       <pubDate>$pubDate</pubDate>\n";

// Calculate the number of items to include in the feed.
$msgCount = imap_num_msg($inbox);
if($maxMsgNum && $msgCount>$maxMsgNum)
$lowerLimit = $msgCount - $maxMsgNum;
else
$lowerLimit = 0;
// Generate item entries
for($i=$msgCount; $i>$lowerLimit; $i--) {
$headers = imap_headerinfo($inbox, $i);
$subject = reEncodeString(htmlentities($headers->subject));
// Use htmlentities() because sometimes the address appears
// inside angle brackets.
$author = reEncodeString(htmlentities($headers->fromaddress));
// If author email munging is enabled...
if($mungeSenderEmail) {
$author = mungeEmailAddress($author);
}
// Format the date according to the standard
$entryDate = date("D, d M Y H:i:s O", $headers->udate);
// Set the item link depending on whether there is a custom
// configuration in use or not.
$itemUrl = $feedLink.((isset($_GET['conf']))?"&amp;":"?")."itemId=$i";

// Negotiate the presence of attachments.
$msgStructure = imap_fetchstructure($inbox, $i);
if(count($msgStructure->parts)>1) {
$body = imap_fetchbody($inbox, $i, "1");
// If the body is plain-text, run the HTML rendering function
if($msgStructure->parts[0]->subtype=="PLAIN")
$body = renderPlainText($body);
$body .= "<h3>Attachments:</h3>\n";
$partCount = 0;
foreach($msgStructure->parts as $part) {
$partCount++;
if (isset($part->disposition)) {
foreach($part->parameters as $param) {
if($param->attribute=="NAME")
// Generate the link for retrieving attachments
$body .="<a href=\"".$feedLink;
if(isset($_GET['conf'])) {
$body .= "&amp;";
} else {
$body .= "?";
}
$body .="itemId=".$i."&attachId=".$partCount."\">";
$body .=$param->value."</a><br/>\n";
break;
}
}
}
} else {
$body = imap_body($inbox, $i);
// If the body is plain-text, run the HTML rendering function
if($msgStructure->subtype=="PLAIN")
$body = renderPlainText($body);
}
// Clean up output to avoid problems with the XML produced
$body = reEncodeString(htmlentities($body));
echo "       <item>\n";
echo "        <title>$subject</title>\n";
echo "               <link>$itemUrl</link>\n";
echo "               <pubDate>$entryDate</pubDate>\n";
echo "               <description>$body</description>\n";
echo "               <dc:creator>$author</dc:creator>\n";
echo "               <guid>$itemUrl</guid>\n";
echo "       </item>\n";
}
echo "     </channel>\n";
echo "</rss> ";

imap_close($inbox);
}

// display page body
// If an itemId has been set, display that item in an HTML page.
// If an itemId and an attachId have been set, return that attachment
// If not, show the entire feed.
if(isset($_GET['itemId'])) {
if(isset($_GET['attachId'])) {
returnAttachment($_GET['itemId'], $_GET['attachId']);
} else {
showArticle($_GET['itemId']);
}
} else {
generateFeed();
}
?> 

You can download the script directly from here

Just make the IMAP mail server settings thats it. Now place the script any of the webserver document root, then you can access these feeds using any of the RSS reader.
To test wheather your script is working or not, you can check that by accessing the mai2rss.php from URL. For eg.
I have placed the script on linuxtrove document root now my URL would be http://linuxtrove.com/mail2rss.php it will show the mails for the user that you have configured in your script in XML format. This script is valid only for one mailbox but you can configure it for multiple mailboxes also.

To use one installation of imap2rss.php to access several mailboxes, you need to create a file in the same directory that you installed the script in, and call it .conf.php. The file should look something like this:

// Server string for IMAP connection.
// See http://www.php.net/manual/en/function.imap-open.php
// for more details on what this string should look like.
// Hint: Changing "localhost" for your hostname should do it.
$srvStr = "{localhost:143/notls}INBOX";
// IMAP account username
$accountUser = "username";
// IMAP account password
$accountPass = "password";
// Maximum number of messages to include in the feed
// (from newest, 0 for no limit)
$maxMsgNum = 30;
// Title for this feed
$feedTitle = "imap2rss.php Feed";
// Feed description
$feedDesc = "Sample description";
// Feed language
$feedLang = "en-gb";
// Feed editor's name
$feedEditor = "Feed Editor";
// Feed editor's email
$feedEditorMail = "editor@example.net";
// General Options
// Munge sender emails - 1 for yes, 0 for no
$mungeSenderEmail = 0;
// Make http addresses links in plain-text emails
$makeHttpLinks = 1;
// Make email addresses mailto: links in plain-text emails
$makeMailtoLinks = 1;
?>
Once you have configured this, you can call imap2rss.php with an additional parameter passed to the script, conf, which should be set to whatever you called the configuration. For example, if your configuration file is called mycfg.conf.php, the url would look like http://yourserver/imap2rss.php?conf=mycfg.
If you have problems hooking up to your IMAP server, read the page referred to near the beginning of the file. Correct configuration for your IMAP server can be tricky

I have tested it with thunderbird and firefox. Firefox need an add-on for this. Any RSS reader will work with it.

All credit goes to http://www.noaxs.net/imap2rss/ who resolved my problem.

Linux

Splunk Server Setup and Configuration

January 6th, 2010

Installation Of Splunk Server

Configure Splunk server on 192.168.10.209
1. Download latest splunk.tar.gz from http://www.splunk.com/download?r=header
2. copy download files to /opt
3. untar the downloaded splunk file

# cd /opt
# tar -xzvf splunk-4.0.8-73243-Linux-i686.tgz
# cd splunk/bin/
# ./splunk start

Accecpt the agreement and default settings.

4. Open the splunk webUI (http://localhost:8000)
5. Use the default username password to login i.e. admin/changeme

#### Setup splunk as a Reciever #####
1. Login to WebUI using the above mentioned credentionals. eg. http://192.168.10.209:8000
2. Go to Manager » Forwarding and receiving » Receive data
3. Click on New Button and add default port i.e. 9997
4. Click on save button to save the settings.
Now Splunk server has been setup as reciever on port 9997.

Note: If you are running any firewall please allow the above Port.

####### Setup Splunk as a Forwarder ####
IP Add of forwarder machine: 192.168.10.225
IP Add for Reciever server: 192.168.10.209

You have the following preconfigured forwarder choices:
* Splunk forwarder
* Splunk light forwarder
1. ssh to forwarder machine(whom to be monitored) eg. ssh ramesh@192.168.10.225
2. Use the above mentioned installation steps to install splunk on client machine
3.

 # cd /opt/splunk/bin
# ./splunk enable app SplunkLightForwarder -auth admin
# ./splunk add forward-server reciever_serverip:port -auth admin
eg.  ./splunk add forward-server 192.168.10.209:9997 -auth admin
# ./splunk restart

######## Setup Splunk Alerts #########
NOTE: We assume that splunk server has been installed on a Linux Box.

1. Login to Splunk server (http://192.168.10.209:8000)
2. Go to App >> Search
3. Click on /var/log/secure under source section
Above will show the whole data of secure file
4. Click on the string/strings that you want to search or setup alert. Eg. “Accepted Password”

It will look like source=”/var/log/secure” “Accepted Password” in search box.

5. Then go to Action >> Save Search
It will pop-up a window.
6. Name – SSH Access Authenticated
Search – will be coming default that we search earlier.
Description – It can be anything you like.
Check on Schedule this search
Schedule Type – Basic
Run Every – Minute
Alert Condition
Perform actions (optional) – if no. of events – is greater than – 0
Alert Action
check on send Email
Email Addresses: abc@abc.com,xyz@xyz.com

Click on save Button to save your Alert.

To verify Your alert setup go to
Manager » Searches and reports >> SSH Access Authenticated

HAPPY ALERTING.. :)

Linux

subprocess pre-removal script returned error exit status 2? error

October 29th, 2009

Recently, I encountered a package management related error in Ubuntu Jaunty Jackalope 32bit.

The package was sharutils and the error was: “E: sharutils: subprocess pre-removal script returned error exit status 2? and details showed:
“dpkg (subprocess): unable to execute pre-removal script: Exec format error
dpkg: error processing sharutils (–remove):
subprocess pre-removal script returned error exit status 2
dpkg (subprocess): unable to execute post-installation script: Exec format error
dpkg: error while cleaning up:
subprocess post-installation script returned error exit status 2
Errors were encountered while processing:
sharutils
E: Sub-process /usr/bin/dpkg returned an error code (1)”

I managed to fix it. Read on for how I did it.

Precaution: The process can break your system if not followed as mentioned (you may get into problems even if you follow the process). Please proceed at your own risk.

First, please try the following in terminal:

sudo aptitude update
sudo aptitude -f install 

If it does not work, then you may want to try:

sudo dpkg --force all --remove

If both of them still produce similar errors, then continue. If the above commands fix your problem, you should not continue.

1. Close Synaptic or any package manager. Wait for or cancel any updates or install\uninstall.
2. Make Backups of current /var/lib/dpkg/status file. Just copy and paste to your home directory or Desktop.
3. Alt+F2 and launch type in gksu gedit /var/lib/dpkg/status and run it. Gedit will be launched with a text file open.
4. Now, search for the exact name of the package with problems and find it.
5. In my case, it I found the entry for the package sharutils:

Package: sharutils
Status: deinstall ok half-configured
Priority: standard
Section: utils
Installed-Size: 968
Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: i386
Version: 1:4.6.3-1build1
Depends: libc6 (>= 2.6-1)
Suggests: mailx
Conflicts: shar, uuencode
Description: shar, unshar, uuencode, uudecode
`shar' makes so-called shell archives out of many files, preparing
them for transmission by electronic mail services.  `unshar' helps
unpacking shell archives after reception.  Other related utility
programs help with other tasks.
.
`uuencode' prepares a file for transmission over an electronic
channel which ignores or otherwise mangles the eight bit (high
order bit) of bytes.  `uudecode' does the converse transformation.
Original-Maintainer: Santiago Vila <sanvila@debian.org>

6. Select and delete that information and that much information only, i.e. you will remove “Package: culprit-package-name” to “Description: culprit package description”. Remmber, “culprit package description” may be multiline and you will need to remove all the lines till a blank line. Don’t forget to leave a line blank between the package description above and the one below. Be careful delete only the culprit package information. As i have mentioned in the highlighted box.

7. Launch Synaptic (or any package manager) and then search for package. You will see the package as not installed. Mark it for installation and install it. If you start to see the same error, restart the same process from Step 1 but the next time, stop at step 6.
8. Now, you should be able to remove it if you no longer want the package. If you can’t, restart the same process from Step 1 but the next time, stop at step 6.

This resolved  my problem, hope will resolve yours too…

NOTE: All credit goes to http://www.khattam.info/2009/08/04/solved-subprocess-pre-removal-script-returned-error-exit-status-2-error/

Linux, Open Source

Reliance DataCard on Ubuntu

October 3rd, 2009

First of all create a file /etc/wvdial.conf

vi /etc/wvdial.conf

[Modem0]
Modem = /dev/ttyUSB0
Baud = 115200
SetVolume = 0
Dial Command = ATDT
Init1 = ATZ
FlowControl = Hardware (CRTSCTS) [Dialer cdma]
Username = 
Password =
Phone = #777
Stupid Mode = 1
Inherits = Modem0

I had connected datacard before booting my system.
(I have enabled root login):
I executed following commands.

#lsusb

It listed many things along with my new reliance usb datacrd.
(
Bus 006 Device 019: ID 12d1:1411 Huawei Technologies Co., Ltd. )
then,

#wvdial cdma
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Modem initialized.
--> Sending: ATDT#777
--> Waiting for carrier.
ATDT#777
CONNECT 153600
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Sat Dec 13 09:04:51 2008
--> Pid of pppd: 6410
--> Using interface ppp0
--> pppd: `?[13] `?[13] ??[13]
--> pppd: `?[13] `?[13] ??[13]
--> pppd: `?[13] `?[13] ??[13]
--> pppd: `?[13] `?[13] ??[13]
--> pppd: `?[13] `?[13] ??[13]
--> pppd: `?[13] `?[13] ??[13]
--> local IP address 220.226.118.181
--> pppd: `?[13] `?[13] ??[13]
--> remote IP address 220.224.135.79
--> pppd: `?[13] `?[13] ??[13]
--> primary DNS address 202.138.103.100
--> pppd: `?[13] `?[13] ??[13]
--> secondary DNS address 202.138.96.2
--> pppd: `?[13] `?[13] ??[13]

Now minimized the terminal and started firefox (work offline has to be disabled). It worked.
(For disconnecting I use ctrl+c in the terminal. can anyone suggest the correct method?)
.
.
If datacard inserted after booting of Ubuntu, command #lsusb didn’t show the datacard.
I executed

#modprobe usbserial

after sometime,

#lsusb 

it worked. (I am not sure ubuntu automatically deteced it or ‘modprobe’ command did it).
Then as usual

#wvdial cdma

You will get the similar output as shown above then minimize the screen and browse internet.

Linux

DHCP on Ubuntu

October 1st, 2009

Goal: Install DHCP server for 192.168.10.0 VLAN. IP Pool would be 192.168.10.101-250

Prerequisite Details:

IP address range: 192.168.10.101 to 192.168.0.250
Subnet Mask: 255.255.255.0
DNS Servers: 202.188.0.133, 202.188.1.5
Domains: transcomus.com
Gateway Address: 192.168.10.1

1.Install the DHCP server using the below commands and make some required changes as below:

$ sudo apt-get install dhcp3-server
$ sudo cp /etc/default/dhcp3-server /etc/default/dhcp3-server_backup
$ sudo gedit /etc/default/dhcp3-server

2. Find this line
… INTERFACES=”"
3. Replace with the following line
INTERFACES=”eth0″
4. Save the edited file

$ sudo cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf_backup
$ sudo gedit /etc/dhcp3/dhcpd.conf

5. Find this section

# option definitions common to all supported networks…
option domain-name “example.org”;
option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;
max-lease-time 7200;

6. Replace with the following lines
# option definitions common to all supported networks…
#option domain-name “example.org”;
#option domain-name-servers ns1.example.org, ns2.example.org;

#default-lease-time 600;
#max-lease-time 7200;
7. Find this section

# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name “internal.example.org”;
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;
# default-lease-time 600;
# max-lease-time 7200;
#}

8. Replace with the following lines

# A slightly different configuration for an internal subnet.
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.0.101 192.168.0.250;
option domain-name-servers 202.54.10.2;
option domain-name "transcomus.com";
option routers 192.168.10.1;
option broadcast-address 192.168.10.255;
default-lease-time 600;
max-lease-time 691200;
}

9. Save the edited file (sample/dhcpd.conf_installdhcpserver)
10. $ sudo /etc/init.d/dhcp3-server restart

Now change the client settings to pickup the IP automatically, if your client machines picking up the IP’s means your DHCP is working fine. If not then please check the log files for errors.

Linux

Tips & Tricks

September 1st, 2009

Grep in colour
Grep can use colours to highlight the matching text using the –color parameter

grep –color=auto

I found this tip at:

http://unstableme.blogspot.com/2009/03/highlight-match-with-color-in-grep.html

Linux

FreeLance Projects

May 30th, 2009

I have hands on experience on so many opensource projects. I have done these projects as my hobby as well as a professional.

Mail Severs

* Postfix
* Sendmail
* Qmail

Proxy

* Squid

WebServers

* Apache
* Lighthttpd
* Tomcat

Telephony

* Asterisk
* Vicidial
* FreeSwitch

DNS

BIND

Webservices

* Amazon
* EC2(Elastic Computer Cloud)
* S3(Simple Storage solution)

Blog

* Roller
* WordPress

Bug-Tracking

* Buggzilla
* Mantis
* Trac

CMS

* Alfresco
* Drupal
* Joomla
* KnowledgeTree

CRM

* SugarCRM

ECM

* Alfresco
* KnowledgeTree

Forum

* phpBB

Portal Server

* Liferay

Version Control

* Subversion

Wiki

* DokuWiki
* MediaWiki
* DokuWiki

eLearning

* Dokeos
* Moodle

If anybody interested or having any problem in above mentioned projects please feel free to contact me at +91 9899184890 or mail me out at ramesh.mimit@gmail.com

Soldier of Fortune

Open Source Projects

May 30th, 2009

In today’s world everybody intersted in implementing the opensource solutions. If anybody want to survive he has to think upon the free solution where he can fulfill his requirements by doing some tweaks to the opensource applications. I have worked on lots of opensource projects, some of them are listed below:

Blog

* Roller
* WordPress

Bug-Tracking

* Mantis
* Redmine
* Buggzilla
* Trac

Business Intelligence

* JasperServer

CMS

* Alfresco
* Drupal
* Enano CMS
* eZ Publish
* Joomla
* KnowledgeTree

CRM

* SugarCRM

ECM

* Alfresco
* KnowledgeTree

Forum

* phpBB

Photo Sharing

* Coppermine Photo Gallery
* Gallery

Planning

* Tracks

Poll Management

* Opina

Portal Server

* JasperServer
* Liferay

Version Control

* Subversion

Wiki

* DokuWiki
* MediaWiki

eLearning

* Dokeos
* Moodle

Infrastructure

* DjangoStack
* JRubyStack
* LAMPStack
* LAPPStack
* MAMPStack
* MAPPStack
* RubyStack
* SAMPStack
* WAMPStack
* WAPPStack

Open Source

iSCSI and LVM

May 23rd, 2009

iSCSI – Brainstorm

iSCSI is a protocol that allows you to use SCSI commands over an IP network. You can use the storage over the network using iSCSI.

SCSI uses a client-server architecture. A “client” (ie: your system) is an initiator, it initiates requests. A “server” (ie: your storage device) is a target, it has something you want and answers requests from the initiator(s).

iSCSI Basics

All devices in an iSCSI enviroment will have addresses. Initiators will have addresses, and targets will have addresses. When you define a target you can specify the address yourself.

iSCSI uses the following form for addresses

iqn.2009-05.com.linuxtrove.avstorage:storage03

iqn (iSCSI Qualified Name)

The date field is the date of the first full month

The Naming Auth is the naming authority (domain name) for this target, reversed.

Following the naming authority is a colon, after which you can put anything you want to help you better remember.

I have used this one: iqn.2009-05.com.linuxtrove.avstorage:storage03

Now we will setup the target first then configure the initiator

<!– @page { margin: 2cm } P { margin-bottom: 0.21cm } H2 { margin-bottom: 0.21cm } H2.cjk { font-family: “DejaVu Sans” } H2.ctl { font-family: “DejaVu Sans” } –>

Setting up a Target

I have follow the following steps:

  1. Install the new machine with Ubuntu-8.4 OS, i have 1TB storage capacity on this machine.

We made the LVM partion because we are gonna to add it up in existing LVM storage.

IP Address for the machine is 192.168.200.23

Install the iscsitarget package using the following command.

apt-get install iscsitarget

3. Edit /etc/ietd.conf file

ietd.conf file contains the information which partition of the system is gonna to export using iSCSI

I have made the entry like this:

Target iqn.2009-05.com.linuxtrove.avstorage:storage03

Lun 1 Path=/dev/sda3,Type=blockio
Alias storage03

Second line Contains the path of the partiton you are going to use for storage
and the type of the device, it may be a file, but in our case it is a block device.

Third line contains the Alias, that is optiona
Save the file then restart the iscsi service using the following command.

#/etc/init.d/iscsitarget restart

NOTE: For more information please read the man pages or do googling.

Setting up an Initiator

  1. Install the open-iscsi package using the following command.

#apt-get install open-iscsi

In my case i have initiator already setup so i skipped the step 1.

  1. To list the targets, do the following

iscsiadm --mode discovery --type sendtargets --portal 192.168.200.23

Once the targets are listed above, they are automatically added into 
	 /etc/iscsi/nodes
  1. You can change the settings in the nodes directory and make it always automatic login on boot. The directories and files to be considered are

  • /etc/iscsi/iscsid.conf <- Make Node as automatic rather than manual
  • /etc/iscsi/nodes/yournodename <- Change the configuration and make it automatic e.g. node.startup=automatic
  1. Start into a node using the following and then monitor /var/log/messages for the block device name

iscsiadm –mode node –targetname iqn. 2009-05.com.vccorp.avstorage:storage03 –portal 192.168.200.23 –login

After that just check the output of fdisk command. New disk will be there as i got.

# fdisk -l

Disk /dev/sdd: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdd1 1 2550 20482843+ 8e Linux LVM

/dev/sdd2 * 2551 9430 55263600 83 Linux

/dev/sdd3 9431 9729 2401717+ 5 Extended

/dev/sdd5 9431 9729 2401686 82 Linux swap / Solaris

Disk /dev/sde: 500.1 GB, 500105217024 byte

255 heads, 63 sectors/track, 60800 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sde1 1 60800 488375968+ 8e Linux LVM

Disk /dev/sdf: 485.5 GB, 485595855360 bytes

255 heads, 63 sectors/track, 59037 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdf1 1 59037 474214671 8e Linux LVM

Disk /dev/sdg: 986.0 GB, 986005440000 bytes

255 heads, 63 sectors/track, 119875 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdg1 1 119875 962895906 8e Linux LVM

Above is just the sample output.

/dev/sdg1 is the newely added partiton by iSCSI.

Now we will add this new storage to our existing LVM.

# pvcreate /dev/sdg1

#pvscan

root@Orion:~# pvscan

PV /dev/sda1 VG recordings lvm2 [74.52 GB / 0 free]

PV /dev/sdb1 VG recordings lvm2 [74.52 GB / 0 free]

PV /dev/sdd1 VG recordings lvm2 [19.53 GB / 0 free]

PV /dev/sdc1 VG recordings lvm2 [335.34 GB / 0 free]

PV /dev/sde1 VG recordings lvm2 [465.75 GB / 0 free]

PV /dev/sdf1 VG recordings lvm2 [452.23 GB / 0 free]

Total: 6 [1.29 TB] / in use: 6 [1.29 TB] / in no VG: 0 [0 ]

Its not showing newely created physical volume.

Physical Volume will not be recognised untill you add it up in any volume group.

#vgextend recordings /dev/sdg1

# pvscan

root@Orion:~# pvscan

PV /dev/sda1 VG recordings lvm2 [74.52 GB / 0 free]

PV /dev/sdb1 VG recordings lvm2 [74.52 GB / 0 free]

PV /dev/sdd1 VG recordings lvm2 [19.53 GB / 0 free]

PV /dev/sdc1 VG recordings lvm2 [335.34 GB / 0 free]

PV /dev/sde1 VG recordings lvm2 [465.75 GB / 0 free]

PV /dev/sdf1 VG recordings lvm2 [452.23 GB / 0 free]

PV /dev/sdg1 VG recordings lvm2 [918.28 GB / 0 free]

Total: 7 [2.29 TB] / in use: 7 [2.29 TB] / in no VG: 0 [0 ]

Now its showing the new PV also.

root@Orion:~# vgdisplay

— Volume group —

VG Name recordings

System ID

Format lvm2

Metadata Areas 7

Metadata Sequence No 22

VG Access read/write

VG Status resizable

MAX LV                          0

Cur LV                              1

Open LV                            1

Max PV                              0

Cur PV                               7

Act PV                              7

VG Size                            2.29 TB

PE Size                            16.00 MB

Total PE                         91001

Alloc PE / Size              91001 / 2.29 TB

Free PE / Size                58770 / 986GB

VG UUID                       wz8pMV-RE63-Flwo-jpUI-G3t7-GCCz-uEAQDT

Now check the Logical volume space using the follwing command.

root@Orion:~# lvdisplay

— Logical volume —

LV Name /dev/recordings/disk1

VG Name recordings

LV UUID                             qy4ywC-oRqH-ccc5-PY47-NkCL-9Fcw-SfLpD1

LV Write Access                read/write

LV Status                              available

# open 1

LV Size                                 1.29 TB

CurrentLE                            149771

Segments                                7

Allocation                          inherit

Read ahead sectors                  0

Block device                          254:0

Now we will extend the size of Logical Volume by using the following command.

# lvextend -l +58770 /dev/recordings/disk1 /dev/sdg1

In the output of vgdisplay you can can the free extents and just add them like the above command.

Now please check the output of “df -h”.

root@Orion:~# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sdd2 52G 16G 35G 31% /

varrun 502M 144K 502M 1% /var/run

varlock 502M 0 502M 0% /var/lock

procbususb 502M 444K 502M 1% /proc/bus/usb

udev 502M 444K 502M 1% /dev

devshm 502M 0 502M 0% /dev/shm

lrm 502M 33M 469M 7% /lib/modules/2.6.20-16-generic/volatile

/dev/mapper/recordings-disk1   1.4T 1.3T 222G 99% /recordings

Size of the logical volume still not increased. To make it visible here and usable, we have two ways.

  1. Reboot the system
  2. Online resizing

In second option we dont require reboot. So i prefer the second one. Use the following command to do that.

# resize2fs /dev/recordings/disk1

It will take some time to resize. Please have patience and wait for atleast 1 hour. If you want to check it that size is increasing or not you can check it by executing the df command without any flag.

Linux

-->

I'm happy to use Increase Sociability.