Copying Files and Directories commands for DBAs:
Copying Files and Directories commands for DBAs:
Hi DBAs,
Many of our tasks deals with copying of Data within same and Different server from Windows to Linux(Unix Based) OS or from any Unix based Operating system
to Other Unix based Operating system.We can use different commands and tools for doing it.Below I'm sharing my experience.
1)tar:tar stands for translate archive.It is most favourite commands for Apps DBAs when performing clonning and refreshing of environment,we use this command for copying huge size directories from one environment to other environment,tar when combined with gzip is the best combination.tar is the most powerful command.
2)scp:scp stands for secure copy.It is the fastest command for copying,again handy tool for DBAs and Apps DBAs.It is use to copy files and directories from one server to another server.
3)gzip and gunzip:gzip is use for compressing files on Unix-based system and gunzip is use for uncompressing the files on Unix-based systems i.e Solaris,Linux,IBM-AIX,HP-UX.
Again very useful command for DBA.
Eg 1:Let's say I want to tar and zip a directory 'bin' and copy it to target server
On Source System:
=================
Tarring and zipping:
===================
tar -cvf - bin | gzip >bin.tar.gz
On Target System:
=================
Copying to Target system:
==========================
scp -rp oracle@testpapp01cdp.comp.com:/product/app/TESTAPPSDB/apps/apps_st/appl/xxtwc/12.0.0/bin.tar.gz .
passwd:
Extracting and Untarring:
=========================
gunzip -c bin.tar.gz|tar -xvf -
Eg 2:
For Compressing:
=================
Let's say you are currently in /product/obiee Directoy and want to compress and zip the OracleBIData Directory,than it can be done as follows:
tar -cvf /product/obiee/OracleBIData.tar OracleBIData/
>ls -altr
total 987816
drwxr-x--- 9 obiee psapps 1024 Jul 6 2010 OracleBIData
drwxr-xr-x 4 obiee psapps 96 Jul 9 2010 java
drwxr-x--- 20 obiee psapps 1024 Dec 9 2010 OracleBI
drwxr-xr-x 16 applmgr oinstall 1024 May 12 2011 ..
drwxrwxrwx 5 obiee oinstall 1024 Aug 8 21:05 .
-rw-r--r-- 1 obidev2 psapps 505448448 Aug 8 21:17 OracleBIData.tar
For Zipping the Directory:
-----------------------------------------------------
$gzip OracleBIData.tar
>ls -altr
total 78256
drwxr-x--- 9 obiee psapps 1024 Jul 6 2010 OracleBIData
drwxr-xr-x 4 obiee psapps 96 Jul 9 2010 java
drwxr-x--- 20 obiee psapps 1024 Dec 9 2010 OracleBI
drwxr-xr-x 16 applmgr oinstall 1024 May 12 2011 ..
-rw-r--r-- 1 obidev2 psapps 40054038 Aug 8 21:17 OracleBIData.tar.gz
Eg 3:
For Unzipping the Directory:
------------------------------------
$gunzip OracleBIData.tar.gz
For untarring/extracting the Directory:
-------------------------------------------
$tar -xvf OracleBIData.tar
Note:
gzip=>compression
c=create
v=verbose
tar with gzip are the best method to take the backup of directory,since we can do it very fast and it saves the Disk space efficiently.
Note:tar command options are operating system dependent,so please check with man command command for using various options.
4)rsync:rsync is a great tool for backing up and restoring files,from source system to target system.It is Useful tool for DBAs.It is very important to remember this command works on linux and Doesn't work on Solaris Operating system as rsync doesn't have manual entry on it.
Eg 4:Copy all directories and file structure with all the ownership,permissions and symbolic links.
On Target System:
=================
rsync -arv oracle@testpapp01cdp.comp.com:/tmp/rafi/bin /tmp/rafi/backup_bin
(/tmp/rafi=>current working directory on Target Server)
5)sftp:sftp stands for secure file transfer protocol.some times if scp ports are disabled due to security reason than you can use sftp.It is very much secure way
of copying files and directories from source to target Server.This is very useful for DBAs and Apps DBAs.
Eg 5:Copying files from one server to other server
Using sftp for copying from qb to prod:
------------------------------------------
On Target System:
=================
oracle@[testpapp01cdp]-> sftp oracle@testqapp02cdp.comp.com:/tmp/rafi
Connecting to testqapp02cdp.comp.com...
Password:
Changing to: /tmp/rafi
sftp> ls
sftp> get lookup_xxtwc_perf_level_planned_perc.ldt
Fetching /tmp/rafi/lookup_xxtwc_perf_level_planned_perc.ldt to lookup_xxtwc_perf_level_planned_perc.ldt
6)winscp:winscp is GUI(Graphical user interface) based tool for copying files from windows to Linux(Unix environment) and vice-versa.I like this tool very much,since it is very much user friendly.But,for copying large amount of data it takes using this tool.In this tool you can save the machine name and login with privilege user and copy the files.
7)ftp:ftp stands for file transfer protocol and use for copying files from windows to linux(Unix environment) and vice-versa.This is fast method of copying files.
2mb of data can be copied in less than 5 minutes.
Eg 7:
On Target System(Windows):
===========================
Go to the target folder in windows.
C:\Documents and Settings\rafiuddin_alvi>cd D:\TEST
C:\Documents and Settings\rafiuddin_alvi>d:
D:\TEST>ftp testdapp01cdc.comp.com
Connected to testdapp01cdc.comp.com.
220 testdapp01cdc.comp.com FTP server ready.
User (testdapp01cdc.comp.com:(none)): oracle
331 Password required for oracle.
Password:
230 User oracle logged in.
ftp> help
Commands may be abbreviated. Commands are:
! delete literal prompt send
? debug ls put status
append dir mdelete pwd trace
ascii disconnect mdir quit type
bell get mget quote user
binary glob mkdir recv verbose
bye hash mls remotehelp
cd help mput rename
close lcd open rmdir
ftp> cd /tmp/rafi
250 CWD command successful.
ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 4640
-rwxrwxrwx 1 oracle twcother 2272275 Aug 6 03:18 cn_reports.rpd
-rwxrwxrwx 1 oracle twcother 8115 Jul 7 19:07 DisputeSrchPG.xml
-rwxrwxrwx 1 appldev2 oinstall 916 Jul 25 04:38 L6958530.log
-rwxrwxrwx 1 appldev2 oinstall 880 Aug 6 08:06 L6960409.log
-rwxr-xr-x 1 oracle twcother 23 Aug 8 20:11 test1.sh
-rwxrwxrwx 1 appldev2 oinstall 22889 Jul 25 04:38 XX_QUINTILE_BATCH.ldt
-rwxrwxrwx 1 oracle twcother 1802 Jul 5 06:48 XXTaskPerzSumCO.class
-rwxrwxrwx 1 oracle twcother 1934 Jul 7 19:07 XXTaskSummaryCO.class
-rwxrwxrwx 1 appldev2 oinstall 20235 Aug 6 08:06 XXTWC_REPORT_METRIC_VAL
.ldt
226 Transfer complete.
ftp: 672 bytes received in 0.08Seconds 8.62Kbytes/sec.
ftp> get test1.sh
200 PORT command successful.
150 Opening ASCII mode data connection for test1.sh (23 bytes).
226 Transfer complete.
ftp: 24 bytes received in 0.00Seconds 24000.00Kbytes/sec.
ftp> get cn_reports.rpd
200 PORT command successful.
150 Opening ASCII mode data connection for cn_reports.rpd (2272275 bytes).
226 Transfer complete.
ftp: 2284457 bytes received in 113.08Seconds 20.20Kbytes/sec.
To exit ftp:
ftp> bye
221-You have transferred 2284481 bytes in 2 files.
221-Total traffic for this session was 2285843 bytes in 3 transfers.
221-Thank you for using the FTP service on testdapp01cdc.comp.com.
221 Goodbye.
b)Putting files from source(Windows) to Target(Linux):
ftp> mput my_docs.txt
mput my_docs.txt? y
200 PORT command successful.
150 Opening ASCII mode data connection for my_docs.txt.
226 Transfer complete.
ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 4640
-rwxrwxrwx 1 oracle twcother 2272275 Aug 6 03:18 cn_reports.rpd
-rwxrwxrwx 1 oracle twcother 8115 Jul 7 19:07 DisputeSrchPG.xml
-rwxrwxrwx 1 appldev2 oinstall 916 Jul 25 04:38 L6958530.log
-rwxrwxrwx 1 appldev2 oinstall 880 Aug 6 08:06 L6960409.log
-rw-r--r-- 1 oracle twcother 0 Aug 8 20:48 my_docs.txt
-rwxr-xr-x 1 oracle twcother 23 Aug 8 20:11 test1.sh
8)cp:cp is the most basic command in linux(Unix environment) for copying files within same directory or directories on Same server.
Eg 8:To copy test1.sh to Target location /tmp/rafi,we can use below command.
testdapp01cdc(/export/home/oracle) >cp test1.sh /tmp/rafi
testdapp01cdc(/tmp/rafi) >ls -altr *test*
-rwxr-xr-x 1 oracle twcother 23 Aug 8 20:11 test1.sh
Hi DBAs,
Many of our tasks deals with copying of Data within same and Different server from Windows to Linux(Unix Based) OS or from any Unix based Operating system
to Other Unix based Operating system.We can use different commands and tools for doing it.Below I'm sharing my experience.
1)tar:tar stands for translate archive.It is most favourite commands for Apps DBAs when performing clonning and refreshing of environment,we use this command for copying huge size directories from one environment to other environment,tar when combined with gzip is the best combination.tar is the most powerful command.
2)scp:scp stands for secure copy.It is the fastest command for copying,again handy tool for DBAs and Apps DBAs.It is use to copy files and directories from one server to another server.
3)gzip and gunzip:gzip is use for compressing files on Unix-based system and gunzip is use for uncompressing the files on Unix-based systems i.e Solaris,Linux,IBM-AIX,HP-UX.
Again very useful command for DBA.
Eg 1:Let's say I want to tar and zip a directory 'bin' and copy it to target server
On Source System:
=================
Tarring and zipping:
===================
tar -cvf - bin | gzip >bin.tar.gz
On Target System:
=================
Copying to Target system:
==========================
scp -rp oracle@testpapp01cdp.comp.com:/product/app/TESTAPPSDB/apps/apps_st/appl/xxtwc/12.0.0/bin.tar.gz .
passwd:
Extracting and Untarring:
=========================
gunzip -c bin.tar.gz|tar -xvf -
Eg 2:
For Compressing:
=================
Let's say you are currently in /product/obiee Directoy and want to compress and zip the OracleBIData Directory,than it can be done as follows:
tar -cvf /product/obiee/OracleBIData.tar OracleBIData/
>ls -altr
total 987816
drwxr-x--- 9 obiee psapps 1024 Jul 6 2010 OracleBIData
drwxr-xr-x 4 obiee psapps 96 Jul 9 2010 java
drwxr-x--- 20 obiee psapps 1024 Dec 9 2010 OracleBI
drwxr-xr-x 16 applmgr oinstall 1024 May 12 2011 ..
drwxrwxrwx 5 obiee oinstall 1024 Aug 8 21:05 .
-rw-r--r-- 1 obidev2 psapps 505448448 Aug 8 21:17 OracleBIData.tar
For Zipping the Directory:
-----------------------------------------------------
$gzip OracleBIData.tar
>ls -altr
total 78256
drwxr-x--- 9 obiee psapps 1024 Jul 6 2010 OracleBIData
drwxr-xr-x 4 obiee psapps 96 Jul 9 2010 java
drwxr-x--- 20 obiee psapps 1024 Dec 9 2010 OracleBI
drwxr-xr-x 16 applmgr oinstall 1024 May 12 2011 ..
-rw-r--r-- 1 obidev2 psapps 40054038 Aug 8 21:17 OracleBIData.tar.gz
Eg 3:
For Unzipping the Directory:
------------------------------------
$gunzip OracleBIData.tar.gz
For untarring/extracting the Directory:
-------------------------------------------
$tar -xvf OracleBIData.tar
Note:
gzip=>compression
c=create
v=verbose
tar with gzip are the best method to take the backup of directory,since we can do it very fast and it saves the Disk space efficiently.
Note:tar command options are operating system dependent,so please check with man command command for using various options.
4)rsync:rsync is a great tool for backing up and restoring files,from source system to target system.It is Useful tool for DBAs.It is very important to remember this command works on linux and Doesn't work on Solaris Operating system as rsync doesn't have manual entry on it.
Eg 4:Copy all directories and file structure with all the ownership,permissions and symbolic links.
On Target System:
=================
rsync -arv oracle@testpapp01cdp.comp.com:/tmp/rafi/bin /tmp/rafi/backup_bin
(/tmp/rafi=>current working directory on Target Server)
5)sftp:sftp stands for secure file transfer protocol.some times if scp ports are disabled due to security reason than you can use sftp.It is very much secure way
of copying files and directories from source to target Server.This is very useful for DBAs and Apps DBAs.
Eg 5:Copying files from one server to other server
Using sftp for copying from qb to prod:
------------------------------------------
On Target System:
=================
oracle@[testpapp01cdp]-> sftp oracle@testqapp02cdp.comp.com:/tmp/rafi
Connecting to testqapp02cdp.comp.com...
Password:
Changing to: /tmp/rafi
sftp> ls
sftp> get lookup_xxtwc_perf_level_planned_perc.ldt
Fetching /tmp/rafi/lookup_xxtwc_perf_level_planned_perc.ldt to lookup_xxtwc_perf_level_planned_perc.ldt
6)winscp:winscp is GUI(Graphical user interface) based tool for copying files from windows to Linux(Unix environment) and vice-versa.I like this tool very much,since it is very much user friendly.But,for copying large amount of data it takes using this tool.In this tool you can save the machine name and login with privilege user and copy the files.
7)ftp:ftp stands for file transfer protocol and use for copying files from windows to linux(Unix environment) and vice-versa.This is fast method of copying files.
2mb of data can be copied in less than 5 minutes.
Eg 7:
On Target System(Windows):
===========================
Go to the target folder in windows.
C:\Documents and Settings\rafiuddin_alvi>cd D:\TEST
C:\Documents and Settings\rafiuddin_alvi>d:
D:\TEST>ftp testdapp01cdc.comp.com
Connected to testdapp01cdc.comp.com.
220 testdapp01cdc.comp.com FTP server ready.
User (testdapp01cdc.comp.com:(none)): oracle
331 Password required for oracle.
Password:
230 User oracle logged in.
ftp> help
Commands may be abbreviated. Commands are:
! delete literal prompt send
? debug ls put status
append dir mdelete pwd trace
ascii disconnect mdir quit type
bell get mget quote user
binary glob mkdir recv verbose
bye hash mls remotehelp
cd help mput rename
close lcd open rmdir
ftp> cd /tmp/rafi
250 CWD command successful.
ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 4640
-rwxrwxrwx 1 oracle twcother 2272275 Aug 6 03:18 cn_reports.rpd
-rwxrwxrwx 1 oracle twcother 8115 Jul 7 19:07 DisputeSrchPG.xml
-rwxrwxrwx 1 appldev2 oinstall 916 Jul 25 04:38 L6958530.log
-rwxrwxrwx 1 appldev2 oinstall 880 Aug 6 08:06 L6960409.log
-rwxr-xr-x 1 oracle twcother 23 Aug 8 20:11 test1.sh
-rwxrwxrwx 1 appldev2 oinstall 22889 Jul 25 04:38 XX_QUINTILE_BATCH.ldt
-rwxrwxrwx 1 oracle twcother 1802 Jul 5 06:48 XXTaskPerzSumCO.class
-rwxrwxrwx 1 oracle twcother 1934 Jul 7 19:07 XXTaskSummaryCO.class
-rwxrwxrwx 1 appldev2 oinstall 20235 Aug 6 08:06 XXTWC_REPORT_METRIC_VAL
.ldt
226 Transfer complete.
ftp: 672 bytes received in 0.08Seconds 8.62Kbytes/sec.
ftp> get test1.sh
200 PORT command successful.
150 Opening ASCII mode data connection for test1.sh (23 bytes).
226 Transfer complete.
ftp: 24 bytes received in 0.00Seconds 24000.00Kbytes/sec.
ftp> get cn_reports.rpd
200 PORT command successful.
150 Opening ASCII mode data connection for cn_reports.rpd (2272275 bytes).
226 Transfer complete.
ftp: 2284457 bytes received in 113.08Seconds 20.20Kbytes/sec.
To exit ftp:
ftp> bye
221-You have transferred 2284481 bytes in 2 files.
221-Total traffic for this session was 2285843 bytes in 3 transfers.
221-Thank you for using the FTP service on testdapp01cdc.comp.com.
221 Goodbye.
b)Putting files from source(Windows) to Target(Linux):
ftp> mput my_docs.txt
mput my_docs.txt? y
200 PORT command successful.
150 Opening ASCII mode data connection for my_docs.txt.
226 Transfer complete.
ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 4640
-rwxrwxrwx 1 oracle twcother 2272275 Aug 6 03:18 cn_reports.rpd
-rwxrwxrwx 1 oracle twcother 8115 Jul 7 19:07 DisputeSrchPG.xml
-rwxrwxrwx 1 appldev2 oinstall 916 Jul 25 04:38 L6958530.log
-rwxrwxrwx 1 appldev2 oinstall 880 Aug 6 08:06 L6960409.log
-rw-r--r-- 1 oracle twcother 0 Aug 8 20:48 my_docs.txt
-rwxr-xr-x 1 oracle twcother 23 Aug 8 20:11 test1.sh
8)cp:cp is the most basic command in linux(Unix environment) for copying files within same directory or directories on Same server.
Eg 8:To copy test1.sh to Target location /tmp/rafi,we can use below command.
testdapp01cdc(/export/home/oracle) >cp test1.sh /tmp/rafi
testdapp01cdc(/tmp/rafi) >ls -altr *test*
-rwxr-xr-x 1 oracle twcother 23 Aug 8 20:11 test1.sh
Detecting new hard disk ,creating partition,formating a partition,creating mount point point for storage purpose on linux platform
Detecting new hard disk ,creating partition,formating a partition,creating mount point point for storage,Using the mount point for storage on linux platform :
-------------------------------------------------------------------------------------
For becoming a best DBA we should have sound knowledge of operating system.The below experiment will be very useful for creating partition on linux ,formating the partition and mounting the disk for our storage purpose.
I got the 50 GB hard disk from my system admin,Now I want to use this hard disk for
storing backup of Database files.before doing I need to do the below steps:
Pre-requistics step:
--------------------
For detecting hard disk in linux server you need to reboot.We can do as follows:
[root@testNODE ~]# shutdown -r now
Broadcast message from root (pts/0) (Wed Apr 20 01:23:45 2009).
The system is going down for reboot NOW!
Note: 'reboot' command is also used.
----
Once ther server is up you can detect your hard disk as follows:
[root@testNODE ~]# fdisk -l =>This is for checking disk in linux.
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 514048+ 83 Linux
/dev/sda2 65 4633 36700492+ 83 Linux
/dev/sda3 4634 5482 6819592+ 83 Linux
/dev/sda4 5483 7832 18876375 5 Extended
/dev/sda5 5483 6265 6289416 82 Linux swap / Solaris
/dev/sda6 6266 7030 6144831 83 Linux
/dev/sda7 7031 7683 5245191 83 Linux
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 4981 40009851 83 Linux
/dev/sdb2 4982 5221 1927800 83 Linux
Disk /dev/sdc: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
So here is my new hard disk '/dev/sdc'.I will create a valid partition for this disk.For creating a valid partition we need to follow below steps:
Step 1: Use the command 'fdisk' as follows:
-------
[root@testNODE ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 6527.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Step 2: To get help for various partition options use 'm' option
-------
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Step 3:As seen above 'n' is used to create a new partition,'e' for extended
---------
partition,'1' is the primary partition used 'w' is for writing to disk
Command (m for help): n =>For creating new partition
Command action
e extended
p primary partition (1-4)
p =>For primary partition
Partition number (1-4): 1
First cylinder (1-6527, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-6527, default 6527):
=>Above you can specify size as +5G,+10G,...if you want to create 2 or more partition,I want to create only 1 partition of size 50G(default value of cylinder)
so I have not given any values.
Command (m for help): p =>for print of partitions which are created.
Disk /dev/sdc: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 6080 48837568+ 83 Linux
Command (m for help): w =>for writing and saving the partition
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
So our partition is created with 50GB of space.
Step 4: Check the filesystems types available
-------
[root@testNODE ~]# cat /etc/filesystems =>Gives types of filesystem available in OS
ext3
ext2
nodev proc
nodev devpts
iso9660
vfat
hfs
hfsplus
Step 5:Our attached hard disk is created with extended based filesystem i.e ext3
------
[root@testNODE ~]# fdisk -l /dev/sdc =>For checking the partition
Disk /dev/sdc: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 6080 48837568+ 83 Linux
So,as you see above we created one partition with size 50GB.
Step 6:Format your partition before mounting
------
a)Check your filesystem with 'e2fsck':
-------------------------------------------
[root@testNODE /]# e2fsck -b 8193 /dev/sdc
e2fsck 1.39 (29-May-2006)
e2fsck: Bad magic number in super-block while trying to open /dev/sdc
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193
From the above error I came to know the partition is not formated,Now for formating use 'mke2fs' for formating extended
filesystem.
[root@testNODE /]# e2fsck -b 8193 /dev/sdc1 =>For filesystem check i.e extended here
e2fsck 1.39 (29-May-2006)
e2fsck: Bad magic number in super-block while trying to open /dev/sdc1
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193
Note 1:'e2fsck' is used to check a Linux ext2/ext3 file system.
Note 2: 'fsck' is used to check and repair a Linux file system
b)Format your partition with 'mke2fs'
------------------------------------------------
[root@testNODE /]# sudo file -s /dev/sdc1
/dev/sdc1: x86 boot sector
[root@testNODE /]# sudo mke2fs -S /dev/sdc1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
6553600 inodes, 13107024 blocks
655351 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@testNODE /]# sudo mke2fs -j /dev/sdc1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
6553600 inodes, 13107024 blocks
655351 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Below are very important notes based on above experiment:
-------------------------------------------------------------
Note 1:'mke2fs' is used to format the extended filesystem.
-------
Note 2:In 'mke2fs' -S option is a very good option as it Write superblock and group descriptors only.
-------
This is useful if all of the superblock and backup superblocks are corrupted, and a last-ditch recovery method is desired. It causes mke2fs to
reinitialize the superblock and group descriptors, while not touching the inode table and the
block and inode bitmaps.
Note 3:'mkfs' is used to build a Linux file system on a device, usually a hard disk partition. filesystem is the device name (e.g. /dev/hda1, /dev/sdb2). blocks is the number of blocks to be used for the file system.
The exit code returned by mkfs is 0 on success and 1 on failure.
Note 4=>'mke2f' -j=>Create the filesystem with an ext3 journal (given the size of the filesystem)
=> So our extended filesystem is formated.
Step 7: Make an entry in /etc/fstab to detect a mount point even after re-boot.
--------
vi /etc/fstab
=>Add the below line.
/dev/sdc1 /u05 ext3 defaults 1 2
Step 8: Mount the filesystem.
-------
Create a directory for mounting as follows:
[root@testNODE /]# mkdir /u05
Once the directory is created we can use this for mounting purpose.
We have to use the 'mount' command to mount a disk with the option as given below.
[root@testNODE /]# mount -t ext3 /dev/sdc1 /u05
=>The above command is for mounting the partition
Here: -t=>is used to indicate the file system type
ext3=>is the filesystem type i.e extended as per entry in the /etc/fstab
/dev/sdc1=>raw disk partition used for mounting
/u05=>Directory used for mounting
[root@testNODE /]# df -h =>For checking the mount point you have created and diskspace utilization.
Filesystem Size Used Avail Use% Mounted on
/dev/sda6 5.7G 4.0G 1.5G 73% /
/dev/sda7 4.9G 4.1G 515M 90% /u01
/dev/sda3 6.3G 1.7G 4.3G 29% /u03
/dev/sda2 34G 32G 719M 98% /u02
/dev/sda1 487M 17M 445M 4% /boot
tmpfs 2.0G 1.4G 641M 68% /dev/shm
/dev/sdb1 38G 34G 2.1G 95% /u04
/dev/sdc1 50G 180M 47G 1% /u05
Let us do filesystem check now after mounting:
[root@testNODE /]# e2fsck -b 8193 /dev/sdc
e2fsck 1.39 (29-May-2006)
e2fsck: Device or resource busy while trying to open /dev/sdc
Filesystem mounted or opened exclusively by another program?
As you see above our raw disk mounted and ready to use.
Step 9:Granting ownership and permission to 'Oracle' user
-------
Once the directory is mounted now let us grant the ownership to 'Oracle' user so that this disk can be used
for various purposes by 'Oracle' owner.
[root@testNODE u05]# chown oracle:oinstall /u05
[root@testNODE u05]# chmod -R 775 /u05
Here:
chown:Granting ownership to operating system user 'Oracle'.
chmod:Granting permission to operating system user 'Oracle'.
Step 10: Login to 'Oracle' user to verify:
--------
[oracle@testNODE u05]$ mkdir TEST
[oracle@testNODE u05]$ cd TEST
[oracle@testNODE TEST]$ touch test1
[oracle@testNODE TEST]$ ls -altr
total 8
drwxrwxr-x 4 oracle oinstall 4096 May 11 17:21 ..
-rw-r--r-- 1 oracle dba 0 May 11 17:22 test1
drwxr-xr-x 2 oracle dba 4096 May 11 17:22 .
Note:'touch' command is used to create an empty file in linux(unix) for creating empty file with 0 byte size'
----
So our directory '/u05' is ready for use.My friends keep on saying me they need more on unix from DBA's point of view.This is just a basic experiment.
-------------------------------------------------------------------------------------
For becoming a best DBA we should have sound knowledge of operating system.The below experiment will be very useful for creating partition on linux ,formating the partition and mounting the disk for our storage purpose.
I got the 50 GB hard disk from my system admin,Now I want to use this hard disk for
storing backup of Database files.before doing I need to do the below steps:
Pre-requistics step:
--------------------
For detecting hard disk in linux server you need to reboot.We can do as follows:
[root@testNODE ~]# shutdown -r now
Broadcast message from root (pts/0) (Wed Apr 20 01:23:45 2009).
The system is going down for reboot NOW!
Note: 'reboot' command is also used.
----
Once ther server is up you can detect your hard disk as follows:
[root@testNODE ~]# fdisk -l =>This is for checking disk in linux.
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 514048+ 83 Linux
/dev/sda2 65 4633 36700492+ 83 Linux
/dev/sda3 4634 5482 6819592+ 83 Linux
/dev/sda4 5483 7832 18876375 5 Extended
/dev/sda5 5483 6265 6289416 82 Linux swap / Solaris
/dev/sda6 6266 7030 6144831 83 Linux
/dev/sda7 7031 7683 5245191 83 Linux
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 4981 40009851 83 Linux
/dev/sdb2 4982 5221 1927800 83 Linux
Disk /dev/sdc: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
So here is my new hard disk '/dev/sdc'.I will create a valid partition for this disk.For creating a valid partition we need to follow below steps:
Step 1: Use the command 'fdisk' as follows:
-------
[root@testNODE ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 6527.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Step 2: To get help for various partition options use 'm' option
-------
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Step 3:As seen above 'n' is used to create a new partition,'e' for extended
---------
partition,'1' is the primary partition used 'w' is for writing to disk
Command (m for help): n =>For creating new partition
Command action
e extended
p primary partition (1-4)
p =>For primary partition
Partition number (1-4): 1
First cylinder (1-6527, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-6527, default 6527):
=>Above you can specify size as +5G,+10G,...if you want to create 2 or more partition,I want to create only 1 partition of size 50G(default value of cylinder)
so I have not given any values.
Command (m for help): p =>for print of partitions which are created.
Disk /dev/sdc: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 6080 48837568+ 83 Linux
Command (m for help): w =>for writing and saving the partition
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
So our partition is created with 50GB of space.
Step 4: Check the filesystems types available
-------
[root@testNODE ~]# cat /etc/filesystems =>Gives types of filesystem available in OS
ext3
ext2
nodev proc
nodev devpts
iso9660
vfat
hfs
hfsplus
Step 5:Our attached hard disk is created with extended based filesystem i.e ext3
------
[root@testNODE ~]# fdisk -l /dev/sdc =>For checking the partition
Disk /dev/sdc: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 6080 48837568+ 83 Linux
So,as you see above we created one partition with size 50GB.
Step 6:Format your partition before mounting
------
a)Check your filesystem with 'e2fsck':
-------------------------------------------
[root@testNODE /]# e2fsck -b 8193 /dev/sdc
e2fsck 1.39 (29-May-2006)
e2fsck: Bad magic number in super-block while trying to open /dev/sdc
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193
From the above error I came to know the partition is not formated,Now for formating use 'mke2fs' for formating extended
filesystem.
[root@testNODE /]# e2fsck -b 8193 /dev/sdc1 =>For filesystem check i.e extended here
e2fsck 1.39 (29-May-2006)
e2fsck: Bad magic number in super-block while trying to open /dev/sdc1
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193
Note 1:'e2fsck' is used to check a Linux ext2/ext3 file system.
Note 2: 'fsck' is used to check and repair a Linux file system
b)Format your partition with 'mke2fs'
------------------------------------------------
[root@testNODE /]# sudo file -s /dev/sdc1
/dev/sdc1: x86 boot sector
[root@testNODE /]# sudo mke2fs -S /dev/sdc1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
6553600 inodes, 13107024 blocks
655351 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@testNODE /]# sudo mke2fs -j /dev/sdc1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
6553600 inodes, 13107024 blocks
655351 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Below are very important notes based on above experiment:
-------------------------------------------------------------
Note 1:'mke2fs' is used to format the extended filesystem.
-------
Note 2:In 'mke2fs' -S option is a very good option as it Write superblock and group descriptors only.
-------
This is useful if all of the superblock and backup superblocks are corrupted, and a last-ditch recovery method is desired. It causes mke2fs to
reinitialize the superblock and group descriptors, while not touching the inode table and the
block and inode bitmaps.
Note 3:'mkfs' is used to build a Linux file system on a device, usually a hard disk partition. filesystem is the device name (e.g. /dev/hda1, /dev/sdb2). blocks is the number of blocks to be used for the file system.
The exit code returned by mkfs is 0 on success and 1 on failure.
Note 4=>'mke2f' -j=>Create the filesystem with an ext3 journal (given the size of the filesystem)
=> So our extended filesystem is formated.
Step 7: Make an entry in /etc/fstab to detect a mount point even after re-boot.
--------
vi /etc/fstab
=>Add the below line.
/dev/sdc1 /u05 ext3 defaults 1 2
Step 8: Mount the filesystem.
-------
Create a directory for mounting as follows:
[root@testNODE /]# mkdir /u05
Once the directory is created we can use this for mounting purpose.
We have to use the 'mount' command to mount a disk with the option as given below.
[root@testNODE /]# mount -t ext3 /dev/sdc1 /u05
=>The above command is for mounting the partition
Here: -t=>is used to indicate the file system type
ext3=>is the filesystem type i.e extended as per entry in the /etc/fstab
/dev/sdc1=>raw disk partition used for mounting
/u05=>Directory used for mounting
[root@testNODE /]# df -h =>For checking the mount point you have created and diskspace utilization.
Filesystem Size Used Avail Use% Mounted on
/dev/sda6 5.7G 4.0G 1.5G 73% /
/dev/sda7 4.9G 4.1G 515M 90% /u01
/dev/sda3 6.3G 1.7G 4.3G 29% /u03
/dev/sda2 34G 32G 719M 98% /u02
/dev/sda1 487M 17M 445M 4% /boot
tmpfs 2.0G 1.4G 641M 68% /dev/shm
/dev/sdb1 38G 34G 2.1G 95% /u04
/dev/sdc1 50G 180M 47G 1% /u05
Let us do filesystem check now after mounting:
[root@testNODE /]# e2fsck -b 8193 /dev/sdc
e2fsck 1.39 (29-May-2006)
e2fsck: Device or resource busy while trying to open /dev/sdc
Filesystem mounted or opened exclusively by another program?
As you see above our raw disk mounted and ready to use.
Step 9:Granting ownership and permission to 'Oracle' user
-------
Once the directory is mounted now let us grant the ownership to 'Oracle' user so that this disk can be used
for various purposes by 'Oracle' owner.
[root@testNODE u05]# chown oracle:oinstall /u05
[root@testNODE u05]# chmod -R 775 /u05
Here:
chown:Granting ownership to operating system user 'Oracle'.
chmod:Granting permission to operating system user 'Oracle'.
Step 10: Login to 'Oracle' user to verify:
--------
[oracle@testNODE u05]$ mkdir TEST
[oracle@testNODE u05]$ cd TEST
[oracle@testNODE TEST]$ touch test1
[oracle@testNODE TEST]$ ls -altr
total 8
drwxrwxr-x 4 oracle oinstall 4096 May 11 17:21 ..
-rw-r--r-- 1 oracle dba 0 May 11 17:22 test1
drwxr-xr-x 2 oracle dba 4096 May 11 17:22 .
Note:'touch' command is used to create an empty file in linux(unix) for creating empty file with 0 byte size'
----
So our directory '/u05' is ready for use.My friends keep on saying me they need more on unix from DBA's point of view.This is just a basic experiment.
Unix operating system interview questions for DBA
Hi,
Below are some of the most important interview questions from Operating system
point of view to a DBA.
1)How can you check the files permission in Unix OS?
Ans: 'ls' command with the below option is used for checking files permission.
$ ls -altr
total 198
drwxr-xr-x 2 root root 4096 Aug 8 2008 srv
drwxr-xr-x 2 root root 4096 Aug 8 2008 mnt
drwxr-xr-x 3 root root 4096 Mar 7 05:10 home
drwxr-xr-x 7 root root 4096 Mar 7 05:47 lib64
2)How can you schedule job in Unix OS?
Ans: 'crontab' command is used for scheduling job in Unix OS.Crontab can be installed and removed as followed:
For commands that need to be executed repeatedly (e.g. hourly, daily or weekly), use crontab, which has the following options:
crontab filename Install filename as your crontab file.
crontab -e Edit your crontab file.
crontab -l Show your crontab file.
crontab -r Remove your crontab file.
Eg: Create a backup script as per your backup strategy and schedule as per strategy
$ vi backupdb.sh
. $HOME/.profile
export ORACLE_SID=
rman nocatalog << EOF
connect target
# backup controlfile
configure controlfile autobackup on;
# backup database,archivelogs and delete backed up archivelogs
backup database plus archivelog delete input;
# delete obsolete
delete obsolete;
yes
EOF
:wq
=>save and quit
Note: In the line ". $HOME/.profile" there has to be a space between . and $, to execute .profile in current shell.
Now schedule it with crontab(cronjob) command.
crontab -e
30 20 * * 1,3,5 /u01/backupdb.sh 1>/u01/backupdb.log 2>&1
:wq
=>save and quit displays the below message.
crontab: installing new crontab
Meaning: 00 =>seconds 00-59,Here it is 30 minutes;
20=>hours in a day 00-23,Here it is 8 pm;
*=>Day of the month,1-30,Here * signify the value does not apply
*=>Month of the year,1-12,Here * signify the value does not apply
1,3,5 =>Day of the week,0-6,Here 1,3,5 is monday,wednesday,friday.
/u01/backupdb.sh=>our backup script
> =>for overriding the content
/u01/backupdb.log =>for checking the output after the scheduled job is executed
& =>for running in backup
3)Which tool you use to copy files from windows to linux or linux to windows?
Ans: Winscp can be used for copying files from windows to linux.Winscp is easy to install GUI based utility for copying files in binary mode by default.Howerver 'ftp' command line utility can also be used.
4)How can you search file in Unix OS?
Ans: Using 'find' command we can search file in unix OS.
$ find /home/oracle -name "*.vim*" -print
/home/oracle/.viminfo
where: /home/oracle: path of the directory where you are searching file.
5)Which command is used to see the disk space details in Unix OS?
Ans: We use 'df -h' =>Linux OS, 'bdf' =>HP-UX OS,'df -g' =>AIX 0S
]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda6 5.7G 4.0G 1.5G 73% /
/dev/sda7 4.9G 4.1G 516M 90% /u01
/dev/sda3 6.3G 2.7G 3.3G 46% /u03
/dev/sda2 34G 32G 720M 98% /u02
Note: In IBM-AIX OS we have to use 'df -g' ; In HP-UX OS we have to use 'bdf' for checking the Disk Space details .
6) Which comand is used to see files usage details in Unix OS?
Ans:'du' command is used to see directories and file usage details in Unix OS.
$ cd /u01
[oracle@node1.u01]$ du -csh *
16K lost+found
756K oracle
4.1G oracle11g
7)Which command is used to schedule job without user intervention and backend?
Ans: 'nohup' command is used to run a command without user intervention.If we use '&' symbol than the command will run in backend.'nohup' command is my favourite command for running export and import jobs.I use this command very often.
Eg: nohup sh file_name.sh >file_output.out &
8)What are frequently used OS command for DBA's?
Ans: mkdir =>for creating directories in Unix OS; cd =>For changing the directory;
rm =>For removing files;rmdir =>For removing directories;grep =>For searching characters in a file; man =>User manual for all commands; useradd=>for creating OS user; chmod=For granting permission to files and Directories;chown=>For changing ownership of Directories.
Eg: mkdir test =>Create test directory
cd /u01/test =>Will change the path of Directory
man grep =>user manual for all command man has it own advantage.
chmod -R 775 /u01/test =>Grants permissions as read,write,execute to owner,groups
useradd -d oracle =>For Creating Operating system user as Oracle.
9)Which command is used to copy or synchronizing two Directories in a secure way on any Unix environment?
Ans : 'rsync' command can be used to copy or synchronize two directories.It is very important command and very handy tool for copying files fast for a DBA,Ofcourse
'scp' can also be use.But I really like using 'rsync' .Below is the example:
Eg:
----
[oracle@node1 HEALTH_CHECK_DB]$ rsync -av /u04/HEALTH_CHECK_DB/ /u05/SCRIPTS_DBA_TASKS/
building file list ... done
./
Database_status.sh
archive_gen.sql
c:&FileName._TESTDB1_20110509.html
c:&FileName._TESTDB2_20110509.html
db_monitor.sql
health_check.sql
sent 4225122 bytes received 158 bytes 8450560.00 bytes/sec
total size is 4224061 speedup is 1.00
[oracle@node1 HEALTH_CHECK_DB]$ cd ..
[oracle@node1 u04]$ cd /u05/SCRIPTS_DBA_TASKS/
[oracle@node1 SCRIPTS_DBA_TASKS]$ ls -altr
total 4176
-rwxrwxrwx 1 oracle dba 1815 Mar 27 23:53 archive_gen.sql
-rwxrwxrwx 1 oracle dba 2724 Mar 27 23:59 db_monitor.sql
-rw-r--r-- 1 oracle dba 1233385 May 9 11:40 health_check.sql
-rw-r--r-- 1 oracle dba 1421433 May 9 11:41 c:&FileName._TESTDB1_20110509.html
-rw-r--r-- 1 oracle dba 1564704 May 9 11:43 c:&FileName._TESTDB2_20110509.html
-rw-r--r-- 1 oracle dba 0 May 18 12:24 Database_status.sh
drwxrwxrwx 2 oracle dba 4096 May 18 12:24 .
drwxrwxr-x 9 oracle oinstall 4096 May 26 12:37 ..
-rwxrwxr-x 1 oracle dba 486 May 26 12:39 SCHEMA_CREATE_SCRIPT_TESTDB1_TESTDB2.sql
-rwxrwxr-x 1 oracle dba 846 May 26 14:06 profile_create.sql
-rwxrwxr-x 1 oracle dba 1252 May 27 20:44 crontab.oracle
-rwxrwxr-x 1 oracle dba 143 May 30 17:12 tablespace_create_script.sql
If you want to copy files from one linux(unix server) to other again it can be very handy,below is the syntax:
rsync -avc my_stuff2/ user@remotehost:~/mystuff3/
rsync copies only those files which are not copyied and this is definetly
useful in syncronizing source and destination directories.Hence it is very fast.
10)Which command is useful to see line by line display in Unix environment?
Ans: 'less' command is used to see line-by-line display('more' for page-by-page display).I find less more useful specially for seeing log files and to find the errors or Warnings in the log files.
Eg: less test1.log =>Will display test1.log file
11)Which command can be used to view file in readonly mode?
Ans:'view' command can be used to view file in readonly mode.A very good option to see cronjob file specially because at any this file should not get modified by mistake as all your daily jobs will be scheduled using cronjob.
Eg: view crontab.oracle
12)How we can delete the files which are few days(N days) old?
Ans:To save the disk space you might be deleting the old files or backup which are 1 week(2 weeks) old or depending on your Disk Space and other requirement.We should automate these tasks as a DBA.We can do this as follows:
For Unix environment:
-----------------------------------
Eg: If I want to delete files from a path which are 7 Days old:
Write one shell script as given below:
#remove_files_back.sh
#Removing 7 days old dump files
find /u03/DB_BACKUP_TESTDB/expdp_fulldb_backup -mtime +6 -exec rm {} \;
Where: find =>Finding the file; /u03/DB_BACKUP_TESTDB/expdp_fulldb_backup =>path;
-mtime=>Modified time,Here I'm giving 7 days(>6);-exec rm =>execute removing for files. Now as per your convenience schedule cronjob for doing this task,For example every sunday at 9 pm than:
00 21 * * 0 /u03/DB_BACKUP_TESTDB/expdp_fulldb_backup/remove_files_back.sh 2>&1 >/u05/DB_BACKUP_TESTDB/logs/CRONJOBS_LOGS/TESTDB_BACK_cron.log
Note: For Windows Environment you can create a .bat file as follows:
--remove_file_back.bat
forfiles /p "D:\dbbackup\testdb\daily" /s /d -7 /c "cmd /c del @file : date >=7 days >NUL"
Where:All files which are 7 days old are removed;D:\dbbackup\testdb\daily =>path.
However Please make a note Please don't use the above command for your /(root) directory or any software specified and confirm and test in test environment before using on the actual system.
14) How to FIND whether OS (kernel) is 32 or 64 bit in Unix Operating systems?
Ans: file /usr/bin/initdb
15)Which command can be use to convert Windows file to Unix file?
Ans: 'dos2unix' command can be use for this purpose.
After copying files with winscp use dos2unix utility to convert.
Unix uses a convention that a line is ended by a line feed character (Ascii 10). Windows/DOS uses a convention that a line is ended by a two character sequence, carriage-return line-feed (Ascii 13 then ascii 10). The dos2unix command converts for Windows/DOS format to Unix format. It writes the result to standard output. To write to a file, just redirect the standard output to the file. For example, use
$dos2unix myfile >mynewfile
Offcourse there are lot of useful commands which a DBA uses in Day-to-Day activities.If I come across few more useful commands I will attach this thread.
Hope it helps.
Below are some of the most important interview questions from Operating system
point of view to a DBA.
1)How can you check the files permission in Unix OS?
Ans: 'ls' command with the below option is used for checking files permission.
$ ls -altr
total 198
drwxr-xr-x 2 root root 4096 Aug 8 2008 srv
drwxr-xr-x 2 root root 4096 Aug 8 2008 mnt
drwxr-xr-x 3 root root 4096 Mar 7 05:10 home
drwxr-xr-x 7 root root 4096 Mar 7 05:47 lib64
2)How can you schedule job in Unix OS?
Ans: 'crontab' command is used for scheduling job in Unix OS.Crontab can be installed and removed as followed:
For commands that need to be executed repeatedly (e.g. hourly, daily or weekly), use crontab, which has the following options:
crontab filename Install filename as your crontab file.
crontab -e Edit your crontab file.
crontab -l Show your crontab file.
crontab -r Remove your crontab file.
Eg: Create a backup script as per your backup strategy and schedule as per strategy
$ vi backupdb.sh
. $HOME/.profile
export ORACLE_SID=
rman nocatalog << EOF
connect target
# backup controlfile
configure controlfile autobackup on;
# backup database,archivelogs and delete backed up archivelogs
backup database plus archivelog delete input;
# delete obsolete
delete obsolete;
yes
EOF
:wq
=>save and quit
Note: In the line ". $HOME/.profile" there has to be a space between . and $, to execute .profile in current shell.
Now schedule it with crontab(cronjob) command.
crontab -e
30 20 * * 1,3,5 /u01/backupdb.sh 1>/u01/backupdb.log 2>&1
:wq
=>save and quit displays the below message.
crontab: installing new crontab
Meaning: 00 =>seconds 00-59,Here it is 30 minutes;
20=>hours in a day 00-23,Here it is 8 pm;
*=>Day of the month,1-30,Here * signify the value does not apply
*=>Month of the year,1-12,Here * signify the value does not apply
1,3,5 =>Day of the week,0-6,Here 1,3,5 is monday,wednesday,friday.
/u01/backupdb.sh=>our backup script
> =>for overriding the content
/u01/backupdb.log =>for checking the output after the scheduled job is executed
& =>for running in backup
3)Which tool you use to copy files from windows to linux or linux to windows?
Ans: Winscp can be used for copying files from windows to linux.Winscp is easy to install GUI based utility for copying files in binary mode by default.Howerver 'ftp' command line utility can also be used.
4)How can you search file in Unix OS?
Ans: Using 'find' command we can search file in unix OS.
$ find /home/oracle -name "*.vim*" -print
/home/oracle/.viminfo
where: /home/oracle: path of the directory where you are searching file.
5)Which command is used to see the disk space details in Unix OS?
Ans: We use 'df -h' =>Linux OS, 'bdf' =>HP-UX OS,'df -g' =>AIX 0S
]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda6 5.7G 4.0G 1.5G 73% /
/dev/sda7 4.9G 4.1G 516M 90% /u01
/dev/sda3 6.3G 2.7G 3.3G 46% /u03
/dev/sda2 34G 32G 720M 98% /u02
Note: In IBM-AIX OS we have to use 'df -g' ; In HP-UX OS we have to use 'bdf' for checking the Disk Space details .
6) Which comand is used to see files usage details in Unix OS?
Ans:'du' command is used to see directories and file usage details in Unix OS.
$ cd /u01
[oracle@node1.u01]$ du -csh *
16K lost+found
756K oracle
4.1G oracle11g
7)Which command is used to schedule job without user intervention and backend?
Ans: 'nohup' command is used to run a command without user intervention.If we use '&' symbol than the command will run in backend.'nohup' command is my favourite command for running export and import jobs.I use this command very often.
Eg: nohup sh file_name.sh >file_output.out &
8)What are frequently used OS command for DBA's?
Ans: mkdir =>for creating directories in Unix OS; cd =>For changing the directory;
rm =>For removing files;rmdir =>For removing directories;grep =>For searching characters in a file; man =>User manual for all commands; useradd=>for creating OS user; chmod=For granting permission to files and Directories;chown=>For changing ownership of Directories.
Eg: mkdir test =>Create test directory
cd /u01/test =>Will change the path of Directory
man grep =>user manual for all command man has it own advantage.
chmod -R 775 /u01/test =>Grants permissions as read,write,execute to owner,groups
useradd -d oracle =>For Creating Operating system user as Oracle.
9)Which command is used to copy or synchronizing two Directories in a secure way on any Unix environment?
Ans : 'rsync' command can be used to copy or synchronize two directories.It is very important command and very handy tool for copying files fast for a DBA,Ofcourse
'scp' can also be use.But I really like using 'rsync' .Below is the example:
Eg:
----
[oracle@node1 HEALTH_CHECK_DB]$ rsync -av /u04/HEALTH_CHECK_DB/ /u05/SCRIPTS_DBA_TASKS/
building file list ... done
./
Database_status.sh
archive_gen.sql
c:&FileName._TESTDB1_20110509.html
c:&FileName._TESTDB2_20110509.html
db_monitor.sql
health_check.sql
sent 4225122 bytes received 158 bytes 8450560.00 bytes/sec
total size is 4224061 speedup is 1.00
[oracle@node1 HEALTH_CHECK_DB]$ cd ..
[oracle@node1 u04]$ cd /u05/SCRIPTS_DBA_TASKS/
[oracle@node1 SCRIPTS_DBA_TASKS]$ ls -altr
total 4176
-rwxrwxrwx 1 oracle dba 1815 Mar 27 23:53 archive_gen.sql
-rwxrwxrwx 1 oracle dba 2724 Mar 27 23:59 db_monitor.sql
-rw-r--r-- 1 oracle dba 1233385 May 9 11:40 health_check.sql
-rw-r--r-- 1 oracle dba 1421433 May 9 11:41 c:&FileName._TESTDB1_20110509.html
-rw-r--r-- 1 oracle dba 1564704 May 9 11:43 c:&FileName._TESTDB2_20110509.html
-rw-r--r-- 1 oracle dba 0 May 18 12:24 Database_status.sh
drwxrwxrwx 2 oracle dba 4096 May 18 12:24 .
drwxrwxr-x 9 oracle oinstall 4096 May 26 12:37 ..
-rwxrwxr-x 1 oracle dba 486 May 26 12:39 SCHEMA_CREATE_SCRIPT_TESTDB1_TESTDB2.sql
-rwxrwxr-x 1 oracle dba 846 May 26 14:06 profile_create.sql
-rwxrwxr-x 1 oracle dba 1252 May 27 20:44 crontab.oracle
-rwxrwxr-x 1 oracle dba 143 May 30 17:12 tablespace_create_script.sql
If you want to copy files from one linux(unix server) to other again it can be very handy,below is the syntax:
rsync -avc my_stuff2/ user@remotehost:~/mystuff3/
rsync copies only those files which are not copyied and this is definetly
useful in syncronizing source and destination directories.Hence it is very fast.
10)Which command is useful to see line by line display in Unix environment?
Ans: 'less' command is used to see line-by-line display('more' for page-by-page display).I find less more useful specially for seeing log files and to find the errors or Warnings in the log files.
Eg: less test1.log =>Will display test1.log file
11)Which command can be used to view file in readonly mode?
Ans:'view' command can be used to view file in readonly mode.A very good option to see cronjob file specially because at any this file should not get modified by mistake as all your daily jobs will be scheduled using cronjob.
Eg: view crontab.oracle
12)How we can delete the files which are few days(N days) old?
Ans:To save the disk space you might be deleting the old files or backup which are 1 week(2 weeks) old or depending on your Disk Space and other requirement.We should automate these tasks as a DBA.We can do this as follows:
For Unix environment:
-----------------------------------
Eg: If I want to delete files from a path which are 7 Days old:
Write one shell script as given below:
#remove_files_back.sh
#Removing 7 days old dump files
find /u03/DB_BACKUP_TESTDB/expdp_fulldb_backup -mtime +6 -exec rm {} \;
Where: find =>Finding the file; /u03/DB_BACKUP_TESTDB/expdp_fulldb_backup =>path;
-mtime=>Modified time,Here I'm giving 7 days(>6);-exec rm =>execute removing for files. Now as per your convenience schedule cronjob for doing this task,For example every sunday at 9 pm than:
00 21 * * 0 /u03/DB_BACKUP_TESTDB/expdp_fulldb_backup/remove_files_back.sh 2>&1 >/u05/DB_BACKUP_TESTDB/logs/CRONJOBS_LOGS/TESTDB_BACK_cron.log
Note: For Windows Environment you can create a .bat file as follows:
--remove_file_back.bat
forfiles /p "D:\dbbackup\testdb\daily" /s /d -7 /c "cmd /c del @file : date >=7 days >NUL"
Where:All files which are 7 days old are removed;D:\dbbackup\testdb\daily =>path.
However Please make a note Please don't use the above command for your /(root) directory or any software specified and confirm and test in test environment before using on the actual system.
14) How to FIND whether OS (kernel) is 32 or 64 bit in Unix Operating systems?
Ans: file /usr/bin/initdb
15)Which command can be use to convert Windows file to Unix file?
Ans: 'dos2unix' command can be use for this purpose.
After copying files with winscp use dos2unix utility to convert.
Unix uses a convention that a line is ended by a line feed character (Ascii 10). Windows/DOS uses a convention that a line is ended by a two character sequence, carriage-return line-feed (Ascii 13 then ascii 10). The dos2unix command converts for Windows/DOS format to Unix format. It writes the result to standard output. To write to a file, just redirect the standard output to the file. For example, use
$dos2unix myfile >mynewfile
Offcourse there are lot of useful commands which a DBA uses in Day-to-Day activities.If I come across few more useful commands I will attach this thread.
Hope it helps.
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.
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
!
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.
No comments:
Post a Comment