operations like OS patching and does not want clusterware to start the daemons automatically.
1. 0 /dev/sda5
2. 0 /dev/sda6
Located 3 voting disk(s).
Some stories mostly on Oracle related things I like to share
| Command | Purpose | Sample Usage |
| sp_helpdb | This gives you information about all databases in the instance or specific information about one database. |
|
| fn_virtualfilestats | This command will show you the number of read and writes to a data file. Use sp_helpdb with the database name to see the logical file numbers for the data files and the database id. |
|
| fn_get_sql() | Returns the text of the SQL statement for the specified SQL handle. This is similar to using DBCC INPUTBUFFER, but this command will show you additional information. This can also be embedded in a process easier then using the DBCC commandMSSQLTips additional info |
|
| sp_lock | This command shows you all of the locks that the system is currently tracking This is similar to information you can see in Enterprise Manager. |
|
| sp_help | This command gives you information about the objects within a database. The command without an objectname will give you a list of all objects within the database. |
|
| sp_who2 | Gives you process information similar to what you see when using Enterprise Manager. |
|
| sp_helpindex | Gives you information about the indexes on a table as well as the columns used for the index.MSSQLTips additional info |
|
| sp_spaceused | This command shows you how much space has been allocated for the database (or if specified an object) and how much space is being used. |
|
| DBCC CACHESTATS | Displays information about the objects currently in the buffer cache. |
|
| DBCC CHECKDB | This will check the allocation of all pages in the database as well as check for any integrity issues. |
|
| DBCC CHECKTABLE | This will check the allocation of all pages for a specific table or index as well as check for any integrity issues. |
|
| DBCC DBREINDEX | This command will reindex your table. If the indexname is left out then all indexes are rebuilt. If the fillfactor is set to 0 then this will use the original fillfactor when the table was created.MSSQLTips additional info |
|
| DBCC PROCCACHE | This command will show you information about the procedure cache and how much is being used. Spotlight will also show you this same information. |
|
| DBCC MEMORYSTATUS | Displays how the SQL Server buffer cache is divided up, including buffer activity. |
|
| DBCC SHOWCONTIG | This command gives you information about how much space is used for a table and indexes. Information provided includes number of pages used as well as how fragmented the data is in the database. |
|
| DBCC SHOW_STATISTICS | This will show how statistics are laid out for an index. You can see how distributed the data is and whether the index is really a good candidate or not. |
|
| DBCC SHRINKFILE | This will allow you to shrink one of the database files. This is equivalent to doing a database shrink, but you can specify what file and the size to shrink it to. Use the sp_helpdb command along with the database name to see the actual file names used.MSSQLTips additional info |
|
| DBCC SQLPERF | This command will show you much of the transaction logs are being used. |
|
| DBCC TRACEON | This command will turn on a trace flag to capture events in the error log. Trace Flag 1204 captures Deadlock information. |
|
| DBCC TRACEOFF | This command turns off a trace flag. |
Explains the RMAN Image copy feature and incrementally updated backups New in Oracle 10G.
• Rman is configured with Recovery Catalog.
• Recovery Catalog Database Name-Orcl
• Database Name test is taken for demo
• Database Test is Running in no archive log mode
• Configured Backup location is 'D:\ORACLE\RMAN\ORA10G'
• During the first and second run of the backup scripts I made some changes in the Database. Also during the second and the third run I made some changes in the Database.
Expanded Image Copying Features: A standard RMAN backup set contains one or more backup pieces, and each of these pieces consists of the data blocks for a particular datafile stored in a special compressed format. When a datafile needs to be restored, therefore, the entire datafile essentially needs to be recreated from the blocks present in the backup piece.
An image copy of a datafile, on the other hand, is much faster to restore because the physical structure of the datafile already exists. Oracle 10g now permit image copies to be created at the database, tablespace, or datafile level through the new RMAN directive BACKUP AS COPY. For example, here is a command script to create image copies for all datafiles in the entire database:
Backup Procedure
Step 1 : Create a image copy of full database
RUN {
ALLOCATE CHANNEL dbkp1 DEVICE TYPE DISK FORMAT 'D:\oracle\rman\ora10G\U%';
BACKUP AS COPY DATABASE; }
Step 2 : Backup incrementally and restore to the image copy
RUN {
# Roll forward any available changes to image copy files
# From the previous set of incremental Level 1 backups
RECOVER COPY OF DATABASE WITH TAG 'cool';
# Create incremental level 1 backup of all datafiles in the database
# For roll-forward application against image copies
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'cool' DATABASE; }
Restore/recovery procedure
In case of a disaster you can now tell rman to just change the locations of the datafiles in the controlfile to the image copies by issuing the following:
RMAN> alter database mount;
RMAN> switch database to copy;
If you want to restore the database
RMAN > restore database;
RMAN > recover database;
from V$ACTIVE_SESSION_HISTORY where event like 'log file sync' AND SESSION_ID=506 group by SESSION_ID,user_id,sql_id,round(sample_time,'hh') order by count(*) desc |
where sql_id='dwbbdanhf7p4a' Another ways from Oracle metalink is by checking block_changes SELECT s.sid, s.serial#, s.username, s.program, i.block_changes FROM v$session s, v$sess_io i WHERE s.sid = i.sid ORDER BY 5 , 1, 2, 3, 4; |
|
FROM dba_hist_seg_stat dhss, dba_hist_seg_stat_obj dhso, dba_hist_snapshot dhs WHERE dhs.snap_id = dhss.snap_id AND dhs.instance_number = dhss.instance_number AND dhss.obj# = dhso.obj# AND dhss.dataobj# = dhso.dataobj# AND begin_interval_time BETWEEN to_date(’2012_01_19 18',’YYYY_MM_DD HH24') AND to_date(’2012_01_19 19',’YYYY_MM_DD HH24') GROUP BY dhso.object_name order by sum(db_block_changes_delta) desc SELECT distinct dbms_lob.substr(sql_text,4000,1) FROM dba_hist_sqlstat dhss, dba_hist_snapshot dhs, dba_hist_sqltext dhst WHERE upper(dhst.sql_text) LIKE ‘%INT_UPLOAD_STATUS%’ AND dhss.snap_id=dhs.snap_id AND dhss.instance_Number=dhs.instance_number AND dhss.sql_id = dhst.sql_id and rownum<2; |
|
{ allocate channel c1 type disk; allocate channel c2 type disk; backup database plus archivelog; backup current controlfile; } |
|
RMAN> set dbid=<dbid from 32 server>; + Restore the controlfile RMAN> restore controlfile from '/disk1/backup/backup_piece_name'; RMAN> alter database mount; RMAN> restore database; |
|
{ set until sequence xxxx; recover database; } RMAN> exit + Migrating to 64 bit SQL> recover database until cancel using backup controlfile; cancel SQL> alter database open resetlogs migrate; SQL> @ ?/rdbms/admin/utlirp.sql Now you must restart the database and explicitly invoke utlrp.sql to recompile invalid objects. SQL> shutdown immediate; SQL> startup; SQL> @ ?/rdbms/admin/utlrp.sql SQL> shutdown immediate; SQL> startup |
SQL> alter system set db_recovery_file_dest_size=2G; SQL> alter system set db_recovery_file_dest='D:\oracle\product\10.2.0\fra'; |
SQL> create restore point pre_activ_snap guarantee flashback database; SQL> select name, time, storage_size,GUARANTEE_FLASHBACK_DATABASE from V$restore_point; NAME TIME STORAGE_SIZE GUA -------------------------------------------------- -------------------------------- ------------ --- PRE_ACTIV_SNAP 20-MAR-10 07.59.35.000000000 PM 8192000 YES |
SQL> alter database activate standby database; SQL> select name, open_mode, controlfile_type from V$database; NAME OPEN_MODE CONTROL -------------------------------------------------- -------------------- ------- ORCL MOUNTED CURRENT SQL> alter database open; SQL> select name, open_mode, controlfile_type from V$database; NAME OPEN_MODE CONTROL -------------------------------------------------- -------------------- ------- ORCL READ WRITE CURRENT |
PRMY> ALTER SYSTEM SET DG_BROKER_START=FALSE; PRMY> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=DEFER; |
STBY> FLASHBACK DATABASE TO RESTORE POINT HOTFIX1; STBY> ALTER DATABASE CONVERT TO PHYSICAL STANDBY; STBY> STARTUP MOUNT FORCE; STBY> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT; |
FROM V$RESTORE_POINT; select * from v$flash_recovery_area_usage; |
Windows server can be configured to run a startup script that is a batch file, VB script. The AutoExnt utility is included in the Resource Kit so that this functionality is available.
The AutoExNT service permits an administrator to configure a Windows 2000-based computer to run a custom batch file when first starting the computer. Also, a user or administrator is not required to be logged on at the time this custom batch file runs.
http://support.microsoft.com/kb/q243486/
SimpleBack is a GUI for Oracle Rman backup. Just select the option from the radio button and click run. It will generate rman scripts and backup your oracle database. It's that easy! This is a free tool for all to share. Tested on Oracle 10g. (should work on Oracle 9i)
Oracle Application Server 10g offers a comprehensive solution for developing, integrating, and deploying your enterprise's applications, portals, and Web services.
Each application server can support up to 70 concurrent users.
Oracle10gappR2AScontrol
This service is used to give access to remote administration of the app server via a web browser interface on port 1810. While this service is running, you can point a browser to the URL http://[appserver]:1810 and you will be asked to log in. The default login and password for that connection are ias_admin‟
Oracle10gappR2ProcessManager
This is the master service that controls all the other services needed by the application server. This service is more of a shell for the other services such as the HTTP_Listener, the OC4J servers, etc. To monitor what this service is actually running, you use the „opmnctl‟ utility from the command line.
OPMNCTL Utility
The opmnctl utility is located on the application server in the \oracle\10gappr2\opmn\bin directory. This utility can be used to view what processes are currently being managed by the Oracle10gappr2ProcessManager service.
Report Queue Manager
Print jobs processed from thin-client sessions can be managed using the Oracle Report Queue Manager utility. From any workstation access the URL - http://[appserver]/reports/rwservlet/showjobs?server=rep[appserver]orcl -
Other user commands
> rwdiag -findall
> rwserver server=rep[servername]
Boot and run Linux from a USB flash memory stick
Carry a portable Linux version with you on a USB flash pen drive. Easily bring your portable desktop with you wherever you go. I have managed to do so, so can you.
USB Feather Linux Prerequisites:
The Feather USB Installation Process:
How to create PLSQL webservice
Required Software
Generating webservice ear
run {
backup as copy
database; }
Here is the description of the recovery process, assuming that the USERS tablespace has been damaged: First, check the file ID (number) and name of the datafile of the tablespace. The output is shown in vertical format:
Instant Recovery
Image copies in the FRA become truly useful when you need an "instant recovery." Remember that these image copies are copies of the datafiles—a fact recorded in the Oracle RMAN catalog and the control file. In case of a disaster, you don't need to restore the file; you can use the copy as the principal datafile immediately.
select file_id, file_name from dba_data_files
where tablespace_name = 'USERS';
FILE_ID : 4 NAME : /home/oracle/oradata/PRODB2/users01.dbf
RMAN> sql 'alter tablespace users offline';
sql statement: alter tablespace users offline
RMAN> switch datafile 4 to copy;
datafile 4 switched to datafile copy "/home/oracle/FRA/PRODB2/datafile/o1_mf_users_2kmqr57t_.dbf"
RMAN> recover datafile 4;
Starting recover at 26-SEP-06 using channel ORA_DISK_1
starting media recovery media recovery complete,
elapsed time: 00:00:03
Finished recover at 26-SEP-06
RMAN> sql 'alter tablespace users online';
sql statement: alter tablespace users online
Switchback
Even though the datafile has been quickly brought online to minimize downtime, it is now in the backup location, which may be on slower disks than what the main database is on. You may not want to run the database with the datafile at this location for long; you would typically want to move the datafile back to the original location—/home/oracle/oradata/PRODB2/—as soon as it becomes available. You can use Oracle RMAN to accomplish this. Here is a summary of the steps:
1. Make an image copy of the datafile at the original location. 2. Take the tablespace offline. 3. Switch the datafile to the "copy" (however, in this case, the "copy" is at the original location). 4. Recover the tablespace. 5. Place the tablespace online.
These steps are presented in Listing 4. After the switchover, you can make sure the datafile is back in its original location:
select name from v$datafile where file# = 4; NAME --------------------------------------- /home/oracle/oradata/PRODB2/users01.dbfRMAN> backup as copy datafile 4 format '/home/oracle/oradata/PRODB2/users01.dbf'; Starting backup at 27-SEP-06 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy input datafile fno=00004 name=/home/oracle/FRA/PRODB2/datafile/o1_mf_users_2kmqr57t_.dbf output filename=/home/oracle/oradata/PRODB2/users01.dbf tag=TAG20060927T103710 recid=45 stamp=602246230 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 27-SEP-06 Starting Control File Autobackup at 27-SEP-06 piece handle=/home/oracle/FRA/PRODB2/autobackup/2006_09_27/ o1_mf_n_602246232_2ko34s42_.bkp comment=NONE Finished Control File Autobackup at 27-SEP-06 RMAN> sql 'alter tablespace users offline'; ... RMAN> switch datafile 4 to copy; datafile 4 switched to datafile copy "/home/oracle/oradata/PRODB2/users01.dbf" RMAN> recover datafile 4; ... RMAN> sql 'alter tablespace users online'; ...In case of a failure, you save valuable time by quickly using the image copy of the datafile in the FRA, and there is no need to restore it first. The same concept can be applied to the entire database as well. If the original location of all the datafiles is damaged, you can easily switch the entire database to the copy stored in the FRA. To switch to the FRA copy, issue the following, which directs the whole database to use all the latest image copies in the FRA location as its datafiles:RMAN> switch database to copy;
Normally, we have multiplexing of controlfiles and they are expected to be placed in different disks.
If one or more controlfile is/are lost,mount will fail as shown below:
....
ORA-00205: error in identifying controlfile, check alert log for more info
**If at least one copy of the controlfile is not affected by the disk failure,
When the database is shutdown cleanly:
(a) Copy a good copy of the controlfile to the missing location
(b) Start the database
Alternatively, remove the lost control file location specified in the nit parameter control_files and start the database.
**If all copies of the controlfile are lost due to the disk failure, then: Check for a backup controlfile. Backup controlfile is normally taken using either of the following commands:
(a) SQL> alter database backup controlfile to '/backup/control.ctl';
-- This would have created a binary backup of the current controlfile --
-->If the backup was done in binary format as mentioned above, restore the file to the lost controlfile locations using OS copying utilities.
--> SQL> startup mount;
--> SQL> recover database using backup controlfile;
--> SQL> alter database open;
(b) SQL> alter database backup controlfile to trace;
-- This would have created a readable trace file containing create controlfile script --
--> Edit the trace file created (check user_dump_dest for the location) and retain the SQL commands alone. Save this to a file say cr_ctrl.sql
è Run the script
In normal cases, we would not have backups of online redo log files. But the inactive logfile changes could already have been checkpointed on the datafiles and even archive log files may be available.
SQL>
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/ORACLE/ORADATA/H817/REDO01.LOG'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.
** Verify if the lost redolog file is Current or not.
SQL> select * from v$log;
SQL> select * from v$logfile;
--> If the lost redo log is an Inactive logfile, you can clear the logfile:
SQL> alter database clear logfile GROUP 1;
Alternatively, you can drop the logfile if you have atleast two other logfiles:
SQL> alter database drop logfile group 1;
--> If the logfile is the Current logfile, then do the following:
SQL> recover database until cancel;
SQL>alter database open resetlogs;
If the database is in noarchivelog mode and if ORA-1547, ORA-1194 and ORA-1110 errors occur, then you would have restore from an old backup and start the database.
Note that all redo log maintenance operations are done in the database mount state
This is not a major loss and can be easily restored. Options are:
1. If there is a backup, restore the file
2. If there is no backup, copy sample file or create a new file and add the required parameters. Ensure that the parameters db_name, control_files,vdb_block_size, compatible are set correctly
3. If the spfile is lost, you can create it from the init parameter file
run {
backup as copy
database; }
|
Instant Recovery Image copies in the FRA become truly useful when you need an "instant recovery." Remember that these image copies are copies of the datafiles—a fact recorded in the Oracle RMAN catalog and the control file. In case of a disaster, you don't need to restore the file; you can use the copy as the principal datafile immediately.Here is the description of the recovery process, assuming that the USERS tablespace has been damaged: First, check the file ID (number) and name of the datafile of the tablespace. The output is shown in vertical format:
|
select file_id, file_name from dba_data_files where tablespace_name = 'USERS';
FILE_ID : 4 NAME : /home/oracle/oradata/PRODB2/ users01.dbf |
|
RMAN> sql 'alter tablespace users offline';
sql statement: alter tablespace users offline RMAN> switch datafile 4 to copy; datafile 4 switched to datafile copy "/home/oracle/FRA/PRODB2/datafile/o1_mf_users_2kmqr57t_.dbf" RMAN> recover datafile 4; Starting recover at 26-SEP-06 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:03 Finished recover at 26-SEP-06 RMAN> sql 'alter tablespace users online'; sql statement: alter tablespace users online |
Switchback Even though the datafile has been quickly brought online to minimize downtime, it is now in the backup location, which may be on slower disks than what the main database is on. You may not want to run the database with the datafile at this location for long; you would typically want to move the datafile back to the original location—/home/oracle/oradata/PRODB2/—as soon as it becomes available. You can use Oracle RMAN to accomplish this. Here is a summary of the steps: 1. Make an image copy of the datafile at the original location. 2. Take the tablespace offline. 3. Switch the datafile to the "copy" (however, in this case, the "copy" is at the original location). 4. Recover the tablespace. 5. Place the tablespace online. These steps are presented in Listing 4. After the switchover, you can make sure the datafile is back in its original location:select name from v$datafile where file# = 4; NAME --------------------------------------- /home/oracle/oradata/PRODB2/users01.dbf
RMAN> backup as copy datafile 4 format '/home/oracle/oradata/PRODB2/users01.dbf';
|
In case of a failure, you save valuable time by quickly using the image copy of the datafile in the FRA, and there is no need to restore it first. The same concept can be applied to the entire database as well. If the original location of all the datafiles is damaged, you can easily switch the entire database to the copy stored in the FRA. To switch to the FRA copy, issue the following, which directs the whole database to use all the latest image copies in the FRA location as its datafiles:RMAN> switch database to copy;
Using Explain Plan
Steps
EXPLAIN PLAN FOR SELECT last_name FROM employees;