ORACLE 11gR2 11.2.0.4 一步一步 物理DG
應朋友的需求,今天搭建物理DG同時寫下文件:
環境介紹:
系統 : RedHat6.3_x64
Oracle:11.2.0.4
這裡的做物理DG前提是你已經安裝好了Oracle軟體,同時DBCA建立好了你的主庫。
我是在同一臺機器裡搭建DG,所以目錄跟主庫的不一樣,如果是雙機做,目錄就可以一模一樣,這樣更方便。
主庫名:prod
備庫名:emrep
搭建物理dg大致一下幾步:
1、建主庫
2、修改主庫和備庫引數檔案
3、恢復備庫
4、啟用歸檔日誌應用
一、首先是建立listener和tnsname.因為DG是走監聽的。
listener.ora 為主庫的監聽
listener1.ora為備庫的監聽。
我這裡分別以例項名命名tnsname.ora裡面的。
注意:tnsname.ora如果是雙機做DG,tnsname.ora就要填寫對方的例項。
假如我的是雙機。即相互連線。 主庫prod的tnsname.ora裡面是指向備庫emrep。備庫的tnsname.ora 裡面指向的是主庫prod。
如果不明白,剛接觸的人,把兩個都加上去,以免出錯。
點選(此處)摺疊或開啟
-
[oracle@zhanglin admin]$ cat listener.ora
-
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0.4/db_1/network/admin/listener.ora
-
# Generated by Oracle configuration tools.
-
-
LISTENER1 = ----備庫監聽,埠號1523
-
(DESCRIPTION =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = zhanglin)(PORT = 1523)) ---host 既可以是主機名,也可以是主機IP,如果是雙機,建-
-
) 議使用IP
-
-
SID_LIST_LISTENER =
-
(SID_LIST =
-
(SID_DESC =
-
(GLOBAL_DBNAME = prod)
-
(ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/db_1)
-
(SID_NAME = prod)
-
)
-
)
-
-
SID_LIST_LISTENER1 =
-
(SID_LIST =
-
(SID_DESC =
-
(GLOBAL_DBNAME = emrep)
-
(ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/db_1)
-
(SID_NAME = emrep)
-
)
-
)
-
-
ADR_BASE_LISTENER1 = /u01/app/oracle
-
-
LISTENER = ----主庫監聽 埠號1521
-
(DESCRIPTION =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = zhanglin)(PORT = 1521))
-
)
-
- ADR_BASE_LISTENER = /u01/app/oracle
點選(此處)摺疊或開啟
-
[oracle@zhanglin admin]$ cat tnsnames.ora
-
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0.4/db_1/network/admin/tnsnames.ora
-
# Generated by Oracle configuration tools.
-
-
PROD =
-
(DESCRIPTION =
-
(ADDRESS_LIST =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = zhanglin)(PORT = 1521))
-
)
-
(CONNECT_DATA =
-
(SERVICE_NAME = prod)
-
)
-
)
-
-
EMREP =
-
(DESCRIPTION =
-
(ADDRESS_LIST =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = zhanglin)(PORT = 1523))
-
)
-
(CONNECT_DATA =
-
(SERVICE_NAME = emrep)
-
)
- )
主庫prod操作:
SQL> create pfile from spfile; ---》由於是dbca建立的主庫,這裡要手動產生PFILE
接下來,修改主庫的歸檔路徑,注意修改為歸檔,需在mount階段做,dbca建立完成例項後,預設是open;
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1.1257E+10 bytes
Fixed Size 2263336 bytes
Variable Size 5939136216 bytes
Database Buffers 5301600256 bytes
Redo Buffers 14352384 bytes
Database mounted.
SQL> alter system set log_archive_dest_1='location=/u01/app/oradata/prod/archivelog' ;
System altered.
SQL> alter database archivelog;
Database altered.
SQL> alter database force logging; ---》強制記錄日誌
Database altered.
預先看一下資料庫的三檔案的位置
點選(此處)摺疊或開啟
-
SQL> select name from v$datafile;
-
-
NAME
-
--------------------------------------------------------------------------------
-
/u01/app/oradata/prod/prod/system01.dbf
-
/u01/app/oradata/prod/prod/sysaux01.dbf
-
/u01/app/oradata/prod/prod/undotbs01.dbf
-
/u01/app/oradata/prod/prod/users01.dbf
-
-
SQL> select name from v$controlfile;
-
NAME
-
--------------------------------------------------------------------------------
-
/u01/app/oradata/prod/prod/control01.ctl
-
/u01/app/oradata/prod/prod/control02.ctl
-
-
SQL> select member from v$logfile;
-
MEMBER
-
--------------------------------------------------------------------------------
-
/u01/app/oradata/prod/prod/redo03.log
-
/u01/app/oradata/prod/prod/redo02.log
- /u01/app/oradata/prod/prod/redo01.log
修改主庫日誌檔案組的大小和成員,這裡你也可以給每個組新增日誌成員,並修改日誌成員大小。
點選(此處)摺疊或開啟
提示:在刪除redo log時,要先檢視日誌的狀態。之後status 是inavtive 和unused才可以被刪除,CURRENT 表示當前正在使用,既然在使用肯定不能刪除啊,
ACTIVE 表示活動狀態,切換日誌後,雖然不是當前使用的,但是由於日誌不可能立即重新整理到磁碟,所以這是日誌還在被使用狀態。
點選(此處)摺疊或開啟
-
SQL> set line190
-
SQL> col MEMBER format a48
-
SQL> col STATUS format a10
-
SQL> select a.GROUP#,a.BYTES/1024/1024,a.MEMBERS,a.STATUS,b.member from v$log a,v$logfile b where a.GROUP#=b.GROUP# order by b.GROUP#;
-
-
GROUP# A.BYTES/1024/1024 MEMBERS STATUS MEMBER
-
---------- ----------------- ---------- ---------- ------------------------------------------------
-
1 50 2 CURRENT /u01/app/oradata/prod/prod/redo01a.log
-
1 50 2 CURRENT /u01/app/oradata/prod/prod/redo01b.log
-
2 50 1 ACTIVE /u01/app/oradata/prod/prod/redo02.log
-
3 40 2 UNUSED /u01/app/oradata/prod/prod/redo03b.log
-
3 40 2 UNUSED /u01/app/oradata/prod/prod/redo03a.log
-
SQL> alter system switch logfile;
-
SQL> alter database drop logfile group 2;
-
-
Database altered.
-
SQL> ! rm -rf /u01/app/oradata/prod/prod/redo02.log
-
-
SQL> alter database add logfile group 2 (\'/u01/app/oradata/prod/prod/redo02a.log\',\'/u01/app/oradata/prod/prod/redo02b.log\') size 50m;
-
- Database altered.
新增standby logfile
standby logfile 官方給出的standby logfile要比redo log 至少多一組,成員大小一樣。
提示:關於standby log 的存放,其實跟redo log的存放類似,要考慮到冗餘,分散I/O。並以方便檢視和管理 為原則。
SQL> ALTER DATABASE ADD STANDBY LOGFILE
group 4 ('/u01/app/oradata/standbylog/redo04a.log','/u01/app/oradata/standbylog/redo04b.log') size 50M,
group 5 ('/u01/app/oradata/standbylog/redo05a.log','/u01/app/oradata/standbylog/redo05b.log') size 50M,
group 6 ('/u01/app/oradata/standbylog/redo06a.log','/u01/app/oradata/standbylog/redo06b.log') size 50M,
group 7 ('/u01/app/oradata/standbylog/redo07a.log','/u01/app/oradata/standbylog/redo07b.log') size 50M;
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oradata/prod/prod/redo03a.log
/u01/app/oradata/prod/prod/redo02a.log
/u01/app/oradata/prod/prod/redo01a.log
/u01/app/oradata/prod/prod/redo01b.log
/u01/app/oradata/prod/prod/redo03b.log
/u01/app/oradata/prod/prod/redo02b.log
/u01/app/oradata/standbylog/redo04a.log
/u01/app/oradata/standbylog/redo04b.log
/u01/app/oradata/standbylog/redo05a.log
/u01/app/oradata/standbylog/redo05b.log
/u01/app/oradata/standbylog/redo06a.log
MEMBER
--------------------------------------------------------------------------------
/u01/app/oradata/standbylog/redo06b.log
/u01/app/oradata/standbylog/redo07a.log
/u01/app/oradata/standbylog/redo07b.log
14 rows selected.
SQL>
修改init檔案
這是修改後的主庫prod :
[oracle@newbidb dbs]$ cat initprod.ora
prod.__db_cache_size=5301600256
prod.__java_pool_size=201326592
prod.__large_pool_size=134217728
prod.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
prod.__pga_aggregate_target=4529848320
prod.__sga_target=6777995264
prod.__shared_io_pool_size=0
prod.__shared_pool_size=1073741824
prod.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/prod/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oradata/prod/prod/control01.ctl','/u01/app/oradata/prod/prod/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='prod'
*.diagnostic_dest='/u01/app/oracle'
#*.dispatchers='(PROTOCOL=TCP) (SERVICE=prodXDB)'
LOG_ARCHIVE_CONFIG='DG_CONFIG=(prod,emrep)'
log_archive_dest_1='location=/u01/app/oradata/prod/archivelog --主庫的歸檔路徑
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=prod'
DB_UNIQUE_NAME=prod
DB_FILE_NAME_CONVERT='/u01/app/oradata/emrep/emrep/','/u01/app/oradata/prod/prod/' --主備庫資料檔案轉換 巧記 先別人 後自己,先備後主
LOG_FILE_NAME_CONVERT='/u01/app/oradata/emrep/emrep/','/u01/app/oradata/prod/prod/' --主備庫日誌檔案轉換
log_archive_dest_2='SERVICE=emrep ASYNC
valid_for=(online_logfiles,primary_role) --備庫的歸檔路徑
db_unique_name=emrep'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
FAL_SERVER=emrep -- failed switch
fal_client=prod
*.memory_target=11298406400
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
[oracle@newbidb dbs]$
---------------------------分割線----------
cp 主庫的pfile檔案生成備庫的pfile檔案
[oracle@newbidb dbs]$ cp initprod.ora initemrep.ora
這是修改後的備庫emrep :
[oracle@newbidb dbs]$ cat initemrep.ora
prod.__db_cache_size=5301600256
prod.__java_pool_size=201326592
prod.__large_pool_size=134217728
prod.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
prod.__pga_aggregate_target=4529848320
prod.__sga_target=6777995264
prod.__shared_io_pool_size=0
prod.__shared_pool_size=1073741824
prod.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/emrep/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
control_files='/u01/app/oradata/emrep/emrep/control01.ctl','/u01/app/oradata/emrep/emrep/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='prod'
*.diagnostic_dest='/u01/app/oracle'
#*.dispatchers='(PROTOCOL=TCP) (SERVICE=prodXDB)'
db_unique_name=emrep
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
LOG_ARCHIVE_CONFIG='DG_CONFIG=(prod,emrep)'
log_archive_dest_1='location=/u01/app/oradata/emrep/archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=emrep'
log_archive_dest_2='SERVICE=prod valid_for=(online_logfiles,primary_role) db_unique_name=prod'
DB_FILE_NAME_CONVERT='/u01/app/oradata/prod/prod/','/u01/app/oradata/emrep/emrep/'
LOG_FILE_NAME_CONVERT='/u01/app/oradata/prod/prod/','/u01/app/oradata/emrep/emrep/'
FAL_SERVER=prod
fal_client=emrep
*.memory_target=11298406400
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
[oracle@newbidb dbs]$
cp 主庫的密碼檔案生成備庫的密碼檔案
[oracle@zhanglin dbs]$ cp orapwprod orapwemrep
備庫emrep操作:
登入到備庫,用initemrep.ora 開啟備庫到nomount階段
[oracle@zhanglin dbs]$ export ORACLE_SID=emrep
[oracle@zhanglin dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Mon Sep 29 12:21:51 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile=/u01/app/oracle/product/11.2.0.4/db_1/dbs/initemrep.ora
ORACLE instance started.
Total System Global Area 1.1257E+10 bytes
Fixed Size 2263336 bytes
Variable Size 5872027352 bytes
Database Buffers 5368709120 bytes
Redo Buffers 14352384 bytes
SQL> !
rman登入同時使用11g新特性duplicate 線上恢復restore 備庫
[oracle@zhanglin u01]$ rman target auxiliary
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Sep 29 12:25:36 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD (DBID=271384494, not open)
connected to auxiliary database: PROD (not mounted)
RMAN> duplicate target database for standby from active database;
由於篇幅較大,這裡省略
rman之後例項emrep預設是mount階段:
SQL> select status from v$instance ;
STATUS
------------
MOUNTED
檢視例項emrep的檔案路徑,如果轉換成功,則引數設定正確。
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oradata/emrep/emrep/system01.dbf
/u01/app/oradata/emrep/emrep/sysaux01.dbf
/u01/app/oradata/emrep/emrep/undotbs01.dbf
/u01/app/oradata/emrep/emrep/users01.dbf
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oradata/emrep/emrep/control01.ctl
/u01/app/oradata/emrep/emrep/control02.ctl
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oradata/emrep/emrep/redo03a.log
/u01/app/oradata/emrep/emrep/redo02a.log
/u01/app/oradata/emrep/emrep/redo01a.log
/u01/app/oradata/emrep/emrep/redo01b.log
/u01/app/oradata/emrep/emrep/redo03b.log
/u01/app/oradata/emrep/emrep/redo02b.log
/u01/app/oradata/standbylog/redo04a.log
/u01/app/oradata/standbylog/redo04b.log
/u01/app/oradata/standbylog/redo05a.log
/u01/app/oradata/standbylog/redo05b.log
/u01/app/oradata/standbylog/redo06a.log
MEMBER
--------------------------------------------------------------------------------
/u01/app/oradata/standbylog/redo06b.log
/u01/app/oradata/standbylog/redo07a.log
/u01/app/oradata/standbylog/redo07b.log
備庫開啟日誌實時應用
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL>
檢視備庫emrep當前的歸檔日誌號
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oradata/emrep/archivelog
Oldest online log sequence 8
Next log sequence to archive 0
Current log sequence 10
SQL>
備庫alert.log
Primary database is in MAXIMUM PERFORMANCE mode
RFS[4]: Assigned to RFS process 10783
RFS[4]: Selected log 4 for thread 1 sequence 9 dbid 271384494 branch 859556145
Media Recovery Log /u01/app/oradata/emrep/archivelog/1_8_859556145.dbf
Media Recovery Waiting for thread 1 sequence 9 (in transit)
Recovery of Online Redo Log: Thread 1 Group 4 Seq 9 Reading mem 0
Mem# 0: /u01/app/oradata/standbylog/redo04a.log
Mem# 1: /u01/app/oradata/standbylog/redo04b.log
Mon Sep 29 13:56:02 2014
RFS[4]: No standby redo logfiles available for thread 1
Mon Sep 29 13:56:02 2014
Archived Log entry 7 added for thread 1 sequence 9 ID 0x102cffa7 dest 1:
RFS[4]: Opened log for thread 1 sequence 10 dbid 271384494 branch 859556145
Mon Sep 29 13:56:02 2014
Media Recovery Waiting for thread 1 sequence 10 (in transit)
主庫:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oradata/prod/archivelog
Oldest online log sequence 8
Next log sequence to archive 10
Current log sequence 10
SQL> 建立一個表空間測試,是否可以傳遞到備庫emrep中:
SQL> create tablespace test datafile '/u01/app/oradata/prod/prod/test.dbf' size 10m;
Tablespace created.
SQL> alter system switch logfile;
System altered.
在備庫上檢視
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oradata/emrep/emrep/system01.dbf
/u01/app/oradata/emrep/emrep/sysaux01.dbf
/u01/app/oradata/emrep/emrep/undotbs01.dbf
/u01/app/oradata/emrep/emrep/users01.dbf
/u01/app/oradata/emrep/emrep/test.dbf
5 rows selected.
SQL>
說明歸檔日誌成功傳遞,併成功被備庫應用。
至此物理DG搭建成功,後面可以做主備切換:
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29494175/viewspace-2120699/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 一步一步搭建 oracle 11gR2 rac + dg 之前傳 (一)Oracle
- 一步一步搭建11gR2 rac+dg之DG SWITCHOVER功能(九)
- 一步一步搭建oracle 11gR2 rac+dg之database安裝(五)OracleDatabase
- 一步一步搭建11gR2 rac+dg之DG 機器配置(七)
- 一步一步搭建oracle 11gR2 rac+dg之環境準備(二)Oracle
- 一步一步搭建oracle 11gR2 rac+dg之共享磁碟設定(三)Oracle
- 一步一步搭建 oracle 11gR2 rac+dg之grid安裝(四)Oracle
- 一步一步搭建11gR2 rac+dg之配置單例項的DG(八)單例
- 一步一步搭建11gR2 rac+dg之結尾篇(十)
- 一步一步搭建Oracle 11g RAC+ DG詳解Oracle
- 一步一步搭建11gR2 rac+dg之安裝rac出現問題解決(六)
- 【DG】[三思筆記]一步一步學DataGuard筆記
- 一步一步學DataGuard(5)物理standby之建立示例
- OEL6.3 64位部署ORACLE 11gR2(11.2.0.4) RAC+DG(9)建立DGOracle
- 一步一步配置Oracle StreamOracle
- 一步一步配置ORACLE STREAM【轉載】Oracle
- ORACLE 11.2.0.4 DG(Broker) for linux 部署OracleLinux
- oracle 11gR2 對CRS dg做映象dgOracle
- oracle物理dg狀態檢查Oracle
- 三思筆記之一步一步學ORACLE筆記Oracle
- 【DG】Oracle 19c使用dbca來搭建物理DGOracle
- OEL6.3 64位部署ORACLE 11gR2(11.2.0.4) RAC+DG(3)建立共享盤Oracle
- OEL6.3 64位部署ORACLE 11gR2(11.2.0.4) RAC+DG(4)環境配置Oracle
- OEL6.3 64位部署ORACLE 11gR2(11.2.0.4) RAC+DG(5)安裝GIOracle
- OEL6.3 64位部署ORACLE 11gR2(11.2.0.4) RAC+DG(6)建立磁碟組Oracle
- Oracle11gR2搭建ADG一步一步操作Oracle
- OEL6.3 64位部署ORACLE 11gR2(11.2.0.4) RAC+DG(1)系統環境Oracle
- OEL6.3 64位部署ORACLE 11gR2(11.2.0.4) RAC+DG(8)建立資料庫Oracle資料庫
- Oracle Enterprise Linux6.5一步一步安裝Oracle 10.2.0.1OracleLinux
- 物理DG!Oracle 10G Data Guard DemoOracle 10g
- 一步一步理解命令模式模式
- 如何一步一步配置webpackWeb
- 一步一步上手MyBatisPlusMyBatis
- 一步一步手寫GPTGPT
- OEL6.3 64位部署ORACLE 11gR2(11.2.0.4) RAC+DG(7)安裝資料庫Oracle資料庫
- ORACLE 11.2.0.4 dg搭建及對DDL的支援驗證Oracle
- 塗抹Oracle—三思筆記之一步一步學Oracle全書目錄Oracle筆記
- 一步一步分析vue之observeVue