Sei sulla pagina 1di 21

Be grace and peace of God with you DBA Guide

Oracle

ERROR: ORA-00257: archiver error. Connect internal only, until freed [ Your archive destination is most likely full, causing ORA-00257. You should b ackup your archive logs, then remove them . After this, archive should restart ] archive log list; select value from v$parameter where name = 'background_dump_dest'; show parameter db_recovery_file_dest; show parameter log_archive_dest; SELECT * FROM V$RECOVERY_FILE_DEST; NAME SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES -------------- ----------- ---------- ----------------- --------------/mydisk/rcva 5368709120 109240320 256000 28 You may find that the SPACE_USED is the same as SPACE_LIMIT, if this is the case , to resolve ORA-00257 should be remedied by moving the archive logs to some oth er destination. move the archive log to another place or change the size of recovery dest alter system archive log stop;You next need to archive the log files by, alter system archive log all; alter system archive log start; alter system switch logfile; then resync rman catalog RMAN> crosscheck archivelog all; RMAN> delete expired archivelog all; AND TAKE FULL BACKUP !!!!!! It is important to note that within step five of the ORA-00257 resolution, you may also encounter ORA-16020 in the LOG_ARCHIVE_MIN_SUCCEED_DEST, and you should use the proper archivelog path and use (keeping in mind that you may need to ta ke extra measures if you are using Flash Recovery Area as you will receive more errors if you attempt to use LOG_ARCHIVE_DEST): alter system set LOG_ARCHIVE_DEST_.. = 'location=/archivelogpath reopen'; The last step in resolving ORA-00257 is to change the logs for verification usin g: SQL> alter system switch logfile; FLASH RECOVERY AND ARCHIVE LOG DB_RECOVERY_FILE_DEST DB_RECOVERY_FILE_DEST_SIZE must be set before DB_RECOVERY_FILE_DEST. DB_RECOVERY_FILE_DEST = LOCATION=/u01/oradata/rcv_area' DB_RECOVERY_FILE_DEST_SIZE = 10G LOG_ARCHIVE_DEST DB_CREATE_ONLINE_LOG_DEST_n ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 10G SCOPE=BOTH SID='*'; ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/flash_rec_ara' SCOPE=BOTH SID='*'; V$FLASH_RECOVERY_AREA_USAGE V$RECOVERY_FILE_DEST. SQL> SELECT * FROM V$RECOVERY_FILE_DEST;

NAME SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES -------------- ----------- ---------- ----------------- --------------/mydisk/rcva 5368709120 109240320 256000 28 Disabling the Flash Recovery Area ALTER SYSTEM SET DB_RECOVERY_FILE_DEST='' SCOPE=BOTH SID="*"; Killing Oracle session SELECT s.SID, s.serial#, s.osuser, s.program FROM v$session s; ALTER SYSTEM KILL SESSION 'sid,serial#'; ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE; SELECT s.SID, p.spid, s.osuser, s.program FROM v$process p, v$session s WHERE p.addr = s.paddr; C:> orakill ORACLE_SID spid Linux# kill -9 spid Oracle 11g password case sensitivity SQL> show parameter sec_case_sensitive_logon NAME TYPE VALUE ------------------------------------ ----------- -----------------------------sec_case_sensitive_logon BOOLEAN TRUE SQL> conn hr/hr ERROR: ORA-01017: invalid username/password; logon denied SQL> ALTER system SET SEC_CASE_SENSITIVE_LOGON=FALSE; SQL> conn hr/hr Connected. Search alert.log for errors (UNIX) sed -n '/Mon Feb 11.*2008/,/Thu Feb 14.*2008/p' alert_ispb.log select * from v$version; Linux command for ORACLE DBA How to Sort files based on Size of file in a Directory Useful in finding out spaces issues ls -l sort -nrk 5 more How to check if a Port is listening for any Service netstat -an grep $PORTNO grep ORA

How to schedule a Job in Unix Use cronjob crontab -l ( list current jobs in cron) crontab -e ( edit current jobs in cron ) _1_ _2_ _3_ _4_ _5_ $Job_Name 1 - Minutes (0-59)

2 - Hours ( 0-24) 3 - day of month ( 1- 31 ) 4 - Month ( 1-12) 5 - A day of week ( 0- 6 ) 0 -> sunday 1-> monday e.g. 0 0 1 * 5 Means run job at Midnight on 1st of month & every friday

Here I am listing Unix/Linux commnads which might be useful while troubl eshooting Oracle Apps. Enable Trace on any Executable to find out whats happening at O.S. Level truss -eafl -o output.trc -o truss.txt <executable> for example for Apache truss -eafl -o output.trc -o truss.txt apachectl This command will trace any system calls and will help you to find out errors. How to find a "word" or pattern in all files in a directory & subdirectories find . -name "*" -exec grep -l <pattern> {} \; -print for example I want to search for word oracle find . -name "*" -exec grep -l oracle {} \; -print How to delete files older than N number of days , Useful to delete old log files find . -name '*.*' -mtime +<T in days> -exec rm {} \; for example if I want to delete all files older than 7 days find . -name '*.*' -mtime +7 -exec rm {} \; *Check carefully & run it first from logs or dump directory Command to Check the RAM Size ORACLE:/home/oracle>free -m total used free shared buffers cached Mem: 998 976 22 0 56 540 -/+ buffers/cache: 379 619 Swap: 4502 77 4425 ORACLE:/home/oracle>vmstat procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---r b swpd free buff cache si so bi bo in cs us sy id wa 0 0 78976 27396 57228 547856 0 0 16 32 575 359 3 0 97 0 ORACLE:/home/oracle>vmstat 2 10 procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---r b swpd free buff cache si so bi bo in cs us sy id wa 0 0 78976 30396 58040 543516 0 0 16 32 575 357 3 0 97 0 0 0 78976 30252 58040 543516 0 0 0 0 1014 218 0 0 100 0 0 0 78976 30252 58040 543516 0 0 0 24 1016 171 0 0 100 0 0 0 78976 30252 58048 543508 0 0 0 166 1038 200 0 0 100 0 top uptime 18:38:23 up 7:40, 9 users, load average: 0.28, 0.13, 0.10 Display Number of CPUs in Linux cat /proc/cpuinfo grep processor ORACLE:/home/oracle>cat /proc/cpuinfo cat /proc/cpuinfo grep processor wc l 16

Netstat Differences On any Sun and Linux server the netstat utility provides information about all n etwork traffic touching the server. However the output from the netstat Foreign Address Proto Recv-Q Send-Q Local Address donsrv1.rov:netbios-ssn intranet.janet.com:1351 0 tcp 0 donsrv1.janet.com:1120 sting.janet.com:ssh 0 tcp 0 donsrv1.janet.com:ssh h pop3-146.gloryroa:1096 40 tcp 0 State ESTABLISHED TIME_WAIT ESTABLISHED

vmstat Provides real-time reports on CPU consumption, CPU dispatcher run queue, RAM page in, scan rate, RAM page outs iostat Provides detailed disk I/O information including disk enqueues and I/O la tency nestat Shows TCP/IP traffic and packet details watch Shows top server task details including server load average ps Shows process-level details on resource consumption Each set of report lines starts with a header row with CPU statistics which repr esents the CPU usage across all processors. Following the CPU information, a de vice header row is displayed with subsequent detail lines of statistics for each device in the system. The following example shows the invocation of iostat specifying a three second i nterval or delay with a total of five samplings or counts: $ iostat 3 5 Linux 2.6.5-1.358 (Dell-Linux) 10/18/2004 avg-cpu: %user %nice %sys %iowait %idle 0.51 0.14 0.22 0.26 98.86 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn hda 0.00 0.02 0.00 1192 38 hdf 0.99 20.83 5.33 1405186 359616 avg-cpu: %user %nice %sys %iowait %idle 0.67 0.00 0.33 0.00 99.00 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn hda 0.00 0.00 0.00 0 0 hdf 0.00 0.00 0.00 0 0 avg-cpu: %user %nice %sys %iowait %idle 0.67 0.00 0.33 0.00 99.00 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn hda 0.00 0.00 0.00 0 0 For the average CPU report, %user, %nice, %iowait, and %idle are defined the sam e as they were in the mpstat command output. One remaining piece of information is defined as: * %sys: The percentage of processor utilization occurring at the system kernel l evel. For the device utilization report: * device: The device name as listed in the /dev directory is displayed. These d evice names are mapped to mount points in the file /etc/fstab and are also liste d in the output of the df command. * tps: The number of transfers (I/O requests) per second issued to the device. * blk_read/s: The number of blocks per second read from the device. * blk_wrtn/s: The number of blocks per second written to the device. * blk_read: The total number of blocks read. * blk_wrtn: The total number of blocks written. This information can assist in the determination of which devices are more heavi ly used than others and perhaps help with the determination of how to better dis tribute data to balance the workload. Displaying Virtual Memory Statistics

The vmstat command displays information about processes, memory, paging, block I O, and different levels of CPU activity. As with iostat, the first detail lines produce report averages since the last reboot. Subsequent detail lines report in formation using the interval specified on the command line. As with the other commands in this section, the vmstat command is driven by dela y and count options that determine the time interval between report lines and th e totals number of intervals to be reported. $ vmstat 3 5 procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---r b swpd free buff cache si so bi bo in cs us sy id wa 0 0 0 63492 94856 24996 0 0 8 3 484 29 1 0 99 0 0 0 0 63492 94856 24996 0 0 0 0 1005 25 1 0 99 0 0 0 0 63492 94860 24996 0 0 0 13 1005 24 1 0 99 0 0 0 0 63492 94860 24996 0 0 0 0 1002 21 0 0 99 0 0 0 0 63492 94864 24996 0 0 0 4 1003 22 1 0 99 0 The Linux man page for vmstat defines the fields displayed as follows: * procs * r: The number of processes waiting for run time * b: The number of processes in uninterruptible sleep, which means they are wait ing on a resource * memory * swpd: Virtual memory used * free: Idle memory * buff: Amount of memory used as buffers * cache: Current memory used as cache * swap * si: Memory swapped in per second from disk * so: Memory swapped out per second to disk * io * bi: Blocks per second received from a block device * bo: Blocks per second sent to a block device * system * in:.Number of interrupts per second, including the clock * cs: Number of context switches per second * cpu: These statistics are percentages of total CPU time: * us: User time spent running non-kernel code, includes nice time * sy: System time spent running kernel code * id: Idle time * wa: Wait time spent waiting for I/O The vmstat information can be invaluable when studying resource utilization tren ds. Here are a few examples of how vmstat output can be interpreted: If over time the run queue value, procs-r, remains consistently higher than the number of processors in the server and CPU idle time is low, the system is CPU b ound and can benefit from the addition of more and/or faster processors. Alterna tively a high number displayed in the procs-b column also indicates a bottleneck , but one where processes are waiting on other resources. If the virtual memory used (memory-swpd) remains high and the free memory (memor y-free) remains low, then the system is memory constrained and will benefit from additional RAM. Consistently high I/O rates paired with consistently low CPU utilization (cpu-us ) indicates an I/O bound system that could benefit from a highly buffered disk a rray or possibly solid-state disk. Linux Command Syntax examples Display the number of CPUs Show top CPU% Display top-10 CPU consumers RAM memory display free cat /proc/cpuinfo grep processor wc l ps aux sort -n +2 ps aux sort -rn +2 head -10

Shutdown server as root Kill all xxx processes Show swap paging space Show Linux syslog errors Show swap disk details See held memory segments Show Linux system parms Linux command history files $ whoami terry $ su Password: rootpassword # whoami root # exit $ whoami terry

/sbin/shutdown -r now pkill [-9] xxx /sbin/swapon -s tail /var/log/messages swapon -s ipcs -m sysctl -a history more

cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 5 model name : Pentium II (Deschutes) stepping : 1 cpu MHz : 398.273 cache size : 512 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr bogomips : 794.62 cat /proc/meminfo MemTotal: 257124 kB MemFree: 67388 kB Buffers: 20516 kB Cached: 124140 kB SwapCached: 0 kB Active: 51736 kB Inactive: 108328 kB HighTotal: 0 kB HighFree: 0 kB LowTotal: 257124 kB LowFree: 67388 kB SwapTotal: 524152 kB SwapFree: 524152 kB Dirty: 0 kB Writeback: 0 kB Mapped: 27752 kB Slab: 26424 kB Committed_AS: 64300 kB PageTables: 1044 kB VmallocTotal: 3874808 kB

VmallocUsed: 1260 kB VmallocChunk: 3873360 kB HugePages_Total: 0 HugePages_Free: 0 Database Tuning o Tune I/O. o Tune memory. o Tune contention. o Tune the operating system The tuning methodology for production systems works by resolving problems when t hey occur: 1. Locate a bottleneck by using tools, such as STATSPACK, UTLBSTAT an d UTLESTAT, or Oracle Enterprise Manager. 2. The bottleneck usually manifests it self as a wait event. Determine the reason for the wait event. 3. Resolve the ca use of the wait. This could mean changing the size of a member of the System Glo bal Area. You can check the time between log switches in the alert.log file. The alert log file consists of a chronological log of messages and errors. The following info rmation is logged in the alert log file: o Internal errors (ORA-600) and block c orruption errors (ORA-1578 or ORA-1498) V$SESSTAT, V$SQL V$SESSION_WAIT

delete a duplicate rows in a oracle table for example here, user HR is having table emp, HR@prod SQL>select * from emp; EMPID ENAME ---------- -------------------10005 palani 10001 Scott Tiger 10002 Frank Naude 10003 rajesh 10004 ramesh 10005 suresh 6 rows selected. to delete duplicate rows in empid column in emp table SQL>delete from emp where rowid not in (select max(rowid) from emp group by empid); 1 row deleted. SQL>select * from emp; EMPID ENAME SAL DEPTNO ---------- -------------------- ---------- ---------10001 Scott Tiger 1000 40 10002 Frank Naude 500 20 10003 rajesh 21000 140 SAL DEPTNO ---------- ---------54544 10 1000 40 500 20 21000 140 3500 220 34567 123

10004 ramesh 10005 suresh ORACLE DBA TIPS SET DEFAULT TABLESPACE

3500 34567

220 123

SELECT PROPERTY_VALUE FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME = 'DEFAULT_TBS_TYPE'; The V$SGA_TARGET_ADVICE view provides information that helps you decide on a value for SGA_TARGET. ALTER DATABASE SET DEFAULT BIGFILE TABLESPACE; The V$SGA_TARGET_ADVICE view provides information that helps you decide on a value for SGA_TARGET. Checking Your Current Release Number SELECT * FROM PRODUCT_COMPONENT_VERSION; SELECT * FROM v$VERSION; Viewing Information about the SGA: v$SGA v$SGAINFO v$SGASTAT v$SGA_DYNAMIC_COMPONENTS v$SGA_DYNAMIC_FREE_MEMORY v$SGA_RESIZE_OPS v$SGA_CURRENT_RESIZE_OPS v$SGA_TARGET_ADVICES show parameters, v$parameter, v$parameter2, v$spparameter. You can find service information in the following service-specific views: DBA_SERVICES ALL_SERVICES or V$SERVICES V$ACTIVE_SERVICES V$SERVICE_STATS V$SERVICE_EVENTS V$SERVICE_WAIT_CLASSES V$SERV_MOD_ACT_STATS V$SERVICE_METRICS V$SERVICE_METRICS_HISTORY The following additional views also contain some information about services: V$SESSION V$ACTIVE_SESSION_HISTORY

DBA_RSRC_GROUP_MAPPINGS DBA_SCHEDULER_JOB_CLASSES DBA_THRESHOLDS 17.Viewing Information About the Database DATABASE_PROPERTIES GLOBAL_NAME V$DATABASES The following views can help you to monitor locks: for getting information about locks, we have to run two scripts utllockt.sql and catblock.sql Lists the locks currently held by Oracle Database and outstanding V$LOCK requests for a lock or latch Displays a session if it is holding a lock on an object for which DBA_BLOCKERS another session is waiting Displays a session if it is waiting for a locked object DBA_WAITERS Lists all DDL locks held in the database and all outstanding DBA_DDL_LOCKS requests for a DDL lock Lists all DML locks held in the database and all outstanding DBA_DML_LOCKS requests for a DML lock Lists all locks or latches held in the database and all outstanding DBA_LOCK requests for a lock or latch Displays a row for each lock or latch that is being held, and one DBA_LOCK_INTERNAL row for each outstanding request for a lock or latch Lists all locks acquired by every transaction on the system V$LOCKED_OBJECT Process and Session Views v$process v$locked_object v$session v$sess_io v$session_longops v$session_wait v$sysstat v$resource_limit v$sqlarea v$latch

What Is a Control File? Every Oracle Database has a control file, which is a small binary file that reco rds the physical structure of the database. The control file includes: The database name Names and locations of associated datafiles and redo log files The timestamp of the database creation The current log sequence number Checkpoint information The following views display information about control files: V$DATABASE Displays database information from the control file V$CONTROLFILE Lists the names of control files V$CONTROLFILE_RECORD_SECTION Displays information about control file record sect ions V$PARAMETER Displays the names of control files as specified in the CONTROL_FILE S initialization parameter 32.Redo Log Contents Redo log files are filled with redo records. A redo record, also called a redo e ntry, is made up of a group of change vectors, each of which is a description of a change made to a single block in the database. Redo entries record data that you can use to reconstruct all changes made to the database, including the undo segments. Therefore, the redo log also protects rol lback data. When you recover the database using redo data, the database reads the chan ge vectors in the redo records and applies the changes to the relevant blocks. 33.Log Switches and Log Sequence Numbers A log switch is the point at which the database stops writing to one redo log fi le and begins writing to another. Normally, a log switch occurs when the current redo l og file is completely filled and writing must continue to the next redo log file. You can also force log switches manually. Oracle Database assigns each redo log file a new log sequence number every time a log switch occurs and LGWR begins writing to it. When the database archives redo log files, the archived log retains its log sequence number. A redo log file that is cycled back for use is given the next available log sequence number. 34. Setting the Size of Redo Log Members The minimum size permitted for a redo log file is 4 MB.

35.Setting the ARCHIVE_LAG_TARGET Initialization Parameter The ARCHIVE_LAG_TARGET initialization parameter specifies the target of how many seconds of redo the standby could lose in the event of a primary shutdown or fai lure if the Oracle Data Guard environment is not configured in a no-data-loss mode. It a lso provides an upper limit of how long (in seconds) the current log of the primary database can span. Because the estimated archival time is also considered, this is not the exact log switch time. The following initialization parameter setting sets the log switch interval to 3 0 minutes (a typical value). ARCHIVE_LAG_TARGET = 1800 A value of 0 disables this time-based log switching functionality. This is the d efault setting. You can set the ARCHIVE_LAG_TARGET initialization parameter even if there is no standby database. For example, the ARCHIVE_LAG_TARGET parameter can be set specifically to force logs to be switched and archived. 36.Verifying Blocks in Redo Log Files If you set the initialization parameter DB_BLOCK_CHECKSUM to TRUE, the database computes a checksum for each database block when it is written to disk, includin g each redo log block as it is being written to the current log. The checksum is s tored the header of the block. Oracle Database uses the checksum to detect corruption in a redo log block. The database verifies the redo log block when the block is read from an archived log during recovery and when it writes the block to an archive log file. An error is raised and written to the alert log if corruption is detected. 37.Clearing a Redo Log File A redo log file might become corrupted while the database is open, and ultimatel y stop database activity because archiving cannot continue. In this situation the ALTER DATABASE CLEAR LOGFILE statement can be used to reinitialize the file without shutting down the database. The following statement clears the log files in redo log group number 3: ALTER DATABASE CLEAR LOGFILE GROUP 3; This statement overcomes two situations where dropping redo logs is not possible : If there are only two log groups The corrupt redo log file belongs to the current group If the corrupt redo log file has not been archived, use the UNARCHIVED keyword i n the statement. ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 3; This statement clears the corrupted redo logs and avoids archiving them. The cle ared redo logs are available for use even though they were not archived. If you clear a log file that is needed for recovery of a backup, then you can no longer recover from that backup. The database writes a message in the alert log describ

ing the backups from which you cannot recover. Note: If you clear an unarchived redo log file, you should make another backup of the database. If you want to clear an unarchived redo log that is needed to bring an offline tablespace online, use the UNRECOVERABLE DATAFILE clause in the ALTER DATABASE CLEAR LOGFILE statement. 38.Viewing Redo Log Information Displays the redo log file information from the control file V$LOG Identifies redo log groups and members and member status V$LOGFILE Contains log history information V$LOG_HISTORY 39.You can use archived redo logs to: Recover a database Update a standby database Get information about the history of a database using the LogMiner utility 40.Changing the database ARCHIVING mode: (1) shutdown (2) startup mount (3) alter database archivelog; (4) alter database open; 41.Performing Manual Archiving ALTER DATABASE ARCHIVELOG MANUAL; ALTER SYSTEM ARCHIVE LOG ALL; note:When you use manual archiving mode, you cannot specify any standby database s in the archiving destinations. 42.Understanding Archive Destination Status Each archive destination has the following variable characteristics that determi ne its status: Valid/Invalid: indicates whether the disk location or service name information i s specified and valid Enabled/Disabled: indicates the availability state of the location and whether t he database can use the destination Active/Inactive: indicates whether there was a problem accessing the destination Several combinations of these characteristics are possible. To obtain the curren t status and other information about each destination for an instance, query the V$ARCHIVE_DEST view. The LOG_ARCHIVE_DEST_STATE_n (where n is an integer from 1 to 10) initialization parameter lets you control the availability state of the specified destination ( n).

ENABLE indicates that the database can use the destination. DEFER indicates that the location is temporarily disabled. ALTERNATE indicates that the destination is an alternate. The availability state of the destination is DEFER, unless there is a failure of its parent destination, in which case its state becomes ENABLE. 43.Viewing Information About the Archived Redo Log You can display information about the archived redo logs using the following sou rces: (1)Dynamic Performance Views (2)The ARCHIVE LOG LIST Command Dynamic Performance Views ------------------------Shows if the database is in ARCHIVELOG or NOARCHIVELOG V$DATABASE mode and if MANUAL (archiving mode) has been specified. Displays historical archived log information from the control V$ARCHIVED_LOG file. If you use a recovery catalog, the RC_ARCHIVED_LOG view contains similar information. Describes the current instance, all archive destinations, and V$ARCHIVE_DEST the current value, mode, and status of these destinations. Displays information about the state of the various archive V$ARCHIVE_PROCESSES processes for an instance. Contains information about any backups of archived logs. If V$BACKUP_REDOLOG you use a recovery catalog, the RC_BACKUP_REDOLOG contains similar information. Displays all redo log groups for the database and indicates V$LOG which need to be archived. Contains log history information such as which logs have V$LOG_HISTORY been archived and the SCN range for each archived log. 44.Bigfile Tablespaces A bigfile tablespace is a tablespace with a single, but very large (up to 4G blo cks) datafile. Traditional smallfile tablespaces, in contrast, can contain multiple d atafiles, but the files cannot be as large. The benefits of bigfile tablespaces are the fo llowing: A bigfile tablespace with 8K blocks can contain a 32 terabyte datafile. A bigfil e tablespace with 32K blocks can contain a 128 terabyte datafile. The maximum number of datafiles in an Oracle Database is limited (usually to 64K files). Therefore, bigfile tablespaces can significantly enhance the storage capacity of

an Oracle Database. 45.Altering a Bigfile Tablespace Two clauses of the ALTER TABLESPACE statement support datafile transparency when you are using bigfile tablespaces: RESIZE: The RESIZE clause lets you resize the single datafile in a bigfile tablespace to an absolute size, without referring to the datafile. For example: ALTER TABLESPACE bigtbs RESIZE 80G; AUTOEXTEND (used outside of the ADD DATAFILE clause): With a bigfile tablespace, you can use the AUTOEXTEND clause outside of the ADD DATAFILE clause. For example: ALTER TABLESPACE bigtbs AUTOEXTEND ON NEXT 20G; An error is raised if you specify an ADD DATAFILE clause for a bigfile tablespac e. 46.Identifying a Bigfile Tablespace The following views contain a BIGFILE column that identifies a tablespace as a b igfile tablespace: DBA_TABLESPACES USER_TABLESPACES V$TABLESPACE 47.Temporary Tablespaces You can view the allocation and deallocation of space in a temporary tablespace sort segment using the V$SORT_SEGMENT view. The V$TEMPSEG_USAGE view identifies the current sort users in those segments. You also use different views for viewing information about tempfiles than you wo uld for datafiles. The V$TEMPFILE and DBA_TEMP_FILES views are analogous to the V$DATAFILE and DBA_DATA_FILES views. 48.Creating a Locally Managed Temporary Tablespace CREATE TEMPORARY TABLESPACE lmtemp TEMPFILE '/u02/oracle/data/lmtemp01.dbf' SIZE 20M REUSE EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M; Altering a Locally Managed Temporary Tablespace ----------------------------------------------ALTER TABLESPACE lmtemp ADD TEMPFILE '/u02/oracle/data/lmtemp02.dbf' SIZE 18M REUSE; (or) ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf' RESIZE 18M; ALTER TABLESPACE lmtemp TEMPFILE OFFLINE; ALTER TABLESPACE lmtemp TEMPFILE ONLINE; ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf' OFFLINE; ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf' ONLINE; Assigning Default Temporary Tablespace: --------------------------------------

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE lmttemp; 49.Multiple Temporary Tablespaces: Using Tablespace Groups: A tablespace group enables a user to consume temporary space from multiple tablespaces. A tablespace group has the following characteristics: It contains at least one tablespace. There is no explicit limit on the maximum number of tablespaces that are contained in a group. It shares the namespace of tablespaces, so its name cannot be the same as any tablespace. You can specify a tablespace group name wherever a tablespace name would appear when you assign a default temporary tablespace for the database or a temporary tablespace for a user. You do not explicitly create a tablespace group. Rather, it is created implicitl y when you assign the first temporary tablespace to the group. The group is deleted whe n the last temporary tablespace it contains is removed from it. The view DBA_TABLESPACE_GROUPS lists tablespace groups and their member tablespaces. 50.Creating a Tablespace Group -----------------------------CREATE TEMPORARY TABLESPACE lmtemp2 TEMPFILE '/u02/oracle/data/lmtemp201.dbf' SIZE 50M TABLESPACE GROUP group1; ALTER TABLESPACE lmtemp TABLESPACE GROUP group2; Changing Members of a Tablespace Group -------------------------------------You can add a tablespace to an existing tablespace group by specifying the exist ing group name in the TABLESPACE GROUP clause of the CREATE TEMPORARY TABLESPACE or ALTER TABLESPACE statement. The following statement adds a tablespace to an existing group. It creates and a dds tablespace lmtemp3 to group1, so that group1 contains tablespaces lmtemp2 and lmtemp3. CREATE TEMPORARY TABLESPACE lmtemp3 TEMPFILE '/u02/oracle/data/lmtemp301.dbf' SIZE 25M TABLESPACE GROUP group1; The following statement also adds a tablespace to an existing group, but in this case because tablespace lmtemp2 already belongs to group1, it is in effect moved from group1 to group2: ALTER TABLESPACE lmtemp2 TABLESPACE GROUP group2; Now group2 contains both lmtemp and lmtemp2, while group1 consists of only tmtemp3. You can remove a tablespace from a group as shown in the following statement: ALTER TABLESPACE lmtemp3 TABLESPACE GROUP ''; Tablespace lmtemp3 no longer belongs to any group. Further, since there are no l onger

any members of group1, this results in the implicit deletion of group1. Assigning a Tablespace Group as the Default Temporary Tablespace ---------------------------------------------------------------ALTER DATABASE sample DEFAULT TEMPORARY TABLESPACE group2;

Re-create lost controlfile Here in this demo i deleted all control files and re-created using trace file. In Oracle forum OTN related to re-create controlfile, confusion between shutdown immediate and shutdown abort after controlfile lost. this demo helps you to recreate lost control file view plaincopy to clipboardprint? 1. SQL> select name from v$controlfile; 2. 3. NAME 4. ------------------------------------------------------------------------------5. /u01/app/oracle/oradata/rev1/control01.ctl 6. /u01/app/oracle/oradata/rev1/control02.ctl 7. /u01/app/oracle/oradata/rev1/control03.ctl 8. 9. SQL> select name from v$datafile; 10. 11. NAME 12. ------------------------------------------------------------------------------13. /u01/app/oracle/oradata/rev1/system01.dbf 14. /u01/app/oracle/oradata/rev1/undotbs01.dbf 15. /u01/app/oracle/oradata/rev1/sysaux01.dbf 16. /u01/app/oracle/oradata/rev1/users01.dbf 17. 18. SQL> col member format a50 19. SQL> select a.group#,a.member,b.status from v$logfile a, v$log b where a .group#=b.group#; 20. 21. GROUP# MEMBER STATUS 22. ---------- -------------------------------------------------- --------------23. 3 /u01/app/oracle/oradata/rev1/redo03.log ACTIVE 24. 2 /u01/app/oracle/oradata/rev1/redo02.log CURRENT 25. 1 /u01/app/oracle/oradata/rev1/redo01.log ACTIVE to create control file trace view plaincopy to clipboardprint? 1. SQL> alter database backup controlfile to trace; 2. 3. Database altered. 4. SQL> show parameter user_dump_dest 5. 6. NAME TYPE VALUE 7. ------------------------------------ ----------- ----------------------------8. user_dump_dest string /u01/app/oracle/admin/r ev1/udump 9. 10. or 11.

12. 13. 14. 15.

SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE 2 AS '/home/oracle/Desktop/create_ctl.sql'; Database altered.

you can find the sample controlfile trace file in the location user_dump_dest /u 01/app/oracle/admin/rev1/udump the last recently created file. view plaincopy to clipboardprint? 1. u01/app/oracle/admin/rev1/udump/rev1_ora_10939.trc 2. Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production 3. With the Partitioning and OLAP options 4. ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1 5. System name: Linux 6. Node name: rac1.localdomain 7. Release: 2.6.9-42.0.0.0.1.ELhugemem 8. Version: #1 SMP Sun Oct 15 14:06:18 PDT 2006 9. Machine: i686 10. Instance name: rev1 11. Redo thread mounted by this instance: 1 12. Oracle process number: 23 13. Unix process pid: 10939, image: oracle@rac1.localdomain (TNS V1-V3) 14. 15. *** SERVICE NAME:(SYS$USERS) 2010-09-21 16:52:23.473 16. *** SESSION ID:(142.32) 2010-09-21 16:52:23.473 17. *** 2010-09-21 16:52:23.472 18. -- The following are current System-scope REDO Log Archival related 19. -- parameters and can be included in the database initialization file. 20. -21. -- LOG_ARCHIVE_DEST='' 22. -- LOG_ARCHIVE_DUPLEX_DEST='' 23. -24. -- LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf 25. -26. -- DB_UNIQUE_NAME="rev1" 27. -28. -- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG' 29. -- LOG_ARCHIVE_MAX_PROCESSES=2 30. -- STANDBY_FILE_MANAGEMENT=MANUAL 31. -- STANDBY_ARCHIVE_DEST=?/dbs/arch 32. -- FAL_CLIENT='' 33. -- FAL_SERVER='' 34. -35. -- LOG_ARCHIVE_DEST_10='LOCATION=USE_DB_RECOVERY_FILE_DEST' 36. -- LOG_ARCHIVE_DEST_10='OPTIONAL REOPEN=300 NODELAY' 37. -- LOG_ARCHIVE_DEST_10='ARCH NOAFFIRM NOEXPEDITE NOVERIFY SYNC' 38. -- LOG_ARCHIVE_DEST_10='REGISTER NOALTERNATE NODEPENDENCY' 39. -- LOG_ARCHIVE_DEST_10='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNI QUE_NAME' 40. -- LOG_ARCHIVE_DEST_10='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)' 41. -- LOG_ARCHIVE_DEST_STATE_10=ENABLE 42. -43. -- Below are two sets of SQL statements, each of which creates a new 44. -- control file and uses it to open the database. The first set opens 45. -- the database with the NORESETLOGS option and should be used only if 46. -- the current versions of all online logs are available. The second 47. -- set opens the database with the RESETLOGS option and should be used 48. -- if online logs are unavailable. 49. -- The appropriate set of statements can be copied from the trace into 50. -- a script file, edited as necessary, and executed when there is a

51. -- need to re-create the control file. 52. -53. -Set #1. NORESETLOGS case 54. -55. -- The following commands will create a new control file and use it 56. -- to open the database. 57. -- Data used by Recovery Manager will be lost. 58. -- Additional logs may be required for media recovery of offline 59. -- Use this only if the current versions of all online logs are 60. -- available. 61. -- After mounting the created controlfile, the following SQL 62. -- statement will place the database in the appropriate 63. -- protection mode: 64. -- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE 65. STARTUP NOMOUNT 66. CREATE CONTROLFILE REUSE DATABASE "REV1" NORESETLOGS FORCE LOGGING ARCHI VELOG 67. MAXLOGFILES 16 68. MAXLOGMEMBERS 3 69. MAXDATAFILES 100 70. MAXINSTANCES 8 71. MAXLOGHISTORY 292 72. LOGFILE 73. GROUP 1 '/u01/app/oracle/oradata/rev1/redo01.log' SIZE 5M, 74. GROUP 2 '/u01/app/oracle/oradata/rev1/redo02.log' SIZE 5M, 75. GROUP 3 '/u01/app/oracle/oradata/rev1/redo03.log' SIZE 5M 76. -- STANDBY LOGFILE 77. DATAFILE 78. '/u01/app/oracle/oradata/rev1/system01.dbf', 79. '/u01/app/oracle/oradata/rev1/undotbs01.dbf', 80. '/u01/app/oracle/oradata/rev1/sysaux01.dbf', 81. '/u01/app/oracle/oradata/rev1/users01.dbf' 82. CHARACTER SET WE8ISO8859P1 83. ; 84. -- Configure RMAN configuration record 1 85. VARIABLE RECNO NUMBER; 86. EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBAC KUP','ON'); 87. -- Commands to re-create incarnation table 88. -- Below log names MUST be changed to existing filenames on 89. -- disk. Any one log file from each branch can be used to 90. -- re-create incarnation records. 91. -- ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/flash_recovery_area/ REV1/archivelog/2010_09_21/o1_mf_1_1_%u_.arc'; 92. -- ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/flash_recovery_area/ REV1/archivelog/2010_09_21/o1_mf_1_1_%u_.arc'; 93. -- ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/flash_recovery_area/ REV1/archivelog/2010_09_21/o1_mf_1_1_%u_.arc'; 94. -- ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/flash_recovery_area/ REV1/archivelog/2010_09_21/o1_mf_1_1_%u_.arc'; 95. -- Recovery is required if any of the datafiles are restored backups, 96. -- or if the last shutdown was not normal or immediate. 97. RECOVER DATABASE 98. -- All logs need archiving and a log switch is needed. 99. ALTER SYSTEM ARCHIVE LOG ALL; 100. -- Database can now be opened normally. 101. ALTER DATABASE OPEN; 102. -- Commands to add tempfiles to temporary tablespaces. 103. -- Online tempfiles have complete space information. 104. -- Other tempfiles may require adjustment.

105. dbf' 106. 107.

ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/rev1/temp01. SIZE 20971520 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M; -- End of tempfile additions.

copy and paste the following lines in the notepad/text editor from the above tra ce files and save it as create_ctl.sql CREATE CONTROLFILE REUSE DATABASE "REV1" RESETLOGS MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 '/u01/app/oracle/oradata/rev1/redo01.log' GROUP 2 '/u01/app/oracle/oradata/rev1/redo02.log' GROUP 3 '/u01/app/oracle/oradata/rev1/redo03.log' -- STANDBY LOGFILE DATAFILE '/u01/app/oracle/oradata/rev1/system01.dbf', '/u01/app/oracle/oradata/rev1/undotbs01.dbf', '/u01/app/oracle/oradata/rev1/sysaux01.dbf', '/u01/app/oracle/oradata/rev1/users01.dbf' CHARACTER SET WE8ISO8859P1 ; FORCE LOGGING ARCHIVELOG

SIZE 5M, SIZE 5M, SIZE 5M

remove the control files(control01.ctl,control02.ctl,control03.ctl) from the loc ation /u01/app/oracle/oradata/rev1/ for testing purpose to re-create it. view plaincopy to clipboardprint? 1. SQL> select name from v$controlfile; 2. 3. NAME 4. -------------------------------------------------5. /u01/app/oracle/oradata/rev1/control01.ctl 6. /u01/app/oracle/oradata/rev1/control02.ctl 7. /u01/app/oracle/oradata/rev1/control03.ctl 8. 9. SQL> host rm -rf /u01/app/oracle/oradata/rev1/control01.ctl 10. 11. SQL> ! rm -rf /u01/app/oracle/oradata/rev1/control02.ctl 12. 13. SQL> ! rm -rf /u01/app/oracle/oradata/rev1/control03.ctl 14. 15. SQL> shutdown immediate 16. 17. SQL> startup 18. ORACLE instance started. 19. 20. Total System Global Area 444596224 bytes 21. Fixed Size 1219904 bytes 22. Variable Size 167772864 bytes 23. Database Buffers 272629760 bytes 24. Redo Buffers 2973696 bytes 25. ORA-00205: error in identifying control file, check alert log for more i nfo

run the create_ctl.sql script to recreate a lost control files SQL> @/home/oracle/Desktop/create_ctl.sql Control file created. SQL> alter database open resetlogs; alter database open resetlogs * ERROR at line 1: ORA-01194: file 1 needs more recovery to be consistent ORA-01110: data file 1: '/u01/app/oracle/oradata/rev1/system01.dbf' SQL> recover database using backup controlfile until cancel; ORA-00279: change 557988 generated at 09/21/2010 16:13:51 needed for thread 1 ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/REV1/archivelog/2010_09_21/o1_mf_1_4_%u_.arc ORA-00280: change 557988 for thread 1 is in sequence #4 Specify log: {=suggested filename AUTO CANCEL} auto ORA-00308: cannot open archived log '/u01/app/oracle/flash_recovery_area/REV1/archivelog/2010_09_21/o1_mf_1_4_%u_.ar c' ORA-27037: unable to obtain file status Linux Error: 2: No such file or directory Additional information: 3 ORA-00308: cannot open archived log '/u01/app/oracle/flash_recovery_area/REV1/archivelog/2010_09_21/o1_mf_1_4_%u_.ar c' ORA-27037: unable to obtain file status Linux Error: 2: No such file or directory Additional information: 3 ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below ORA-01194: file 1 needs more recovery to be consistent ORA-01110: data file 1: '/u01/app/oracle/oradata/rev1/system01.dbf'

apply the current online redolog files for recover the database here in our exam ple the current logfile is redo02.log SQL> col member format a50 SQL> select a.group#,a.member,b.status from v$logfile a, v$log b where a.group#= b.group#; GROUP# MEMBER STATUS ---------- -------------------------------------------------- ---------------3 /u01/app/oracle/oradata/rev1/redo03.log ACTIVE 2 /u01/app/oracle/oradata/rev1/redo02.log CURRENT 1 /u01/app/oracle/oradata/rev1/redo01.log ACTIVE SQL> recover database using backup controlfile until cancel;

ORA-00279: change 557988 generated at 09/21/2010 16:13:51 needed for thread 1 ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/REV1/archivelog/2010_09_21/o1_mf_1_4_%u_.arc ORA-00280: change 557988 for thread 1 is in sequence #4 Specify log: {=suggested filename AUTO /u01/app/oracle/oradata/rev1/redo02.log Log applied. Media recovery complete. SQL> alter database open resetlogs; Database altered. SQL> archive log list; Database log mode Automatic archival Archive destination Oldest online log sequence Next log sequence to archive Current log sequence hope, this will helps you Archive Mode Enabled USE_DB_RECOVERY_FILE_DEST 0 1 1 CANCEL}

Potrebbero piacerti anche