Linux Commands

rename

As you know, the mv command renames files. For example,

$ mv oldname newname
renames the file oldname to newname. However, what if you don’t know the filenames yet? The rename command comes in really handy here.

rename .log .log.‘date +%F-%H:%M:%S‘ *

replaces all files with the extension .log with .log.. So sqlnet.log becomes sqlnet.log.2006-09-12-23:26:28.

alias and unalias

Suppose you want to check the ORACLE_SID environment variable set in your shell. You will have to type:

echo $ORACLE_HOME

As a DBA or a developer, you frequently use this command and will quickly become tired of typing the entire 16 characters. Is there is a simpler way?

There is: the alias command. With this approach you can create a short alias, such as “os”, to represent the entire command:

alias os=’echo $ORACLE_HOME’

Now whenever you want to check the ORACLE_SID, you just type “os” (without the quotes) and Linux executes the aliased command.

However, if you log out and log back in, the alias is gone and you have to enter the alias command again. To eliminate this step, all you have to do is to put the command in your shell’s profile file. For bash, the file is .bash_profile (note the period before the file name, that’s part of the file’s name) in your home directory. For bourne and korn shells, it’s .profile, and for c-shell, .chsrc.

You can create an alias in any name. For instance, I always create an alias for the command rm as rm -i, which makes the rm command interactive.

alias rm=’rm -i’

Whenever I issue an rm command, Linux prompts me for confirmation, and unless I provide “y”, it doesn’t remove the file—thus I am protected form accidentally removing an important file. I use the same for mv (for moving the file to a new name), which prevents accidental overwriting of existing files, and cp (for copying the file).

Here is a list of some very useful aliases I like to define:

alias bdump=’cd $ORACLE_BASE/admin/$ORACLE_SID/bdump’
alias l=’ls -d .* –color=tty’
alias ll=’ls -l –color=tty’
alias mv=’mv -i’
alias oh=’cd $ORACLE_HOME’
alias os=’echo $ORACLE_SID’
alias rm=’rm -i’
alias tns=’cd $ORACLE_HOME/network/admin’

Painless Changes to Owner, Group, and Permissions

# ls -l
total 8
-rw-r–r– 1 test users 70 Aug 4 04:02 file1
-rwxr-xr-x 1 oracle dba 132 Aug 4 04:02 file2
-rwxr-xr-x 1 oracle dba 132 Aug 4 04:02 file3
-rwxr-xr-x 1 oracle dba 132 Aug 4 04:02 file4
-rwxr-xr-x 1 oracle dba 132 Aug 4 04:02 file5
-rwxr-xr-x 1 oracle dba 132 Aug 4 04:02 file6

and you need to change the permissions of all the files to match those of file1. Sure, you could issue chmod 644 * to make that change—but what if you are writing a script to do that, and you don’t know the permissions beforehand? Or, perhaps you are making several permission changes and based on many different files and you find it infeasible to go though the permissions of each of those and modify accordingly.

A better approach is to make the permissions similar to those of another file. This command makes the permissions of file2 the same as file1:

chmod –reference file1 file2

Now if you check:

# ls -l file[12]
total 8
-rw-r–r– 1 test users 70 Aug 4 04:02 file1
-rw-r–r– 1 oracle dba 132 Aug 4 04:02 file2

The file2 permissions were changed exactly as in file1. You didn’t need to get the permissions of file1 first.

You can also use the same trick in group membership in files. To make the group of file2 the same as file1, you would issue:

# chgrp –reference file1 file2
# ls -l file[12]
-rw-r–r– 1 test users 70 Aug 4 04:02 file1
-rw-r–r– 1 oracle users 132 Aug 4 04:02 file2

Of course, what works for changing groups will work for owner as well. Here is how you can use the same trick for an ownership change. If permissions are like this:

# ls -l file[12]
-rw-r–r– 1 test users 70 Aug 4 04:02 file1
-rw-r–r– 1 oracle dba 132 Aug 4 04:02 file2

You can change the ownership like this:

# chown –reference file1 file2
# ls -l file[12]
-rw-r–r– 1 test users 70 Aug 4 04:02 file1
-rw-r–r– 1 test users 132 Aug 4 04:02 file2

Note that the group as well as the owner have changed.

Advertisements

Do you need to put tablespaces hot backup mode when using RMAN

To understand why RMAN does not require extra logging or backup mode, you must first understand why those features are required for non-RMAN online backups.

A non-RMAN online backup consists of a non-Oracle tool, such as cp or dd, backing up a datafile at the same time that DBWR is updating the file. Oracle can’t prevent the tool from reading a particular block at the exact same time that DBWR is updating that block. When that happens, the non-Oracle tool might read a block in a half-updated state, so that the block which is copied to the backup media might only have been updated in its first half, while the second half contains older data. This is called a “fractured block”. If this backup needs to be restored later, and that block needs to be recovered, recovery will fail because that block is not usable.

The ‘alter tablespace begin backup’ command is oracle solution for the fractured block problem. When a tablespace is in backup mode, and a change is made to a data block, instead of logging just the changed bytes to the redo log, oracle also log a copy of the entire block image before the change, so that it can reconstruct this block if media recovery finds that this block was fractured. That block image logging is what causes extra redo to be generated while files are in backup mode.

The reason that RMAN does not require extra logging is that it guarantees that it will never back up a fractured block. it can make that guarantee because we know the format of Oracle data blocks, and it verify that each block that it read is complete before it copy it to the backup. If it read a fractured block, it will read the block again to obtain a complete block before backing it up. non-Oracle tools are not able to do the same thing because they do not know how to verify the contents of an Oracle data block.

Backup mode has another effect, which is to ‘freeze’ the checkpoint in the header of the file until the file is removed from backup mode. Oracle does this because it cannot guarantee that the third-party backup tool will copy the file header prior to copying the data blocks. RMAN does not need to freeze the file header checkpoint because it knows the order in which it will read the blocks, which enables it to capture a known good checkpoint for the file.

UNIX COMMANDS- AIX Command Crib Sheet

oslevel Returns operating system level

whence (program) Returns full path of program
whereis (program) Returms full path of program

what (program) Displays identifying info from the executable
like version number, when compiled.

lslpp -L all list all installed software
lslpp -L (program set name) Check if software installed
lslpp -f Lists filesets vs packages
lslpp -ha Lists installation history of filesets

instfix -ik (fix number eg IX66617) Checks id fix is installed
instfix -ik 4330-02_AIX_ML

compress -c file.txt > file.Z Create a compressed file.

uuencode (infile) (extract-file-name) > (output file)
Converts a binary file to an ASCII file for transfer by modem or email

uudecode (encoded file)
Extracts a binary file from encoded file and calls it the extract-file-name

examples :-

uuencode maymap maymap > maymap.enc
uuencode maymap.enc

od -c /tmp Displays contents of the /tmp directory file
ls -i Lists files with their inode numbers
echo * Lists files, can be used if ls is corrupt/missing

alog -o -t boot View the boot log

chtz (timezone eg GMT0BST) Changes the timezone in /etc/environment file
chlang (language eg En_GB) Changes the language in /etc/environment file

ar -v -t (archive file) List contents of an archive
ar -v -x (archive file) Extracts the archive
ar -v -t /usr/lib/libC-r.a Lists contents of the libC_r.a library

find /source -print | cpio -pdm /target
Copying directories using cpio, creates /target/source directory.

dump -nTv (binary executable) Displays the contents of an executable file

dump -c Displays string information
dump -o Displays object file headers
dump -l Displays line numbers
dump -s Displays the text section

snap -ao /dev/rmt0 Create a snapshot onto tape
snap -ad (directory) Create a snapshot into a named directory other
than the default (/tmp/ibmsupt)

/usr/dt/bin/dtconfig -d Disables desktop logins
/usr/dt/bin/dtconfig -e Enables desktop logins
/var/dt/Xpid PID of the dtlogin process

——————————————————————————–
TERMINALS
——————————————————————————–

tty Displays what the tty/pty number of the terminal is.

termdef reports the termtype setup in smit for the tty port
that termdef is run on.

chdev -l (device eg tty1) -a term=vt100 Sets tty to a vt100 terminal type

penable tty0 adds getty line into /etc/inittab for tty0 and starts getty
pdisable tty0 disables the getty line and disables getty

penable / pdisable -a option is for all

stty erase ^? Set backspace key for vt100 terminals
stty erase ^H Set backspace key for wyse50 terminals

lscons Displays the console device
chcons -a login=enable (device eg /dev/tty1) Changes the console device

Create ttys on ports 0 to 7 on adapter sa2 :-

for i in 0 1 2 3 4 5 6 7
do
mkdev -c tty1 -t tty -s rs232 -p sa2 -w$i -a login=enable -a term=vt100
done

portmir -t /dev/tty0 Mirror current terminal onto /dev/tty0
portmir -o Turns off port mirroring

——————————————————————————–
NETWORK
——————————————————————————–

host (ip or hostname) Resolves a hostname / ip address

hostname Displays hostname
hostname (hostname) Sets the hostname until next reboot

chdev -l (device name) -a hostname=(hostname) Changes hostname permanently
chdev -l inet0 -a hostname=thomas

ifconfig (device name) Displays network card settings
ifconfig (device name) up Turns on network card
ifconfig (device name) down Turns off network card
ifconfig (device name) detach Removes the network card from the
network interface list
ifconfig en0 inet 194.35.52.1 netmask 255.255.255.0 up

ifconfig lo0 alias 195.60.60.1 Create alias ip address for loopback

route (add/delete) (-net/-host) (destination) (gateway)
Adds or deletes routes to other networks or hosts, does not update
the ODM database and will be lost at reboot.
route add -net 194.60.89.0 194.60.90.4

lsattr -EHl inet0 Displays routes set in ODM and hostname
odmget -q “name=inet0” CuAt Displays routes set in ODM and hostname

refresh -s inetd Refresh inetd after changes to inetd.conf
kill -1 (inetd PID) Refresh inetd after changes to inted.conf

netstat -i Displays interface statistics
entstat -d (ethernet adapter eg en0) Displays ethernet statistics

arp -a Displays ip to mac address table from arp cache

no -a Displays network options use -o to set individual options or
-d to set individual options to default.
no -o option=value (this value is reset at reboot)
no -o “ipforwarding=1”

traceroute (name or ipaddress) Displays all the hops from source to
destination supplied.

ping -R (name or ipaddress) Same as traceroute except repeats.

——————————————————————————–
N.F.S.
——————————————————————————–

exportfs Lists all exported filesystems

exportfs -a Exports all fs’s in /etc/exports file

exportfs -u (filesystem) Un-exports a filesystem

mknfs Configures and starts NFS services

rmnfs Stops and un-configures NFS services

mknfsexp -d /directory Creates an NFS export directory

mknfsmnt Creates an NFS mount directory

mount hostname:/filesystem /mount-point Mount an NFS filesystem

nfso -a Display NFS Options
nfso -o option=value Set an NFS Option
nfso -o nfs_use_reserved_port=1

——————————————————————————–
BACKUPS
——————————————————————————–

MKSYSB
——

mkszfile -f Creates /image.data file (4.x onwards)
mkszfile -X Creates /fs.size file (3.x)

mksysb (device eg /dev/rmt0)

CPIO ARCHIVE
————

find (filesystem) -print | cpio -ocv > (filename or device)

eg find ./usr/ -print | cpio -ocv > /dev/rmt0

CPIO RESTORE
————

cpio -ict < (filename or device) | more Lists archive
cpio -icdv < (filename or device)
cpio -icdv < (filename or device) ("files or directories to restore")

eg cpio -icdv < /dev/rmt0 "tcpip/*" Restore directory and contents
cpio -icdv new.filename
Strips out ^M characters from ascii files that have been transferred as binary.
To enter crontrol characters type ctrl v then ctrl ? where ? is whatever
ctrl character you need.

——————————————————————————–
DEVICES
——————————————————————————–

lscfg lists all installed devices
lscfg -v lists all installed devices in detail
lscfg -vl (device name) lists device details

bootinfo -b reports last device the system booted from
bootinfo -k reports keyswitch position
1=secure, 2=service, 3=normal

bootinfo -r reports amount of memory (/ by 1024)
bootinfo -s (disk device) reports size of disk drive
bootinfo -T reports type of machine ie rspc

lsattr -El sys0 -a realmem reports amount of useable memory

mknod (device) c (major no) (minor no) Creates a /dev/ device file.
mknod /dev/null1 c 2 3

lsdev -C lists all customised devices ie installed
lsdev -P lists all pre-defined devices ie supported
lsdev -(C or P) -c (class) -t (type) -s (subtype)

chdev -l (device) -a (attribute)=(new value) Change a device attribute
chdev -l sys0 -a maxuproc=80

lsattr -EH -l (device) -D Lists the defaults in the pre-defined db
lsattr -EH -l sys0 -a modelname

rmdev -l (device) Change device state from available to defined
rmdev -l (device) -d Delete the device
rmdev -l (device) -SR S stops device, R unconfigures child devices

lsresource -l (device) Displays bus resource attributes of a device.

Power Management (PCI machines)
——————————-

pmctrl -a Displays the Power Management state

rmdev -l pmc0 Unconfigure Power Management
mkdev -l pmc0 Configure Power Management

——————————————————————————–
TAPE DRIVES
——————————————————————————–

rmt0.x where x = A + B + C

A = density 0 = high 4 = low
B = retension 0 = no 2 = yes
C = rewind 0 = no 1 = yes

tctl -f (tape device) fsf (No) Skips forward (No) tape markers
tctl -f (tape device) bsf (No) Skips back (No) tape markers
tctl -f (tape device) rewind Rewind the tape
tctl -f (tape device) offline Eject the tape
tctl -f (tape device) status Show status of tape drive

chdev -l rmt0 -a block_size=512 changes block size to 512 bytes
(4mm = 1024, 8mm = variable but
1024 recommended)

bootinfo -e answer of 1 = machine can boot from a tape drive
answer of 0 = machine CANNOT boot from tape drive

diag -c -d (tape device) Hardware reset a tape drive.

tapechk (No of files) Checks Number of files on tape.

(filename) Output crontab entrys to a file
crontab (filename) Enter a crontab from a file
crontab -r Removes all crontab entrys
crontab -v Displays crontab submission time.

/var/adm/cron/cron.allow File containing users allowed crontab use.
/var/adm/cron/cron.deny File containing users denied crontab use.
/var/adm/cron/crontab Directory containing users crontab entries.

at (now + 2 minutes, 13:05, etc) {return} Schedule a job using at
Command or schell script {return}
{CTRL D}

at -l
atq Lists out jobs scheduled to run via at command

at -r (at job No)
atrm (at job No) Removes an at job scheduled to run.

/var/adm/cron/at.allow File containing users allowed at use.
/var/adm/cron/at.deny File containing users denied at use.
/var/adm/cron/atjobs Directory containing users at entries.

——————————————————————————–
SECURITY
——————————————————————————–

groups Lists out the groups that the user is a member of
setgroups Shows user and process groups

chmod abcd (filename) Changes files/directory permissions

Where a is (4 SUID) + (2 SGID) + (1 SVTX)
b is (4 read) + (2 write) + (1 execute) permissions for owner
c is (4 read) + (2 write) + (1 execute) permissions for group
d is (4 read) + (2 write) + (1 execute) permissions for others

-rwxrwxrwx -rwxrwxrwx -rwxrwxrwx
||| ||| |||
– – –
| | |
Owner Group Others

-rwSrwxrwx = SUID -rwxrwSrwx = SGID drwxrwxrwt = SVTX

chown (new owner) (filename) Changes file/directory owners
chgrp (new group) (filename) Changes file/directory groups

chown (new owner).(new group) (filename) Do both !!!

umask Displays umask settings
umask abc Changes users umask settings

where ( 7 – a = new file read permissions)
( 7 – b = new file write permissions)
( 7 – c = new file execute permissions)

eg umask 022 = new file permissions of 755 = read write and execute for owner
read —– and execute for group
read —– and execute for other

mrgpwd > file.txt Creates a standard password file in file.txt

passwd Change current user password

pwdadm (username) Change a users password

pwdck -t ALL Verifies the correctness of local authentication

lsgroup ALL Lists all groups on the system
mkgroup (new group) Creates a group
chgroup (attribute) (group) Change a group attribute
rmgroup (group) Removes a group

——————————————————————————–
USERS
——————————————————————————–

passwd -f Change current users gecos (user description)
passwd -s Change current users shell

chfn (username) Changes users gecos
chsh (username) (shell) Changes users shell

env Displays values of environment variables
printenv

id Displays current user’s uid and gid details
id (user) Displays user uid and gid details

whoami Displays current user details
who am i (or who -m)

who Displays details of all users currently logged in.
w
who -b Displays system reboot time

uptime Displays number of users logged in, time since last
reboot, and the machine load averages.

lslicense Displays number of current user licensese
chlicense -u (number) Changes the number of user licenses

lsuser ALL Lists all users details
lsuser (username) Lists details for user
lsuser -a(attribute) (username or ALL) Lists user attributes
lsuser -a home ALL

mkuser -a(attributes) (newuser) Add a new user

chuser (attributes) (user) Change a user
chuser login=false (user) Lock a user account

rmuser -p (user) Removes a user and all entries in security files

usrck -t ALL Checks all the user entires are okay.

fuser -u (logical volume) Displays processes using the files in that LV

lsattr -D -l sys0 -a maxuproc Displays max number of processes per user
chdev -l sys0 -a maxuproc=(number) Changes max number of processes per user

——————————————————————————–
REMOTE USERS
——————————————————————————–

ruser -a -f (user) Adds entry into /etc/ftpusers file
ruser -a -p (host) Adds entry into /etc/host.lpd file
ruser -a -r (host) Adds entry into /etc/hosts.equiv file

ruser -d -f (user) Deletes entry in /etc/ftpusers file
ruser -d -p (host) Deletes entry in /etc/host.lpd file
ruser -d -r (host) Deletes entry in /etc/hosts.equiv file

ruser -s -F Shows all entries in /etc/ftpusers file
ruser -s -P Shows all entries in /etc/host.lpd file
ruser -s -R Shows all entries in /etc/hosts.equiv file

ruser -X -F Deletes all entries in /etc/ftpusers file
ruser -X -P Deletes all entries in /etc/host.lpd file
ruser -X -R Deletes all entries in /etc/hosts.equiv file

——————————————————————————–
INITTAB
——————————————————————————–

telinit S Switches to single user mode.
telinit 2 Switches to multi user mode.
telinit q Re-examines /etc/inittab

lsitab -a Lists all entries in inittab
lsitab (ident eg tty1) Lists the tty1 entry in inittab

mkitab (“details”) Creates a new inittab entry
chitab (“details”) Ammends an existing inittab entry

rmitab (ident eg tty1) Removes an inittab entry.

chitab “tty1:2:respawn:/usr/bin/getty /dev/tty1”

——————————————————————————–
ODM
——————————————————————————–

odmget -q “name=lp1” CuDv |more Gets lp1 info from pre-defined database.

odmget -q “name-lp1” CuAt |more Gets lp1 info from customised database.

odmdelete -o CuAt -q “name=lp1” Deletes lp1 info from customised db.

odmget -q “name=lp1” CuAt > lp1.CuAt Export ODM info to text file.
odmadd < lp1.CuAt Import ODM info from text file.

——————————————————————————–
ERROR LOGGING
——————————————————————————–

/usr/lib/errdemon -l Displays errorlog attributes.
/usr/lib/errdemon Starts error logging.
/usr/lib/errstop Stops error logging.

errpt Displays summary errorlog report.
errpt -a Displays detailed errorlog report.
errpt -j (identifier) Displays singe errorlog report.

Note : errorlog classes are H=Hardware S=Software O=Information V=Undetermined

errclear (days) Deletes all error classes in the errorlog.
errclear -d (class) (days) Deletes all error class entries in errlog.

Note : The errclear command will delete all entries older than the numbers of
days specified in the days paramenter. To delete ALL entries used 0.

errlogger "message up to 230 chrs"
Enters an operator notifaction message into the errorlog.

——————————————————————————–
PERFORMANCE MONITORING
——————————————————————————–

vmstat (drive) (interval) (count) Reports virtual memory statistics.
vmstat hdisk0 5 20

vmstat -s Diplays number of paging events since system start.
vmstat -f Diplays number of forks since system start.
vmstat -i Diplays number of interupts by device since system start.

iostat (drive) (interval) (count) Reports i/o and cpu statistics.
iostat hdisk0 5 20

iostat -d (drive) (interval) (count) Limits report to drive statistics.
iostat -t (interval) (count) Limits report to tty statistics.

sar -u -P ALL 10 10 Displays %usr %sys %wio %idle for all processors

——————————————————————————–
DOS DISKETTES
——————————————————————————–

dosdir Reads directory listing of a diskette
dosdir (directory) Reads directory listing of a named directory

dosread -D/dev/fd0 C41.TXT c41.txt Gets C41.TXT from diskette drive fd0

dosread -D/dev/fd0 DIRECTORY/C41.TXT c41.txt
(-D option can be dropped if using fd0)

doswrite -D/dev/fd0 (unixfile) (dosfile) Writes a file to diskette

dosdel (dosfile) Deletes a dos file on diskette

dosformat Formats the diskette

——————————————————————————–
SENDMAIL
——————————————————————————–

sendmail -bi Creates new aliase db from /etc/aliase file.
newaliases

sendmail -bp Displays the contents of the mail queue
mailq

sendmail -q Processe the sendmail queue NOW

sendmail -bt -d0.4 < /dev/null
Prints out sendmail version, compile defines and system information

refresh -s sendmail Restart sendmail
kill -l (sendmail PID)

——————————————————————————–
SP / PSSP
——————————————————————————–

dsh (command) Runs the command on all the nodes

Efence Diplays which node are currently fenced
Efence (node number) Fences the node

Eunfence (node number) Unfences the node

Estart Starts the switch

spmon -q Starts SP monitor in gui
spmon -d -G Diag info, lists LED and switch info for all nodes
spmon -L frame1/node3 Displays LED for node 3 in frame 1

spmon -p off frame1/node3 Powers off the node
spmon -p on frame1/node3 Powers on the node

spled Diplays all the nodes LED's in a updating gui

s1term -w (frame number) (node number) Opens serial terminal (read and write)
s1term (frame number) (node number) Opens serial terminal (read only)

Example :-

s1term 1 1 Opens a serial terminal to console port on frame 1 node 1
which is read only. When rebooting a node use read only.

splstdata -e Lists site environment database information
-d Displays df command from each node
-n Lists node configuration
-h Diplays lscfg command from each node
-s Lists switch node information
-b Lists boot/installation information
-a Lists LAN database information
-i Displays netstat -in command from each node

SCRIPT: what is the session doing

select
–‘alter system kill session ”’|| s.SID||’,’ || s.serial# ||”” ,
–‘kill -9 ‘ || p.spid,
p.SPID UnixProcess ,s.SID,s.serial#,
s.USERNAME,s.COMMAND,s.MACHINE,
s.SQL_ADDRESS,s.SQL_HASH_VALUE
,s.program, cpu_time,fetches,
disk_reads,buffer_gets,rows_processed,
executions,child_latch,event,sql_text,COMMAND_TYPE,
sbc.name,to_char(sbc.last_captured,’yyyy-mm-dd hh24:mi:ss’),
sbc.value_string
from v$session s
join v$process p on p.ADDR = s.PADDR — and p.SID in (27817)
left outer join v$sqlarea sa on sa.ADDRESS = s.SQL_ADDRESS
left outer join V$SQL_BIND_CAPTURE sbc on sbc.ADDRESS = s.SQL_ADDRESS
where 1=1
–and s.program like ‘imp%’
–and s.username =’SIEBEL’
–AND p.SPID in (15179,8304)
–and s.SID in (1019)

ORA-27054: NFS file system where the file is created or resides is not mounted with correct options

NFS Mount Options

You must mount NFS volumes used for storing database files with special mount options on the host where the database server is running. When mounting an NFS file system, Oracle recommends that you use the same mount point options that your NAS vendor used when certifying the device. Refer to your device documentation or contact your vendor for information about recommended mount-point options.

In general, most vendors recommend that you use the NFS mount options listed in the following table.

Option Requirement Description
hard Mandatory Generate a hard mount of the NFS file system. If the connection to the server fails or is temporarily lost, connection attempts are made until the NAS device responds.
bg Optional Try to connect in the background if connection fails.
tcp Optional Use the TCP protocol rather than UDP. TCP is more reliable than UDP.
nfsvers=3 Optional Use NFS version 3. Oracle recommends that you use NFS version 3 where available, unless the performance of version 2 is higher.
suid Optional Allow clients to run executables with SUID enabled. This option is required for Oracle software mount points.
rsize Mandatory The number of bytes used when reading from the NAS device. This value should be set to the maximum database block size supported by this platform. A value of 8192 is often recommended for NFS version 2 and 32768 is often recommended for NFS version 3.
wsize Mandatory The number of bytes used when writing to the NAS device. This value should be set to the maximum database block size supported by this platform. A value of 8192 is often recommended for NFS version 2 and 32768 is often recommended for NFS version 3.
nointr (or intr) Optional Do not allow (or allow) keyboard interrupts to kill a process that is hung while waiting for a response on a hard-mounted file system.

Note: Different vendors have different recommendations about this option. Contact your vendor for advice.

actime=0 or noac Mandatory Disable attribute caching.

Note: You must specify this option for NFS file systems where you want to install the software. If you do not use this option, Oracle Universal Installer will not install the software in the directory that you specify.

The mandatory mount options comprise the minimum set of mount options that you must use while mounting the NFS volumes. These mount options are essential to protect the integrity of the data and to prevent any database corruption. Failure to use these mount options may result in the generation of file access errors. Refer to your operating system or NAS device documentation for more information about the specific options supported on your platform.

For AIX:
cio,rw,bg,hard,nointr,rsize=32768,wsize=32768,proto=tcp,noac,vers=3,timeo=600

For HP-UX:
forcedirectio,rw,bg,hard,nointr,rsize=32768,wsize=32768,proto=tcp,noac,vers=3,timeo=600,suid

Restoring Rman backup on a different node with different backup directory structures and different database directory structures .

Oracle Server – Enterprise Edition – Version: 10.1.0.2 to 11.1.0.8
Information in this document applies to any platform.
Goal

++ Rman backup of database is done on NODE 1.
++ The database has to be has to be restored from the Rman backup on NODE 2.
++ The directory structures for the backups and the database files are different on NODE 2.
++ The Rman backups have to put in new directory structure on NODE 2 unlike as they were on NODE 1.
++ Also the database has to be restored to a different directory structure on NODE 2.
Solution

ASSUMPTIONS
———————–
++ The backups on NODE 1 are done to ‘/node1/database/backup’
++ The database files on NODE 1 are in ‘/node1/database/prod’
++ The backups on NODE 2 will be in location ‘/node2/database/backup’
++ The database files on NODE 2 will be restored to ‘/node2/database/prod

Steps to acheive the goal:

1) Connect to the target database using rman and backup the database —> ON NODE 1
$ rman target /

Recovery Manager: Release 10.2.0.1.0 – Production on Tue Feb 13 00:29:33 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10G (DBID=3932056136)

RMAN> backup database plus archivelog;

Starting backup at 13-FEB-07
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=143 recid=109 stamp=614392105
channel ORA_DISK_1: starting piece 1 at 13-FEB-07
channel ORA_DISK_1: finished piece 1 at 13-FEB-07
piece handle=/node1/database/backup/o1_mf_annnn_TAG20070213T002825_2x21kbds
_.bkp tag=TAG20070213T002825 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 13-FEB-07

Starting backup at 13-FEB-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00003 name=/node1/database/prod/sysaux01.dbf
input datafile fno=00001 name=/node1/database/prod/system01.dbf
input datafile fno=00002 name=/node1/database/prod/undotbs01.dbf
input datafile fno=00004 name=/node1/database/prod/users01.dbf
input datafile fno=00005 name=/node1/database/prod/1.dbf
input datafile fno=00006 name=/node1/database/prod/sysaux02.dbf
input datafile fno=00007 name=/node1/database/prod/undotbs02.dbf
channel ORA_DISK_1: starting piece 1 at 13-FEB-07
channel ORA_DISK_1: finished piece 1 at 13-FEB-07
piece handle=/node1/database/backup/o1_mf_nnndf_TAG20070213T002827_2x21kd12
_.bkp tag=TAG20070213T002827 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
Finished backup at 13-FEB-07

Starting backup at 13-FEB-07
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=144 recid=110 stamp=614392165
channel ORA_DISK_1: starting piece 1 at 13-FEB-07
channel ORA_DISK_1: finished piece 1 at 13-FEB-07
piece handle=/node1/database/backup/o1_mf_annnn_TAG20070213T002925_2x21m6ty
_.bkp tag=TAG20070213T002925 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 13-FEB-07

Starting Control File and SPFILE Autobackup at 13-FEB-07
piece handle=/u01/oracle/product/ora10g/dbs/c-3932056136-20070213-02 comment=NONE
Finished Control File and SPFILE Autobackup at 13-FEB-07

RMAN> exit

2) Move the following files to the NODE 2:

+ The database backup pieces to location ‘/node2/database/backup’
+ Controlfile backup piece to the location ‘/node2/database/backup’
+ The parameter file i.e init.ora file to the default location i.e $ORACLE_HOME/dbs

3) Edit the PFILE on NODE 2 to change the environment specific parameters like .
user_dump_dest =
background_dump_dest =
control_files =

4) Once the PFILE is suitably modified invoke Rman on the NODE 2 after setting the Oracle environment variables and start the database in nomount mode:

[oracle@test-br test]$ export ORACLE_HOME=/u01/oracle/product/ora10g
[oracle@test-br test]$ export ORACLE_SID=ora10g
[oracle@test-br test]$ export PATH=$ORACLE_HOME/bin:$PATH
[oracle@test-br test]$ rman target /
Recovery Manager: Release 10.2.0.1.0 – Production on Tue Feb 13 00:36:55 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup nomount
Oracle instance started
Total System Global Area 205520896 bytes
Fixed Size 1218508 bytes
Variable Size 75499572 bytes
Database Buffers 121634816 bytes
Redo Buffers 7168000 bytes

5) Restore the controlfile from the backup piece.
RMAN> restore controlfile from ‘/node2/database/backup/c-3932056136-20070213-02’;
Starting restore at 13-FEB-07
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete,
elapsed time: 00:00:02
output filename=/node2/database/prod/control01.ctl
Finished restore at 13-FEB-07

6) Mount the database
RMAN > alter database mount

7) Now catalog the backup pieces that were shipped from NODE 1

RMAN> catalog backuppiece ‘/node2/database/backup/o1_mf_annnn_TAG20070213T002925_2x21m6ty_.bkp’;

RMAN> catalog backuppiece ‘/node2/database/backup/o1_mf_annnn_TAG20070213T002825_2x21kbds_.bkp’;

RMAN> catalog backuppiece ‘/node2/database/backup/o1_mf_nnndf_TAG20070213T002827_2x21kd12_.bkp’;

This feature of cataloging backup pieces is available from ORACLE 10g versions. Prior to Oracle 10g we were not able to catalog the backup pieces. For more information on cataloging options refer the metalink note 470463.1

8) Get to know the last sequence available in the archivelog backup using the following command.This will help us in recovering the database till that archivelog.

RMAN > list backup of archivelog all;

Let us assume the last sequence of last archivelog in the backup is 50.

9) Rename the Redologfiles,so that they can be created in new locations when opened the database is opened in resetlogs

SQL> alter database rename file ‘/node1/database/prod/redo01.log’ to ‘/node2/database/prod/redo01.log’;
……
……
……

10) Now restore the datafiles to new locations and recover. Since we are recovering the database here till the archivelog sequence 50 the sequence number in the SET UNTIL SEQUENCE clause should be 50 (+1)

RMAN> run
{
set until sequence 51;
set newname for datafile 1 to ‘/node2/database/prod/sys01.dbf’;
set newname for datafile 2 to ‘/node2/database/prod/undotbs01.dbf’;
set newname for datafile 3 to ‘/node2/database/prod/sysaux01.dbf’;
set newname for datafile 4 to ‘/node2/database/prod/users01.dbf’;
set newname for datafile 5 to ‘/node2/database/prod/1.dbf’;
set newname for datafile 6 to ‘/node2/database/prod/sysaux02.dbf’;
set newname for datafile 7 to ‘/node2/database/prod/undotbs02.dbf’;
restore database;
switch datafile all;
recover database;
alter database open resetlogs;
}