Tuesday, April 5, 2011

Logical Volume Manager & HARD DISK PARTITIONING AND NFS ON SOLARIS AND LINUX

Hi,
When it comes to volume manager for Solaris and Linux or any other unix platforms,If there is lack of resource in a small or mid-sized company the below task can be useful for DBA,where DBA have to perform the below task before installation of oracle softwares.

Note: The below steps is for Solaris platform,but when you are doing for linux and any other platforms there are only few changes command wise:
1)'Format' command for creating partitions in Solaris is replaced by 'fdisk ' in Linux.
2)Network file system(NFS) :For NFS sharing /etc/dfs/dfstab file of Solaris is replaced by /etc/exports in Linux

# format (ENTER)
TYPE THE DISK NUMBER I.E. 0, 1, 2, ETC.
IF YOU DON’T SEE THE DISKS, THEN RUN

** How to detect the external and internal devices:
#devfsadm ( normally used for all devices)
To check whether it has detected or not, use
#format, if this don’t work, run
#rmformat ( normally used for external or removable devices) wait for 3 to 4 seconds and run format to check, if this don’t work, run
#touch /reconfigure
# init 6 (for reboot)

After reboot, it must have detected the devices.
If this donot work out for cd / dvdrom, go to
# cd /etc/init.d
#./volmgt stop

Wait for 3 to 5 seconds

# ./volmgt start
Wait for 3 to 5 seconds to start. And then check with format command.

# format
Searching for disks...done

Steps for creating partitions and Filesystem for our usage:


AVAILABLE DISK SELECTIONS:
0. c1t0d0
/pci@0,0/pci1000,30@10/sd@0,0
1. c1t1d0
/pci@0,0/pci1000,30@10/sd@1,0
2. c1t2d0
/pci@0,0/pci1000,30@10/sd@2,0
Specify disk (enter its number): 0

you will see some screen with format menu and at the end you will have format prompt, type in ‘p’ at the prompt to get the partition menu

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
! - execute , then return
quit
partition>

now give the partition number you wan to configure and press enter


partition> 0
Part Tag Flag Cylinders Size Blocks
0 root wm 580 - 1301 5.53GB (722/0/0) 11598930

Enter partition id tag[root]:
Enter partition permission flags[wm]:
Enter new starting cyl[580]:
Enter partition size[11598930b, 722c, 1301e, 5663.54mb, 5.53gb]: 1gb
partition>

now to save the partition layout type in ‘label’ at the partition prompt and then type ‘q’ to quit from partition prompt. You will be in format prompt now, give again ‘label’ to save and again ‘q’ to quit from format prompt and you will be on # prompt

partition > label
then enter ‘y’ when asked to continue
partition > q
format > label
then enter ‘y’ when asked to continue
format > q
#

Now we have a raw partition and we need to construct file system on it.
The raw partition will be identified like /dev/rdsk/c0t0d0s0

#newfs /dev/rdsk/c0t0d0s0 (enter)
Wait till it formats

To mount this partition, following steps need to be done
#mkdir /dirname
Edit the vfstab file and add the entry like bold line
#vi /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 /dirname ufs 2 yes -

Press :wq to save and quit

#mountall
This will mount the c0t0d0s0 partition on the /dirname

** How to share a directory for network access:


To share a directory across the network, edit the /etc/dfs/dfstab file and add the line as follows on the same machine from where you want to share the folder.

share -F nfs -o rw,anon=0 /dirname
#shareall
#share (this should display the list of dirs. Being shared like

- /dirname rw,anon=0 ""
If you don’t see your dir. To be shared, then
#cd /etc/init.d
#./nfs.server stop
#./nfs.server strart
#share (to check whether the dir. Is being shared or not)
Make the dir on the client m/c
#mkdir /u01 this dir. We will use to mount the share dir.
Now on the m/c where you want to use this shared dir., edit the /etc/vfstab and add the following entry
#vi /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options

sol1:/dirname - /u01 nfs - yes -

where sol1 is the server m/c from where we are sharing the folder


** LVM ON SOLARIS: (RAID-0)
CREATE 4 PARTITIONS AS ABOVE STEPS
WE WILL BE USING THESE PARTITIONS TO CREATE A LOGICAL VOLUME.
The partitions are c1t3d0s0, c1t3d0s1,c1t3d0s3 and c1t3d0s4.

#metadb –a -f c1t3d0s1 c1t3d0s3 c1t3d0s4
#metadb –i (to check the information about the slices)
#metadb –a –c 3 c1t3d0s0
#metadb –i
-c is to create replica
3 specifies the no. of replicas to be created.
#metainit d20 1 3 c1t3d0s1 c1t3d0s3 c1t3d0s4
This will create a concate/stripe from above three partitions named d20.
Now to create soft partitions,
#metastat (to display the information of concat/stripe
#metainit d21 –p d20 512mb
This will create soft partition of 512mb named d21 from volume d20.
#metainit d22 –p d20 512mb
#metainit d23 –p d20 512mb

Use the metastat command to get the information about the soft partitions like what slices being used, what is the size of the soft partitions.

Now to create a file system on the soft partition,
#newfs /dev/md/rdsk/d21 (enter)
#newfs /dev/md/rdsk/d22
#newfs /dev/md/rdsk/d23

To mount this slices, make three folders on root
#mkdir /p01 /p02 /p03
Edit the /etc/vfstab and add the following lines

/dev/md/dsk/d21 /dev/md/rdsk/d21 /p01 ufs 2 yes -
/dev/md/dsk/d22 /dev/md/rdsk/d22 /p02 ufs 2 yes -
/dev/md/dsk/d23 /dev/md/rdsk/d23 /p03 ufs 2 yes -

#mountall
#df –h will display the /p01 /p02 and /p03

To add a slice to volume:
- create a slice using format utility
- now attack this slice to volume d20 with the following command
#metadb –a c1t3d0s5
#metattach d20 c1t3d0s5

* To attach/grow the soft partition:
Suppose in our case soft partition d21 which is mounted on /p01 is falling short of space and we want to grow or attach some more space then,

#metattach d21 1g (this will attach 1gb of raw space from logical volume d20 to soft partition d21 and we have to grow the filesystem)
#growfs –M /p01 /dev/md/rdsk/d21

** How to remove the logical volume
First clear all soft partitions
#metaclear d21
#metaclear d22
To clear or delete the logical volume
#metadb –d c1t3d0s1
Similarly remove all slices attached to volume
To remove replica
#metadb –d –f c1t3d0s0 (name of the slice where replica resides)
Check wth metadb -i


Hope this helps.


Best regards,

Rafi.

1 comment:

  1. Thanks lol...
    Below mentioned link is very easy to understand,
    http://www.redhatlinux.info/2010/11/lvm-logical-volume-manager.html

    ReplyDelete