Debian下配置Oracle DataGuard
分別安裝主庫和備庫的oracle軟體,主庫建立資料庫庫,備庫只安裝資料庫軟體。
一. 配置primary database
--設定primary庫為force Logging模式(為了便於切換,建議standby庫也設定為force logging),這樣所有的改變都會放入重做日誌中,確保了可靠的恢復。
SQL> ALTER DATABASE FORCE LOGGING;
SQL> select force_logging from v$database;
--設定主庫初始化引數並修改
SQL> create pfile from spfile;
複製兩份:一份修改為primary,一份修改為standby
--設定歸檔模式。
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
SQL> archive log list;
--Create a Backup Copy of the Primary Database Datafiles
rman target /
RMAN> run{
allocate channel c1 type disk;
backup format '/oracle/rman/%u_%s.bak' database;
sql 'alter system archive log current';
backup filesperset 10 archivelog all format '/oracle/rman/%u_%s.bak';
backup format '/oracle/rman/controlbak.bak' current controlfile for standby;
release channel c1;
}
也可以這樣建立控制檔案或在RMAN備份裡執行,二者複製到備庫後複製多份,複製改名為(control01.ctl,control02.ctl,control03.ctl)
--Create a Control File for the Standby Database
SQL> alter database create standby controlfile as '/oracle/rman/controlbak.bak';
或
RMAN> copy current controlfile for standby to '/oracle/rman/controlbak.bak';
--修改主庫引數檔案:
*.instance_name='orcl'
*.service_names='primary','orcl'
*.db_unique_name=primary
*.log_archive_config='DG_CONFIG=(primary,standby)'
*.log_archive_dest_1='location=/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=primary'
*.LOG_ARCHIVE_DEST_2='SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.LOG_ARCHIVE_MAX_PROCESSES=3
*.FAL_SERVER=standby
*.FAL_CLIENT=primary
*.STANDBY_FILE_MANAGEMENT=AUTO
##下面這段可以省略
--在主庫建立standby redo log大小與主庫聯機日誌檔案大小一樣,組數至少比primary中的log file數量大1(可以省略)
SQL> alter database add standby logfile group 5 '/oracle/oradata/orcl/standbyredo05.log' size 100M;
SQL> alter database add standby logfile group 6 '/oracle/oradata/orcl/standbyredo06.log' size 100M;
SQL> alter database add standby logfile group 7 '/oracle/oradata/orcl/standbyredo07.log' size 100M;
SQL> alter database add standby logfile group 8 '/oracle/oradata/orcl/standbyredo08.log' size 100M;
SQL> alter database add standby logfile group 9 '/oracle/oradata/orcl/standbyredo09.log' size 100M;
--查詢
SQL> SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;
SQL>shutdown immediate
--刪除主庫的spfileorcl.ora引數檔案
--用pfile啟動,再重新建立spfile.
SQL> create spfile from pfile='/oracle/app/oracle/product/10.2.0/db_1/dbs/initorcl.ora';
SQL> startup
--分別在主庫和備庫配置監聽並啟動
二. 配置standby database
--複製Backup datafiles 、Standby control file 、pfile、password file等到相應的目錄
(將standby.ctl複製到備庫後複製多份,複製改名為control01.ctl,control02.ctl,control03.ctl)
:~> scp *.bak 10.1.11.32:/oracle/rman
--Prepare an Initialization Parameter File for the Standby Database
*.instance_name='orcl'
*.service_names='standby','orcl'
*.db_unique_name=standby
*.log_archive_config='DG_CONFIG=(primary,standby)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'
*.LOG_ARCHIVE_DEST_2='SERVICE=primary LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=primary'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.LOG_ARCHIVE_MAX_PROCESSES=3
*.FAL_SERVER=primary
*.FAL_CLIENT=standby
*.STANDBY_FILE_MANAGEMENT=AUTO
--在備庫端還原資料庫
依照主庫的資料檔案位置,在備庫上建立相應的目錄結構(最好與主庫一致);
mkdir -p /oracle/app/oracle/admin/orcl/adump
mkdir -p /oracle/app/oracle/admin/orcl/udump
mkdir -p /oracle/app/oracle/admin/orcl/bdump
mkdir -p /oracle/app/oracle/admin/orcl/cdump
mkdir -p /oracle/app/oracle/admin/orcl/pfile
mkdir -p /oracle/app/oracle/admin/orcl/dpdump
sqlplus /nolog
SQL> conn / as sysdba
SQL> create spfile from pfile='/oracle/app/oracle/product/10.2.0/db_1/dbs/initorcl.ora';
SQL> startup nomount;
rman target /
RMAN> restore controlfile from '/oracle/rman/controlbak.bak';
RMAN> alter database mount;
RMAN> restore database;
RMAN> recover database;
SQL> alter database add standby logfile group 5 '/oracle/oradata/orcl/standbyredo05.log' size 100M;
SQL> alter database add standby logfile group 6 '/oracle/oradata/orcl/standbyredo06.log' size 100M;
SQL> alter database add standby logfile group 7 '/oracle/oradata/orcl/standbyredo07.log' size 100M;
SQL> alter database add standby logfile group 8 '/oracle/oradata/orcl/standbyredo08.log' size 100M;
SQL> alter database add standby logfile group 9 '/oracle/oradata/orcl/standbyredo09.log' size 100M;
--查詢
SQL> SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;
--啟動redo apply
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
***取消redo應用***
SQL> alter database recover managed standby database cancel;
SQL> shutdown immediate;
--測試是否成功
--確認現有備庫歸檔重做日誌檔案
SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
--在主資料庫上執行, 測試歸檔操作到物理備資料庫
SQL> ALTER SYSTEM SWITCH LOGFILE;
--在備庫上檢查是否歸檔和應用
SQL> SELECT SEQUENCE#, FIRST_TIME,NEXT_TIME,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
--檢視資料庫角色
SQL> select database_role,protection_mode,protection_level,switchover_status from v$database;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7478833/viewspace-441045/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle dataguard broker 配置Oracle
- Oracle 單機配置DataGuardOracle
- Oracle 11g dataguard 配置簡約步驟Oracle
- 【DATAGUARD】Oracle Dataguard nologging 塊修復Oracle
- Oracle資料庫(DataGuard)遷移方案(下)Oracle資料庫
- 【DATAGUARD】Oracle Dataguard體系架構詳解Oracle架構
- Oracle 11.2.0.4 physical dataguard和snapshot dataguard切換Oracle
- 【DATAGUARD】Oracle19c dataguard新特性及部署Oracle
- Oracle dataguard failover 實戰OracleAI
- debian配置(2)
- 【DATAGUARD】Dataguard遠端同步配置最佳實踐
- oracle 19c dataguard silent install (oracle 19c dataguard 靜默安裝)Oracle
- Oracle 11.2 DataGuard RAC To RAC搭建Oracle
- Oracle之11g DataGuardOracle
- 【DATAGUARD】Oracle Dataguard物理備庫切換最佳實踐(sqlplus)OracleSQL
- 【Dataguard】Oracle多租戶環境對Dataguard的影響Oracle
- Oracle Linux7下部署oralce 11gr2 dataguardOracleLinux
- Oracle Dataguard故障轉移(failover)操作OracleAI
- 7 Oracle DataGuard 命令列參考Oracle命令列
- oracle11g dataguard切換Oracle
- debian國內源 配置
- Oracle DataGuard 主備切換 (switchover) oracle11gOracle
- 【DATAGUARD】Oracle19c Data Guard BrokerOracle
- Oracle 11.2.0.4 Dataguard兩則故障處理Oracle
- 跨平臺級聯dataguard配置
- 【DG】Oracle11g異構平臺之Linux To Windows DataGuard安裝配置--duplicateOracleLinuxWindows
- oracle 11.2.0.4 DataGuard Broker配置過程中可能遇到的問題及解決方法Oracle
- 【linux】Debian10.0配置vsftpdLinuxFTP
- Debian 11 配置優化指南優化
- 【DATAGUARD】Oracle21c Dataguard建立注意事項及主要引數介紹Oracle
- Oracle資料庫(DataGuard)遷移方案(上)Oracle資料庫
- Oracle資料庫(DataGuard)遷移方案(中)Oracle資料庫
- Oracle dataguard報錯:Error 1017 received logging on to the standbyOracleError
- 【ASK_ORACLE】手動配置DataGuard的自動化Client Failover(故障轉移)的serviceOracleclientAI
- 【DATAGUARD】Oracle 通過Dataguard指定恢復時間用於找回丟失資料Oracle
- Debian9安裝配置CaddyServerServer
- debian11 hexo+nginx 配置httpsHexoNginxHTTP
- Oracle DataGuard歸檔日誌丟失處理方法Oracle
- oracle10g DataGuard的日誌傳輸方式Oracle