Oracle DG搭建1(duplicate方式)
(1) 主庫:開啟歸檔模式
(2) 主庫:開啟強制寫日誌功能
(3) 主庫:關閉閃回
(4) 主庫:配置靜態監聽,配置tnsnames 檔案
(5) 主庫:增加standby logfile 檔案
(6) 主庫:修改引數檔案
(7) 主庫: 複製主庫檔案到備庫
(8) 備庫:配置靜態監聽,配置tnsnames.ora檔案
(9) 備庫:修改引數檔案和口令檔案
(10) 備庫:根據據引數檔案建立相應的目錄
(11) 備庫:startup nomount
(12)主庫: 透過rman duplicate 方式進行備庫恢復
(13)驗證是否搭建成功
(14)主從切換
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';
SQL> select force_logging from v$database;
SQL> alter database force logging;
SQL> select flashback_on from v$database;
SQL> alter database flashback off;
[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
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;
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 spfilechicago.ora.bak
SQL> shutdown immediate
SQL> create spfile from pfile;
SQL> startup
SQL> show parameter log_archive_dest_2
監聽檔案,TNS檔案,引數檔案、密碼檔案到備庫並改名
[oracle@chen dbs]$ mkdir /home/oracle/dg
[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 ~]$ tar -zcvf dg.tar.gz dg/
[oracle@chen ~]$ scp dg.tar.gz jch:/home/oracle
[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@jch admin]$ lsnrctl start
(9) 備庫:修改引數檔案和口令檔案
[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
(10) 備庫:根據據引數檔案建立相應的目錄
[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
(11) 備庫:startup nomount
[oracle@jch ~]$ export ORACLE_SID=boston
[oracle@jch ~]$ sqlplus / as sysdba
SQL> create spfile from pfile;
SQL> startup nomount
(12)主庫: 透過rman duplicate 方式進行備庫恢復
[oracle@chen ~]$ export ORACLE_SID=chicago
[oracle@chen ~]$ rman target / auxiliary sys/oracle@boston
RMAN> duplicate target database for standby from active database;
(13)驗證是否搭建成功
主庫:
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;
(14)主從切換
主庫:
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-2146553/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【DG】備庫RMAN還原方式搭建DG(不使用duplicate命令)
- Oracle DG搭建2(冷備方式)Oracle
- rman duplicate搭建第二個 dg
- oracle 19c dg搭建duplicate過程中報錯Oracle
- duplicate搭建DG最大效能(rac-單例項)單例
- Oracle RAC+DG搭建Oracle
- ora11_node_dg(1)DG搭建過程
- ORACLE DG 11G 搭建Oracle
- 【DG】在Linux平臺上搭建單例項的dataguard--duplicateLinux單例
- 搭建11g data guard(duplicate from active database方式)Database
- 11g dg 備庫搭建多種方式
- 【DG】Oracle 19c使用dbca來搭建物理DGOracle
- oracle11g 搭建 rac+dgOracle
- oracle 11g dg搭建筆記Oracle筆記
- oracle DG支援搭建的平臺列表Oracle
- DG搭建
- DG rman duplicate 複製庫錯誤
- 【DG】搭建(一)
- oracle實驗記錄 手工 duplicate database(1)OracleDatabase
- oracle實驗記錄Rman duplicate database(1)OracleDatabase
- Oracle 11g單主搭建物理DGOracle
- linux-oracle11g-dg搭建日誌LinuxOracle
- G007-ORACLE-INS-DG-01 ORACLE 19C DG 1P1S-CDB Ins ON RHEL 8.2Oracle
- DG搭建配置方案
- 【DG】Oracle 19c使用dbca來搭建物理DG--主rac備racOracle
- 【DG】Oracle11g異構平臺之Linux To Windows DataGuard安裝配置--duplicateOracleLinuxWindows
- DG RAC - 單點搭建
- RMAN不停機搭建DG
- ORACLE 11.2.0.4 dg搭建及對DDL的支援驗證Oracle
- 物理DG、邏輯DG和快照DG的搭建(視訊講解)
- Oracle 11g RAC 配置單例項 DataGuard(通過 DUPLICATE 方式)Oracle單例
- Oracle OCP 1Z0 053 Q21(RMAN Duplicate)Oracle
- Oracle OCP 1Z0 053 Q700(RMAN Duplicate)Oracle
- Oracle 1Z0 053 Q289(Duplicate&NOFILENAMECHECK)Oracle
- ORACLE11G RAC 環境搭建物理 DATA GUARD (不用duplicate)Oracle
- 10g+dg+rman+windows(借鑑rman方式做dg)Windows
- ORACLE RAC TO RAC DG搭建過程中可能遇到的問題Oracle
- 【DG】Data Guard搭建(physical standby)