您好,登錄后才能下訂單哦!
1.環境:Primary Database: ning
Physical Standby Database: test
2.修改初始化參數dg_broker_start
SQL> alter system set dg_broker_start=true;
3.確認數據庫使用的是spfile啟動
4.啟動DGMGRL
C:>dgmgrl
DGMGRL for 32-bit Windows: Version 10.2.0.1.0 - Production
Copyright (c) 2000, 2005, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
5.連接到Primary庫DGMGRL> connect
Username: sys@ning
Password:
Connected.
6.創建配置
DGMGRL> create configuration 'DGTEST' as
> primary database is 'ning'
> connect identifier is ning;
Configuration "DGTEST" created with primary database "ning"
7.添加備用庫
DGMGRL> add database 'test'
> as connect identifier is test
> maintained as physical;
Database "test" added
8.查看配置DGMGRL> show configuration
Configuration
Name: DGTEST
Enabled: NO
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
ning - Primary database
test - Physical standby database
Current status for "DGTEST": DISABLED
9.設置數據庫屬性
DGMGRL>edit database 'ning' set property 'LogArchiveFormat' = 'log_%t_%s_%r_%d.arc';
Property "LogArchiveFormat" updated
10.顯示數據庫屬性
DGMGRL> show database verbose 'ning'
Database
Name: ning
Role: PRIMARY
Enabled: NO
Intended State: OFFLINE
Instance(s):
ning
Properties:
InitialConnectIdentifier = 'ning'
LogXptMode = 'ARCH'
Dependency = ''
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '180'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'MANUAL'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '2'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = ''
LogFileNameConvert = ''
FastStartFailoverTarget = ''
StatusReport = '(monitor)'
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
HostName = 'dgmis'
SidName = 'ning'
LocalListenerAddress = '(ADDRESS=(PROTOCOL=tcp)(HOST=dgmis)(PORT=
1521))'
StandbyArchiveLocation = 'e:oraclearch3ning'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = 'log_%t_%s_%r_%d.arc'
LatestLog = '(monitor)'
TopWaitEvents = '(monitor)'
Current status for "ning":
DISABLED
11.啟用配置
DGMGRL> enable configuration
Enabled.
DGMGRL> enable database 'ning'
Enabled.
DGMGRL> enable database 'test'
Enabled.
12.檢查數據庫狀態
DGMGRL> show database 'ning'
Database
Name: ning
Role: PRIMARY
Enabled: YES
Intended State: ONLINE
Instance(s):
ning
Current status for "ning":
SUCCESS
DGMGRL> show database 'test'
Database
Name: test
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: ONLINE
Instance(s):
test
Current status for "test":
SUCCESS
DGMGRL> show configuration
Configuration
Name: DGTEST
Enabled: YES
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
ning - Primary database
test - Physical standby database
Current status for "DGTEST":
SUCCESS
13.修改Data Guard的保護模式
DGMGRL> edit configuration set protection mode as maxperformance;
Succeeded.
14.更改備用庫到只讀狀態
DGMGRL> edit database test set state='read-only';
Succeeded.
15.停止主庫到從庫的日志傳送DGMGRL> edit database ning set state='log-transport-off';
Succeeded.
16.將主庫離線
DGMGRL> edit database ning set state='offline';
Operation requires shutdown of instance "ning" on database "ning"
Shutting down instance "ning"...
Database closed.
Database dismounted.
ORACLE instance shut down.
注:要將主庫重新上線,需要先手動啟動數據庫,然后
DGMGRL> connect sys@ning
Password:
Connected.
DGMGRL> edit database ning set state='online';
Succeeded.
17.禁用配置
DGMGRL> disable configuration
Disabled.
18.禁用某個備用庫DGMGRL> disable database 'test';
Disabled.
19.從配置中刪除備用庫
DGMGRL> remove database 'test'
Removed database "test" from the configuration
20.刪除配置
DGMGRL> remove configuration
Removed configuration.
21.執行Switchover切換
DGMGRL> switchover to 'test';
Performing switchover NOW, please wait...
Operation requires shutdown of instance "ning" on database "ning"
Shutting down instance "ning"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires shutdown of instance "test" on database "test"
Shutting down instance "test"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "ning" on database "ning"
Starting instance "ning"...
ORACLE instance started.
Database mounted.
Operation requires startup of instance "test" on database "test"
ORACLE instance started.
Database mounted
Switchover succeeded. New primary is "test"
DGMGRL> show configuration
Configuration
Name: DGTEST
Enabled: YES
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
ning - Physical standby database
test - Primary database
Current status for "DGTEST":
SUCCESS
22.執行Failover切換
DGMGRL> FAILOVER TO "test";
23.生成數據庫狀態報告(如果你遇到Ora-16810時可以使用)
DGMGRL> show database 'ning' 'statusreport'
STATUS REPORT
INSTANCE_NAME SEVERITY ERROR_TEXT
附錄:
ORA-16525: the Data Guard broker is not yet available請檢查數據庫的初始化參數dg_broker_start是否為true
ORA-16797: database is not using a server parameter file請檢查數據庫是否以spfile啟動
ORA-16792: configuration property value is inconsistent with database setting
檢查數據庫的某些屬性和數據的初始化參數設置是否一致,例如LogArchiveFormat屬性和log_archive_format參數的設置是否一致
ORA-16505: site ID is invalid
檢查該數據庫是否處于enable狀態
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。