{"id":416,"date":"2009-02-13T10:44:54","date_gmt":"2009-02-13T15:44:54","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=416"},"modified":"2009-02-13T10:44:54","modified_gmt":"2009-02-13T15:44:54","slug":"oracle-8i-backup-and-recovery","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=416","title":{"rendered":"Oracle 8i Backup and Recovery"},"content":{"rendered":"<p>B&#038;R I<br \/>\n\u2022Oracle structure<br \/>\nv$sga<br \/>\nv$sgastat<br \/>\nv$database<br \/>\nv$instance<br \/>\nv$process<br \/>\nv$bgprocess<br \/>\nv$datafile<\/p>\n<p>\u2022Large pool<br \/>\n-set by LARGE_POOL_SIZE<br \/>\n-min 300k max 2gb<br \/>\n-DBWR_IO_SLAVES (if > 0, ARCn,LGWR,RM are set to 4)<br \/>\n-BACKUP_TAPE_IO_SLAVES (if true, an i\/o slave process is used to rw tape device)<\/p>\n<p>\u2022Data Buffer Cache<br \/>\n-stores mru data blocks<\/p>\n<p>\u2022DBWn<br \/>\n-writes dirty buffers from db buffer cache to data files<br \/>\n-triggered by ckpt event<br \/>\n-DBW1 -> DBW9<br \/>\n-not useful on uniprocessor systems<\/p>\n<p>\u2022Data files<br \/>\n-commited: normal<br \/>\n-uncommited: shutdown abort, db fail<\/p>\n<p>\u2022Tablespace<br \/>\n-temp: can be recreated<br \/>\n-rbs: should have own tablespace<br \/>\n-readonly tblspc<br \/>\n-index data:  can be recreated<\/p>\n<p>\u2022Redo Log Buffer<br \/>\n-circular buffer about changes made<\/p>\n<p>\u2022LGWR<br \/>\n-writes redo entries to redo log files:<br \/>\n\tredo log buff is 1\/3 full<br \/>\n\ttime out occurs (every 3 sec)<br \/>\n\tbefore DBWn writes<br \/>\n\twhen transaction commits<\/p>\n<p>\u2022Redo Log Files<br \/>\n-need at least two log groups<br \/>\n-each group should >2 members<br \/>\n-multiplexing Redo Log Files.<br \/>\n-To move a redo log file<br \/>\n\t1 alter system switch log file;<br \/>\n\t2 copy file to new location<br \/>\n\t3 alter database db<br \/>\n\t\trename file &#8216;file'[, &#8216;file&#8217;] &#8230;<br \/>\n\t\tto &#8216;file'[, &#8216;file&#8217;]&#8230;<br \/>\n-To add a member to a group<br \/>\n\talter database db<br \/>\n\tadd logfile member<br \/>\n\t&#8230;<br \/>\n-To drop a member from a group<br \/>\n\talter database db<br \/>\n\tdrop logfile member<br \/>\n\t&#8216;file'[, &#8216;file&#8217;]&#8230;<\/p>\n<p>\u2022Redo Log switch<br \/>\n-current redo log group is assigned a log seq no which is also used for sync<br \/>\n-when<br \/>\n\tLGWR filled one log file group<br \/>\n\tdba issues ALTER SYSTEM SWITCH LOGFILS<br \/>\n-checkpoint automatically occurs<\/p>\n<p>\u2022Dynamic views<br \/>\n-v$log<br \/>\n-v$logfile<br \/>\n-v$log_history<\/p>\n<p>\u2022CKPT<br \/>\n-at ckpt<br \/>\n\t1 modified db buffers written to db file -> db header files marked curr<br \/>\n\t2 ckpt seq no written to cont file<br \/>\n-occurs<br \/>\n1 every log switch<br \/>\n2 fast-start checkpointing<br \/>\n3 > log_checkpoint_interval need to be read during instance recovery<br \/>\n4 instance shutdown unless aborted<br \/>\n5 alter system checkpoint<br \/>\n6 tblspc taken offline or an online backup is started<br \/>\n-sync<br \/>\n\tat ckpt, ckpt no is updated in evere db file header and in cont file<br \/>\n\tif redo, control, and data files have same ckpt no -> consistent db<br \/>\n-expedite instance recovery<\/p>\n<p>\u2022Multiplexing control files<br \/>\n1 shutdown db<br \/>\n2 copy cont file to different loc<br \/>\n3 edit CONTROL_FILES<br \/>\n4 start db<\/p>\n<p>\u2022ARCn and Archive Log Files<\/p>\n<p>B&#038;R II<br \/>\n\u2022Statement failure<br \/>\n-no dba intervention required<br \/>\n\u2022User Process Failure<br \/>\n-no dba intervention required<br \/>\n-PMON automatically handles it<br \/>\n\u2022User error failure<br \/>\n\u2022Instance failure<br \/>\n-no dba intervention required<br \/>\n-SMON handles it automatically<\/p>\n<p>\u2022Fast-start parallel rollback<br \/>\n-SMON uses parallel query slaves when a transaction is larger than 100 rollback blocks<br \/>\n-FAST_START_PARALLEL_ROLLBACK<br \/>\n\tFALSE\tnone<br \/>\n\tLOW\t2 * cpu_count<br \/>\n\tHIGH\t4 * cpu_count<br \/>\n-v$fast_start_servers<br \/>\n-v$fast_start_transactions<\/p>\n<p>\u2022Archivelog mode<br \/>\n-media recovery can be restored to<br \/>\n\tspecific point in time<br \/>\n\tend of a specific arch log file<br \/>\n\tspecific scn<br \/>\n-log_archive_dest_n where n = 1 &#8211; 5<br \/>\n~_1 = &#8220;location=\/arch1 mandatory reopen&#8221; (default to reopen=300)<br \/>\n~_2 = &#8220;service=db1&#8221;<br \/>\n-log_archive_min_succeed_dest<br \/>\n-log_archive_dest_state_n=[defer|enable]<br \/>\n\u2022Enable archivelog mode<br \/>\n1 shutdown immediate<br \/>\n2 startup mount<br \/>\n3 alter database [archivelog| noarchivelog]<br \/>\n4 alter database open<br \/>\n5 shutdown immediate<br \/>\n6 full db backup<\/p>\n<p>\u2022Multiple arch process<br \/>\n-log_archive_max_processes<br \/>\n-log_archive_start<\/p>\n<p>\u2022Enabling archive process in an open instance<br \/>\n1 archive log list<br \/>\n2 alter system archive log start to &#8216;\/u04\/ora\/test\/log&#8217;;<\/p>\n<p>\u2022Start or stop additional arch proc<br \/>\n-alter system set loq_archive_max_processes=3;<\/p>\n<p>-alter system archive log stop;<br \/>\n-log_archive_start=false<br \/>\n-set db to noachivelog<\/p>\n<p>\u2022Dynamic views<br \/>\nv$archived_log<br \/>\nv$archived_dest<br \/>\nv$log_history<br \/>\nv$database<br \/>\nv$archive_processes<br \/>\narchive log list;<\/p>\n<p>\u2022Closed Database Backups<br \/>\nFiles to backup<br \/>\n-data files V$DATAFILE dba_datafiles<br \/>\n-control files V$CONTROLFILE<br \/>\n-parameter files V$LOGFILE<br \/>\n-password files<br \/>\n-redo log files (optional)<\/p>\n<p>Procedure<br \/>\n1 shutdown db<br \/>\n2 backup files<br \/>\n3 open db<\/p>\n<p>\u2022Open db backup<br \/>\n1 alter tablespace user begin backup;<br \/>\n2 cp user01.dbf \/backup!user01.dbf<br \/>\n3  alter tablespace user end backup;<br \/>\n4 alter system switch logfiles;<br \/>\n5 repeat for all tblspc including system, temp, rbs&#8230;<\/p>\n<p>-v$backup<br \/>\n-v$datafile_header<\/p>\n<p>\u2022Backup control file<br \/>\n-alter database backup control file to &#8216;control.bak&#8217;;<br \/>\n-alter database backup control file to<br \/>\ntrace;<br \/>\n-needed after every change to db config.<\/p>\n<p>\u2022Read-only Tablespace backup<br \/>\n-alter tablespace query_data read only<\/p>\n<p>\u2022Logging and nologging options<br \/>\n-enable nologging on tblspc, tbl, ind, or partition for direct load operations<br \/>\n-enable logging afterward<\/p>\n<p>B&#038;R III<\/p>\n<p>Complete recoveryin achive mode<\/p>\n<p>\u2022Restore file to diff location<br \/>\n1 startup mount pfile=init.ora;<br \/>\n2 alter database rename file<br \/>\n&#8216;\/d1\/user.dbf&#8217; to &#8216;\/d2\/user.dbf;<br \/>\n3 alter database open;<\/p>\n<p>\u2022Files needed for recovery<br \/>\n-v$recover_file<br \/>\n-v$log_history<br \/>\n-v$recovery_log<\/p>\n<p>\u2022Apply redo log files automatically<br \/>\nsql>set autorecovery on;<br \/>\nor<br \/>\nsql>recover automatic datafile 4<\/p>\n<p>\u2022Recovering a closed database<br \/>\n1 restore file from backup<br \/>\n2 startup mount pfile=&#8217;\/d2\/df2.dbf&#8217;<br \/>\n3 alter database open;<\/p>\n<p>\u2022recover open db initially opened<br \/>\n-recovered files do not belong to system or rb tblspc<br \/>\n1 restore datafile<br \/>\n2 recover datafile &#8216;\/d2\/db2.dbf&#8217;;<br \/>\nor recover tablespace USER_DATA;<br \/>\n3 alter database datafile &#8216;\/d2\/db2.dbf&#8217; online;<br \/>\nor alter tablespace USER_DATA online<\/p>\n<p>\u2022recover open db initially closed<br \/>\n-recovered files do not belong to system or rb tblspc<br \/>\n1 startup mount pfile=\/d1\/init.ora;<br \/>\n2 alter database datafile &#8216;\/d1\/df2.dbf&#8217; offline;<br \/>\n3 alter database open;<br \/>\n4 copy datafile<br \/>\n5 alter database rename file &#8216;\/d1\/df2.dbf&#8217; to &#8216;\/d3\/df2.dbf&#8217;;<br \/>\n6 recover datafile &#8216;\/d2\/db2.dbf&#8217;;<br \/>\nor recover tablespace USER_DATA;<br \/>\n7 alter database datafile &#8216;\/d2\/db2.dbf&#8217; online;<br \/>\nor alter tablespace USER_DATA online<\/p>\n<p>\u2022Recover loss of data file w\/ no bak<br \/>\n1 alter tablespace TABLE_DATA offline immediate;<br \/>\n2 alter database create datafile &#8216;\/d2\/df2.dbf&#8217; as &#8216;\/d1\/df2.dbf&#8217;;<br \/>\n3 recover tablespace TABLE_DATA;<br \/>\n4 alter tablespace TABLE_DATA online<\/p>\n","protected":false},"excerpt":{"rendered":"<p>B&#038;R I \u2022Oracle structure v$sga v$sgastat v$database v$instance v$process v$bgprocess v$datafile \u2022Large pool -set by LARGE_POOL_SIZE -min 300k max 2gb -DBWR_IO_SLAVES (if > 0, ARCn,LGWR,RM are set to 4) -BACKUP_TAPE_IO_SLAVES (if true, an i\/o slave process is used to rw &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=416\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[35],"tags":[],"class_list":["post-416","post","type-post","status-publish","format-standard","hentry","category-oracle"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-6I","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=416"}],"version-history":[{"count":1,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/416\/revisions"}],"predecessor-version":[{"id":417,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/416\/revisions\/417"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}