Total Pageviews

Sunday, 9 February 2014

Root & Swap Mirroring in SVM !!!

In this post let us discuss about steps of Root and Swap Mirroring.

For mirroring we create meta devices on disks and bring them under control of SVM 
(Solaris Volume Manager). RAID 1 technique is called Mirroring.

To perform mirroring ,both the disks should be with same VTOC(Volume Table Of Contents).

login as: root
Using keyboard-interactive authentication.
Password:
Last login: Thu Dec 20 01:09:51 2012
Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
# bash
bash-3.2#
bash-3.2# df -kh
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c1t0d0s0       30G   5.6G    24G    20%    /
/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                   118G   1.6M   118G     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   5.6G    24G    20%    /platform/sun4u-us3/lib/libc_psr.so.1
/platform/sun4u-us3/lib/sparcv9/libc_psr/libc_psr_hwcap2.so.1
                        30G   5.6G    24G    20%    /platform/sun4u-us3/lib/sparcv9/libc_psr.so.1
fd                       0K     0K     0K     0%    /dev/fd
swap                   118G   136K   118G     1%    /tmp
swap                   118G    40K   118G     1%    /var/run
bash-3.2#

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

Check whether both disks are of same VTOC , if not copy vtoc of primary disk to secondary....
Creating Meta database on 7th slice. c#t#d#s7

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


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


AVAILABLE DISK SELECTIONS:
       0. c1t0d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848>
          /pci@8,600000/SUNW,qlc@2/fp@0,0/ssd@w500000e018038181,0
       1. c1t1d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848>
          /pci@8,600000/SUNW,qlc@2/fp@0,0/ssd@w500000e018038291,0
       2. c1t2d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848>
          /pci@8,600000/SUNW,qlc@2/fp@0,0/ssd@w500000e01804c751,0
       3. c1t3d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848>
          /pci@8,600000/SUNW,qlc@2/fp@0,0/ssd@w500000e018046841,0
Specify disk (enter its number): 0
selecting c1t0d0                          ---------- selected disk 0.
[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 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
        repair     - repair a defective sector
        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
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !<cmd>     - execute <cmd>, then return
        quit
format> 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
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 -  9686       64.00GB    (6595/0/0)  134221440
  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> 7
Part      Tag    Flag     Cylinders         Size            Blocks
  7 unassigned    wm       0                0         (0/0/0)             0

Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]: 14070
Enter partition size[0b, 0c, 14070e, 0.00mb, 0.00gb]: 14085e
partition> p
Current partition table (unnamed):
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 -  9686       64.00GB    (6595/0/0)  134221440
  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   14070 - 14085      159.00MB    (16/0/0)       325632

partition> 7
Part      Tag    Flag     Cylinders         Size            Blocks
  7 unassigned    wm   14070 - 14085      159.00MB    (16/0/0)       325632

Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[14070]:
Enter partition size[325632b, 16c, 14085e, 159.00mb, 0.16gb]: 0
partition> p
Current partition table (unnamed):
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 -  9686       64.00GB    (6595/0/0)  134221440
  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> 7
Part      Tag    Flag     Cylinders         Size            Blocks
  7 unassigned    wm       0                0         (0/0/0)             0

Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]: 14073
Enter partition size[0b, 0c, 14073e, 0.00mb, 0.00gb]: 14085e
partition> p
Current partition table (unnamed):
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 -  9686       64.00GB    (6595/0/0)  134221440
  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   14073 - 14085      129.19MB    (13/0/0)       264576

partition> l
Ready to label disk, continue? y

partition>
partition>
partition> p
Current partition table (unnamed):
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 -  9686       64.00GB    (6595/0/0)  134221440
  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   14073 - 14085      129.19MB    (13/0/0)       264576

partition>
partition>
partition> q


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
        repair     - repair a defective sector
        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
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !<cmd>     - execute <cmd>, then return
        quit
format> q
bash-3.2#

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

Creating Meta database on 7th slice of 1st disk. c#t#d#s7

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

bash-3.2#
bash-3.2# metadb -f -a -c 3 c1t0d0s7
bash-3.2#
bash-3.2#
bash-3.2# metadb -i
        flags           first blk       block count
     a        u         16              8192            /dev/dsk/c1t0d0s7
     a        u         8208            8192            /dev/dsk/c1t0d0s7
     a        u         16400           8192            /dev/dsk/c1t0d0s7
 r - replica does not have device relocation information
 o - replica active prior to last mddb configuration change
 u - replica is up to date
 l - locator for this replica was read successfully
 c - replica's location was in /etc/lvm/mddb.cf
 p - replica's location was patched in kernel
 m - replica is master, this is replica selected as input
 W - replica has device write errors
 a - replica is active, commits are occurring to this replica
 M - replica had problem with master blocks
 D - replica had problem with data blocks
 F - replica had format problems
 S - replica is too small to hold current data base
 R - replica had device read errors
bash-3.2#
bash-3.2#
bash-3.2# metainit -f d11 1 1 c1t0d0s0
d11: Concat/Stripe is setup
bash-3.2#
bash-3.2# metainit -f d10 -m d11
d10: Mirror is setup
bash-3.2#
bash-3.2# metastat -c
d10              m   30GB d11
    d11          s   30GB c1t0d0s0
bash-3.2#
bash-3.2#
bash-3.2# metainit -f d21 1 1 c1t0d0s1
d21: Concat/Stripe is setup
bash-3.2#
bash-3.2#
bash-3.2# metainit -f d20 -m d21
d20: Mirror is setup
bash-3.2#
bash-3.2#
bash-3.2# metastat -c
d20              m   64GB d21
    d21          s   64GB c1t0d0s1
d10              m   30GB d11
    d11          s   30GB c1t0d0s0
bash-3.2#
bash-3.2#
bash-3.2# metaroot d10        ------ THIS WILL AUTOMATICALLY UPDATES ENTRY OF 
                                                        ROOT IN /etc/vfstab
bash-3.2#
bash-3.2#
bash-3.2# more /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/dsk/c1t0d0s1       -       -       swap    -       no      -
/dev/md/dsk/d10 /dev/md/rdsk/d10        /       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     -
bash-3.2#

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

We need to manually update the entry of swap as meta device in /etc/vfstab .

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

bash-3.2# vi /etc/vfstab
"/etc/vfstab" 12 lines, 401 characters
#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/dsk/c1t0d0s1    -       -       swap    -       no      -
/dev/md/dsk/d20 -       -       swap    -       no      -
/dev/md/dsk/d10 /dev/md/rdsk/d10        /       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     -
~
~
~
~
"/etc/vfstab" 13 lines, 436 characters
bash-3.2#
bash-3.2#
bash-3.2# more /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/dsk/c1t0d0s1    -       -       swap    -       no      -
/dev/md/dsk/d20         -       -       swap    -       no      -
/dev/md/dsk/d10 /dev/md/rdsk/d10        /       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     -
bash-3.2#
bash-3.2#
##############################

/etc/system gets updated with metaroot d10 cmd automatically.......

##############################
bash-3.2#
bash-3.2#
bash-3.2# cat /etc/system |grep -i root
* Begin MDD root info (do not edit)
rootdev:/pseudo/md@0:0,10,blk
set md:mirrored_root_flag=1
* End MDD root info (do not edit)

bash-3.2#reboot

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

Take a reboot of the system and check df -kh output where we can see that root (/) filesystem will be a metadevice under SVM as follows,

bash-3.2# df -kh /
Filesystem             size   used  avail capacity  Mounted on
/dev/md/dsk/d10       30G   5.6G    24G    20%    /

**********************************************************
Till now which is completed is called as one way mirroring , to make it a 2-way mirror 
just bring the secondary disk under SVM , 

create metadb on 7th slice and metadevices for "/ and swap" partitions 
then attach to d10 and d20 respectively.

bash-3.2#metadb -a -f -c3 c1t1d0s7

bash-3.2# metainit -f d12 1 1 c1t1d0s0

bash-3.2# metainit -f d22 1 1 c1t1d0s1

bash-3.2# metattach d10 d12

bash-3.2# metattach d20 d22


bash-3.2#metastat -c 
d20              m   64GB d21 d22
    d21          s   64GB c1t0d0s1
    d22          s   64GB c1t1d0s1
d10              m   30GB d11 d12
    d11          s   30GB c1t0d0s0
    d12          s   30GB c1t1d0s0

    *************  TWO WAY MIRRORING COMPLETED  *************

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





#####################  ONE WAY MIRRORING in SHORT #####################

AVAILABLE DISK SELECTIONS:
       0. c1t0d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848>
          /pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000018628382f9,0
       1. c1t1d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848>
          /pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000018628389f1,0

Specify disk (enter its number): Specify disk (enter its number):

1) metadb -a -f -c3 c1t0d0s7

2) metainit -f d11 1 1 c1t0d0s0

3) metainit -f d21 1 1 c1t0d0s1

4) metainit d10 -m d11

5) metainit d20 -m d21

6) metaroot d10

7) Edit swap entry in /etc/vfstab and check rootdev entry in /etc/system file.

8) Take reboot , After reboot configure dump device and swap device with new swap (/dev/md/dsk/d20).

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

No comments:

Post a Comment