June 19, 2009

Importing a Virtual Machine/Appliance into ESX Server

Import a virtual machine into VMware ESX Server


ESX 3.5 with .vmx

    Copy the VMware image to the ESX server, it must be unzipped and untarred. Browse to the data store using the datastore browser in VMware Infrastructure Client (Click the inventory button). Right-click on the .vmx file and choose "Add to     inventory"

ESX 3.5 with .ovf

    Go to File> Virtual Appliance> Import within VMware Infrastructure Client. Choose "Import from file" and give the path to the .ovf file. Continue with the wizard.

May 27, 2009

Solaris 10 and Net-SNMP

Apparently Net-SNMP is now included in Solaris 10 by default, however it is not enabled by default. To use it you must first disable Sun's SNMP

#svcadm disable svc:/application/management/snmpdx:default

Net-SNMP is part of Solaris' System Management Agent. More about that here:
Solaris System Management Agent Developer's Guide

Net-SNMP daemon is located at /usr/sfw/sbin/snmpd, and its configuration file is located in /etc/sma/snmp.

You will need to use svcadm to start and stop Net-SNMP:

#svcadm enable svc:/application/management/sma:default
#svcadm disable svc:/application/management/sma:default

Apparently there are two logs that you can reference for Net-SNMP

SMA's log is located here -- /var/svc/log/application-management-sma\:default.log.
However the default log file of snmpd is /var/log/snmpd.log.

You also have an init script in /etc/init.d called  init.sma


April 02, 2009

Solaris Package Management Cheat Sheet

Images Basic Package Management Commands

Show description about <pkg>

pkginfo -l <pkg>

Install <pkg-file> pkgadd -d <pkg-file>
Remove <pkg> pkgrm <pkg>
Find package which owns <file> pkgchk -l -p <file>
List files in installed <pkg> pkgchk -l <pkg>|awk '/^Pathname/ {print $2}'
List files in <pkg-file> pkgchk -l -d <pkg-file>|awk '/^Pathname/ {print $2}'
List all installed packages pkginfo
Verify integrity of installed files from <pkg> pkgchk <pkg>
Verify integrity of install files from all packages pkginfo|awk '{print $2}'|xargs pkgchk

April 01, 2009

Shell Script: List all RPMs and their Requirements on RHEL

 The command below is sort of like a fingerprint for a box. It lists all rpms that are installed and the files that are required by those rpms.

rpm -qa | sed -e "s,-[0-9]*\\., ,1" | tee rpm-qa.txt | awk '{print $1}' | xargs rpm -q --requires | sort | uniq | tee rpm-qa-requires.txt

Shell Script: Test SSH Connectivty to a list of boxes

#!/bin/ksh

ERROR=0

for SERVER in `cat server.list`
do
        ssh -n -o Batchmode=yes -o ConnectTimeout=30 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $SERVER "uname -n > /dev/null" > /dev/null 2>&1
        if [ $? -ne 0 ]
        then
                echo "FAILED: $SERVER"
                ERROR=1
        else
                echo "SUCCESS: $SERVER"
        fi
done

March 30, 2009

ZFS Quick Start

Images ZFS is a filesystem, designed by Sun, and implemented in Solaris 10. Unlike traditional filesystems, which reside on single disk devices and thus require a volume manager to use more than one device, ZFS filesystems are built on top of virtual storage pools called zpools, which elimiate the need to create individuall volumes. When creating a filesystem, you do not need to specify a size, as filesystems will grow automatically withing the zpool . When new storage is added, all file systems within the pool can immediately use the additional space without additional work. Most importantly ZFS is simple and pretty easy to administer. See my simple notes below which outline how to get started.


1. First create your pool. I called mine database_pool

-bash-3.00# zpool create database_pool c1t14d0s6 c1t13d0s6 c1t12d0s6

2. Now admire your new pool. Yours may differ in size :)

-bash-3.00# zpool list
NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
database_pool          50.2G   60.5K   50.2G     0%  ONLINE     -

3. Create your volumes. In this example I create two similar to what we will be doing in Philly.
-bash-3.00# zfs create database_pool/apdru
-bash-3.00# zfs create database_pool/apdi2

4. Take a look at your new mounts
-bash-3.00# df -k
Filesystem            kbytes    used   avail capacity  Mounted on
database_pool        51867648      25 51867511     1%    /database_pool
database_pool/db1  51867648      24 51867511     1%    /database_pool/db1
database_pool/db2 51867648      24 51867511     1%    /database_pool/db2

5. Make the directory structure for your new volumes if the above path is not where you want them mounted.
-bash-3.00# mkdir -p /db1/v1
-bash-3.00# mkdir -p /db2/v1

6. Mount your new volumes where you want them to go using zfs set. Note there is no leading / on the pool name

-bash-3.00# zfs set mountpoint=
/db1/v1 database_pool/db1
-bash-3.00# zfs set mountpoint=
/db2/v1/apdru database_pool/db2

7. Admire your work. You do not have to create a filesystem, its already there and each mount point/volume will grow as needed up to the total capacity of the pool. So no need to worry about sizing each volume for each database.


-bash-3.00# df -k
Filesystem            kbytes    used   avail capacity  Mounted on
database_pool        51867648      25 51867498     1%    /database_pool
database_pool/apdi2  51867648      24 51867498     1%    /db1/v1
database_pool/apdru  51867648      24 51867498     1%    /db2/v1

Shell Scripting - Prompting for User Input.

Shell_25194_sm First off let me start out this post by stating that I am a pretty lousy scripter. I just have not taken the time to write a lot of scripts. So I have created a new Category called "Shell Scripting" and plan to do my best to keep adding little "scriptlets" whenever I can.


Prompting for user input

# echo -n "Enter your name and press [ENTER]:"
# read name
# echo -n "Enter your gender and press [ENTER]:"
# read -n 1 gender (read returns after 1 character is read)
# echo

Adding A Swap File to Linux

SWAP File

The following commands illustrate how to add a swap file of 2GB to a RedHat system:

# dd if=/dev/zero of=/temp_swap bs=1024 count=2097152
# mkswap /temp_swap
# swapon /temp_swap

To enable it at boot time, edit /etc/fstab to include:

/temp_swap swap swap defaults 0 0

After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command:

# free -mo

March 05, 2009

Remove a Lun From Redhat

Note that removing a SAN lun is a semi-tedious process that must be followed. Failure to do so will result in your server being left in a funky state. The process varries depending on how you are using your disk


Using LVM?

For Example: Is the disk part of a Logical Volume and under LVM control? Then shrink the volume group and then remove the disk from the volume group using pvremove.

vgreduce VolGroup <device name from `vgdisplay -v vgname` output>
pvremove <device name from `pvscan` output>

Kpartx & Multipath


Despite its name, its not a KDE-tool for partitioning disks.
Kpartx is a Partition device manager for device-mapper devices that is usually shipped as part of
multipath. Its purpose is to read the partition table of a device or a
file and create device map entries for the individual partitions.
When removing a disk from a system, you will need to remove the partition map of the multipathed device.

kpartx -d /dev/mapper/mpath5 <to remove the /dev/mapper/mpath5p1 device>
multipath -f mpath5 <where mpath5 is the alias for the multipathed device <br>

see example:


mpath5 (360060e801004e780052fab2800000064) dm-7 HITACHI,DF600F
[size=1.0G][features=1 queue_if_no_path][hwhandler=0]
\_ round-robin 0 [prio=1][active]
\_ 3:0:0:3 sdj 8:144 [active][ready]
\_ 4:0:0:3 sdh 8:112 [active][ready]


Removing the disk from Linux Control.

This is the most important step, as not doing this part is what will screw up your box.

cd to /sys/class/scsi_device
then cd to the number of the SCSI device, for example 4:0:0:3 is the device id for /dev/sdh
then type

echo 1 > device/delete

February 02, 2009

Linux SAN Disk Managment via DM-Multipath

A little background...
Most of the time, I have used the RDAC driver in Linux to manage SAN disks in Linux. The RDAC driver is used to hide the complexity of multiple paths and to present redundant paths as a single path which can be used as you would a standard SCSI / IDE / SAS / SATA drive. Seeing only one device makes managing your disks much easier.

However where I work we only use RDAC with our IBM FastT, Sun 6140 and STK Flexline storage arrays. RDAC is not for LSI based storage such as Hitachi, Clarion, and EMC. For these servers we manage SAN disk with DM-Multipath.

Setup...
Setting up DM-Multipath is not hard, first you need to make sure that you install the package, device-mapper-mulitpath, and you will need to configure your multipath.conf and drop it into /etc. Below is some info on how to do so.

http://kbase.redhat.com/faq/docs/DOC-3691

You will also need to make sure that you enable the multipathd daemon. This daemon is in charge of checking for failed paths.

Multipath Command...
For those use to using RDAC, DM-Multipath takes some getting used to, especially when you see the output from fdisk -ll.

In one particular instance I was given the disk name of /dev/sdm as the name of the new disk on this box. The output from the fdisk -l command is not exactly helpful, as there are a ton of psuedo devices showing up in my output. This is where the multipath command comes in handy.

Continue reading "Linux SAN Disk Managment via DM-Multipath" »