当前位置: 代码迷 >> 综合 >> Oracle 11gR2 dataguard搭建说明 --- rman方式
  详细解决方案

Oracle 11gR2 dataguard搭建说明 --- rman方式

热度:40   发布时间:2024-01-12 23:41:22.0

Oracle 11gR2 dataguard 介绍

Oracle 11gR2 dataguard搭建说明 --- duplicate方式

 

1.配置参数文件

主库参数文件


INCA.__db_cache_size=18589155328
INCA.__java_pool_size=134217728
INCA.__large_pool_size=201326592
INCA.__oracle_base='/ora/app/oracle'#ORACLE_BASE set from environment
INCA.__pga_aggregate_target=3422552064
INCA.__sga_target=21474836480
INCA.__shared_io_pool_size=0
INCA.__shared_pool_size=2348810240
INCA.__streams_pool_size=67108864
*.audit_file_dest='/ora/app/oracle/admin/INCA/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/data/INCA/control01.ctl','/data/INCA/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='INCA'
*.diagnostic_dest='/ora/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=INCAXDB)'
*.job_queue_processes=1000
*.log_archive_dest_1='LOCATION=/data/arch'
*.log_archive_format='%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=3365928960
*.processes=3000
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=3305
*.sga_max_size=27917287424
*.sga_target=21474836480
*.undo_tablespace='UNDOTBS1'
#dg_parameter
*.db_file_name_convert='/data/INCA','/data/incadg'
*.db_unique_name='INCA'
*.fal_client='INCA'
*.fal_server='incadg'
*.log_archive_config='DG_CONFIG=(INCA,incadg)'
*.log_archive_dest_1='LOCATION=/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=INCA'
*.log_archive_dest_2='SERVICE=incadg ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=incadg COMPRESSION=ENABLE'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=30

备库参数文件

incadg.__db_cache_size=8589934592
incadg.__java_pool_size=134217728
incadg.__large_pool_size=201326592
incadg.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
incadg.__pga_aggregate_target=838860800
incadg.__sga_target=12884901888
incadg.__shared_io_pool_size=0
incadg.__shared_pool_size=1073741824
incadg.__streams_pool_size=67108864
*.audit_file_dest='/u01/app/oracle/admin/incadg/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/data/incadg/control01.ctl','/data/incadg/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='inca'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=INCAXDB)'
*.job_queue_processes=1000
*.log_archive_dest_1='LOCATION=/data/arch'
*.log_archive_format='%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=838860800
*.processes=3000
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=3305
*.sga_max_size=12884901888
*.sga_target=12884901888
*.undo_tablespace='UNDOTBS1'
#dg_parameter
*.db_file_name_convert='/data/INCA','/data/incadg'
*.db_unique_name='incadg'
*.fal_client='incadg'
*.fal_server='INCA'
*.log_archive_config='DG_CONFIG=(INCA,incadg)'
*.log_archive_dest_1='LOCATION=/data/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=incadg'
*.log_archive_dest_2='SERVICE=INCA ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=INCA COMPRESSION=ENABLE'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=30

2.备库创建adump、dpdump、pfile目录

mkdir /u01/app/oracle/admin/incadg/adump
mkdir /u01/app/oracle/admin/incadg/dpdump
mkdir /u01/app/oracle/admin/incadg/pfile

3.备份主库

source /home/oracle/.bash_profile
export DB_BASE=$ORACLE_BASE
export DB_HOME=$ORACLE_HOME
export OPATCH=$ORACLE_HOME/OPatch
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/share/lib
CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/jdbc/lib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
PATH=$PATH:$ORACLE_HOME/bin:$OPATCH
export CLASSPATH
export LD_LIBRARY_PATH
export dt=`date +%Y%m%d`
export PATHrman target / log=/backup/cerptraindb/log/cerptraindb_$dt.log <<eof
RUN {
ALLOCATE CHANNEL t1 TYPE disk maxpiecesize=20480m;
ALLOCATE CHANNEL t2 TYPE disk maxpiecesize=20480m;
ALLOCATE CHANNEL t3 TYPE disk maxpiecesize=20480m;
ALLOCATE CHANNEL t4 TYPE disk maxpiecesize=20480m;BACKUP
format '/backup/cerptraindb/rman/%d_%s_%p_%T.bak'
DATABASE;
sql 'alter system archive log current';
backup 
format '/backup/cerptraindb/rman/%d_%s_%p_%T.arc'
archivelog all delete all input;
release channel t1;
release channel t2;
release channel t3;
release channel t4;
ALLOCATE CHANNEL c1 TYPE disk;
ALLOCATE CHANNEL c2 TYPE disk;
backup spfile include current controlfile 
format '/backup/cerptraindb/rman/%d_%s_%p_%T.ctl';
release channel c1;
release channel c2;
}
exit;
eof

4.同步密码文件

scp /ora/app/oracle/product/11.2.0/dbhome_1/dbs/orapwINCA cerp01:/u01/app/oracle/product/11.2.0/db_1/orapwincadg

5.恢复备库

run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
set until sequence 1175 thread 1;
set newname for datafile 1 to '/data/incadg/system01.dbf';
set newname for datafile 2 to '/data/incadg/sysaux01.dbf';
set newname for datafile 3 to '/data/incadg/undotbs01.dbf';
set newname for datafile 4 to '/data/incadg/users01.dbf';
set newname for datafile 5 to '/data/incadg/tasly20180102_01.dbf';
set newname for datafile 6 to '/data/incadg/tasly20180102_02.dbf';
set newname for datafile 7 to '/data/incadg/tasly20180102_index_01.dbf';
set newname for datafile 8 to '/data/incadg/cerpzs.dbf';
set newname for datafile 9 to '/data/incadg/cerpzs_index.dbf';
set newname for datafile 10 to '/data/incadg/tasly20180123_01.dbf';
set newname for datafile 11 to '/data/incadg/tasly20180123_02.dbf';
set newname for datafile 12 to '/data/incadg/tasly20180123_index_01.dbf';
set newname for datafile 13 to '/data/incadg/tasly20180123_index_02.dbf';
set newname for tempfile 1 to '/data/incadg/temp01.dbf';
restore database;
switch datafile all; 
release channel d1;
release channel d2;
release channel d3;
release channel d4;
}

6.主库创建standby控制文件

#创建standby_controlfile
SQL> alter database create standby controlfile as '/home/oracle/incadg.ctl';#复制备机控制文件
scp /home/oracle/incadg.ctl cerp01:/home/oracle/incadg.ctl

7.备库使用pfile启动数据库

startup mount pfile=’ /u01/app/oracle/product/11.2.0/db_1/dbs/initincadg.ora’;

8.恢复备库

run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
set until sequence 1175 thread 1;
set newname for datafile 1 to '/data/incadg/system01.dbf';
set newname for datafile 2 to '/data/incadg/sysaux01.dbf';
set newname for datafile 3 to '/data/incadg/undotbs01.dbf';
set newname for datafile 4 to '/data/incadg/users01.dbf';
set newname for datafile 5 to '/data/incadg/tasly20180102_01.dbf';
set newname for datafile 6 to '/data/incadg/tasly20180102_02.dbf';
set newname for datafile 7 to '/data/incadg/tasly20180102_index_01.dbf';
set newname for datafile 8 to '/data/incadg/cerpzs.dbf';
set newname for datafile 9 to '/data/incadg/cerpzs_index.dbf';
set newname for datafile 10 to '/data/incadg/tasly20180123_01.dbf';
set newname for datafile 11 to '/data/incadg/tasly20180123_02.dbf';
set newname for datafile 12 to '/data/incadg/tasly20180123_index_01.dbf';
set newname for datafile 13 to '/data/incadg/tasly20180123_index_02.dbf';
set newname for tempfile 1 to '/data/incadg/temp01.dbf';
restore database;
switch datafile all; 
release channel d1;
release channel d2;
release channel d3;
release channel d4;
}

9.主库、备库创建standby redo文件

主库:

alter database add standby logfile group 4 ('/data/INCA/standby04.log') size 512M;
alter database add standby logfile group 5 ('/data/INCA/standby05.log') size 512M;
alter database add standby logfile group 6 ('/data/INCA/standby06.log') size 512M;
alter database add standby logfile group 7 ('/data/INCA/standby07.log') size 512M;
alter database add standby logfile group 8 ('/data/INCA/standby08.log') size 512M;

备库:

alter database add standby logfile group 4 ('/data/incadg/standby04.log') size 512M;
alter database add standby logfile group 5 ('/data/incadg/standby05.log') size 512M;
alter database add standby logfile group 6 ('/data/incadg/standby06.log') size 512M;
alter database add standby logfile group 7 ('/data/incadg/standby07.log') size 512M;
alter database add standby logfile group 8 ('/data/incadg/standby08.log') size 512M;
alter database add standby logfile group 9 ('/data/incadg/standby08.log') size 512M;

10.备库启动DG

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
recover managed standby database cancel;

11.查看DG状态

SQL> select open_mode,database_role,switchover_status from v$database;OPEN_MODE	     DATABASE_ROLE    SWITCHOVER_STATUS
-------------------- ---------------- --------------------
READ WRITE	     PRIMARY	      UNRESOLVABLE GAPSQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME, APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

 

  相关解决方案