Oracle DG搭建2(冷備方式)
(1) 主庫:開啟歸檔模式
(2) 主庫:開啟強制寫日誌功能
(3) 主庫:關閉閃回
(4) 主庫:配置靜態監聽,配置tnsnames 檔案
(5) 主庫:增加standby logfile 檔案
(6) 主庫:修改引數檔案
(7) 主庫:停庫冷備
(8) 主庫:生成standby controlfil
e
(9) 主庫: 複製主庫檔案到備庫
(10)備庫:配置靜態監聽,配置tnsnames.ora檔案
(11)備庫:修改引數檔案和口令檔案
(12)備庫:根據據引數檔案建立相應的目錄
(13)備庫:解壓備份檔案
(14)備庫:啟動備庫
(15)驗證是否搭建成功
(16)主備切換
(1) 主庫:開啟歸檔模式
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
SQL> alter system set db_recovery_file_dest_size=10G;
SQL> alter system set db_recovery_file_dest='/home/oracle/flash';
(2) 主庫:開啟強制寫日誌功能
SQL> select force_logging from v$database;
SQL> alter database force logging;
(3) 主庫:關閉閃回
SQL> select flashback_on from v$database;
SQL> alter database flashback off;
(4) 主庫:配置靜態監聽,配置tnsnames 檔案
[oracle@chen ~]$ cd $ORACLE_HOME/network/admin
[oracle@chen admin]$ vi listener.ora
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=chicago.us.oracle.com)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=chicago)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = chen.example.com)(PORT = 1521))
)
)
[oracle@chen admin]$ vi tnsnames.ora
chicago =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = chen.example.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = chicago.us.oracle.com)
)
)
boston =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = jch.example.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = boston.us.oracle.com)
)
)
[oracle@chen admin]$ lsnrctl stop
[oracle@chen admin]$ lsnrctl start
(5) 主庫:增加standby logfile 檔案
SQL> select member from v$logfile;
SQL> select bytes/1024/1024 from v$log;
SQL> alter database add standby logfile group 4 '/u01/app/oracle/oradata/chicago/standby_redo04.log' size 50M;
SQL> alter database add standby logfile group 5 '/u01/app/oracle/oradata/chicago/standby_redo05.log' size 50M;
SQL> alter database add standby logfile group 6 '/u01/app/oracle/oradata/chicago/standby_redo06.log' size 50M;
SQL> alter database add standby logfile group 7 '/u01/app/oracle/oradata/chicago/standby_redo07.log' size 50M;
(6) 主庫:修改引數檔案
Example 3-1 Primary Database: Primary Role Initialization Parameters
Example 3-2 Primary Database: Standby Role Initialization Parameters
SQL> create pfile from spfile;
[oracle@chen admin]$ cd $ORACLE_HOME/dbs
[oracle@chen dbs]$ vi initchicago.ora
*.DB_NAME=chicago
*.DB_UNIQUE_NAME=chicago
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago,boston)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/flash VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=chicago'
*.LOG_ARCHIVE_DEST_2='SERVICE=boston ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=boston'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
*.LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
*.FAL_SERVER=boston
*.DB_FILE_NAME_CONVERT='boston','chicago'
*.LOG_FILE_NAME_CONVERT='boston,'chicago'
*.STANDBY_FILE_MANAGEMENT=AUTO
[oracle@chen dbs]$ cp spfilechicago.ora spfileboston.ora.bak
SQL> shutdown immediate
SQL> create spfile from pfile;
SQL> startup
SQL> show parameter log_archive_dest_2
(7)主庫:停庫冷備
SQL> shutdown immediatre
[oracle@chen admin]$ cd /u01/app/oracle/oradata/chicago
[oracle@chen PROD1]$ tar -zcvf /home/oracle/dg/chicago.tar.gz *
(8)主庫:生成standby controlfile
SQL> startup mount;
SQL> alter database create standby controlfile as '/home/oracle/dg/standby_control01.ctl';
(9) 主庫: 複製主庫檔案到備庫
冷備檔案,監聽檔案,TNS檔案,引數檔案、密碼檔案
[oracle@chen dbs]$ cp initchicago.ora /home/oracle/dg/
[oracle@chen dbs]$ cp orapwchicago /home/oracle/dg/
[oracle@chen admin]$ cp listener.ora /home/oracle/dg/
[oracle@chen admin]$ cp tnsnames.ora /home/oracle/dg/
[oracle@chen PROD1]$ cp chicago.tar.gz /home/oracle/dg
[oracle@chen ~]$ tar -zcvf dg.tar.gz dg/
[oracle@chen ~]$ scp dg.tar.gz jch:/home/oracle
(10) 備庫:配置靜態監聽,配置tnsnames.ora檔案
[oracle@jch ~]$ tar -zxvf dg.tar.gz
[oracle@jch ~]$ cd $ORACLE_HOME/network/admin
[oracle@jch admin]$ mv listener.ora listener.ora.bak
[oracle@jch admin]$ mv tnsnames.ora tnsnames.ora.bak
[oracle@jch admin]$ cp /home/oracle/dg/listener.ora .
[oracle@jch admin]$ cp /home/oracle/dg/tnsnames.ora .
[oracle@jch admin]$ vi listener.ora
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=boston.us.oracle.com)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
(SID_NAME=boston)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = jch.example.com)(PORT = 1521))
)
)
[oracle@edbjr2p2 admin]$ lsnrctl start
(11) 備庫:修改引數檔案和口令檔案
[oracle@jch dbs]$ cp /home/oracle/dg/initchicago.ora .
[oracle@jch dbs]$ cp /home/oracle/dg/orapwchicago .
[oracle@jch dbs]$ mv orapwchicago orapwboston
[oracle@jch dbs]$ mv initchicago.ora initboston.ora
[oracle@jch dbs]$ vi initboston.ora
:%s/chicago/AAAA/g
:%s/boston/chicago/g
:%s/AAAA/boston/g
*.DB_NAME=chicago
*.DB_UNIQUE_NAME=boston
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(boston,chicago)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/flash VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=boston'
*.LOG_ARCHIVE_DEST_2='SERVICE=chicago ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=chicago'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
*.LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
*.FAL_SERVER=chicago
*.DB_FILE_NAME_CONVERT='chicago','boston'
*.LOG_FILE_NAME_CONVERT='chicago','boston'
*.STANDBY_FILE_MANAGEMENT=AUTO
(12) 備庫:根據據引數檔案建立相應的目錄
[oracle@jch ~]$ mkdir flash
[oracle@jch ~]$ cd /u01/app/oracle/admin/
[oracle@jch admin]$ mkdir boston/adump -p
[oracle@jch ~]$ mkdir /u01/app/oracle/oradata/boston
(13)備庫:解壓備份檔案
[oracle@jch dg]$ cd /u01/app/oracle/oradata/boston/
[oracle@jch dg]$ tar -zxvf chicago.tar.gz
(14)備庫:啟動備庫
SQL> startup nomount;
[oracle@jch dg]$ export ORACLE_SID=boston
[oracle@jch dg]$ rman target /
rman>restore controlfile from '/home/oracle/control_standby.ctl';
SQL> alter database mount;
SQL> alter database open;
SQL> recover managed standby database using current logfile disconnect from session;
(15)驗證是否搭建成功
主庫:
SQL> archive log list;
SQL> alter system switch logfile;
備庫:
SQL> archive log list;
SQL> select process, pid, status, client_process from v$managed_standby;
SQL> SELECT PROTECTION_MODE, PROTECTION_LEVEL,DATABASE_ROLE ROLE,SWITCHOVER_STATUS FROM V$DATABASE;
備庫:sync 資料
SQL> alter database open;
SQL> recover managed standby database using current logfile disconnect from session;
-----SQL> recover managed standby database cancel;
主庫:
SQL> create table test1 as select level as id from dual connect by level<=3;
備庫:
SQL> select * from test1;
(16)主從切換
主庫:
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
SQL> SHUTDOWN ABORT;
SQL> STARTUP MOUNT;
備庫:
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
SQL> ALTER DATABASE OPEN;
---SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
當主庫無法故障時,透過上面的方式主從切換回報錯如下:
Database not available for switchover
End-Of-REDO archived log file has not been recovered
Archived log files detected beyond End-Of-REDO
Incomplete recovery SCN:0:1038219 archive SCN:0:1037990
解決方案:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
---ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH FORCE;
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
SQL> ALTER DATABASE OPEN;
歡迎關注我的微信公眾號"IT小Chen",共同學習,共同成長!!!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29785807/viewspace-2146569/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【DG】備庫RMAN還原方式搭建DG(不使用duplicate命令)
- 11g dg 備庫搭建多種方式
- Oracle RAC+DG搭建Oracle
- 【DG】Oracle 19c使用dbca來搭建物理DG--主rac備racOracle
- oracle冷備恢復Oracle
- ORACLE DG之備庫角色Oracle
- Oracle OCP(60):冷備份Oracle
- Oracle DG異構主備支援Oracle
- 【DG】Oracle 19c使用dbca來搭建物理DGOracle
- 【DG】Oracle之級聯DG--(cascade dg) --(一主一備一級聯)Oracle
- 一步一步搭建oracle 11gR2 rac+dg之環境準備(二)Oracle
- ORACLE OCM備考OEM搭建DG報錯:NMO not setuid-root(Unix-only)OracleUI
- oracle自動冷備份指令碼Oracle指令碼
- ORACLE DG從庫 Rman備份恢復Oracle
- Oracle資料庫冷備和恢復Oracle資料庫
- Oracle 11g單主搭建物理DGOracle
- Oracle DG備庫手動管理新增資料檔案Oracle
- oracle 19c dg搭建duplicate過程中報錯Oracle
- Oracle:DG 的 switchoverOracle
- oracle dg報錯Oracle
- DG搭建配置方案
- ORACLE RAC TO RAC DG搭建過程中可能遇到的問題Oracle
- 熱備份/冷備份/ 冷啟動/熱啟動
- Oracle DG 日常點檢Oracle
- Oracle DG管理Broker配置Oracle
- 【邏輯DG滾動升級二】ORACLE11204 邏輯DG滾動升級至12C---DG端前期準備Oracle
- 物理DG、邏輯DG和快照DG的搭建(視訊講解)
- 【UP_ORACLE】如何給Oracle DG打補丁(二)備庫安裝補丁步驟Oracle
- Oracle 12c DG備庫啟動報錯standby database requires recoveryOracleDatabaseUI
- Oracle-DG最大保護模式下,dg備庫出現問題對主庫有什麼影響?Oracle模式
- Oracle DG運維常用SQLOracle運維SQL
- oracle dg切換操作示例Oracle
- ORACLE 11.2.0.4 DG(Broker) for linux 部署OracleLinux
- Oracle DG Standby Database型別OracleDatabase型別
- Oracle DG建立Physical Standby DatabaseOracleDatabase
- Oracle DG建立Logical Standby DatabaseOracleDatabase
- 【DG】Data Guard搭建(physical standby)
- [20221130]最佳化備庫dg遇到的問題2.txt
- 【ASK_ORACLE】Oracle Data Guard(一)DG架構Oracle架構