How to setup RAID 1 on Ubuntu Linux?

RAID 1 creates a mirror on the second drive. .You will need to create RAID aware partitions on your drives before you can create RAID and you will need to install mdadm on Ubuntu.

raid1

You may have to create the RAID device first by indicating the RAID device with the block major and minor numbers. Be sure to increment the “2” number by one each time you create an additional RAID device.

# mknod /dev/md1 b 9 2

This will create the device if you have already used /dev/md0.

Create RAID 1

# mdadm –create /dev/md1 –level=1 –raid-devices=2 /dev/sdb7 /dev/sdb8

–create
This will create a RAID array. The device that you will use for the first RAID array is /dev/md1.

–level=1
The level option determines what RAID level you will use for the RAID.

–raid-devices=2 /dev/sdb7 /dev/sdb8
Note: for illustration or practice this shows two partitions on the same drive. This is NOT what you want to do, partitions must be on separate drives. However, this will provide you with a practice scenario. You must list the number of devices in the RAID array and you must list the devices that you have partitioned with fdisk. The example shows two RAID partitions.
mdadm: array /dev/md0 started.

Verify the Create of the RAID

# cat /proc/mdstat

Personalities : [raid0] [raid1]

md2 : active raid1 sdb8[1] sdb7[0]

497856 blocks [2/2] [UU]

[======>…………..] resync = 34.4% (172672/497856) finish=0.2min speed=21584K/sec

md0 : active raid0 sdb6[1] sdb5[0]

995712 blocks 64k chunks

unused devices:

# tail /var/log/messages

You can also verify that RAID is being built in /var/log/messages.

May 19 09:21:45 ub1 kernel: [ 5320.433192] md: raid1 personality registered for level 1

May 19 09:21:45 ub1 kernel: [ 5320.433620] md2: WARNING: sdb7 appears to be on the same physical disk as sdb8.

May 19 09:21:45 ub1 kernel: [ 5320.433628] True protection against single-disk failure might be compromised.

May 19 09:21:45 ub1 kernel: [ 5320.433772] raid1: raid set md2 active with 2 out of 2 mirrors

May 19 09:21:45 ub1 kernel: [ 5320.433913] md: resync of RAID array md2

May 19 09:21:45 ub1 kernel: [ 5320.433926] md: minimum _guaranteed_ speed: 1000 KB/sec/disk.

May 19 09:21:45 ub1 kernel: [ 5320.433934] md: using maximum available idle IO bandwidth (but not more than 200000 KB/sec) for resync.

May 19 09:21:45 ub1 kernel: [ 5320.433954] md: using 128k window, over a total of 497856 blocks.

Create the File System ext 3.
You have to place a file system on your RAID device. The journaling system ext3 is placed on the device in this example.

# mke2fs -j /dev/md1

mke2fs 1.40.8 (13-Mar-2008)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

124928 inodes, 497856 blocks

24892 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=67633152

61 block groups

8192 blocks per group, 8192 fragments per group

2048 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

Mount the RAID on the /raid Partition

In order to use the RAID array you will need to mount it on the file system. For testing purposes you can create a mount point and test. To make a permanent mount point you will need to edit /etc/fstab.

# mount /dev/md1 /raid

# df
The df command will verify that it has mounted.

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sda2 5809368 2699256 2817328 49% /

varrun 1037732 104 1037628 1% /var/run

varlock 1037732 0 1037732 0% /var/lock

udev 1037732 80 1037652 1% /dev

devshm 1037732 12 1037720 1% /dev/shm

/dev/sda1 474440 49252 400691 11% /boot

/dev/sda4 474367664 1738024 448722912 1% /home

/dev/md1 482090 10544 446654 3% /raid

You should be able to create files on the new partition. If this works then you may edit the /etc/fstab and add a line that looks like this:

/dev/md1 /raid defaults 0 2

Be sure to test and be prepared to enter single user mode to fix any problems with the new RAID device.

Create a Failed RAID Disk

In order to test your RAID 1 you can fail a disk, remove it and reinstall it. This is an important feature to practice.

# mdadm /dev/md1 -f /dev/sdb8
This will deliberately make the /dev/sdb8 faulty.

mdadm: set /dev/sdb8 faulty in /dev/md1

root@ub1:/etc/network# cat /proc/mdstat

Personalities : [raid0] [raid1]

md2 : active raid1 sdb8[2](F) sdb7[0]

497856 blocks [2/1] [U_]

md0 : active raid0 sdb6[1] sdb5[0]

995712 blocks 64k chunks

unused devices:

Hot Remove the Failed Disk
You can remove the faulty disk from the RAID array.

# mdadm /dev/md1 -r /dev/sdb8

mdadm: hot removed /dev/sdb8

Verify the Process

You should be able to see the process as it is working.

# cat /proc/mdstat

Personalities : [raid0] [raid1]

md2 : active raid1 sdb7[0]

497856 blocks [2/1] [U_]

md0 : active raid0 sdb6[1] sdb5[0]

995712 blocks 64k chunks

unused devices:

Add a Replacement Drive HOT

This will allow you to add a device into the array to replace the bad one.
# mdadm /dev/md1 -a /dev/sdb8

mdadm: re-added /dev/sdb8

Verify the Process.

# cat /proc/mdstat

Personalities : [raid0] [raid1]

md2 : active raid1 sdb8[2] sdb7[0]

497856 blocks [2/1] [U_]

[=====>……………] recovery = 26.8% (134464/497856) finish=0.2min speed=26892K/sec

md0 : active raid0 sdb6[1] sdb5[0]

995712 blocks 64k chunks

unused devices:

0
0

How to setup RAID 0 on Ubuntu Linux?

RAID 0 will create striping to increase read/write speeds as the data can be read and written on separate disks at the same time. This level of RAID is what you want to use if you need to increase the speed of disk access.You will need to create RAID aware partitions on your drives before you can create RAID and you will need to install mdadm on Ubuntu.

raid0
These commands must be done as root or you must add the sudo command in front of each command.

# mdadm –create /dev/md0 –level=0 –raid-devices=2 /dev/sdb5 /dev/sdb6

–create
This will create a RAID array. The device that you will use for the first RAID array is /dev/md0.

–level=0
The level option determines what RAID level you will use for the RAID.

–raid-devices=2 /dev/sdb5 /dev/sdb6
Note: for illustration or practice this shows two partitions on the same drive. This is NOT what you want to do, partitions must be on separate drives. However, this will provide you with a practice scenario. You must list the number of devices in the RAID array and you must list the devices that you have partitioned with fdisk. The example shows two RAID partitions.
mdadm: array /dev/md0 started.

Check the development of the RAID.

# cat /proc/mdstat

Personalities : [raid0]

md0 : active raid0 sdb6[1] sdb5[0]

995712 blocks 64k chunks
unused devices:

# tail /var/log/messages
You can also verify that RAID is being built in /var/log/messages.

May 19 09:08:51 ub1 kernel: [ 4548.276806] raid0: looking at sdb5

May 19 09:08:51 ub1 kernel: [ 4548.276809] raid0: comparing sdb5(497856) with sdb6(497856)

May 19 09:08:51 ub1 kernel: [ 4548.276813] raid0: EQUAL

May 19 09:08:51 ub1 kernel: [ 4548.276815] raid0: FINAL 1 zones

May 19 09:08:51 ub1 kernel: [ 4548.276822] raid0: done.

May 19 09:08:51 ub1 kernel: [ 4548.276826] raid0 : md_size is 995712 blocks.

May 19 09:08:51 ub1 kernel: [ 4548.276829] raid0 : conf->hash_spacing is 995712 blocks.

May 19 09:08:51 ub1 kernel: [ 4548.276831] raid0 : nb_zone is 1.

May 19 09:08:51 ub1 kernel: [ 4548.276834] raid0 : Allocating 4 bytes for hash.

Create the ext 3 File System
You have to place a file system on your RAID device. The journaling system ext3 is placed on the device in this example.

# mke2fs -j /dev/md0

mke2fs 1.40.8 (13-Mar-2008)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

62464 inodes, 248928 blocks

12446 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=255852544

8 block groups

32768 blocks per group, 32768 fragments per group

7808 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

Create a Place to Mount the RAID on the File System

In order to use the RAID array you will need to mount it on the file system. For testing purposes you can create a mount point and test. To make a permanent mount point you will need to edit /etc/fstab.

# mkdir /raid

Mount the RAID Array

# mount /dev/md0 /raid

You should be able to create files on the new partition. If this works then you may edit the /etc/fstab and add a line that looks like this:

/dev/md0 /raid defaults 0 2

Be sure to test and be prepared to enter single user mode to fix any problems with the new RAID device.

Hope you find this article helpful.

0
0

How do I bind NIC interrupts to selected CPU?

I read this interesting mailing thread few weeks back. I won’t be late to share this with open source enthusiast like you. Here goes the story:

nic2

I have a 4 Quad server, am trying to bind NIC eth0 interrupt(s) to CPU4 and CPU5. As of now, my eth0 is found bind to all the 8’s.
#grep eth0 /proc/interrupts | awk ‘{print $NF}’ | sort

eth0-0
eth0-1
eth0-2
eth0-3
eth0-4
eth0-5
eth0-6
eth0-7

How to move ahead?

Solution: Follow these steps to get it done.

As I am using Broadcom card(bnx2), I am going to run this command and reboot my machine.

Open the terminal:

echo “options bnx2 disable_msi=1” > /etc/modprobe.d/bnx2.conf

then reboot, after you’ll only see one irq for eth0.

Next, run this command:

echo cpumask > /proc/irq/IRQ-OF-ETH0-0/smp_affinity

I believe the mask for cpu4 is 10 and cpu5 is 20.
(don’t forget to disable irqbalance)

you can only bind the irqs for one nic to one core at a time.

or you could do something fancy/silly with isolcpus and….

isolcpus all but 4/5 so that all irqs will be scheduled on 4/5. this will
mean that the kernel can only schedule tasks on cpu4/5.

Hope it helps !!!
then use cpusets/taskset/tuna to move all the processes off cpu 4/5… and
you’ll have to use taskset/cpuset/tuna for every task to ensure its not
using cpu4/5

0
0

Puppet Module for JBOSS

Recently one of my colleague called me up with a problem statement where he was finding difficulty configuring JBOSS through puppet. I tried to help him through one of VMware Workstation box on my Dell Inspiron.

puppetlabs_1304099092_11

I tried to google but couldn’t find the working example. I tried my hands of my own and YES…I did it finally.

I am sharing the overall idea how to deploy and configure JBOSS through Puppet.

Let’s say you have the following steps which you manually perform for installing JBOSS on your Linux machine:

1.$ su -c “yum install java-1.6.0-openjdk-devel”

2.$ java –version

3.wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip

4.$ unzip jboss-as-7.1.1.Final.zip -d /usr/share

5.$ adduser jboss

6.$ chown -fR jboss.jboss /usr/share/jboss-as-7.1.1.Final/

7.$ su jboss

8.$ cd /usr/share/jboss-as-7.1.1.Final/bin/

9.$ ./add-user.sh

You should see the following message on the console after executing the command:

What type of user do you wish to add?

a) Management User (mgmt-users.properties)

b) Application User (application-users.properties)

(a): a

We select “a”, next you should see the following message:

Enter the details of the new user to add.

Realm (ManagementRealm) :

Username : jboss

Password :

Re-enter Password :

* hit enter for Realm to use default, then provide a username and password

We select the default value for the Realm (ManagementRealm), by hitting enter, and select “jboss” as our username. By default, we supply “jb0ss” as our password, of course, you can provide any password you prefer here.

Step 4: Start the JBoss AS 7 server:

Once the appropriate JBoss users are created, we are now ready to start our new JBoss AS 7 server. With JBoss AS 7, a new standalone and domain model has been introduced. In this tutorial, we focus on starting up a standalone server. The domain server will be part of a future tutorial.

Startup a JBoss 7, standalone instance:

A standalone instance of JBoss 7 can be starting by executing:

$ ./standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.

We can automate those steps for client through Puppet.Let’s start writing puppet init.pp from scratch. I will be delivering step by step of init.pp to achieve every components of init.pp.

Line 1 – 4

The Line 1 to 4 does nothing but downloading JBOSS to /usr/share directory. What we are going to do is put the downloaded jboss-as-7.1.1.Final on /var/lib/puppet/files directory on puppet master and push it to the puppet-client at /usr/share/jboss-as directory.

Here is the below init.pp

The above init.pp define a class jboss-custom, takes JBOSS-as-7.1.1-Final from the puppet-master /var/lib/puppet/files/ and push it to the puppet-client.

Que: How does it know which directory to pull the files from?

Answer: Under /etc/puppet/fileserver.conf, we define those path and permission as shown below:

Shall we start?

Ensure that you have put JBOSS-as-7.1.1-Final under /var/lib/puppet/files directory with permission:

#chown –R puppet:puppet /var/lib/puppet

The permission is very important and shouldn’t be skipped.

Now run the command from the puppet-client to check if it runs without any issue:

Wow !!! Our first program went well and the server has pushed the file to the puppet-client successfully.

Line:5 to 9

The easiest way of performing the overall step is writing a shell script which will run on the remote machine:

Go to /var/lib/puppet/files and create a script called jbossdeploy.sh

#!/bin/bash

groupadd jbossas

useradd -g jbossas -p deQcvEr1PRPSM jbossas

chown -fR jbossas:jbossas /usr/share/jboss-as-7.1.1.Final/

cd /usr/share/jboss-as/

#!/usr/bin/expect

spawn ./add-user.sh

expect “(a):”

send “a”

expect “Realm (ManagementRealm):”

send “ManagementRealm”

expect “Username:”

send “jbossas”

expect “Password:”

send “jbossas”

expect “Re-enter Password:”

send “jbossas”

cd /usr/share/jboss-as-7.1.1.Final/bin

./standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0&

The above script will create jboss user and group, run add-user.sh command under /usr/share/jboss-as/jboss-as-7.1.1.Final/bin directory. I have used expect library (ensure it is already installed) in perl.

Lets modify the init.pp so as to accommodate this script execution as shown:

class jboss-custom {

file {‘/usr/share/jboss-as/jboss-7.1.1.Final’:

owner => ‘root’,

group => ‘root’,

mode => ‘0440’,

source => ‘puppet://puppet-server.test.com/files/jboss-as-7.1.1.Final’

}

file { ‘/usr/share/jboss-as/jbossdeploy.sh’:

source => ‘puppet://puppet-server.test.com/files/jbossdeploy.sh’

}

exec { “/usr/share/jboss-as/jbossdeploy.sh”:}

}

If you run now the following it goes all fine and start the JBOSS application server.

Lets test it.

puppet agent –test –verbose –server puppet-server.test.com

info: Caching catalog for puppet-client.test.com

info: Applying configuration version ‘1345944985’

notice: /File[/usr/share/jboss-as/jbossdeploy.sh]/content:

— /usr/share/jboss-as/jbossdeploy.sh 2012-08-29 17:37:01.365003616 -0400

+++ /tmp/puppet-file20120829-18751-81r0p8-0 2012-08-29 17:44:40.993732919 -0 400

@@ -1,12 +1,10 @@

#!/bin/bash

groupadd jbossas

useradd -g jbossas -p deQcvEr1PRPSM jbossas

chown -fR jbossas:jbossas /usr/share/jboss-as-7.1.1.Final/

-cd /usr/share/jboss-as/jboss-as-7.1.1.Final/bin

+cd /usr/share/jboss-as/

#!/usr/bin/expect

-/usr/bin/expect << EOD

-spawn sh add-user.sh

+spawn ./add-user.sh

expect “(a):”

send “a”

expect “Realm (ManagementRealm):”

@@ -17,7 +15,6 @@

send “jbossas”

expect “Re-enter Password:”

send “jbossas”

-EOD

cd /usr/share/jboss-as-7.1.1.Final/bin

./standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0. 0.0.0&

info: FileBucket adding {md5}afc9bd6b8229da628396b90f2759f41f

info: /File[/usr/share/jboss-as/jbossdeploy.sh]: Filebucketed /usr/share/jboss-a s/jbossdeploy.sh to puppet with sum afc9bd6b8229da628396b90f2759f41f

notice: /File[/usr/share/jboss-as/jbossdeploy.sh]/content: content changed ‘{md5 }afc9bd6b8229da628396b90f2759f41f’ to ‘{md5}140ab2a8605d1164793c2175aa972675’

notice: /Stage[main]/Jboss-custom/Exec[/usr/share/jboss-as/jbossdeploy.sh]/retur ns: executed successfully

notice: /File[/usr/share/jboss-as/jboss-7.1.1.Final]/ensure: created

notice: Finished catalog run in 0.79 seconds

[root@puppet-client ~]#

0
0

Automated shutdown of ESXi and VMs through Powershell

My friend was running a cybercafe center. He has dozens of ESXi running 100 of VMs. He was using Dell Multi-UPS Management console to handle his small computer center. The very often power cut was ruining his business. He called up me to see there is a possible solution to handle graceful shutdown of VMs and then ESXi through the available tools and technique. This solution really helped us to handle the situation gracefully.

I just noted down the steps roughly and will not be late to share it with you:

1. Download the Dell Multi-UPS Management Console from http://www.dell.com/support/home/us/en/19/Drivers/DriversDetails?driverId=R318771

2. Execute DELL_MULTI-DEVICE_A00_R318771.exe and run the setup to install on Windows 2008 R2.

3. Once installed, try accessing it through:

http://127.0.0.1:4679/default.html

4. The default credential for the MUMC login is admin/admin

5.A quick scan is automatically performed and you will get to see the overall power devices available.

6. Click on Settings > Systems and enable shutdown as shown below

7. Click on Shutdown option and configure as shown below

The above shown is a sample entry. Change it as per your required IPs.

In our case, that’s :

Power Source: 192.168.1.99

Load Segment: Master Output

Login/password: admin/admin

Shutdown timer : 180 sec

Shutdown duration: 120 sec

Type: Script

Location: C:\scripts/Ajeet.bat

8. Save the settings

9. Now let’s create a required scripts one by one for shutting down ESXi and VMs.

Script 1:

location: C:\scripts\Ajeet.bat

Start shutdownvms.bat

Script 2:

location: C:\scripts\shutdownvms.bat

———- Start——–

PowerShell.exe C:\Scripts\shutdownallvms.ps1

———End————–

Script 3:

Location:C:\scripts\shutdownallvms.ps1

========= START =========

Add-Snappin “Vmware. Automation.Core”

Connect-VIServer IPADDRESS

# Get All the ESX Hosts

$ESXSRV = Get-VMHost

# For each of the VMs on the ESX hosts

Foreach ($VM in ($ESXSRV | Get-VM)){

# Shutdown the guest cleanly

$VM | Shutdown-VMGuest -Confirm:$false

}

# Set the amount of time to wait before assuming the remaining powered on guests are stuck

$waittime = 200 #Seconds

$Time = (Get-Date).TimeofDay

do {

# Wait for the VMs to be Shutdown cleanly

sleep 1.0

$timeleft = $waittime – ($Newtime.seconds)

$numvms = ($ESXSRV | Get-VM | Where { $_.PowerState -eq “poweredOn” }).Count

Write “Waiting for shutdown of $numvms VMs or until $timeleft seconds”

$Newtime = (Get-Date).TimeofDay – $Time

} until ((@($ESXSRV | Get-VM | Where { $_.PowerState -eq “poweredOn” }).Count) -eq 0 -or ($Newtime).Seconds -ge $waittime)

# Shutdown the ESX Hosts

$ESXSRV | Foreach {Get-View $_.ID} | Foreach {$_.ShutdownHost_Task($TRUE)}

Write-Host “Shutdown Complete”

===== END ========

10. Now its time to test drive the scripts. Just try running those script manually and confirm if those works or not.

11. Now time to test drive with UPS System menu option. Click on Shutdown option of MUMC and Click on Test Shutdown. The Script should work and power-on VMs and ESXi gradually.

12. Try creating the power-off situation and let UPS perform this activity of running the scripts to shutdown ESXi and VMs.

It really went flawless saving couple of rupees for my friend. He treated me the next day for the overall efforts and we rocked the party too 🙂

0
0

Installing Java Development Toolkit (JDK) on Linux

Installing Java Development toolkit on Linux is always matter of difficulty since Oracle provides both RPM and tarballs in their official website. Installing RPM is pretty simple but installing through tarballs need sufficient environmental variable declaration which is little different from Windows Operating System.

javalinux

Follow the steps mentioned below to install java-1.6.

1.Download jdk-6u16-linux-x64.bin (From the URL mentioned in the prerequisites section) to /opt directory.

2.Change the permission of jdk-6u16-linux-x64.bin file to 755.

[root@bang opt]# chmod 755 jdk-6u16-linux-x64.bin

3.Execute the jdk-6u16-linux-x64.bin file to start installation.

[root@bang opt]# ./jdk-6u16-linux-x64.bin

Sun Microsystems, Inc. Binary Code License Agreement

for the JAVA 2 PLATFORM STANDARD EDITION DEVELOPMENT KIT 6.0

SUN MICROSYSTEMS, INC. (“SUN”) IS WILLING TO LICENSE THE

SOFTWARE IDENTIFIED BELOW TO YOU ONLY UPON THE CONDITION

THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS BINARY

CODE LICENSE AGREEMENT AND SUPPLEMENTAL LICENSE TERMS

(COLLECTIVELY “AGREEMENT”). PLEASE READ THE AGREEMENT

CAREFULLY. BY DOWNLOADING OR INSTALLING THIS SOFTWARE, YOU

ACCEPT THE TERMS OF THE AGREEMENT. INDICATE ACCEPTANCE BY

SELECTING THE “ACCEPT” BUTTON AT THE BOTTOM OF THE

AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY ALL THE

TERMS, SELECT THE “DECLINE” BUTTON AT THE BOTTOM OF THE

AGREEMENT AND THE DOWNLOAD OR INSTALL PROCESS WILL NOT

CONTINUE.

1. DEFINITIONS. “Software” means the identified above in

binary form, any other machine readable materials

(including, but not limited to, libraries, source files,

header files, and data files), any updates or error

corrections provided by Sun, and any user manuals,

programming guides and other documentation provided to you

by Sun under this Agreement. “General Purpose Desktop

Computers and Servers” means computers, including desktop,

laptop and tablet computers, or servers, used for general

computing functions under end user control (such as but not

specifically limited to email, general purpose Internet

browsing, and office suite productivity tools). The use of

Software in systems and solutions that provide dedicated

functionality (other than as mentioned above) or designed

for use in embedded or function-specific software

applications, for example but not limited to: Software

embedded in or bundled with industrial control systems,

wireless mobile telephones, wireless handheld devices,

kiosks, TV/STB, Blu -ray Disc devices, telematics and

network control switching equipment, printers and storage

management systems, and other related systems are excluded

from this definition and not licensed under this Agreement.

“Programs” means Java technology applets and applications

intended to run on the Java Platform Standard Edition (Java

SE) ptaform on Java-enabled General Purpose Desktop

Computers and Servers.

4.Press the Tab key until you reach the End of License Agreement Screen

5.Type yes and hit Enter key

6.It will installs jdk-1.6.0_16

F. Source Code. Software may contain source code that,

unless expressly licensed for other purposes, is provided

solely for reference purposes pursuant to the terms of this

Agreement. Source code may not be redistributed unless

expressly provided for in this Agreement.

G. Third Party Code. Additional copyright notices and

license terms applicable to portions of the Software are set

forth in the THIRDPARTYLICENSEREADME.txt file. In addition

to any terms and conditions of any third party

opensource/freeware license identified in the

THIRDPARTYLICENSEREADME.txt file, the disclaimer of warranty

and limitation of liability provisions in paragraphs 5 and 6

of the Binary Code License Agreement shall apply to all

Software in this distribution.

H. Termination for Infringement. Either party may

terminate this Agreement immediately should any Software

become, or in either party’s opinion be likely to become,

the subject of a claim of infringement of any intellectual

property right.

I. Installation and Auto-Update. The Software’s

installation and auto-update processes transmit a limited

amount of data to Sun (or its service provider) about those

specific processes to help Sun understand and optimize them.

Sun does not associate the data with personally identifiable

information. You can find more information about the data

Sun collects at http://java.com/data/.

For inquiries please contact: Sun Microsystems, Inc., 4150

Network Circle, Santa Clara, California 95054, U.S.A.

(LFI#143333/Form ID#011801)

Do you agree to the above license terms? [yes or no]

yes

Unpacking…

Checksumming…

0

0

Extracting…

UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).

inflating: jdk-6u16-linux-x64-rpm

Preparing… #################################### [100%]

1:jdk #################################### [100%]

Done.

#

7.Add below lines in /etc/profile file to define JAVA_HOME and its PATH

export JAVA_HOME=/usr/java/jdk-1.6.0_16

export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:

8. Verify the java installation by running the following command in the new window.`

[root@bang opt]# java -version

java version “1.6.0_16”

Java(TM) SE Runtime Environment (build 1.6.0_16-b01)

Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)

[root@bangvbapp opt]#

0
0

How to setup Domain Name Server (DNS) on Linux?

It has been long I was thinking of writing something about DNS(Domain Name Server). DNS is a database of the IP to Name and Name to IP conversion.I went through lots of tutorials related to DNS but couldnt satisfy myself unless and until I started writing commands and configuring files for the initial setup.After lot of tweaking and command line I was able to setup a simple DNS server.

dns_process

Lets travel into the world of DNS.

I have a RHEL 4 Machine ready with bind packages installed.The Minimal requirement are:

[root@localhost ~]# rpm -qa bind*

bind-libs-9.2.4-24.EL4

bind-utils-9.2.4-24.EL4

bind-9.2.4-24.EL4

bind-chroot-9.2.4-24.EL4

bind-devel-9.2.4-24.EL4

bind-libs-9.2.4-24.EL4

[root@localhost ~]#

The IP Details of my Machine are:

[root@localhost ~]# ifconfig

eth0 Link encap:Ethernet HWaddr 00:16:17:C6:BE:47

inet addr:10.14.77.33 Bcast:10.14.77.127 Mask:255.255.255.128

inet6 addr: fe80::216:17ff:fec6:be47/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:36287 errors:0 dropped:0 overruns:0 frame:0

TX packets:19141 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:5408275 (5.1 MiB) TX bytes:2370680 (2.2 MiB)

Interrupt:201

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:18714 errors:0 dropped:0 overruns:0 frame:0

TX packets:18714 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:10174891 (9.7 MiB) TX bytes:10174891 (9.7 MiB)

[root@localhost ~]#

The Exact Steps I followed are mentioned Below:

1. Open a file /etc/hosts and make it look like this:

[root@localhost ~]# cat /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1 localhost.localdomain localhost

[root@localhost ~]#

2.Edit the file /etc/resolv.conf:

[root@localhost ~]# cat /etc/resolv.conf

; generated by /sbin/dhclient-script

search tuxbuddy.raina.com

nameserver 10.14.77.33

[root@localhost ~]#

3. Run this Command:

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

BOOTPROTO=dhcp

HWADDR=00:16:17:C6:BE:47

ONBOOT=yes

TYPE=Ethernet

PEERDNS=no

[root@localhost ~]#

4. Follow this step:

[root@localhost etc]# pwd

/var/named/chroot/etc

[root@localhost etc]# vi named.conf

//

// named.conf for Red Hat caching-nameserver

//

options {

directory “/var/named”;

dump-file “/var/named/data/cache_dump.db”;

statistics-file “/var/named/data/named_stats.txt”;

/*

* If there is a firewall between you and nameservers you want

* to talk to, you might need to uncomment the query-source

* directive below. Previous versions of BIND always asked

* questions using port 53, but BIND 8.1 uses an unprivileged

* port by default.

*/

// query-source address * port 53;

};

//

// a caching only nameserver config

//

controls {

inet 127.0.0.1 allow { localhost; } keys { rndckey; };

};

zone “.” IN {

type hint;

file “named.ca”;

};

zone “tuxbuddy.raina.com” IN {

type master;

file “tuxbuddy.raina.com.zone”;

allow-update { none; };

};

zone “33.77.14.10.in-addr.arpa” IN {

type master;

file “10.14.77.33.zone”;

allow-update { none; };

};

zone “localhost” IN {

type master;

file “localhost.zone”;

allow-update { none; };

};

zone “0.0.127.in-addr.arpa” IN {

type master;

file “named.local”;

allow-update { none; };

};

zone “0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa” IN {

type master;

file “named.ip6.local”;

allow-update { none; };

};

zone “255.in-addr.arpa” IN {

type master;

file “named.broadcast”;

allow-update { none; };

};

zone “0.in-addr.arpa” IN {

type master;

file “named.zero”;

allow-update { none; };

};

include “/etc/rndc.key”;

Save the file.

5.Edit the Database Files:

[root@localhost named]# pwd

/var/named/chroot/var/named

[root@localhost named]#vi tuxbuddy.raina.com

$TTL 86400

@ IN SOA station1.tuxbuddy.raina.com. root.station1.tuxbuddy.raina.com. (

2009091100; Serial

28800 ; Refresh

14400 ; Retry

3600000 ;Expire

0 ) ; Negative

@ IN NS station1.tuxbuddy.raina.com.

@ IN A 10.14.77.33

station1.tuxbuddy.raina.com. IN A 10.14.77.33

www IN A 10.14.77.33

ftp IN A 10.14.77.33

pop IN A 10.14.77.33

www1 IN CNAME station1.tuxbuddy.raina.com.

www2 IN CNAME station2.tuxbuddy.raina.com.

www.station1.tuxbuddy.raina.com IN A 10.14.77.33

Innovation2.groupinfra.com. IN A 10.14.16.215

@ IN MX 10 station1.tuxbuddy.raina.com.

station1 IN MX 10 station1.tuxbuddy.raina.com.

~

[root@localhost named]#

6. Edit this file too:

[root@localhost named]# pwd

/var/named/chroot/var/named

[root@localhost named]#

[root@localhost named]# cat 10.14.77.33.zone

$TTL 86400

@ IN SOA station1.tuxbuddy.raina.com. root.station1.tuxbuddy.raina.com. (

4 10800 3600 604800 86400 )

IN NS station1.tuxbuddy.raina.com.

33.77.14.10.IN-ADDR.ARPA. IN PTR station1.tuxbuddy.raina.com.

[root@localhost named]#

JUST REMEMBER DONT MISS ANY . during the configuration.

DNS IS VERY SENSITIVE TO SINGLE SIGN.

Thats ALL !!!

YOUR SIMPLE DNS SERVER IS READY.

Testing the DNS SERVER

[root@localhost named]# dig -x 10.14.77.33

; <<>> DiG 9.2.4 <<>> -x 10.14.77.33

;; global options: printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48322 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1 ;; QUESTION SECTION: ;33.77.14.10.in-addr.arpa. IN PTR ;; ANSWER SECTION: 33.77.14.10.in-addr.arpa. 86400 IN PTR station1.tuxbuddy.raina.com. ;; AUTHORITY SECTION: 33.77.14.10.in-addr.arpa. 86400 IN NS station1.tuxbuddy.raina.com.

;; ADDITIONAL SECTION:

station1.tuxbuddy.raina.com. 86400 IN A 10.14.77.33

;; Query time: 1 msec

;; SERVER: 10.14.77.33#53(10.14.77.33)

;; WHEN: Wed Oct 7 07:28:30 2009

;; MSG SIZE rcvd: 114

[root@localhost named]#

Just See..Your IP is resolving to Hostname and vice versa.

Other Way to see if things work or not !!

[root@localhost named]# host 10.14.77.33

33.77.14.10.in-addr.arpa domain name pointer station1.tuxbuddy.raina.com.

[root@localhost named]#

These too,

[root@localhost named]# host www

www.tuxbuddy.raina.com has address 10.14.77.33

[root@localhost named]#

0
0

How to test Multicast Packet Filtering?

Today morning I started my day testing with Multicast Packet Filtering. I had buntu 12.04.1 and CentOS 6.5 in my VM running over ESX 5.5.I decided to make CentOS as Client and Ubuntu as server for the setup.

iperf-client-server
First of all, I downloaded iperf as I had no YUM working at my internal lab.
Its simple to install,download the package and install. Luckily, I dint get any dependency hell.

On Ubuntu Box:

SERVER MACHINE
=====================================

sudo iperf -s -u -B 224.0.65.68 -i 1
————————————–

server listening on UDP port 5001
Binding to local address 224.0.65.68
Joining multicast group 224.0.65.68
UDP Buffer size: 120 Kbytes(default)
——————————————

[ 3] local 224.0.65.688 port 5001 connected with 10.112.173.86 port 38577
[ 3] 0.0.-1.0 sec 128 KBytes 1.05 Mbits/sec 0.228 ms 0/ 89 (0%)

On CenTOS Box(Client):

iperf -c 224.0.65.68 -u -T 5 -t 5
———————————-
Client connecting to 224.0.65.68, UDP port 5001
sending 1470 byte datagrams
setting multicast TTL to 5
UDP buffer size: 126 KBytes(default)
——————————————
[ 3] local 10.112.173.86 port 38577 connected with 224.0.65.68 port 5001
[ 3] 0.0- 5.0 sec 642 Kbytes 1.05 Mbits/sec
[ 3] Sent 447 datagrams

1.It clearly shows that multicast address is 224.0.65.68.
e.g. server> iperf -s -u -B -i 1

This will have the iperf servers listening for datagram (-u) from the address (-B multicast address), with a periodic interval of 1s (-i 1)

2. Configure the client VM, connecting to the multicast group address and setting the TTL (-T, –ttl) as needed
e.g. client> iperf -c -u -T 5 -t 5

This will have the client connected to the multicast address (-c multicast address), with a TTL of 5 (-T 5), sending data for 5 seconds
NOTE: Use tcpdump or ethereal on server VMs to capture and analyze IP packets and ensure its validity.

Run the test for 120 sec.

That’s it..
You Have just finally tested Multicast packet Filtering.

0
0

Understanding /proc/cpuinfo

A hyperthreaded processor has the same number of function units as an older, non-hyperthreaded processor. It just has two execution contexts, so it can maybe achieve better function unit utilization by letting more than one program execute concurrently. On the other hand, if you’re running two programs which compete for the same function units, there is no advantage at all to having both running “concurrently.” When one is running, the other is necessarily waiting on the same function units.

cpu

A dual core processor literally has two times as many function units as a single-core processor, and can really run two programs concurrently, with no competition for function units.

A dual core processor is built so that both cores share the same level 2 cache. A dual processor (separate physical cpus) system differs in that each cpu will have its own level 2 cache. This may sound like an advantage, and in some situations it can be but in many cases new research and testing shows that the shared cache can be faster when the cpus are sharing the same or very similar tasks.

In general Hyperthreading is considered older technology and is no longer supported in newer cpus. Hyperthreading can provide a marginal (10%) for some server workloads like mysql, but dual core technology has essentially replaced hyperthreading in newer systems.

A dual core cpu running at 3.0Ghz should be faster then a dual cpu (separate core) system running at 3.0Ghz due to the ability to share the cache at higher bus speeds.

The examples below details how we determine what kind of cpu(s) are present.

The kernel data Linux exposes in /proc/cpuinfo will show each logical cpu with a unique processor number. A logical cpu can be a hyperthreading sibling, a shared core in a dual or quad core, or a separate physical cpu. We must look at the siblings, cpu cores and core id to tell the difference.

If the number of cores = the number of siblings for a given physical processor, then hyperthreading is OFF.

/bin/cat /proc/cpuinfo | /bin/egrep ‘processor|model name|cache size|core|sibling|physical’

Example 1: Single processor, 1 core, no Hyperthreading

processor : 0
model name : AMD Duron(tm) processor
cache size : 64 KB

Example 2: Single processor, 1 core, Hyperthreading is enabled.

Notice how we have 2 siblings, but only 1 core. The physical cpu id is the same for both: 0.

processor : 0
model name : Intel(R) Pentium(R) 4 CPU 2.80GHz
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
processor : 1
model name : Intel(R) Pentium(R) 4 CPU 2.80GHz
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1

Example 3. Single socket Quad Core

Notice how each processor has its own core id. The number of siblings matches the number of cores so there are no Hyperthreading siblings. Also notice the huge l2 cache – 6 MB. That makes sense though, when considering 4 cores share that l2 cache.

processor : 0
model name : Intel(R) Xeon(R) CPU E5410 @ 2.33GHz
cache size : 6144 KB
physical id : 0
siblings : 4
core id : 0
cpu cores : 4
processor : 1
model name : Intel(R) Xeon(R) CPU E5410 @ 2.33GHz
cache size : 6144 KB
physical id : 0
siblings : 4
core id : 1
cpu cores : 4
processor : 2
model name : Intel(R) Xeon(R) CPU E5410 @ 2.33GHz
cache size : 6144 KB
physical id : 0
siblings : 4
core id : 2
cpu cores : 4
processor : 3
model name : Intel(R) Xeon(R) CPU E5410 @ 2.33GHz
cache size : 6144 KB
physical id : 0
siblings : 4
core id : 3
cpu cores : 4

Example 3a. Single socket Dual Core

Again, each processor has its own core so this is a dual core system.

processor : 0
model name : Intel(R) Pentium(R) D CPU 3.00GHz
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
processor : 1
model name : Intel(R) Pentium(R) D CPU 3.00GHz
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2

Example 4. Dual Single core CPU, Hyperthreading ENABLED

This example shows that processer 0 and 2 share the same physical cpu and 1 and 3 share the same physical cpu. The number of siblings is twice the number of cores, which is another clue that this is a system with hyperthreading enabled.

processor : 0
model name : Intel(R) Xeon(TM) CPU 3.60GHz
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
processor : 1
model name : Intel(R) Xeon(TM) CPU 3.60GHz
cache size : 1024 KB
physical id : 3
siblings : 2
core id : 0
cpu cores : 1
processor : 2
model name : Intel(R) Xeon(TM) CPU 3.60GHz
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
processor : 3
model name : Intel(R) Xeon(TM) CPU 3.60GHz
cache size : 1024 KB
physical id : 3
siblings : 2
core id : 0
cpu cores : 1

Example 5. Dual CPU Dual Core No hyperthreading

Of the 5 examples this should be the most capable system processor-wise. There are a total of 4 cores; 2 cores in 2 separate socketed physical cpus. Each core shares the 4MB cache with its sibling core. The higher clock rate (3.0 Ghz vs 2.3Ghz) should offer slightly better performance than example 3.

processor : 0
model name : Intel(R) Xeon(R) CPU 5160 @ 3.00GHz
cache size : 4096 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
processor : 1
model name : Intel(R) Xeon(R) CPU 5160 @ 3.00GHz
cache size : 4096 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
processor : 2
model name : Intel(R) Xeon(R) CPU 5160 @ 3.00GHz
cache size : 4096 KB
physical id : 3
siblings : 2
core id : 0
cpu cores : 2
processor : 3
model name : Intel(R) Xeon(R) CPU 5160 @ 3.00GHz
cache size : 4096 KB
physical id : 3
siblings : 2
core id : 1
cpu cores : 2

Hope you find it useful for your interview preparation.

0
0

How to setup vsFTP server on Linux?

FTP refers to File Transfer Protocol. By default, Red Hat supports vsftp. If you do minimal RHEL installation, you mightn’t have vsftp related RPM packages installed.

ftp

To setup an anonymous ftp server on Red Hat Enterprise Linux, follow these steps:

1. Verify that the vsftpd package is installed.

#rpm -qa |grep vsftpd

If it is not installed, the install it as follows:

RHEL 3 and 4

# up2date -i vsftpd

RHEL 5
# yum install vsftpd

2. Verify the localhost line in /etc/hosts looks like the following:

127.0.0.1 localhost.localdomain localhost

3. Next configure the vsftpd.conf file. NOTE: Back up the vsftpd.conf file

# cd /etc/vsftpd
# cp vsftpd.conf ./vsftpd.conf.ORIG

Using an editor, open the file vsftpd.conf. Uncomment the line
anonymous_enable=YES. Save and quit the vsftpd.conf file.

4. Start the vsftpd service

# service vsftpd start

5. To have the vsftpd service persistent across reboot:

# chkconfig vsftpd on

6. To test the configuration run the following commands:

# ftp localhost

Login with:
username: anonymous
password: root@local

This should show an ftp prompt. Type ‘bye’ to exit to the command prompt.
NOTE: ports 20 and 21 must be opened on the firewall.

0
0