Total Pageviews

Showing posts with label SOLARIS. Show all posts
Showing posts with label SOLARIS. Show all posts

Wednesday, 30 November 2016

Host Side Scanning of Luns (OpenFiler Storage) !!!

In this post we are going to learn how to scan luns from host side. In many of the interviews it is a common question, "Explain me step by step how do you make a LUN visible at host side?"

Let me make it clear what exactly Host side scanning means. Whenever Sys Admins request for new luns, Storage team will assign the LUNs as per the request. Then it is an admin task to make it visible at OS level for the application use.

To make a LUN ready to use and to make it visible at host side we need to follow few steps carefully. When it comes to LUNs visibility and Storage, iSCSI target and iSCSI initiator are the most common terms we come across.

iSCSI initiator initiates a SCSI session, that means it requests the LUN (our Host server).
iSCSI target is the Storage Network, that means it is the server which contains the LUNs (Target Node -- OpenFiler).

In my scenario, I created 4 Luns in my OpenFiler storage. Now I will show you the steps to make them visible at my Solaris host.

Steps we need to follow,

1. Check whether iscsitgt service is online or not. (Make it online)
2. Using "iscsiadm" command, we need to add our iSCSI target to our host.
3. Then comes the actual host side scanning using "devfsadm" command.



Output of format command before assigning luns...

bash-3.2# echo| format
Searching for disks...

AVAILABLE DISK SELECTIONS:
       0. c0d0 <▒x▒▒▒▒▒▒▒▒▒@▒▒▒ cyl 2085 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
Specify disk (enter its number): Specify disk (enter its number):

bash-3.2#

Proceed with our steps,

bash-3.2# svcs iscsitgt
STATE          STIME    FMRI
disabled       15:12:02 svc:/system/iscsitgt:default
bash-3.2#

bash-3.2# svcadm enable iscsitgt
bash-3.2#

bash-3.2# svcs iscsitgt
STATE          STIME    FMRI
online         17:34:06 svc:/system/iscsitgt:default
bash-3.2#

Then the Step 2,

bash-3.2# iscsiadm list static-config
bash-3.2#                                                           ---- No targets are available.

Add the iSCSI target, (Careful with the name, when you have many available targets at Storage end)

bash-3.2# iscsiadm add static-config iqn.2006-01.com.openfiler:tsn.d896e2cf3975,10.0.0.129:3260
bash-3.2#                                                     --- Port 3260 is a TCP port for iSCSI traffic.
bash-3.2# iscsiadm list static-config
Static Configuration Target: iqn.2006-01.com.openfiler:tsn.d896e2cf3975,10.0.0.129:3260
bash-3.2#

Then the final step, scanning disks at host side....

bash-3.2# devfsadm -i iscsi
bash-3.2#

bash-3.2#
bash-3.2# echo|format
Searching for disks...

AVAILABLE DISK SELECTIONS:
       0. c0d0 <▒x▒▒▒▒▒▒▒▒▒@▒▒▒ cyl 2085 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c2t2d0 <OPNFILE-VIRTUAL-DISK   -0    cyl 1529 alt 2 hd 128 sec 32>
          /iscsi/disk@0000iqn.2006-01.com.openfiler%3Atsn.d896e2cf39750001,0
       2. c2t3d0 <OPNFILE-VIRTUAL-DISK   -0    cyl 2043 alt 2 hd 128 sec 32>
          /iscsi/disk@0000iqn.2006-01.com.openfiler%3Atsn.d896e2cf39750001,1
       3. c2t4d0 <OPNFILE-VIRTUAL-DISK   -0    cyl 1017 alt 2 hd 64 sec 32>
          /iscsi/disk@0000iqn.2006-01.com.openfiler%3Atsn.d896e2cf39750001,2
       4. c2t5d0 <OPNFILE-VIRTUAL-DISK   -0    cyl 505 alt 2 hd 64 sec 32>
          /iscsi/disk@0000iqn.2006-01.com.openfiler%3Atsn.d896e2cf39750001,3
Specify disk (enter its number): Specify disk (enter its number):
bash-3.2#

If we have EMC storage in our environment, then there are other commands to deal with powerpath to scan the luns. Similarly to make use of these luns under Veritas control, we use vxscandisks command to scan.... 

Regarding above scenarios, I already posted earlier...

https://solarishandy.blogspot.com/2015/02/making-luns-visible-at-host-side.html

#####################################################################################

Friday, 10 October 2014

OS Live Upgrade !!!

Live Upgrade is the concept of upgrading the OS with minimum downtime.Whole concept revolves around boot environments.
Idea is to create a new boot environment and upgrade the new one while OS is still running on old Boot Environment.

So that once we upgrade the OS for new BE, we have to restart the server by activating the newBE.
The whole OS upgrade procedure will be carried out while OS online and running using old BE.So a single reboot is the actual downtime which we require once OS is upgraded.

For this live upgrade procedure we need following "lu" packages :

SUNWlucfg
SUNWluu
SUNWlur

After adding the mentioned packages we have to create a new boot environment and then we need to upgrade the newBE.
Once we upgrade the system , we need to activate the new BE so that whenever we reboot the system,this newBE will be activated.

root@mysrv1 # bash
root@mysrv1 # df -kh
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c1t0d0s0       30G    25G   4.0G    87%    /
/devices                 0K     0K     0K     0%    /devices
ctfs                     0K     0K     0K     0%    /system/contract
proc                     0K     0K     0K     0%    /proc
mnttab                   0K     0K     0K     0%    /etc/mnttab
swap                    29G   1.7M    29G     1%    /etc/svc/volatile
objfs                    0K     0K     0K     0%    /system/object
sharefs                  0K     0K     0K     0%    /etc/dfs/sharetab
/platform/sun4u-us3/lib/libc_psr/libc_psr_hwcap2.so.1
                        30G    25G   4.0G    87%    /platform/sun4u-us3/lib/libc_psr.so.1
/platform/sun4u-us3/lib/sparcv9/libc_psr/libc_psr_hwcap2.so.1
                        30G    25G   4.0G    87%    /platform/sun4u-us3/lib/sparcv9/libc_psr.so.1
fd                       0K     0K     0K     0%    /dev/fd
swap                    29G    32K    29G     1%    /tmp
swap                    29G    40K    29G     1%    /var/run
swap                    29G     0K    29G     0%    /dev/vx/dmp
swap                    29G     0K    29G     0%    /dev/vx/rdmp
root@mysrv1 #

Check the current OS version :

root@mysrv1 # uname -a
SunOS mysrv1 5.10 Generic_137137-09 sun4u sparc SUNW,Sun-Fire-V490
root@mysrv1 #
root@mysrv1 # cat /etc/release
                      Solaris 10 10/08 s10s_u6wos_07b SPARC
           Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                            Assembled 27 October 2008
root@mysrv1 #

Check whether "lu" packages are installed or not. If not install the packages....

root@mysrv1 # pkginfo -l SUNWlucfg
   PKGINST:  SUNWlucfg
      NAME:  Live Upgrade Configuration
  CATEGORY:  application
      ARCH:  sparc
   VERSION:  11.10,REV=2007.03.09.13.13
   BASEDIR:  /
    VENDOR:  Sun Microsystems, Inc.
      DESC:  Live Upgrade Configuration
    PSTAMP:  on10-adms-patch20080801101319
  INSTDATE:  Jan 04 2014 13:35
   HOTLINE:  Please contact your local service provider
    STATUS:  completely installed
     FILES:        5 installed pathnames
                   3 shared pathnames
                   3 directories
                  35 blocks used (approx)

root@mysrv1 # pkginfo -l SUNWluu
   PKGINST:  SUNWluu
      NAME:  Live Upgrade (usr)
  CATEGORY:  application
      ARCH:  sparc
   VERSION:  11.10,REV=2005.01.10.00.03
   BASEDIR:  /
    VENDOR:  Sun Microsystems, Inc.
      DESC:  Live Upgrade (usr)
    PSTAMP:  on10-adms-patcH20080730164103
  INSTDATE:  Jan 04 2014 13:38
   HOTLINE:  Please contact your local service provider
    STATUS:  completely installed
     FILES:      162 installed pathnames
                   9 shared pathnames
                  11 directories
                  42 executables
                2537 blocks used (approx)

root@mysrv1 # pkginfo -l SUNWlur
   PKGINST:  SUNWlur
      NAME:  Live Upgrade (root)
  CATEGORY:  application
      ARCH:  sparc
   VERSION:  11.10,REV=2005.01.10.00.03
   BASEDIR:  /
    VENDOR:  Sun Microsystems, Inc.
      DESC:  Live Upgrade (root)
    PSTAMP:  on10-adms-patch20080730164055
  INSTDATE:  Jan 04 2014 13:38
   HOTLINE:  Please contact your local service provider
    STATUS:  completely installed
     FILES:       39 installed pathnames
                  11 shared pathnames
                   4 linked files
                  15 directories
                  13 executables
                2596 blocks used (approx)
root@mysrv1 #
root@mysrv1 #

Check the second disk status, so that we can select 2nd disk for creating newBE within it.

root@mysrv1 #
root@mysrv1 # df -kh /
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c1t0d0s0       30G    25G   4.0G    87%    /
root@mysrv1 #
root@mysrv1 # echo | format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c1t0d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848>
          /pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000000875c9aa4,0
       1. c1t1d0 <HITACHI-HUS1014FASUN146G-2A08 cyl 14087 alt 2 hd 24 sec 848>
          /pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000000875cbe35,0
Specify disk (enter its number): Specify disk (enter its number):
root@mysrv1 #
root@mysrv1 #
root@mysrv1 # format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c1t0d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848>
          /pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000000875c9aa4,0
       1. c1t1d0 <HITACHI-HUS1014FASUN146G-2A08 cyl 14087 alt 2 hd 24 sec 848>
          /pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000000875cbe35,0
Specify disk (enter its number): 0
selecting c1t0d0
[disk formatted]
Warning: Current Disk has mounted partitions.
/dev/dsk/c1t0d0s0 is currently mounted on /. Please see umount(1M).
/dev/dsk/c1t0d0s1 is currently used by swap. Please see swap(1M).

format> p

partition> p
Current partition table (original):
Total disk cylinders available: 14087 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0       root    wm       0 -  3091       30.01GB    (3092/0/0)   62928384
  1       swap    wu    3092 -  4740       16.00GB    (1649/0/0)   33560448
  2     backup    wm       0 - 14086      136.71GB    (14087/0/0) 286698624
  3 unassigned    wm       0                0         (0/0/0)             0
  4 unassigned    wm       0                0         (0/0/0)             0
  5 unassigned    wm       0                0         (0/0/0)             0
  6 unassigned    wm       0                0         (0/0/0)             0
  7 unassigned    wm       0                0         (0/0/0)             0

partition> q

format> disk 1
selecting c1t1d0
[disk formatted]
format> p

partition> p

Current partition table (unnamed):
Total disk cylinders available: 14087 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0 unassigned    wm       0 -  3091       30.01GB    (3092/0/0)   62928384
  1 unassigned    wm    3092 -  4740       16.00GB    (1649/0/0)   33560448
  2     backup    wu       0 - 14086      136.71GB    (14087/0/0) 286698624
  3 unassigned    wm       0                0         (0/0/0)             0
  4 unassigned    wm       0                0         (0/0/0)             0
  5 unassigned    wm       0                0         (0/0/0)             0
  6 unassigned    wm       0                0         (0/0/0)             0
  7 unassigned    wu       0                0         (0/0/0)             0

partition> q

format> q
root@mysrv1 #

We can use this 2nd disk for creating newBE on it.

CMD :  lucreate -c current_BE -m mountpoint:device:FStype -n new_BE

This takes long time, so while in progress we can check progress in duplicate session :

root@mysrv1 #
root@mysrv1 # lucreate -c oldBE -m /:/dev/dsk/c1t1d0s0:ufs -n newBE-disk1
Discovering physical storage devices
Discovering logical storage devices
Cross referencing storage devices with boot environment configurations
Determining types of file systems supported
Validating file system requests
Preparing logical storage devices
Preparing physical storage devices
Configuring physical storage devices
Configuring logical storage devices
Analyzing system configuration.
No name for current boot environment.
Current boot environment is named <oldBE>.
Creating initial configuration for primary boot environment <oldBE>.
The device </dev/dsk/c1t0d0s0> is not a root device for any boot environment; cannot get BE ID.
PBE configuration successful: PBE name <oldBE> PBE Boot Device </dev/dsk/c1t0d0s0>.
Comparing source boot environment <oldBE> file systems with the file
system(s) you specified for the new boot environment. Determining which
file systems should be in the new boot environment.
Updating boot environment description database on all BEs.
Searching /dev for possible boot environment filesystem devices

Updating system configuration files.
The device </dev/dsk/c1t1d0s0> is not a root device for any boot environment; cannot get BE ID.
Creating configuration for boot environment <newBE-disk1>.
Source boot environment is <oldBE>.
Creating boot environment <newBE-disk1>.
Creating file systems on boot environment <newBE-disk1>.
Creating <ufs> file system for </> in zone <global> on </dev/dsk/c1t1d0s0>.
Mounting file systems for boot environment <newBE-disk1>.
Calculating required sizes of file systems for boot environment <newBE-disk1>.
Populating file systems on boot environment <newBE-disk1>.
Checking selection integrity.
Integrity check OK.
Populating contents of mount point </>.
Copying.
Creating shared file system mount points.
Copying root of zone <zonea>.
zoneadm: zone 'zonea': illegal UUID value specified
Creating compare databases for boot environment <newBE-disk1>.
Creating compare database for file system </>.
Updating compare databases on boot environment <newBE-disk1>.
Making boot environment <newBE-disk1> bootable.
Population of boot environment <newBE-disk1> successful.
Creation of boot environment <newBE-disk1> successful.
root@mysrv1 #

############ $$$$$$$$$$$$$$$$$$$$$ #################

Checking in other session :

root@mysrv1 # date
Tuesday, September  2, 2014  5:43:22 PM IST
root@mysrv1 #
root@mysrv1 # lustatus
Boot Environment           Is       Active Active    Can    Copy
Name                       Complete Now    On Reboot Delete Status
-------------------------- -------- ------ --------- ------ ----------
oldBE                      yes      yes    yes       no     -
newBE-disk1                no       no     no        no     ACTIVE

After sometime, around 1hr it will be completed....

root@mysrv1 # date
Tuesday, September  2, 2014  6:50:55 PM IST
root@mysrv1 #
root@mysrv1 # lustatus
Boot Environment           Is       Active Active    Can    Copy
Name                       Complete Now    On Reboot Delete Status
-------------------------- -------- ------ --------- ------ ----------
oldBE                      yes      yes    yes       no     -
newBE-disk1                yes      no     no        yes    -

############ $$$$$$$$$$$$$$$$$$$$$ #################

Now let us proceed with live upgrading the OS on this newBE which is created....


First of all copy the source of OS image file .....

root@mysrv1 #
root@mysrv1 # mount 10.20.30.185:/eisdvd /mnt                        ------ MY EISDVD
root@mysrv1 #
root@mysrv1 # df -kh /mnt
Filesystem             size   used  avail capacity  Mounted on
10.20.30.185:/eisdvd    32G    30G   1.4G    96%    /mnt
root@mysrv1 #
root@mysrv1 # cd /mnt
root@mysrv1 #
root@mysrv1 # ls -lrth *ola*
-rw-r--r--   1 root     root        5.4M Mar 31  2012 scli-1.7.1-18.sparc.Solaris.pkg
-rw-r--r--   1 root     root        2.1M Jul 18  2012 scli-1.7.3-20.sparc.Solaris.pkg.z
-rwxr-xr-x   1 root     root        1.3G Dec 12  2013 VRTS_SF_HA_Solutions_6.1_Solaris_SPARC.tar

PP-Solaris11:
total 54768
-rw-r--r--   1 root     root         27M Jun  4  2013 EMCPower.SOLARIS11.5.5.P02.b012.tar.gz

Solaris10U11:
total 4523184
-rw-r--r--   1 root     root        2.2G Mar 27  2013 sol-10-u11-ga-sparc-dvd.iso

Solaris_11:
total 5811648
-rw-r--r--   1 root     root        2.1G Jun 14  2013 p16941261_1100_Solaris86-64.zip
-rw-r--r--   1 root     root        678M May  7 12:19 sol-11_1-text-sparc.iso
root@mysrv1 #
root@mysrv1 #
root@mysrv1 # cd Solaris10U11
root@mysrv1 #
root@mysrv1 # ls -rlth
total 4523184
-rw-r--r--   1 root     root        2.2G Mar 27  2013 sol-10-u11-ga-sparc-dvd.iso
root@mysrv1 #
root@mysrv1 # cp sol-10-u11-ga-sparc-dvd.iso /tmp
root@mysrv1 #
root@mysrv1 #
root@mysrv1 # cd /tmp
root@mysrv1 #
root@mysrv1 # ls -lrth
total 4521040
-rw-r--r--   1 root     root        2.2G Mar 27  2013 sol-10-u11-ga-sparc-dvd.iso
drwxr-xr-x   2 noaccess noaccess     178 Aug 29 03:53 hsperfdata_noaccess
drwxr-xr-x   2 root     root         117 Aug 29 03:53 hsperfdata_root
root@mysrv1 #

Mount the image file to give the path of it for live upgrade.

root@mysrv1 #
root@mysrv1 # lofiadm -a /tmp/sol-10-u11-ga-sparc-dvd.iso
/dev/lofi/1
root@mysrv1 #
root@mysrv1 #
root@mysrv1 # mkdir /sol10
root@mysrv1 #
root@mysrv1 # mount -F hsfs /dev/lofi/1 /sol10
root@mysrv1 #
root@mysrv1 #
root@mysrv1 # df -kh
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c1t0d0s0       30G    25G   3.9G    87%    /
/devices                 0K     0K     0K     0%    /devices
ctfs                     0K     0K     0K     0%    /system/contract
proc                     0K     0K     0K     0%    /proc
mnttab                   0K     0K     0K     0%    /etc/mnttab
swap                    26G   1.7M    26G     1%    /etc/svc/volatile
objfs                    0K     0K     0K     0%    /system/object
sharefs                  0K     0K     0K     0%    /etc/dfs/sharetab
/platform/sun4u-us3/lib/libc_psr/libc_psr_hwcap2.so.1
                        30G    25G   3.9G    87%    /platform/sun4u-us3/lib/libc_psr.so.1
/platform/sun4u-us3/lib/sparcv9/libc_psr/libc_psr_hwcap2.so.1
                        30G    25G   3.9G    87%    /platform/sun4u-us3/lib/sparcv9/libc_psr.so.1
fd                       0K     0K     0K     0%    /dev/fd
swap                    29G   2.2G    26G     8%    /tmp
swap                    26G    40K    26G     1%    /var/run
swap                    26G     0K    26G     0%    /dev/vx/dmp
swap                    26G     0K    26G     0%    /dev/vx/rdmp
/dev/lofi/1            2.2G   2.2G     0K   100%    /sol10
root@mysrv1 #

So let us start upgrading the OS on this newBE ...
This takes long time, so check the status in other session.

root@mysrv1 # luupgrade -u -n newBE-disk1 -s /sol10

67352 blocks
miniroot filesystem is <lofs>
Mounting miniroot at </sol10/Solaris_10/Tools/Boot>
Validating the contents of the media </sol10>.
The media is a standard Solaris media.
The media contains an operating system upgrade image.
The media contains <Solaris> version <10>.
Constructing upgrade profile to use.
Locating the operating system upgrade program.
Checking for existence of previously scheduled Live Upgrade requests.
Creating upgrade profile for BE <newBE-disk1>.
Determining packages to install or upgrade for BE <newBE-disk1>.
Performing the operating system upgrade of the BE <newBE-disk1>.
CAUTION: Interrupting this process may leave the boot environment unstable
or unbootable.
Upgrading Solaris: 100% completed
Installation of the packages from this media is complete.
Updating package information on boot environment <newBE-disk1>.
Package information successfully updated on boot environment <newBE-disk1>.
Adding operating system patches to the BE <newBE-disk1>.
The operating system patch installation is complete.
INFORMATION: The file </var/sadm/system/logs/upgrade_log> on boot
environment <newBE-disk1> contains a log of the upgrade operation.
INFORMATION: The file </var/sadm/system/data/upgrade_cleanup> on boot
environment <newBE-disk1> contains a log of cleanup operations required.
INFORMATION: Review the files listed above. Remember that all of the files
are located on boot environment <newBE-disk1>. Before you activate boot
environment <newBE-disk1>, determine if any additional system maintenance
is required or if additional media of the software distribution must be
installed.
The Solaris upgrade of the boot environment <newBE-disk1> is complete.
root@mysrv1 #

############# $$$$$$$$$$$$$$$ ##############

To check the status from duplicate session :

root@mysrv1 # date
Tuesday, September  2, 2014  7:31:17 PM IST
root@mysrv1 #
root@mysrv1 # lustatus
Boot Environment           Is       Active Active    Can    Copy
Name                       Complete Now    On Reboot Delete Status
-------------------------- -------- ------ --------- ------ ----------
oldBE                      yes      yes    yes       no     -
newBE-disk1                yes      no     no        no     UPDATING
root@mysrv1 #
root@mysrv1 #

After sometime, around 30 -- 45 mins it will be completed...

root@mysrv1 #
root@mysrv1 # lustatus
Boot Environment           Is       Active Active    Can    Copy
Name                       Complete Now    On Reboot Delete Status
-------------------------- -------- ------ --------- ------ ----------
oldBE                      yes      yes    yes       no     -
newBE-disk1                yes      no     no        yes    -
root@mysrv1 #

############# $$$$$$$$$$$$$$$ ##############

Now check it with luactivate command :

root@mysrv1 #
root@mysrv1 # luactivate
oldBE
root@mysrv1 #

Currently activated BE is oldBE , now let us activate newBE so, on next reboot this newBE will be activated....

root@mysrv1 # luactivate newBE-disk1
A Live Upgrade Sync operation will be performed on startup of boot environment <newBE-disk1>.

**********************************************************************

The target boot environment has been activated. It will be used when you
reboot. NOTE: You MUST NOT USE the reboot, halt, or uadmin commands. You
MUST USE either the init or the shutdown command when you reboot. If you
do not use either init or shutdown, the system will not boot using the
target BE.

**********************************************************************

In case of a failure while booting to the target BE, the following process
needs to be followed to fallback to the currently working boot environment:

1. Enter the PROM monitor (ok prompt).

2. Change the boot device back to the original boot environment by typing:

     setenv boot-device
/pci@9,600000/SUNW,qlc@2/fp@0,0/disk@w21000000875c9aa4,0:a

3. Boot to the original boot environment by typing:

     boot

**********************************************************************

Modifying boot archive service
Activation of boot environment <newBE-disk1> successful.
root@mysrv1 #

We successfully activated the newBE.....
We can check it , as following :

root@mysrv1 #
root@mysrv1 # luactivate
newBE-disk1
root@mysrv1 #
root@mysrv1 # lustatus
Boot Environment           Is       Active Active    Can    Copy
Name                       Complete Now    On Reboot Delete Status
-------------------------- -------- ------ --------- ------ ----------
oldBE                      yes      yes    no        no     -
newBE-disk1                yes      no     yes       no     -
root@mysrv1 #
root@mysrv1 #

On next reboot of system, the newBE will be activated and thus OS will be upgraded...
Till now our server is up and running, so the final reboot will be the only downtime which we require in LIVE UPGRADE.

Take the Console , and reboot the server :

RSC version 2.2.3 (EDMSCON1)

Please login: admin
Please Enter password:

rsc>
rsc>
rsc> console

mysrv1 console login: root
Password:
Last login: Tue Sep  2 18:22:11 from 10.82.19.13
Sep  2 20:34:31 mysrv1 login: ROOT LOGIN /dev/console
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
You have mail.
Sourcing //.profile-EIS.....
root@mysrv1 #
root@mysrv1 #
root@mysrv1 # init 6
root@mysrv1 #
root@mysrv1 #
root@mysrv1 #
root@mysrv1 # Sep  2 20:35:29 mysrv1 syseventd[399]: SIGHUP caught - reloading modules
Sep  2 20:35:30 mysrv1 syseventd[399]: Daemon restarted
svc.startd: The system is coming down.  Please wait.
svc.startd: 105 system services are now being stopped.
Sep  2 20:35:42 mysrv1 syslogd: going down on signal 15
svc.startd: The system is down.
syncing file systems... done
rebooting...

Resetting ...

RSC Alert: Host System has Reset
ChassisSerialNumber 0752AM0784

Sun Fire V490, No Keyboard
Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
OpenBoot 4.30.4.c, 16384 MB memory installed, Serial #72009526.
Ethernet address 0:14:4f:4a:c7:36, Host ID: 844ac736.

Rebooting with command: boot
Boot device: /pci@9,600000/SUNW,qlc@2/fp@0,0/disk@w21000000875cbe35,0:a  File and args:
SunOS Release 5.10 Version Generic_147147-26 64-bit
Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
Hostname: mysrv1

Configuring devices.
Loading smf(5) service descriptions: 60/60

mysrv1 console login: root
Password:
Last login: Tue Sep  2 17:43:41 from 10.52.98.13
Sep  2 20:38:10 mysrv1 login: ROOT LOGIN /dev/console
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
You have mail.
Sourcing //.profile-EIS.....
root@mysrv1 #

After successful reboot, we can check OS version :

root@mysrv1 #
root@mysrv1 # uname -a
SunOS mysrv1 5.10 Generic_147147-26 sun4u sparc SUNW,Sun-Fire-V490
root@mysrv1 #
root@mysrv1 #
root@mysrv1 # cat /etc/release
                   Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC
  Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
                            Assembled 17 January 2013
root@mysrv1 #
root@mysrv1 # df -kh
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c1t1d0s0       30G    24G   5.0G    83%    /
/devices                 0K     0K     0K     0%    /devices
ctfs                     0K     0K     0K     0%    /system/contract
proc                     0K     0K     0K     0%    /proc
mnttab                   0K     0K     0K     0%    /etc/mnttab
swap                    29G   1.7M    29G     1%    /etc/svc/volatile
objfs                    0K     0K     0K     0%    /system/object
sharefs                  0K     0K     0K     0%    /etc/dfs/sharetab
/platform/sun4u-us3/lib/libc_psr/libc_psr_hwcap2.so.1
                        30G    24G   5.0G    83%    /platform/sun4u-us3/lib/libc_psr.so.1
/platform/sun4u-us3/lib/sparcv9/libc_psr/libc_psr_hwcap2.so.1
                        30G    24G   5.0G    83%    /platform/sun4u-us3/lib/sparcv9/libc_psr.so.1
fd                       0K     0K     0K     0%    /dev/fd
swap                    29G   112K    29G     1%    /tmp
swap                    29G    48K    29G     1%    /var/run
swap                    29G     0K    29G     0%    /dev/vx/dmp
swap                    29G     0K    29G     0%    /dev/vx/rdmp
/vol/dev/dsk/c0t0d0/sol_10_1008_sparc
                       2.5G   2.5G     0K   100%    /cdrom/sol_10_1008_sparc
root@mysrv1 #

By this we upgrade the OS using live upgrade procedure.....
Now compare the BE's...

root@mysrv1 # lufslist newBE-disk1
               boot environment name: newBE-disk1
               This boot environment is currently active.
               This boot environment will be active on next system boot.

Filesystem              fstype    device size Mounted on          Mount Options
----------------------- -------- ------------ ------------------- --------------
/dev/dsk/c1t0d0s1       swap                ? -                   -
/dev/dsk/c1t1d0s0       ufs       32219332608 /                   -
root@mysrv1 #
root@mysrv1 #
root@mysrv1 # lufslist oldBE
               boot environment name: oldBE

Filesystem              fstype    device size Mounted on          Mount Options
----------------------- -------- ------------ ------------------- --------------
/dev/dsk/c1t0d0s1       swap                ? -                   -
/dev/dsk/c1t0d0s0       ufs       32219332608 /                   -
root@mysrv1 #

For comparing the BE's :

root@mysrv1 # lucompare oldBE
Determining the configuration of oldBE ...

        < newBE-disk1
        > oldBE

Processing Global Zone
Comparing / ...

Compare complete for /.
root@mysrv1 #

############ $$$$$$$$$$$ #############

We can check the status from duplicate session :

root@mysrv1 # lustatus
Boot Environment           Is       Active Active    Can    Copy
Name                       Complete Now    On Reboot Delete Status
-------------------------- -------- ------ --------- ------ ----------
oldBE                      yes      no     no        no     COMPARING
newBE-disk1                yes      yes    yes       no     -
root@mysrv1 #

After successful comparison,

root@mysrv1 #
root@mysrv1 # lustatus
Boot Environment           Is       Active Active    Can    Copy
Name                       Complete Now    On Reboot Delete Status
-------------------------- -------- ------ --------- ------ ----------
oldBE                      yes      no     no        yes    -
newBE-disk1                yes      yes    yes       no     -
root@mysrv1 #

############ $$$$$$$$$$$ #############

OS live upgrade is helpful to upgrade any system using BE concept with very minimum downtime.

#################################################################################

Sunday, 6 April 2014

Configuring bash shell !!!

Let us play with bash shell, Usually admins like us prefer working with bash shell. It is more comfortable shell to make things simple.
Now let us configure bash shell in such a way that it provides much more flexibility.

Below are the main files for configuring bash shell...

[root@mysrv1 ~]# ls -lrth .bash*
-rw-r--r--. 1 root root  176 May 20  2009 .bash_profile
-rw-r--r--. 1 root root   17 Apr  6 04:30 .bash_logout
-rw-------. 1 root root 1.1K Apr  6 04:36 .bash_history
-rw-r--r--. 1 root root  211 Apr  6 04:43 .bashrc
[root@mysrv1 ~]#

.bash_profile    --- When we invoke the bash shell, it first attempts to read and execute commands                                 from this file.
.bash_logout     --- When we exits from bash shell, it read and execute commands from this file.
.bash_history    --- This file maintains the command history in bash shell.
.bashrc              --- In this file we can specify our own aliases and functions.

Usually for temporary login prompt we can give ,

[root@mysrv1 ~]# PS1='MY SERVER# '
MY SERVER#
MY SERVER#
MY SERVER# exit
logout
[root@mysrv1 ~]#
[root@mysrv1 ~]#              --- soon after exiting from the shell,changes in prompt will be reverted

But to maintain a particular prompt for a user we need to edit his .bashrc file so that whenever he invokes a shell mentioned prompt will be displayed.

[root@mysrv1 ~]# vi .bashrc
[root@mysrv1 ~]#
[root@mysrv1 ~]#
[root@mysrv1 ~]# cat .bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
PS1='\h@root #'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
[root@mysrv1 ~]#

Now to observe the change take a new session,

login as: root
root@192.168.18.133's password:
Last login: Sun Apr  6 04:40:30 2014 from 192.168.18.1
mysrv1@root #
mysrv1@root #
mysrv1@root #

So from now onwards root user's login prompt will be the displayed output.

Now let us see the other use of .bashrc file.This time I will create new alias for different commands for ease purpose.

[root@mysrv1 ~]# alias                           --- cmd to see defined aliases
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@mysrv1 ~]#

[root@mysrv1 ~]#
[root@mysrv1 ~]# alias c=clear
[root@mysrv1 ~]#
[root@mysrv1 ~]# c

[root@mysrv1 ~]#
[root@mysrv1 ~]#                    ------ Now the screen is cleared
[root@mysrv1 ~]#

[root@mysrv1 ~]# exit            ------- exit from current session
exit
[root@mysrv1 ~]#
[root@mysrv1 ~]#
[root@mysrv1 ~]# c
-bash: c: command not found      ------- this time my alias won't work, since it is set temporary.
[root@mysrv1 ~]#

So now to set a alias permanently we need to give alias in .bashrc file.

[root@mysrv1 ~]# bash
[root@mysrv1 ~]#
[root@mysrv1 ~]#
[root@mysrv1 ~]# vi .bashrc
[root@mysrv1 ~]#
[root@mysrv1 ~]#
[root@mysrv1 ~]# cat .bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias c='clear'                 --- c is for clear screen
alias i='ifconfig'              --- i is for ifconfig

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
[root@mysrv1 ~]#

Let us try checking it...

[root@mysrv1 ~]# su -
[root@mysrv1 ~]#
[root@mysrv1 ~]# c            --- for c screen is cleared...
[root@mysrv1 ~]#
[root@mysrv1 ~]#
[root@mysrv1 ~]#

[root@mysrv1 ~]# i            --- for i ifconfig is executed...
eth0      Link encap:Ethernet  HWaddr 00:0C:29:4F:66:DD
          inet addr:192.168.18.133  Bcast:192.168.18.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe4f:66dd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4624 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2877 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:436891 (426.6 KiB)  TX bytes:457876 (447.1 KiB)

eth1      Link encap:Ethernet  HWaddr 00:0C:29:4F:66:E7
          inet addr:192.168.18.134  Bcast:192.168.18.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe4f:66e7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:514 errors:0 dropped:0 overruns:0 frame:0
          TX packets:23 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:49306 (48.1 KiB)  TX bytes:2518 (2.4 KiB)

eth2      Link encap:Ethernet  HWaddr 00:0C:29:4F:66:F1
          inet addr:192.168.18.132  Bcast:192.168.18.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe4f:66f1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:513 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:49246 (48.0 KiB)  TX bytes:2333 (2.2 KiB)

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:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:822 (822.0 b)  TX bytes:822 (822.0 b)

[root@mysrv1 ~]#

I will exit from bash and again I will invoke bash shell to check....

[root@mysrv1 ~]# exit
logout
[root@mysrv1 ~]#
[root@mysrv1 ~]#
[root@mysrv1 ~]#
[root@mysrv1 ~]# i
bash: i: command not found
[root@mysrv1 ~]# bash
[root@mysrv1 ~]#
[root@mysrv1 ~]# i
eth0      Link encap:Ethernet  HWaddr 00:0C:29:4F:66:DD
          inet addr:192.168.18.133  Bcast:192.168.18.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe4f:66dd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4666 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2907 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:440409 (430.0 KiB)  TX bytes:463064 (452.2 KiB)

eth1      Link encap:Ethernet  HWaddr 00:0C:29:4F:66:E7
          inet addr:192.168.18.134  Bcast:192.168.18.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe4f:66e7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:515 errors:0 dropped:0 overruns:0 frame:0
          TX packets:23 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:49366 (48.2 KiB)  TX bytes:2518 (2.4 KiB)

eth2      Link encap:Ethernet  HWaddr 00:0C:29:4F:66:F1
          inet addr:192.168.18.132  Bcast:192.168.18.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe4f:66f1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:514 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:49306 (48.1 KiB)  TX bytes:2333 (2.2 KiB)

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:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:822 (822.0 b)  TX bytes:822 (822.0 b)

[root@mysrv1 ~]#
[root@mysrv1 ~]# c
[root@mysrv1 ~]#
[root@mysrv1 ~]#
[root@mysrv1 ~]#   --- So even after logging into a new session of bash we can able to use alias....
[root@mysrv1 ~]#

.bash_profile is starting file which it will read and execute when we invoke bash shell.
Observe the content of .bash_profile file , it internally executes .bashrc file and its 
commands like PATH...

[root@mysrv1 ~]# cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin                ---- Here we can export EDITOR by giving EDITOR=vi

export PATH
[root@mysrv1 ~]#

.bash_history maintains history of commands that are used in bash shell...

[root@mysrv1 ~]# tail .bash_history
bash
vi .bash_logout
bash
cd /etc/
ls -lrth isuue*
ls -lrth issue*
c
bash
[root@mysrv1 ~]#

.bash_logout file is useful utility of bash shell with the which help of which we can take 
backup of some files and output of some commands automatically before exiting from 
bash shell.This file gets executed when we exit from bash shell.

[root@mysrv1 ~]#
[root@mysrv1 ~]# cat .bash_logout
# ~/.bash_logout
[root@mysrv1 ~]#
[root@mysrv1 ~]# vi .bash_logout
[root@mysrv1 ~]# 
[root@mysrv1 ~]#
[root@mysrv1 ~]# cat .bash_logout
# ~/.bash_logout
cp /etc/passwd /etc/passwd_old                 --- file which I need backup.
ls -lrth >>/tmp/oo                                       --- command which I need output.
[root@mysrv1 ~]#
[root@mysrv1 ~]# ls -lrth
total 96K
-rw-r--r--. 1 root root 9.0K Mar 15 14:37 install.log.syslog
-rw-r--r--. 1 root root  39K Mar 15 14:41 install.log
-rw-------. 1 root root 2.3K Mar 15 14:41 anaconda-ks.cfg
drwxr-xr-x. 3 root root 4.0K Apr  4 03:34 test
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Templates
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Public
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Downloads
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Videos
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Pictures
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Music
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Documents
drwxr-xr-x. 2 root root 4.0K Apr  5 05:35 Desktop
[root@mysrv1 ~]#
[root@mysrv1 ~]#
[root@mysrv1 ~]# ls -lrth /etc/passwd*                      --- now there is no passwd_old file
-rw-r--r--. 1 root root 1.4K Mar 15 14:42 /etc/passwd-
-rw-r--r--. 1 root root 1.4K Mar 15 14:42 /etc/passwd.OLD
-rw-r--r--. 1 root root 1.4K Mar 15 14:42 /etc/passwd
[root@mysrv1 ~]#
[root@mysrv1 ~]#
[root@mysrv1 ~]# cat /tmp/oo                                     --- now there is no /tmp/oo file
cat: /tmp/oo: No such file or directory
[root@mysrv1 ~]#

Now I will exit from my bash shell to check my new .bash_logout file

[root@mysrv1 ~]# exit
[root@mysrv1 ~]#
[root@mysrv1 ~]# logout
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# su -
[root@mysrv1 ~]#
[root@mysrv1 ~]# cat /tmp/oo               ----- /tmp/oo is created and grabbed the output of ls -lrth
total 96K
-rw-r--r--. 1 root root 9.0K Mar 15 14:37 install.log.syslog
-rw-r--r--. 1 root root  39K Mar 15 14:41 install.log
-rw-------. 1 root root 2.3K Mar 15 14:41 anaconda-ks.cfg
drwxr-xr-x. 3 root root 4.0K Apr  4 03:34 test
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Templates
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Public
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Downloads
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Videos
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Pictures
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Music
drwxr-xr-x. 2 root root 4.0K Apr  4 03:57 Documents
drwxr-xr-x. 2 root root 4.0K Apr  5 05:35 Desktop
[root@mysrv1 ~]#
[root@mysrv1 ~]#
[root@mysrv1 ~]# ls -lrth /etc/passwd*
-rw-r--r--. 1 root root 1.4K Mar 15 14:42 /etc/passwd-
-rw-r--r--. 1 root root 1.4K Mar 15 14:42 /etc/passwd.OLD
-rw-r--r--. 1 root root 1.4K Mar 15 14:42 /etc/passwd
-rw-r--r--. 1 root root 1.4K Apr  6 05:42 /etc/passwd_old    ----- backup of passwd file is taken
[root@mysrv1 ~]#
[root@mysrv1 ~]#

Thus We can configure a bash shell as per our requirement to make our login shell much more convenient and tasks can be performed much more easier.

################################################################################