你說的是oracle的dg技術(shù)嗎?可以使用select open_mode,database_role from v$database語句查詢數(shù)據(jù)庫(kù)角色
公司主營(yíng)業(yè)務(wù):成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、移動(dòng)網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)推出金秀免費(fèi)做網(wǎng)站回饋大家。
oracle的從庫(kù)有三種角色,物理備庫(kù)、邏輯備庫(kù)、快照備庫(kù)。
物理備庫(kù)只能處于只讀狀態(tài),無法執(zhí)行寫的操作
邏輯備庫(kù)處于讀寫的狀態(tài),但是在備庫(kù)寫入的數(shù)據(jù)不會(huì)同步到主庫(kù)的
快照備庫(kù)處于讀寫狀態(tài),類似于給數(shù)據(jù)庫(kù)創(chuàng)建一個(gè)還原點(diǎn)。
三者之間是可以互相轉(zhuǎn)換的。
1、oracle雙機(jī)熱備叫做DataGuard簡(jiǎn)稱DG,簡(jiǎn)單來說就一些步驟,每個(gè)步驟都有些概念需要了解。
2、10g和11g稍微有點(diǎn)區(qū)別,10g備庫(kù)在熱備狀態(tài)不能open查詢,11g支持ActiveDataguard備庫(kù)可以在熱備狀態(tài)open并select數(shù)據(jù):alter database open read only;。
3、DG多配置幾次就會(huì)輕車熟路。
4、首先數(shù)據(jù)庫(kù)必須開啟歸檔模式,然后復(fù)制一份主庫(kù)到備庫(kù),這個(gè)步驟11g也有更先進(jìn)的命令,11g支持-Active database duplicate。
備份主庫(kù)過程可以熟悉一下rman這個(gè)工具。
5、DG配置監(jiān)聽listener.ora和initSID.ora
在使用DATA GUARD 時(shí),要求使用強(qiáng)制記錄日志模式。日志記錄模式(LOGGING 、FORCE LOGGING 、NOLOGGING)
ALTER DATABASE FORCE LOGGING;
6、啟動(dòng)備庫(kù)
物理standby極少情況下可以以read-write模式打開,某些情況下可以以read-only模式打開,所以默認(rèn)情況下,加載到mount狀態(tài)即可。
SQL STARTUP MOUNT;
啟動(dòng)redo應(yīng)用
SQL ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
啟動(dòng)實(shí)時(shí)應(yīng)用
SQL ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
7、DG主庫(kù)和備庫(kù)之間角色切換
DATAGUARD包含三個(gè)服務(wù)(日志傳輸、日志應(yīng)用、角色轉(zhuǎn)換)
8、DATAGUARD的幾種保護(hù)模式:最大保護(hù)maximum protection,最大可用maximum availability,最大性能maximum performance
例如在主庫(kù)修改保護(hù)模式為maximize availability,并打開數(shù)據(jù)庫(kù)
ALTER DATABASE SET STANDBY DATABASE TO maximize availability;
你這個(gè)屬于主、備機(jī)切換
1.?察看主庫(kù)狀態(tài)
select?switchover_status?from?v$database;
收集主庫(kù)上的臨時(shí)表空間的情況,原因是備庫(kù)激活后臨時(shí)文件可能丟失,需要手工建上去:
col?file_name?format?a40
select?file_name,tablespace_name,bytes/1024/1024?from?dba_temp_files;
FILE_NAME????????????????????????????????TABLESPACE_NAME??????BYTES/1024/1024
----------------------------------------?--------------------?---------------
/data/oradata/alihr/temp01.dbf???????????TEMP????????????????????????????2048
2.切換主庫(kù)到standby
alter?database?commit?to?switchover?to?physical?standby;
或:
ALTER?DATABASE?COMMIT?TO?SWITCHOVER?TO?PHYSICAL?STANDBY?WITH?SESSION?SHUTDOWN;
shutdown?immediate;
startup?nomount;
alter?database?mount?standby?database;
3.驗(yàn)證要被切換的standby是否接收到switch?to?通知
SELECT?SWITCHOVER_STATUS?FROM?V$DATABASE;?
以前的狀態(tài)就是SESSIONS?ACTIVE,現(xiàn)在就變?yōu)門O?PRIMARY
4.切換物理standby到主用模式,檢查redo?log是否創(chuàng)建好
ALTER?DATABASE?COMMIT?TO?SWITCHOVER?TO?PRIMARY;
shutdown?immediate;
startup;
5.?standby數(shù)據(jù)庫(kù)切換成主庫(kù)后,檢查是否需要、對(duì)臨時(shí)表空間增加臨時(shí)文件:
先檢查臨時(shí)文件是否丟失:
col?file_name?format?a60
select?file_name,tablespace_name?from?dba_temp_files;
把結(jié)果前面原主庫(kù)上的臨時(shí)文件進(jìn)行對(duì)比,如有丟失則使用如下命令增加:
alter?tablespace?temp?add?tempfile?'/data/oradata/alihr/temp02.dbf'?size?2048M?reuse;
正常情況下,如果db_file_name_convert參數(shù)設(shè)置正確的話,11g會(huì)自動(dòng)建立temp?file
6.在新的standby機(jī)器上
alter?system?set?log_archive_dest_state_2='defer';
alter?database?recover?managed?standby?database?disconnect?from?session;
7.檢查主備庫(kù)中fal參數(shù)
fal_server服務(wù)名是在standby機(jī)器的tnsnames中,指向主庫(kù),fal_client是在主庫(kù)上的tnsnames中,指向standby。
fal參數(shù)只在standby機(jī)器上生效,所以在standby機(jī)器上fal_server指向主庫(kù),fal_client機(jī)器指向備庫(kù).
而主庫(kù)上的fal參數(shù)雖然不生效,但為了避免主庫(kù)切換成standby時(shí),我們還要修改fal參數(shù),所以現(xiàn)在就設(shè)置好,
讓fal_server指向現(xiàn)在的standby數(shù)據(jù)庫(kù),fal_client指向自己。
8.在新的主庫(kù)
alter?system?set?log_archive_dest_state_2='enable';
alter?system?archive?log?current;?
然后到備庫(kù)上檢查備庫(kù)機(jī)器上日志是否正常的傳過來了。
9.檢查和調(diào)整主備庫(kù)兩臺(tái)機(jī)器中的crontab中的數(shù)據(jù)庫(kù)備份腳本和刪除歸檔腳本。
=================oracle11g的最大保護(hù)和最大可用模式下的切換==================
如果主庫(kù)是意外宕機(jī)的,則直接把備庫(kù)切換成主庫(kù):
ALTER?DATABASE?RECOVER?MANAGED?STANDBY?DATABASE?CANCEL;
ALTER?DATABASE?RECOVER?MANAGED?STANDBY?DATABASE?FINISH;
shutdown?immediate;
connect?/?as?sysdba;
startup?mount;
ALTER?DATABASE?COMMIT?TO?SWITCHOVER?TO?PRIMARY;
shutdown?immediate;
connect?/?as?sysdba;
startup?mount;
ALTER?DATABASE?SET?STANDBY?DATABASE?TO?MAXIMIZE?AVAILABILITY;
alter?database?open;
注意:上面操作中是手工的把數(shù)據(jù)庫(kù)重新置成MAXIMIZE?AVAILABILITY,否則數(shù)據(jù)庫(kù)起來后是最大性能模式。
檢查數(shù)據(jù)庫(kù)的角色:
select?database_role?from?v$database;
原有主庫(kù)啟動(dòng)后,如果不是硬盤壞,主庫(kù)上的數(shù)據(jù)還存在,則把主庫(kù)轉(zhuǎn)換成standby就可以了:
主庫(kù)上:
startup?mount;
recover?automatic?database;
ALTER?DATABASE?CONVERT?TO?PHYSICAL?STANDBY;
shutdown?immediate;
注意千萬不要把主庫(kù)打開了,否則會(huì)導(dǎo)致主庫(kù)的SCN發(fā)生變化,無法轉(zhuǎn)換成standby數(shù)據(jù)庫(kù)了。
在把原先的主庫(kù)轉(zhuǎn)化為standby時(shí),有時(shí)可能報(bào)如下錯(cuò)誤:
SQL?alter?database?recover?managed?standby?database?finish;
alter?database?recover?managed?standby?database?finish
*
ERROR?at?line?1:
ORA-00283:?recovery?session?canceled?due?to?errors
ORA-19909:?datafile?1?belongs?to?an?orphan?incarnation
ORA-01110:?data?file?1:?'/opt/oracle/oradata/oratest/system01.dbf'
這里把到rman中:
list?incarnation?of?database;
reset?database?to?incarnation?1;
recover?database;
reset?database?to?incarnation?2;
=========================================================
failover在物理standby的切換
1.檢查standby看是否使用了standby?log
2.有standby?log,執(zhí)行下面的命令
ALTER?DATABASE?RECOVER?MANAGED?STANDBY?DATABASE?CANCEL;
ALTER?DATABASE?RECOVER?MANAGED?STANDBY?DATABASE?FINISH;
2.1?沒有standby?log則不執(zhí)行上面的
ALTER?DATABASE?RECOVER?MANAGED?STANDBY?DATABASE?FINISH?SKIP?STANDBY?LOGFILE;
3.?切換
ALTER?DATABASE?COMMIT?TO?SWITCHOVER?TO?PRIMARY;
3.1?如果上面3步驟失敗,則
ALTER?DATABASE?ACTIVATE?STANDBY?DATABASE;
4.?重啟db
shutdown?immediate
startup
switchover的方法:
主庫(kù)和物理standby的切換
1.察看主庫(kù)狀態(tài)
SELECT?SWITCHOVER_STATUS?FROM?V$DATABASE;
2.切換
ALTER?DATABASE?COMMIT?TO?SWITCHOVER?TO?PHYSICAL?STANDBY;
3.原主庫(kù)
shutdown?immediate;
startup?nomount
alter?database?mount?standby?database;
4.驗(yàn)證要被切換的standby是否接收到switch?to?通知
SELECT?SWITCHOVER_STATUS?FROM?V$DATABASE;?
增加online?redo日志
5.切換物理standby到主
ALTER?DATABASE?COMMIT?TO?SWITCHOVER?TO?PRIMARY;
shutdown?immediate;
startup;
6.在新的standby機(jī)器(也就是老的主庫(kù))
ALTER?DATABASE?RECOVER?MANAGED?STANDBY?DATABASE?DISCONNECT?FROM?SESSION;
7.在新的主庫(kù)
alter?system?archive?log?current;?
========active?standby?database===========
當(dāng):
alter?database?activate?standby?database;
原來的主庫(kù)只能通過閃回轉(zhuǎn)化成standby?database,但要求數(shù)據(jù)庫(kù)的flashback打開。
在新主庫(kù)上:
select?to_char(standby_became_primary_scn)?from?v$database;
在舊主庫(kù)上:
SHUTDOWN?IMMEDIATE;
STARTUP?MOUNT;
FLASHBACK?DATABASE?TO?SCN?standby_became_primary_scn;
ALTER?DATABASE?CONVERT?TO?PHYSICAL?STANDBY;
select?max(sequence#)?from?v$log_history?where?RESETLOGS_TIME=(select?max(RESETLOGS_TIME)?from?v$log_history);?
實(shí)例恢復(fù):
recover?managed?standby?database?disconnect?using?current?logfile;
=================lgwr設(shè)置====================================
alter?system?set?log_archive_dest_3?=?'location=/disk3/arch/bopscha?reopen=2?MAX_FAILURE=3';
alter?system?set?log_archive_dest_state_3?=?alternate;
alter?system?set?log_archive_dest_1?=?'location=/disk2/arch/bopscha?alternate=log_archive_dest_3?reopen=60?MAX_FAILURE=5'?;
*.log_archive_dest_2='SERVICE=DTMRT?LGWR?ASYNC??VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)?DB_UNIQUE_NAME=DTMRT';
alter?database?add?standby?logfile?group?4?('/oracle/u02/ORA10GDG/STANDBYRD01.LOG')?size?200M;
select?group#,thread#,sequence#,archived,status?from?v$standby_log;
alter?database?set?standby?database?to?maximize?{availability?|?performance?|?protection};
select?protection_mode?from?v$database;
ORA-19527:
LOG_FILE_NAME_CONVERT='/u02/oracle/oradata/oract/','/u02/oracle/oradata/oract/'
alter?system?set?log_archive_dest_2='SERVICE=bopsteststb?lgwr?sync?affirm';
select?frequency,?duration?from?v$redo_dest_resp_histogram?where?dest_id=2?and?frequency1;
SQL?ALTER?DATABASE?RECOVER?MANAGED?STANDBY?DATABASE?CANCEL;
SQL?ALTER?DATABASE?OPEN;
SQL?ALTER?DATABASE?RECOVER?MANAGED?STANDBY?DATABASE?USING?CURRENT?LOGFILE?DISCONNECT;?
alter?database?convert?to?snapshot?standby;
alter?database?convert?to?physical?standby;
ALTER?DATABASE?RECOVER?MANAGED?STANDBY?DATABASE?USING?CURRENT?LOGFILE?DISCONNECT;
alter?database?commit?to?switchover?to?physical?standby;
alter?database?activate?standby?database?finish?apply;
alter?database?recover?managed?standby?database?finish;?
舊主庫(kù)轉(zhuǎn)換成standby的步驟:
在新主庫(kù)上:
select?to_char(standby_became_primary_scn)?from?v$database;
在舊主庫(kù)上:
SHUTDOWN?IMMEDIATE;
STARTUP?MOUNT;
FLASHBACK?DATABASE?TO?SCN?standby_became_primary_scn;
ALTER?DATABASE?CONVERT?TO?PHYSICAL?STANDBY;
ALTER?DATABASE?COMMIT?TO?SWITCHOVER?TO?PRIMARY?WITH?SESSION?SHUTDOWN;
ALTER?DATABASE?RECOVER?MANAGED?STANDBY?DATABASE?FINISH?FORCE;
SQL select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
2.確認(rèn)主庫(kù)處于歸檔模式
SQL archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u02/arch
Oldest online log sequence 154
Next log sequence to archive 156
Current log sequence 156
3.創(chuàng)建備庫(kù)instance
windows平臺(tái)利用oradim工具創(chuàng)建一個(gè)新的instance,unix/linux平臺(tái)設(shè)置新的ORACLE_SID即可
4.準(zhǔn)備好主備庫(kù)的參數(shù)文件
主庫(kù):
orcl.__db_cache_size=184549376
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__shared_pool_size=88080384
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/oracle/admin/orcl/adump'
*.background_dump_dest='/u01/oracle/admin/orcl/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/oracle/oradata/orcl/control01.ctl','/u01/oracle/oradata/orcl/control02.ctl','/u01/oracle/oradata/orcl/control03.ctl'
*.core_dump_dest='/u01/oracle/admin/orcl/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/u02/arch'
*.log_archive_format='%t_%s_%r.dbf'
*.nls_language='SIMPLIFIED CHINESE'
*.nls_territory='CHINA'
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=285212672
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/oracle/admin/orcl/udump'
#################################
db_unique_name=node1
service_names=orcl
log_archive_config='dg_config=(node1,node2)'
log_archive_dest_2='service=dbstandby valid_for=(online_logfiles,primary_role) db_unique_name=node2'
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
fal_server=dbstandby
standby_file_management=AUTO
備庫(kù):
orcl.__db_cache_size=184549376
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__shared_pool_size=88080384
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/oracle/admin/orcl/adump'
*.background_dump_dest='/u01/oracle/admin/orcl/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/oracle/oradata/orcl/control01.ctl','/u01/oracle/oradata/orcl/control02.ctl','/u01/oracle/oradata/orcl/control03.ctl'
*.core_dump_dest='/u01/oracle/admin/orcl/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/u02/arch'
*.log_archive_format='%t_%s_%r.dbf'
*.nls_language='SIMPLIFIED CHINESE'
*.nls_territory='CHINA'
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=285212672
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/oracle/admin/orcl/udump'
#################################
db_unique_name=node2
service_names=orcl
log_archive_config='dg_config=(node1,node2)'
log_archive_dest_2='service=dbprimary valid_for=(online_logfiles,primary_role) db_unique_name=node1'
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
fal_server=dbprimary
fal_client=dbstandby
standby_file_management=AUTO
5.生成password file
c:/orapwd file=d:/oracle/ora92/DATABASE/PWDtest.ORA password=pass
或者直接將主庫(kù)上的密碼文件copy一份到備庫(kù)上
6.配置網(wǎng)絡(luò)
配置主備庫(kù)的listener.ora,tnsnames.ora。修改完listener.ora后需要重啟監(jiān)聽器。
主庫(kù):
listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/product/10.2.0)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = s1.gti.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
tnsnames.ora
dbprimary =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.131)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
dbstandby =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.132)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
備庫(kù):
listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = orcl)
(ORACLE_HOME = /u01/oracle/product/10.2.0)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.132)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
tnsnames.ora
dbprimary =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.131)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
dbstandby =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.132)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
7.使用rman備份主庫(kù)
[oracle@s1 ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Thu May 29 19:52:37 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1171867028)
RMAN backup full format='/u02/db_%U' database include current controlfile for standby;
...................
8.歸檔主庫(kù)當(dāng)前日志
SQL alter system archive log current;
System altered.
9.啟動(dòng)備庫(kù)到nomount
sqlplus "/ as sysdba"
Connected to an idle instance.
SQL startup nomount
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 96470608 bytes
Database Buffers 184549376 bytes
Redo Buffers 2973696 bytes
10.利用rman恢復(fù)備庫(kù)
[oracle@s1 ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Thu May 29 19:53:21 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1171867028)
RMAN connect auxiliary sys/a@dbstandby
connected to auxiliary database: ORCL (DBID=1171867028, not mount)
RMAN duplicate target database for standby nofilenamecheck;
.............................
如果第8步?jīng)]有歸檔當(dāng)前日志,duplicate時(shí)可能出現(xiàn)錯(cuò)誤:
RMAN-05507: standby controlfile checkpoint (710256) is more recent than duplicat
ion point in time (709530)
至此,備庫(kù)創(chuàng)建成功。
11.將備庫(kù)置于自動(dòng)恢復(fù)狀態(tài)
SQL conn / as sysdba
Connected.
SQLalter database recover managed standby database disconnect from session;
Media recovery complete.
12.switchover
物理STANDBY的SWITCHOVER切換會(huì)把當(dāng)前的一個(gè)物理STANDBY切換為PRIMARY數(shù)據(jù)庫(kù),而PRIMARY數(shù)據(jù)庫(kù)且變成物理STNADBY數(shù)據(jù)庫(kù)。
一般SWITCHOVER切換都是計(jì)劃中的切換,特點(diǎn)是在切換后,不會(huì)丟失任何的數(shù)據(jù),而且這個(gè)過程是可逆的,整個(gè)DATA GUARD環(huán)境不會(huì)被破壞,原來DATA GUARD環(huán)境中的所有物理和邏輯STANDBY都可以繼續(xù)工作。
在進(jìn)行DATA GUARD的物理STANDBY切換前需要注意:
確認(rèn)主庫(kù)和從庫(kù)間網(wǎng)絡(luò)連接通暢;
確認(rèn)沒有活動(dòng)的會(huì)話連接在數(shù)據(jù)庫(kù)中;
PRIMARY數(shù)據(jù)庫(kù)處于打開的狀態(tài),STANDBY數(shù)據(jù)庫(kù)處于MOUNT狀態(tài);
確保STANDBY數(shù)據(jù)庫(kù)處于ARCHIVELOG模式;
如果設(shè)置了REDO應(yīng)用的延遲,那么將這個(gè)設(shè)置去掉;
確保配置了主庫(kù)和從庫(kù)的初始化參數(shù),使得切換完成后,DATA GUARD機(jī)制可以順利的運(yùn)行。
主庫(kù):
[oracle@s1 ~]$ sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Thu May 29 19:55:02 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL alter database commit to switchover to physical standby;
Database altered.
SQL shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL startup nomount
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 96470608 bytes
Database Buffers 184549376 bytes
Redo Buffers 2973696 bytes
SQL alter database mount standby database;
Database altered.
SQL alter database recover managed standby database disconnect from session;
Database altered.
備庫(kù):
SQL alter database commit to switchover to primary;
Database altered.
SQL shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 96470608 bytes
Database Buffers 184549376 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL
答案來自;bs=asp.net%C1%AC%BD%D3sql%CA%FD%BE%DD%BF%E2sr=z=cl=3f=8tn=baiduwd=Oracle+create+databasect=0
主從數(shù)據(jù)庫(kù)的建立一般基于以下三個(gè)方面考慮:
1、容災(zāi):備庫(kù)在異地,主庫(kù)不存在了,備庫(kù)可以立即接管,無須恢復(fù)時(shí)間
2、負(fù)載均衡:主庫(kù)做增刪改,備庫(kù)做查詢,這樣很多查詢業(yè)務(wù)不占用主庫(kù)資源
3、數(shù)據(jù)集中和分發(fā):此種模式主要用于數(shù)據(jù)從分公司集中到總公司,或從總公司分發(fā)到分公司,前提是公司需要同步的數(shù)據(jù)很少,另外各公司間業(yè)務(wù)系統(tǒng)不是同一家公司開發(fā)的
同步功能主要通過數(shù)據(jù)庫(kù)同步軟件實(shí)現(xiàn)的,象ORACLE的DATAGUARD、QUEST的SHAREPLEX、沃信科技的PAC、ORACLE的GOLDEN GATE、迪思杰的REALSYNC
但是建議可以用沃信科技的產(chǎn)品,因?yàn)橹挥兴麄円患耶a(chǎn)品是安裝到主備之外的第三臺(tái)機(jī)器上的,不站用主庫(kù)資源,其他產(chǎn)品必須安裝到主庫(kù)機(jī)器上,大家試用起來很不方便
oracle ?DG 啟動(dòng)和關(guān)閉順序
啟動(dòng)順序:先啟動(dòng)備庫(kù),后啟動(dòng)主庫(kù)
關(guān)閉順序:先關(guān)閉主庫(kù),后關(guān)閉備庫(kù)
1、正確打開備庫(kù)和主庫(kù)
備庫(kù):
SQL STARTUPMOUNT;
SQLALTERDATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
主庫(kù):
SQL STARTUPMOUNT;
SQL ALTERDATABASE ARCHIVELOG;
SQL ALTER DATABASEOPEN;
2、正確關(guān)閉順序
主庫(kù)
SQLSHUTDOWN IMMEDIATE;
備庫(kù):
SQL ALTER DATABASE RECOVER MANAGED STANDBYDATABASE CANCEL;
SQLSHUTDOWN IMMEDIATE;