第7章:備用資料庫之初始化備用資料庫
/* 2008/05/30
*環境:Windows XP +Oracle10.2.0.1
*Oracle 備份與恢復培訓教程 Kenny Smith,Stephan Haisley著 周琪、韓岷、李渝琳等譯
*第二部分:使用者管理的備份與恢復
*第7章:備用資料庫
*/
練習7.1:初始化備用資料庫
1、為備用資料庫做準備
為準備建立standby資料庫建立所有路徑:
C:\>set oracle_sid=standby
C:\>set oracle_base=G:\oracle
C:\>set ORACLE_HOME=G:\oracle\product\10.2.0\db_1
C:\>mkdir G:\oracle\product\10.2.0\admin\standby
C:\>mkdir G:\oracle\product\10.2.0\admin\standby\pfile
C:\>mkdir G:\oracle\product\10.2.0\admin\standby\bdump
C:\>mkdir G:\oracle\product\10.2.0\admin\standby\cdump
C:\>mkdir G:\oracle\product\10.2.0\admin\standby\udump
C:\>mkdir G:\oracle\product\10.2.0\admin\standby\create
C:\>mkdir G:\oracle\product\10.2.0\oradata\standby
C:\>mkdir G:\oracle\product\10.2.0\oradata\standby\archive
2、製作開啟資料庫的備份
熱備份資料到standby資料庫
在e:\open_backup.sql指令碼,內容為:
Set feedback off pagesize 0 heading off verify off linesize 200 trimspool on
define dir='G:\oracle\product\10.2.0\oradata\standby'
define fil='e:\open_backup_commands.sql'
define spo='&dir\open_backup_output.lst'
prompt *** Spooling to &fil
set serveroutput on
spool &fil
prompt spool &spo
prompt archive log list;;
prompt alter system switch logfile;;
declare
cursor cur_tablespace is
select tablespace_name from dba_tablespaces
where status<>'READ ONLY' and tablespace_name<>'TEMP';
cursor cur_datafile (tn varchar) is
select file_name
from dba_data_files
where tablespace_name=tn;
begin
for ct in cur_tablespace loop
dbms_output.put_line('alter tablespace '||ct.tablespace_name||' begin backup;');
for cd in cur_datafile (ct.tablespace_name) loop
dbms_output.put_line('host copy '||cd.file_name||' &dir');
end loop;
dbms_output.put_line('alter tablespace '|| ct.tablespace_name||' end backup;');
end loop;
end;
/
prompt alter system switch logfile;;
prompt alter database create standby controlfile as 'G:\oracle\product\10.2.0\oradata\standby\standby.ctl' reuse;;
prompt archive log list;;
prompt spool off;;
spool off;
@&fil
在risenet資料庫上執行該指令碼
SQL> @e:\open_backup.sql
3、配置備用引數檔案
SQL> create pfile from spfile;
在G:\oracle\product\10.2.0\db_1\database\生成initrisenet.ora檔案
複製risenet資料庫的引數檔案:G:\oracle\product\10.2.0\db_1\database\initrisenet.ora,到G:\oracle\product\10.2.0\db_1
\database\initstandby.ora,並修改相關資料庫名稱。
修改後內容:
standby.__db_cache_size=163577856
standby.__java_pool_size=4194304
standby.__large_pool_size=4194304
standby.__shared_pool_size=92274688
standby.__streams_pool_size=0
*.audit_file_dest='G:\oracle\product\10.2.0/admin/standby/adump'
*.background_dump_dest='G:\oracle\product\10.2.0/admin/standby/bdump'
*.compatible='10.2.0.1.0'
*.control_files='G:\oracle\product\10.2.0/oradata/standby/\standby.ctl'
*.core_dump_dest='G:\oracle\product\10.2.0/admin/standby/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=8
*.db_name='risenet'
*.db_recovery_file_dest='G:\oracle\product\10.2.0/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=standbyXDB)'
*.job_queue_processes=10
*.log_archive_format='ARC%S_%R.%T'
*.open_cursors=300
*.pga_aggregate_target=89128960
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=269484032
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='G:\oracle\product\10.2.0/admin/standby/udump'
*.db_file_name_convert='G:\oracle\product\10.2.0\oradata\risenet','G:\oracle\product\10.2.0\oradata\standby'
建立口令:
C:\>oradim -new -sid standby -intpwd standby
例項已建立。
4、載入備用資料庫
C:\>set oracle_sid=standby
C:\>sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 1月 30 11:36:14 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> connect sys/standby as sysdba
已連線到空閒例程。
SQL> startup nomount;
ORACLE 例程已經啟動。
Total System Global Area 272629760 bytes
Fixed Size 1248476 bytes
Variable Size 100664100 bytes
Database Buffers 163577856 bytes
Redo Buffers 7139328 bytes
SQL> alter database mount standby database;
alter database mount standby database
*
第 1 行出現錯誤:
ORA-01102: ??? EXCLUSIVE ????????
eygle提到:
注意,此時試圖載入資料庫時出現錯誤,因為當前資料庫被另外一個例項(instance)載入。在非並行模式(OPS/RAC)下,一個資料庫同時只能被
一個例項載入。
來自:http://www.itpub.net/313101.html
主資料庫和備用資料庫不能同時啟動的問題已經找到了,原因是兩個資料庫在同一臺電腦上,只要在pfile後加*.lock_name_space=standby
更改initstandby.ora內容為:
standby.__db_cache_size=163577856
standby.__java_pool_size=4194304
standby.__large_pool_size=4194304
standby.__shared_pool_size=92274688
standby.__streams_pool_size=0
*.audit_file_dest='G:\oracle\product\10.2.0/admin/standby/adump'
*.background_dump_dest='G:\oracle\product\10.2.0/admin/standby/bdump'
*.compatible='10.2.0.1.0'
*.control_files='G:\oracle\product\10.2.0/oradata/standby/\standby.ctl'
*.core_dump_dest='G:\oracle\product\10.2.0/admin/standby/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=8
*.db_name='risenet'
*.db_recovery_file_dest='G:\oracle\product\10.2.0/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=standbyXDB)'
*.job_queue_processes=10
*.log_archive_format='ARC%S_%R.%T'
*.open_cursors=300
*.pga_aggregate_target=89128960
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=269484032
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='G:\oracle\product\10.2.0/admin/standby/udump'
*.db_file_name_convert='G:\oracle\product\10.2.0\oradata\risenet','G:\oracle\product\10.2.0\oradata\standby'
*.lock_name_space=standby
重新啟動
C:\>set oracle_sid=standby
C:\>sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 1月 30 12:27:30 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
已連線到空閒例程。
SQL> startup nomount
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE 例程已經啟動。
Total System Global Area 272629760 bytes
Fixed Size 1248476 bytes
Variable Size 100664100 bytes
Database Buffers 163577856 bytes
Redo Buffers 7139328 bytes
SQL> alter database mount standby database;
資料庫已更改。
成功!!!
問答:
1、為什麼要恢復備用資料庫?
A、備用資料庫崩潰了
B、來自主資料庫歸檔日誌的變化必須要應用到備用資料庫上
C、備用資料庫的聯機重做日誌已經重新設定了
D、在備用資料庫上進行的恢復使之與主資料庫保持一致
答案:BD
2、當備用資料庫開啟以備查詢時,可以繼續恢復該資料庫
A、True
B、False
答案:B
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12778571/viewspace-324461/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle資料庫備份之exp增量備份Oracle資料庫
- 資料庫備份資料庫
- oracle 備份資料庫,匯出資料庫Oracle資料庫
- mysql 資料庫 備份MySql資料庫
- 資料庫的災備資料庫
- 資料庫備份策略資料庫
- MongoDB資料庫備份MongoDB資料庫
- mongodb資料庫備份與恢復(資料庫資料遷移)MongoDB資料庫
- 使用RMAN備份資料庫資料庫
- 資料庫備份恢復資料庫
- SQL資料庫備份管理SQL資料庫
- innobackupex 備份MySQL資料庫MySql資料庫
- 資料庫備份指令碼資料庫指令碼
- mysqlpump 資料庫備份程式MySql資料庫
- mysqldump 資料庫備份程式MySql資料庫
- Openfire安裝準備-MySQL資料庫準備MySql資料庫
- 利用RMAN備份重建資料庫資料庫
- mysql資料庫備份命令大全MySql資料庫
- dnf資料庫備份&遷移資料庫
- 2.4.14 Step 13: 備份資料庫資料庫
- DM資料庫熱備試驗資料庫
- 備份mysql資料庫報告MySql資料庫
- 1. 備份MySQL資料庫MySql資料庫
- postgresql資料庫怎麼備份SQL資料庫
- MySQL資料庫的基本備份MySql資料庫
- Mysql資料庫自動備份MySql資料庫
- 定時備份MySQL資料庫MySql資料庫
- SQL Server2019資料庫備份與還原指令碼,資料庫可批量備份SQLServer資料庫指令碼
- SqlServer資料庫恢復備份資料的方法SQLServer資料庫
- 帝國cms備份的資料庫資料夾資料庫
- Dedecms備份的資料檔案位置及備份資料庫的方法資料庫
- DM8資料庫備份還原的原理及應用資料庫
- BMMySQL定時備份資料庫(全庫備份)的實現meuMySql資料庫
- (7) MySQL資料庫備份詳解MySql資料庫
- Oracle資料庫冷備和恢復Oracle資料庫
- sqlserver資料庫的備份還原SQLServer資料庫
- golang實現mysql資料庫備份GolangMySql資料庫
- Mysql資料庫備份及恢復MySql資料庫
- sqlserver資料庫備份,還原操作SQLServer資料庫