Nov 20, 2009

Move ASM files across diskgroups

Below are the steps to move ASM files from one ASM disk group to another:

Note:Make sure the database is in archive log mode before proceeding with the below exercise.

  1. Identify the data file to be moved.
  2. SQL>Select file_name from dba_data_files;
    FILE_NAME
    --------------------------------------------------------------------------------
    +DATA/easydw/datafile/tbl_abacus.271.703296941
  3. Identify the diskgroup on to which the file has to be moved.
  4. ASM>SELECT name FROM v$asm_diskgroup;
    NAME
    ------------------------------
    DATA
    FRA
  5. Take the file offline.
  6. SQL>ALTER DATABASE DATAFILE '+DATA/easydw/datafile/tbl_abacus.271.703296941' OFFLINE';
  7. Copy the file to new diskgroup using RMAN.
  8. $ rman target /
    RMAN> COPY DATAFILE '+DATA/easydw/datafile/tbl_abacus.271.703296941' TO '+FRA';
    Starting backup at 20-NOV-09
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=140 devtype=DISK
    channel ORA_DISK_1: starting datafile copy
    input datafile fno=00028 name=+DATA/easydw/datafile/tbl_abacus.271.703296941
    output filename=+FRA/easydw/datafile/tbl_abacus.316.703382539 tag=TAG20091120T000218 recid=2 stamp=703382539
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
    Finished backup at 20-NOV-09
    Starting Control File and SPFILE Autobackup at 20-NOV-09
    piece handle=+FRA/easydw/autobackup/2009_11_20/s_703382539.317.703382541 comment=NONE
    Finished Control File and SPFILE Autobackup at 20-NOV-09
  9. Rename the file to point to new location.
  10. SQL>ALTER DATABASE RENAME FILE '+DATA/easydw/datafile/tbl_abacus.271.703296941'
              TO '+FRA/easydw/datafile/tbl_abacus.316.703382539';
  11. Switch data file copy
  12. RMAN> SWITCH DATAFILE '+FRA/easydw/datafile/tbl_abacus.316.703382539' TO COPY;
  13. Recover the file.
  14. SQL> RECOVER DATAFILE '+FRA/easydw/datafile/tbl_abacus.316.703382539';
  15. Bring the file online.
  16. SQL> ALTER DATABASE DATAFILE '+FRA/easydw/datafile/tbl_abacus.316.703382539' ONLINE;
  17. Verify the new file locations.
  18. SQL>SELECT file_name FROM dba_data_files;
    FILE_NAME
    --------------------------------------------------------------------------------
    +FRA/easydw/datafile/tbl_abacus.316.703382539
  19. Delete the file from its original location.
  20. $ export ORACLE_SID=+ASM
    $ sqlplus "/ as sysdba"
    ASM> ALTER DISKGROUP DATA DROP FILE '+DATA/easydw/datafile/tbl_abacus.271.703296941';

Nov 19, 2009

Unix command reference

Command
Action
Example
Creates a temporary name for a Unix command.
alias   name command
 
To remove an alias:
unalias   name
ansiprint
Prints a file to a printer connected to your computer.
ansiprint   file
assets
Displays your account resources, use, and threshold.
     
Places a suspended job in the background.
     
Displays a specified file.
cat   file
cd
Changes current directory to a different directory.
cd   directory
 
To change back to your home directory:
cd    
 
Directory abbreviations:
~     Home directory
..     Parent directory
.       Current working directory
 
chmod
Changes permission status for a file or directory.
chmod   code file
chmod   code directory

 
To keep a file private:
chmod   600 file
 
To give everyone read permission:
chmod   664 file
compress
Reduces the size of a file and adds .Z to the file's name.
compress   file
 
To restore a compressed file:
uncompress   file.Z
cp
Makes a copy of a file.
cp   file1 file2
 
To copy a file into a different directory:
cp   file directory
 
To inquire before overwriting an existing file:
cp -i   file1 file2
Compares two files and displays the differences.
     
Restarts a suspended job in the foreground.
     
finger
Displays user information at the specified computer.
finger   userid@computer
 
To change your finger entry information:
chfn
ftp
Starts the file transfer program with a remote computer.
ftp   address
Finds lines in a file matching a character pattern.
grep -icvn   pattern file
 
-i     Ignores case
-c     Lists count of lines that contain pattern
-v     Lists all lines except those with pattern
-n     Lists line number for each found pattern
 
Displays the first ten lines of a file.
head   file
 
To display the first n number of lines:
head -n   file
help
Displays an online help note.
help   note
 
To display a list of help notes:
help -l
history
Displays a list of your most recent commands.
history
 
To repeat the nth command from the list:
!   n
 
To repeat your most recent command:
!!
Displays active jobs and their corresponding job numbers.
jobs
 
To start a job in the background:
job   &
 
To return a job to the foreground by the job number:
fg   %number
 
To send a running job to the background:
z bg
Terminates a process by its process identification number.
kill   pid
 
To use the strongest form of the kill command:
kill -9   pid
Ends your computer session.
 
ls
Lists the files and subdirectories in your current directory.
ls -Fltra
 
-l     Lists long format
-t     Lists by modification time
-r     Lists in reverse order
-F     Lists file type with special character
-a     Lists all files including dot (.) files
 
lynx
Starts a text-only Web browser session at UW home page.
lynx
 
Starts a Web browser session at a specific Web address.
lynx   url
Displays Unix Manual entry for a command.
man   command
 
To search Manual Index for a keyword or topic:
man -k   keyword
mesg
Displays your talk and write message access status.
mesg
 
To set your message status to yes or no:
mesg y (or n)
mkdir
Creates a new directory within your current directory.
mkdir   directory
more
Displays a file one screen at a time.
more   file
 
Use to scroll forward and q to quit.
 
mv
Moves a file to a different directory.
mv   file directory
 
Moves a directory to a second directory.
mv   directory1 directory2
 
To rename file1 as file2:
mv   file1 file2
 
To rename directory1 as directory2:
mv   directory1 directory2
 
To inquire before overwriting an existing file:
mv -i   file1 file2
Starts program to change account password.
 
pico
Starts the Pico text editor with a file.
pico   file
pine
Starts the Pine® electronic mail program.
 
prt
Sends a file to a Uniform Access printer.
prt -q   printer file
 
To display a list of the available printers:
prt -printers | more
ps
Displays processes and their corresponding process identification numbers.
 
pwd
Displays absolute pathname of current directory.
 
Permanently deletes a file.
rm   file
 
To verify prior to removal:
rm -i   file
rmdir
Deletes an empty directory.
rmdir   directory
 
To verify prior to removal:
rmdir -i   directory
Checks the spelling in a file.
spell   file
staffdir
Displays the Online UW Staff Directory.
staffdir   "lastname, firstname"
 
To display all fields:
staffdir -full   "lastname, firstname"
telnet
Starts a telnet session with a remote computer.
telnet   address
Starts the vi text editor with a file.
vi   file
Displays a list of who is on system.
 
wc
Counts lines, words, and characters in a file.
wc   file

Special commands and characters:
Redirection
   
<    
Routes input to command from file
   
>    
Routes output from command to file
   
>>  
Appends output to existing file
   
|    
Routes output between commands
Wildcards used in filenames
   
*    
Matches any number of characters
   
?    
Matches one character
Control codes
   
s    
Suspends the screen display
   
q    
Restarts suspended display
   
d    
Signals end of file
   
c    
Cancels a command
   
z    
Suspends a process or job:
use fg to restart

   
u    
Clears the command line

Search This Blog