Monday, December 22, 2014

              Procedure to add a new disk in DM multipath 


Multipathing (Device Mapper Multipath) is a technology which is available from RHEL 5 for providing redundancy in I/O paths from storage devices .  Multiple paths are configured from your server to storage and these physical paths are include HBA,cables and switches.
















DM multipath have following capabilities 

1. Redundancy 

Two types of multipath are available active/active and active/passive . In first case both paths are accessible, but in second case only 1 path is accessible at a time. 

2. Improved Performance 

DM multipath can detect loading of the I/O paths and dynamically balance the load.

Almost all of the SAN devices are supported in multpathing. The details of the supported devices are given in multipath.conf.defaults file and when ever we need to change we will add the devices in /etc/multipath.conf file 


Components which is required for multipathing

Kernel components

dm-multipath module - This particular component reroutes the I/O and supports failover for the paths and groups 

multipathd daemon- Monitors the path and takes the action when ever necessary (like failed paths and restored paths)

.Configuration file details 

/etc/multipath.conf - Main configuration file and it is located at /etc

multipath.conf.defaults - This is the default file which contains all the supported SAN devices. The location of the file is /usr/share/device-mapper-multipath 

kpartx command - This tool is derived from util linux partx package . It is used to set up device mapping for the partitions for any partitioned block device . This tool can be used for non linux partitions which is need to be added with DM-MP.

So now i think you got an idea about the DM multipath architecture, Now let us go for adding a new device to DM setup .

 1. First we have to scan the new physical disk

echo "- - -" > /sys/class/scsi_host/host3/scan
echo "- - -" > /sys/class/scsi_host/host4/scan

2. Some times new physical disk will not be visible initially, so need to restart multipath daemon

#service multipathd restart

3. Make alias of the new disk in /etc/multipath.conf file (in this case i have given silverdisk08)

multipath {
                wwid                    put the new uuid no. here
                alias                   silverdisk08
                  }

* you will get the wwid details of the new disk once you restart the multipath service

4. Now add the disk in multipath

#multipath -f silverdisk08

5. Again restart the multipath daemon

#service multipathd restart

6.Now create a physical disk

#pvcreate /dev/mpath/silverdisk08

7. Extend the file system (you can also go for creating new LVM setup as per your requirement)

#vgextend datavg /dev/silverdisk08
#lvextend -L +94G /dev/mapper/datavg-u2ecllv
#resize2fs  /dev/mapper/datavg-u2ecllv





  




Wednesday, December 17, 2014

root mirroring in solaris-10 using SVM

                      Root mirroring in solaris-10 using SVM


Root mirroring is a useful method in solaris 10 for redundancy and this is a very useful method for live upgrade , where patches are applied in root environment and if any issue is faced system will be booted from mirrored environment. 

Detailed steps
*************
1. First we need to identify the disks attached for mirroring this can be done using format command , in below case c0d0 and c0d1 are available disks
***********************************************
bash-3.00# format


Searching for disks...done


AVAILABLE DISK SELECTIONS:
       0. c0d0 <DEFAULT cyl 2085 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c0d1 <DEFAULT cyl 2086 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0


Specify disk (enter its number): 0
selecting c0d0
Controller working list found
[disk formatted, defect list found]
Warning: Current Disk has mounted partitions.
/dev/dsk/c0d0s0 is currently mounted on /. Please see umount(1M).
/dev/dsk/c0d0s1 is currently used by swap. Please see swap(1M).


FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        fdisk      - run the fdisk program
        repair     - repair a defective sector
        show       - translate a disk address
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        volname    - set 8-character volume name
        !<cmd>     - execute <cmd>, then return
        quit
format> p (press p)


PARTITION MENU:
        0      - change `0' partition
        1      - change `1' partition
        2      - change `2' partition
        3      - change `3' partition
        4      - change `4' partition
        5      - change `5' partition
        6      - change `6' partition
        7      - change `7' partition
        select - select a predefined table
        modify - modify a predefined partition table
        name   - name the current table
        print  - display the current table
        label  - write partition map and label to the disk
        !<cmd> - execute <cmd>, then return
        quit
partition> p (press p)
Current partition table (original):
Total disk cylinders available: 2085 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
  0       root    wm     820 - 2084        9.69GB    (1265/0/0) 20322225
  1       swap    wu       3 -  133        1.00GB    (131/0/0)   2104515
  2     backup    wm       0 - 2084       15.97GB    (2085/0/0) 33495525
  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
  8       boot    wu       0 -    0        7.84MB    (1/0/0)       16065
  9 alternates    wu       1 -    2       15.69MB    (2/0/0)       32130

In above partition table we can see that 3,4,5,6 are unassigned partitions with in that we can select any partition (in this case i am selecting partition 3)

partition> 3
Part      Tag    Flag     Cylinders        Size            Blocks
  3 unassigned    wm       0               0         (0/0/0)           0

Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]: 134
Enter partition size[0b, 0c, 134e, 0.00mb, 0.00gb]: 3gb
partition> l
Ready to label disk, continue? yes

partition> p
Current partition table (unnamed):
Total disk cylinders available: 2085 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
  0       root    wm     820 - 2084        9.69GB    (1265/0/0) 20322225
  1       swap    wu       3 -  133        1.00GB    (131/0/0)   2104515
  2     backup    wm       0 - 2084       15.97GB    (2085/0/0) 33495525
  3 unassigned    wm     134 -  525        3.00GB    (392/0/0)   6297480-------- ( newly created slice) 
  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
  8       boot    wu       0 -    0        7.84MB    (1/0/0)       16065
  9 alternates    wu       1 -    2       15.69MB    (2/0/0)       32130

2. Secondly we have to create HDD1 partition table same as HDD0
******************************************************
#prtvtoc /dev/rdsk/c0d0s2 | fmthard -s - /dev/rdsk/c0d1s2

(here from partition table we can see that partition 2 contains full back up of the entire disk and same will be copied to new disk HDD1)

3. create the state database in each disk (here i have choose slice no 7 )
*******************************************************
metadb -afc 3 c0d0s7 c0d1s7

a= add the state database 
f=force (this is needed for HDD0 which is mounted 
c=number of state database in each slice

We can see 3 slices of each disk using below command

bash-3.00# metadb
        flags           first blk       block count
     a m  p  luo        16              8192            /dev/dsk/c0d0s7
     a    p  luo        8208            8192            /dev/dsk/c0d0s7
     a    p  luo        16400           8192            /dev/dsk/c0d0s7
     a    p  luo        16              8192            /dev/dsk/c0d1s7
     a    p  luo        8208            8192            /dev/dsk/c0d1s7
     a    p  luo        16400           8192            /dev/dsk/c0d1s7

4. Initialize each disk
**********************************
HDD0

  metainit -f d100 1 1 c0d0s0
  metainit -f d101 1 1 c0d0s1
  metainit -f d103 1 1 c0d0s3

HDD1


  metainit d200 1 1 c0d1s0
  metainit d201 1 1 c0d1s1
  metainit d203 1 1 c0d1s3

5. Initialize the mirrors
****************************
  metainit d0 -m d100
  metainit d1 -m d101
  metainit d3 -m d103

6.Metaroot and editing of /etc/vfstab to boot to our mirror.
********************************************************

 metaroot d0

bash-3.00# cat /etc/vfstab
#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options
#
fd      -       /dev/fd fd      -       no      -
/proc   -       /proc   proc    -       no      -
/dev/md/dsk/d1  -       -       swap    -       no      -
/dev/md/dsk/d0  /dev/md/rdsk/d0 /       ufs     1       no      -
/devices        -       /devices        devfs   -       no      -
sharefs -       /etc/dfs/sharetab       sharefs -       no      -
ctfs    -       /system/contract        ctfs    -       no      -
objfs   -       /system/object  objfs   -       no      -
swap    -       /tmp    tmpfs   -       yes     -
/dev/md/dsk/d3  /dev/md/rdsk/d3 /test1  ufs     2       yes     -


7.Reboot the server

8. Attach the mirror disk using below command

bash-3.00# metattach d0 d200
d0: submirror d200 is attached
bash-3.00# metattach d1 d201
d1: submirror d201 is attached
bash-3.00# metattach d3 d203

(we have to wait till the completion of the sync it is purely depends upon the size of the file system)

d3: submirror d203 is attached

9. Next is we will install the grub in mirrored disk as redundant ( in this case c0d1 is our mirrored disk)

bash-3.00# format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
       0. c0d0 <DEFAULT cyl 2085 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c0d1 <DEFAULT cyl 2085 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0


bash-3.00# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0d1s0
stage1 written to partition 0 sector 0 (abs 16065)
stage2 written to partition 0, 273 sectors starting at 50 (abs 16115)

10. We can boot from c0d1 and check the status