Monday, August 25, 2008

Solaris disk mirroring

Setting up solaris disk mirroring:

#1. copy vtoc (partition table ) from the first disk to another disk
prtvtoc /dev/rdsk/c1t0d0s2 fmthard -s - /dev/rdsk/c1t1d0s2fmthard:
New volume table of contents now in place

#2. this will create 2 replicas on each disk
# metadb -a -f -c2 /dev/dsk/c1t0d0s4
# metadb -a -f -c2 /dev/dsk/c1t1d0s4

#metadb -i ( check metadb state database replica status)
AVAILABLE DISK SELECTIONS:
0. c1t0d0 /pci@0/pci@0/pci@2/scsi@0/sd@0,0
1. c1t1d0 /pci@0/pci@0/pci@2/scsi@0/sd@1,0
Specify disk (enter its number):

metadb -a -c n -l nnnn -f ctds-of-slice
-a specifies to add a state database replica.
-f specifies to force the operation, even if no replicas exist.
-c n specifies the number of replicas to add to the specified slice.
-l nnnn specifies the size of the new replicas, in blocks.

ctds-of-slice specifies the name of the component that will hold the replica.


#3. setting up sub-mirrors
The -f option forces the creation of the submirror even though the specified slice is a mounted filesystem. The second two options 1 1 specify the number of stripes on the metadevice and the number of slices that make up the stripe. In a mirroring situation, this should always be 1 1

# metainit -f d10 1 1
c1t0d0s0d10: Concat/Stripe is setup
# metainit -f d11 1 1
c1t1d0s0d11: Concat/Stripe is setup

#4. Setting up logical mirror device

# metainit d1 -m d10
d1: Mirror is setup

#5.After mirroring the root partition, we need to run the metaroot command. This command will update the root entry in /etc/vfstab with the new metadevice as well as add the appropriate configuration information into /etc/system. Ommitting this step is one of the most common mistakes made by those unfamiliar with DiskSuite. If you do not run the metaroot command before you reboot, you will not be able to boot the system!

/etc/vfstab changes
from/dev/dsk/c1t0d0s0 /dev/rdsk/c1t0d0s0 / ufs 1 no
to
/dev/md/dsk/d1 /dev/md/rdsk/d1 / ufs 1 no -

# metaroot d1
at this point we should reboot to see if the server comes up fine with d1

#lockfs -fa
#init 6lock -f

Flushes all transactions out of the log and write the transactions to the master file system. This option is valid only if logging has been enabled on the file systemlocak -a Apply command to all mounted, UFS type file systems

6. attach the second half of the mirrors.
# metattach d1 d11
d1: submirror d11 is attached

metastatus before attaching the second mirror
#metastat -p more
d4 -m d40 1
d40 1 1 c1t0d0s5
d3 -m d30 1
d30 1 1 c1t0d0s4
d2 -m d20 1
d20 1 1 c1t0d0s1
d1 -m d10 1
d10 1 1 c1t0d0s0
d5 -m d50 1
d50 1 1 c1t0d0s7
d51 1 1 c1t1d0s7
d41 1 1 c1t1d0s5
d31 1 1 c1t1d0s4
d21 1 1 c1t1d0s1
d11 1 1 c1t1d0s0

metastatus after attaching the second mirror
metastat -p more
d4 -m d40 d41 1
d40 1 1 c1t0d0s5
d41 1 1 c1t1d0s5
d3 -m d30 d31 1
d30 1 1 c1t0d0s4
d31 1 1 c1t1d0s4
d2 -m d20 d21 1
d20 1 1 c1t0d0s1
d21 1 1 c1t1d0s1
d1 -m d10 d11 1
d10 1 1 c1t0d0s0
d11 1 1 c1t1d0s0
d5 -m d50 d51 1
d50 1 1 c1t0d0s7
d51 1 1 c1t1d0s7

Troubleshooting commands:
metaclear d11
metastat -p (check mirror status)
metadb -i ( check metadb state database replica status)

The Solaris Volume Manager state database contains configuration and status information for all volumes, hot spares, and disk sets

metainit d1 -m d10 + d11 / c1t0d0s0
metainit d2 -m d20 + d21 /usr c1t0d0s1
metainit d3 -m d30 + d31 /opt c1t0d0s4
metainit d4 -m d40 + d41 /home c1t0d0s5
metainit d5 -m d50 + d51 /data c1t0d0s7

http://spiralbound.net/2004/06/11/solaris-disk-partition-layout-mirroring-scriptshttp://slacksite.com/solaris/disksuite/disksuite.php

my volume manager scripts
#!/bin/sh
#Mirroring 1 of 2 .sh
prtvtoc /dev/rdsk/c1t0d0s2 fmthard -s - /dev/rdsk/c1t1d0s2
metadb -a -f -c2 /dev/dsk/c1t0d0s6# /dev/dsk/c1t1d0s3
metadb -a -f -c2 /dev/dsk/c1t1d0s6# /dev/dsk/c1t1d0s4
metainit -f d10 1 1 c1t0d0s0metainit -f d11 1 1 c1t1d0s0
metainit d1 -m d10metaroot d1
metainit -f d20 1 1 c1t0d0s1metainit -f d21 1 1 c1t1d0s1
metainit d2 -m d20
metainit -f d30 1 1 c1t0d0s4metainit -f d31 1 1 c1t1d0s4
metainit d3 -m d30
metainit -f d40 1 1 c1t0d0s5metainit -f d41 1 1 c1t1d0s5
metainit d4 -m d40
metainit -f d50 1 1 c1t0d0s7metainit -f d51 1 1 c1t1d0s7
metainit d5 -m d50
lockfs -fa
init 6

# after reboot run mirroring 2of2.sh
#!/bin/sh
#Mirroring 2 of 2 .sh
metattach d1 d11
metattach d2 d21
metattach d3 d31
metattach d4 d41
metattach d5 d51

No comments: