Sunday, 9 September 2012

Health Check Scripts for R12 APPS/DB
1.Display disk free space in Linux
         df -h
2.Display Memory Usage in Linux
         free -m
3.List the processes running on the system & to check load averages
         top
4.Process status of the database
         ps -ef | grep pmon
5.Process status of the listener
         ps -ef | grep tns

6.sqlplus / as sysdba

6(i).To find the size of the tablespaces

set pages 999
col tablespace_name format a40
col "size MB" format 999,999,999
col "free MB" format 99,999,999
col "% Used" format 999
select tsu.tablespace_name, ceil(tsu.used_mb) "size MB"
, decode(ceil(tsf.free_mb), NULL,0,ceil(tsf.free_mb)) "free MB"
, decode(100 - ceil(tsf.free_mb/tsu.used_mb*100), NULL, 100,
               100 - ceil(tsf.free_mb/tsu.used_mb*100)) "% used"
from (select tablespace_name, sum(bytes)/1024/1024 used_mb
from dba_data_files group by tablespace_name union all
select tablespace_name || '  **TEMP**'
, sum(bytes)/1024/1024 used_mb
from dba_temp_files group by tablespace_name) tsu
, (select tablespace_name, sum(bytes)/1024/1024 free_mb
from dba_free_space group by tablespace_name) tsf
where tsu.tablespace_name = tsf.tablespace_name (+)
order by 4
/

6(ii).To find the Database size 

col "Database Size" format a20
col "Free space" format a20
col "Used space" format a20
select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || ' GB' "Database Size"
, round(sum(used.bytes) / 1024 / 1024 / 1024 ) - 
round(free.p / 1024 / 1024 / 1024) || ' GB' "Used space"
, round(free.p / 1024 / 1024 / 1024) || ' GB' "Free space"
from    (select bytes
from v$datafile
union all
select bytes
from v$tempfile
union all
select bytes
from v$log) used
, (select sum(bytes) as p
from dba_free_space) free
group by free.p
/

6(iii).To find the INVALID objects
select count (*) from dba_objects where status='INVALID';

6(iv).To find the location of the alertlog files
show parameter background_dump_dest;

7.To find the total library process running
ps -fu $LOGNAME | grep -i libr | wc -l


OAD stopped error while starting APPS11i
While i am trying to start the APPS 11i i got this error with exit status 1.

/ebiz/alsumora/8.0.6/vbroker/bin/osagent
Started osagent.
Osagent logs messages to the file /ebiz/alsumora/8.0.6/discwb4/util/osagent.log.
Waiting for OAD to start...
Started OAD.
OAD logs messages to the file /ebiz/alsumora/8.0.6/discwb4/util/oad.log.
Failed to start locator.
Cannot bind to OAD. Re-starting...

OAD is stopped
Osagent is stopped
Unable to stop locator. No process-id  file found.
Unable to stop gatekeeper. No process-id  file found.
Unable to stop any Discoverer Sessions. No process-id  file found.
Unable to stop any Discoverer Preference. No process-id  file found.
Unable to stop any Discoverer Collector. No process-id  file found.
/ebiz/alsumora/8.0.6/vbroker/bin/osagent
Started osagent.
Osagent logs messages to the file /ebiz/alsumora/8.0.6/discwb4/util/osagent.log.
Waiting for OAD to start...
Started OAD.
OAD logs messages to the file /ebiz/alsumora/8.0.6/discwb4/util/oad.log.
Failed to start locator.
Registering Discoverer Session
Registering the Collector
Applying preferences from file : /ebiz/alsumora/8.0.6/discwb4/util/pref.txt
Finished applying preferences
Registering Discoverer Preference Repository

addisctl.sh: exiting with status 1


.end std out.
/ebiz/alsumora/8.0.6/jre1183o/lib/i686/green_threads/libzip.so: symbol errno, version GLIBC_2.0 not defined in file libc.so.6 with link time reference (libzip.so)
Unable to initialize threads: cannot find class java/lang/Thread
Could not create Java VM
/ebiz/alsumora/8.0.6/jre1183o/lib/i686/green_threads/libzip.so: symbol errno, version GLIBC_2.0 not defined in file libc.so.6 with link time reference (libzip.so)
Unable to initialize threads: cannot find class java/lang/Thread
Could not create Java VM
/ebiz/alsumora/8.0.6/jre1183o/lib/i686/green_threads/libzip.so: symbol errno, version GLIBC_2.0 not defined in file libc.so.6 with link time reference (libzip.so)
Unable to initialize threads: cannot find class java/lang/Thread
Could not create Java VM
/ebiz/alsumora/8.0.6/jre1183o/lib/i686/green_threads/libzip.so: symbol errno, version GLIBC_2.0 not defined in file libc.so.6 with link time reference (libzip.so)
Unable to initialize threads: cannot find class java/lang/Thread
Could not create Java VM
/ebiz/alsumora/8.0.6/jre1183o/lib/i686/green_threads/libzip.so: symbol errno, version GLIBC_2.0 not defined in file libc.so.6 with link time reference (libzip.so)
Unable to initialize threads: cannot find class java/lang/Thread
Could not create Java VM
/ebiz/alsumora/8.0.6/jre1183o/lib/i686/green_threads/libzip.so: symbol errno, version GLIBC_2.0 not defined in file libc.so.6 with link time reference (libzip.so)
Unable to initialize threads: cannot find class java/lang/Thread
Could not create Java VM
Memory fault
/ebiz/alsumora/8.0.6/jre1183o/lib/i686/green_threads/libzip.so: symbol errno, version GLIBC_2.0 not defined in file libc.so.6 with link time reference (libzip.so)
Unable to initialize threads: cannot find class java/lang/Thread
Could not create Java VM

.end err out.

****************************************************


Check logfile /ebiz/alsumcomn/admin/log/ALSUM_oracle11i/04131720.log for details

Exiting with status 1

The solution for the above error is to change / assume the kernel version

SOLUTION:
LD_ASSUME_KERNEL=2.4.19
export LD_ASSUME_KERNEL


Wednesday, 5 September 2012

Oracle  Archive Log Mode  

General
Note: Archive logging is essential for production databases where the loss of a transaction might be fatal. It is generally considered unnecessary in development and test environments.
Init.ora Parameters

Configure for multiple archiver processes
log_archive_max_processes=<integer>;
SELECT value
FROM gv$parameter
WHERE name = 'log_archive_max_processes';

ALTER SYSTEM SET log_archive_max_processes=3;

SELECT value
FROM gv$parameter
WHERE name = 'log_archive_max_processes';
Startup The Database In Archivelog Mode

Steps Required To Take A Database Not In Archive Log Mode And Alter It To Archive Log Mode
SELECT log_mode
FROM v$database;

SHUTDOWN;

STARTUP MOUNT EXCLUSIVE;

ALTER DATABASE ARCHIVELOG;

ALTER DATABASE OPEN;

SELECT log_mode
FROM v$database;
Startup The Database In NoArchivelog Mode

Steps Required To Take A Database In Archive Log Mode And Alter It To No Archive Log Mode
SELECT log_mode
FROM v$database;

SHUTDOWN;

STARTUP MOUNT EXCLUSIVE;

ALTER DATABASE NOARCHIVELOG;

ALTER DATABASE OPEN;

SELECT log_mode
FROM v$database;
Restart After Archiving Logging Failure
Archive Logging RestartSHUTDOWN;

STARTUP;

ARCHIVE LOG START;

ARCHIVE LOG ALL;
Archive Log Related Commands
Start Archive Loggingalter system archive log start;
Stop Archive Loggingalter system archive log stop;
Force archiving of all log filesalter system archive log all;
Force archiving of the current log filealter system archive log current;
Shell Scripts

Move Archive Logs
export ARCH_DIR="/tmp/rim"
NEW_DIR ="/tmp/rim/new_dir"
export FILE_EXT="arc"
export MOVELIST="/tmp/move.list"
export CALF="/tmp/calc.tmp"
export TMPF="/tmp/workfile.tmp"
CMD="ls -ltr $ARCH_DIR/*.$FILE_EXT | awk {'print $9'}
    | sort -r > $TMPF"
export FILE_COUNT="

echo "Number of files found is $FILE_COUNT"
cat $TMPF
echo $FILE_COUNT< - 1" > $CALF
echo "quit" >> $CALF
MOVE ="/usr/bin/bc/ $CALF"
echo "Number of files to move is $MOVE"
/usr/bin/tail -$MOVE $TMPF > $MOVELIST
echo "File to be moved"
cat $MOVELIST
while read FILE
do

echo "Moving file $FILE to $NEW_DIR"
done < $MOVELIST
Start / Stop Services in Oracle Applications R12 ( Database & Application Tier)

Step by step instructions of How to Start/Stop services in Oracle Applications R12 are shown Below.

Specifications :

Application Tier O.S. User : applmgr (applmgr is default password )
Database Tier O.S. User : oracle (oracle is default password )
R12 install base : /oracle/apps/r12/Testr12
Database SID : Test
Database Version : 11.1.0
Hostname : hostr12
Operating System : Unix/Linux
Apps Schema Password : apps (apps is default password) 

1.Start-Up Order :
1.1.Start the database tier
1.2.Start the Application tier.

2.Shut-down Order :
2.1.Stop the Application tier
2.2.Stop the  database  tier.

1.Start-Up Order:
1.1.Start Database Tier
    (i) Login as database tier user (oracle)
    (ii) Set environment variable 
           - cd /oracle/apps/r12/Testr12/db/tech_st/11.1.0 ( $Home/db/tech_st/11.1.0 )
           - . Test_hostr12.com ( $SID_hostname.env  )
    (iii) Start database
          - sqlplus “/as sysdba”
          - SQL> startup
    (iv) 
Start Database Listener (lsnrctl start $SID)
           - lsnrctl start Test

1.2.Start Application Tier
    (i) Login as application tier user (oracle)
    (ii) Set environment variable 
           - cd /oracle/apps/r12/Testr12/apps/apps_st/appl
           - . Test_hostr12.com ( $SID_hostname.env  )
    (iii) Start Application Tier 
           - cd $ADMIN_SCRIPTS_HOME
           - . /adstrtal.sh apps/apps  (adstrtall.sh apps/appspassword)

2.Shut-down Order : 
2.1.Stop the Application tier
    (i) Login as application tier user (oracle)
    (ii) Set environment variable 
           - cd /oracle/apps/r12/Testr12/apps/apps_st/appl
           - . Test_hostr12.com ( $SID_hostname.env  )
    (iii) Stop Application Tier 
          - cd $ADMIN_SCRIPTS_HOME
          - . /adstpall.sh apps/apps  (adstpall.sh apps/appspassword)

2.2.Stop the  database  tier
    (i) Login as database tier user (oracle)
    (ii) Set environment variable 
           - cd /oracle/apps/r12/Testr12/db/tech_st/11.1.0 ( $Home/db/tech_st/11.1.0 )
           - . Test_hostr12.com ( $SID_hostname.env  )
    (iii) Stop database
          - sqlplus “/as sysdba”
          - SQL> Shutdown immediate
    (iv) 
Stop Database Listener 
           - lsnrctl stop Test


Delete Apache log files :
Stop the Apache.
delete all the log files from
$IAS_ORACLE_HOME/Apache/Apache/logs
$IAS_ORACLE_HOME/Apache/Jserv/logs/jvm
$IAS_ORACLE_HOME/Apache/Jserv/logs
Start the Apache

Upgrade from 9i to 10g Release 2 Manually

   This procedure describes the steps necessary to manually upgrade a database from 9.2.x to 10.2.x. It assumes that you have already installed 10g onto the server. Of course, it is essential that you take a backup of your database before attempting any upgrade.

  • 1. Compile any invalid objects
@?/rdbms/admin/utlrp.sql
  • 2. Create a sysaux tablespace
Having a sysaux tablespace is a requirement in 10g. So, if you haven't already got one, create one now.
create tablespace sysaux
datafile '<file_name>' size 512M
extent management local
segment space management auto
/
  • 3. Run utlu102i.sql
This utility script checks that the database is ready to be upgraded to 10g. It also identifies any actions that need to be taken. The script is located in the 10g oracle home, so you will need to specify the full path to it.
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/utlu102i.sql
Review the output and make any necessary alterations. Make a note of how many invalid objects there are.

  • 4. Shut the database down with either normal or immediate
shutdown immediate
  • 5. Copy the spfile (or pfile) and the password file from the existing home to the 10g one.
cp ${ORACLE_HOME}/dbs/*${ORACLE_SID}* <new_home>/dbs/
  • 6. Edit oratab
Alter /etc/oratab (or /var/opt/oracle/oratab) to point to the10g home. Once done, rerun oraenv to bring the alteration into effect.

  • 7. Upgrade the database
sqlplus "/ as sysdba"

startup upgrade
This next bit is the upgrade itself. It takes roughly half an hour to complete. Spool the output to a file so that you can review it afterward.
@?/rdbms/admin/catupgrd.sql
  • 8. Recompile any invalid objects
@?/rdbms/admin/utlrp.sql
Compare the number of invalid objects with the number noted in step 3. It should hopefully be the same or less.

  • 9. Then check the status of the upgrade
@?/rdbms/admin/utlu102s.sql
  • 10. Alter or remove initialisation parameters
Temporarily creating a pfile is the easiest way.
create pfile from spfile;

shutdown immediate

vi ${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora
Alter/remove parameters identified in step 9. Set compatible to 10.2.0.0.0
startup

create spfile from pfile;

shutdown immediate

startup
That's it!

Renaming or Moving Oracle Data Files & Control Files

This article presents a brief explanation of how assorted Oracle files can be renamed or moved to a new location. The examples are based on a default Oracle 10g installation on Windows, but the method is the same for different versions of Oracle on any platform, with the exception of the host command used to rename the file.

Controlfiles

The current location of the controlfiles can be queried from the V$CONTROLFILE view, as shown below.
SQL> select name from v$controlfile;

NAME
-------------------------------------------------------------
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL01.CTL
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL02.CTL
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL03.CTL

3 rows selected.

SQL>
In order to rename or move these files we must alter the value of the control_files instance parameter.
SQL> show parameter control_files

NAME                                 TYPE                             VALUE
------------------------------------ -------------------------------- ------------------------------
control_files                        string                           C:\ORACLE\ORADATA\DB10G\CONTRO
                                                                      L01.CTL, C:\ORACLE\ORADATA\DB1
                                                                      0G\CONTROL02.CTL, C:\ORACLE\OR
                                                                      ADATA\DB10G\CONTROL03.CTL
SQL>
To move or rename a controlfile do the following.
  • Alter the control_files parameter using the ALTER SYSTEM comamnd.
  • Shutdown the database.
  • Rename the physical file on the OS.
  • Start the database.
The following SQL*Plus output shows how this is done for an instance using an spfile. For instances using a pfile replace the spfile manipulation steps with an amendment of the parameter in the init.ora file.
SQL> ALTER SYSTEM SET control_files='C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_CONTROL01.CTL', -
> 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL02.CTL', -
> 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL03.CTL' SCOPE=SPFILE;

System altered.

SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> HOST MOVE C:\ORACLE\ORADATA\DB10G\CONTROL01.CTL C:\ORACLE\ORADATA\DB10G\RENAME_CONTROL01.CTL

SQL> STARTUP
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                   787968 bytes
Variable Size              61864448 bytes
Database Buffers          104857600 bytes
Redo Buffers                 262144 bytes
Database mounted.
SQL>
Repeating the initial query shows that the the controlfile has been renamed in the data dictionary.
SQL> select name from v$controlfile;

NAME
-------------------------------------------------------------
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_CONTROL01.CTL
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL02.CTL
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL03.CTL

3 rows selected.

SQL>

Logfiles

The current location of the logfiles can be queried from the V$LOGFILE view, as shown below.
SQL> SELECT member FROM v$logfile;

MEMBER
-------------------------------------------------
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO03.LOG
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO02.LOG
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO01.LOG

3 rows selected.

SQL>
To move or rename a logfile do the following.
  • Shutdown the database.
  • Rename the physical file on the OS.
  • Start the database in mount mode.
  • Issue the ALTER DATABASE RENAME FILE command to rename the file within the Oracle dictionary.
  • Open the database.
The following SQL*Plus output shows how this is done.
SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> HOST MOVE C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO01.LOG C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_REDO01.LOG

SQL> STARTUP MOUNT
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                   787968 bytes
Variable Size              61864448 bytes
Database Buffers          104857600 bytes
Redo Buffers                 262144 bytes
Database mounted.
SQL> ALTER DATABASE RENAME FILE 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO01.LOG' -
>  TO 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_REDO01.LOG';

Database altered.

SQL> ALTER DATABASE OPEN;

Database altered.

SQL>
Repeating the initial query shows that the the logfile has been renamed in the data dictionary.
SQL> SELECT member FROM v$logfile;

MEMBER
-------------------------------------------------
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO03.LOG
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO02.LOG
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_REDO01.LOG

3 rows selected.

SQL>

Datafiles


Manual

The process for manually renaming a datafile is the same as renaming a logfile, but for the same of clarity it is repeated below. The current location of the datafiles can be queried from the V$DATAFILE view, as shown below.
SQL> SELECT name FROM v$datafile;

NAME
---------------------------------------------------------
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\SYSTEM01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\UNDOTBS01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\SYSAUX01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\USERS01.DBF

4 rows selected.

SQL>
To move or rename a datafile do the following.
  • Shutdown the database.
  • Rename the physical file on the OS.
  • Start the database in mount mode.
  • Issue the ALTER DATABASE RENAME FILE command to rename the file within the Oracle dictionary.
  • Open the database.
The following SQL*Plus output shows how this is done.
SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> HOST MOVE C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\USERS01.DBF C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_USERS01.DBF

SQL> STARTUP MOUNT
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                   787968 bytes
Variable Size              61864448 bytes
Database Buffers          104857600 bytes
Redo Buffers                 262144 bytes
Database mounted.
SQL> ALTER DATABASE RENAME FILE 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\USERS01.DBF' -
>  TO 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_USERS01.DBF';

Database altered.

SQL> ALTER DATABASE OPEN;

Database altered.

SQL>
Repeating the initial query shows that the the datafile has been renamed in the data dictionary.
SQL> SELECT name FROM v$datafile;

NAME
---------------------------------------------------------
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\SYSTEM01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\UNDOTBS01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\SYSAUX01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_USERS01.DBF

4 rows selected.

SQL>

RMAN

RMAN can be used to move files with less downtime by copying them in advance of the move, then recovering them as part of the move itself. First, log in to RMAN and list the current files.
RMAN> REPORT SCHEMA;

Report of database schema for database with db_unique_name DB11G

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    750      SYSTEM               ***     /u01/app/oracle/oradata/DB11G/system01.dbf
2    1150     SYSAUX               ***     /u01/app/oracle/oradata/DB11G/sysaux01.dbf
3    444      UNDOTBS1             ***     /u01/app/oracle/oradata/DB11G/undotbs01.dbf
4    120      USERS                ***     /u01/app/oracle/oradata/DB11G/users01.dbf
5    345      EXAMPLE              ***     /u01/app/oracle/oradata/DB11G/example01.dbf
8    3277     SOE                  ***     /u01/app/oracle/product/11.2.0.2/db_1/dbs/soe.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    370      TEMP                 32767       /u01/app/oracle/oradata/DB11G/temp01.dbf

RMAN>
Copy the file(s) to the new location.
RMAN> COPY DATAFILE 8 TO '/u01/app/oracle/oradata/DB11G/soe.dbf';
Turn the tablespace to offline. We could have turned the tablespace offline before the copy, removing the need for a recovery, but the tablespace would have been offline longer using that method.
RMAN> SQL 'ALTER TABLESPACE soe OFFLINE';
Switch to the new datafile copy(s) and recover the tablespace.
RMAN> SWITCH DATAFILE 8 TO COPY;
RMAN> RECOVER TABLESPACE soe;
Turn the tablespace online again.
RMAN> SQL 'ALTER TABLESPACE soe ONLINE';
Remove the old datafile(s).
RMAN> HOST 'rm /u01/app/oracle/product/11.2.0.2/db_1/dbs/soe.dbf';
Listing the current files shows the move is complete.
RMAN> REPORT SCHEMA;

Report of database schema for database with db_unique_name DB11G

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    750      SYSTEM               ***     /u01/app/oracle/oradata/DB11G/system01.dbf
2    1150     SYSAUX               ***     /u01/app/oracle/oradata/DB11G/sysaux01.dbf
3    444      UNDOTBS1             ***     /u01/app/oracle/oradata/DB11G/undotbs01.dbf
4    120      USERS                ***     /u01/app/oracle/oradata/DB11G/users01.dbf
5    345      EXAMPLE              ***     /u01/app/oracle/oradata/DB11G/example01.dbf
8    3277     SOE                  ***     /u01/app/oracle/oradata/DB11G/soe.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    370      TEMP                 32767       /u01/app/oracle/oradata/DB11G/temp01.dbf

RMAN>
Moving the SYSTEM tablespace is possible using a similar method, but the database must be shutdown and mounted before the switch and recover can be done.

Recreating the Controlfile

For largescale rearrangements it may be easier to manipulate the controlfile contents manually by backing up the controlfile to trace.
SQL> CONN sys/password AS SYSDBA
Connected.
SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE;

Database altered.

SQL>
The resulting trace file in the user_dump_dest directory contains commands and instructions for recreating the controlfile. The paths in the CREATE CONTROLFILE command can be manipulated to rename all datafiles and logfiles on one step.
This is quite a drastic step and it may affect the usefulness of existing backups, especially if the controlfile is being used as the recovery catlog.

    Basic vi editor commands for RHEL OS

   Redhat
    Basic vi commands while in command mode
  • To invoke  vi editor type ‘vi’ <filename> on the command line.
  • vi filename

 Input CommandDescription
ddDelete line
3dd Delete 3 lines
dwDelete word
4dwDelete 4 words
ESCTerminate insert mode
Undo last change
Undo all changes to entire line
h/j/k/lMove cursor left/down/up/right
spacebarMove cursor right one space
ctrl-dScroll down one half of a page
ctrl-dScroll down one half of a page
ctrl-uScroll up one half of a page
ctrl-fScroll forward one page
ctrl-bScroll back one page
ggFor going to top of file
shift+gFor bottom of file
/wordFor searching the word in Entire File
yyFor copying
3yywill copy 3 lines
pFor pasting
x10delete (cut) 10 characters
: uundo last command
:%s/apple/ball/gIt searches and replaces all the occurrence of word apple with ball  in the entire file




Enabling ARCHIVELOG Mode

If your going to enable archivelog mode on a real database thats important to you, I would recommend shutting down the database and doing a cold backup just in case. Keeping a "final noarchivelog mode backup" seems to be a good and excepted practice.
Lets start by checking the current archive mode.


SQL> SELECT LOG_MODE FROM SYS.V$DATABASE;

LOG_MODE
------------
NOARCHIVELOG


So we're in NOARCHIVELOG mode and we need to change.
We can use a database alter statement, but that won't be perminant, so lets just update the pfile directly.
The pfile should be in either $ORACLE_BASE/admin/SID/pfile or $ORACLE_HOME/admin/SID/pfile.


I'll add the following lines to the end of the file:
############################
# Archive Log Destinations
############################
log_archive_dest_1='location=/u01/oradata/dir/archive'
log_archive_start=TRUE


Now we can startup the database in mount mode and put it in archivelog mode.


[oracle@oracle11i ~]$ sqlplus sys/passwd as sysdba
SQL*Plus: Release 11.2.0.2.0 - Production on Wed Sep 04 16:00:58 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to an idle instance.


SQL> startup mount
ORACLE instance started.
Total System Global Area 184549376 bytes

Fixed Size 1300928 bytes
Database Buffers 25165824 bytes

Variable Size 157820480 bytes 
Redo Buffers 262144 bytes
Database mounted.


SQL> alter database archivelog;
Database altered.


SQL> alter database open;
Database altered.


SQL> select log_mode from v$database;

LOG_MODE
 ------------
ARCHIVELOG

Thus the database is enabled in archivelog mode.
System views that can provide us with information reguarding archives are listed below:


V$DATABASE

Identifies whether the database is in ARCHIVELOG or NOARCHIVELOG mode and whether MANUAL (archiving mode) has been specified.

V$ARCHIVED_LOG
Displays historical archived log information from the control file. If you use a recovery catalog, the RC_ARCHIVED_LOG view contains similar information.

V$ARCHIVE_DEST
Describes the current instance, all archive destinations, and the current value, mode, and status of these destinations.


V$ARCHIVE_PROCESSES

Displays information about the state of the various archive processes for an instance.

V$BACKUP_REDOLOG
Contains information about any backups of archived logs. If you use a recovery catalog, the RC_BACKUP_REDOLOG contains similar information.

V$LOG
Displays all redo log groups for the database and indicates which need to be archived.

V$LOG_HISTORY
Contains log history information such as which logs have been archived and the SCN range for each archived log.