码迷,mamicode.com
首页 > 其他好文 > 详细

通过RMAN创建dataguard(原创)

时间:2018-06-04 17:48:10      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:ADG

通过RMAN创建dataguard(原创)

环境介绍:数据库版本10G,两个节点分别是rednum1(192.168.212.128)和rednum2(192.168.212.130)
主库主机名称是rednum1,从库主机名称是rednum2
配置步骤如下:
1、在主库和从库配置tnsnames如下:
standbydb1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rednum1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = standbydb01) (UR=A)
)
)

standbydb2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rednum2)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = standbydb02)(UR=A)
)
)
2、在主库上配置inits
standbydb.db_cache_size=637534208
standbydb.
java_pool_size=16777216
standbydb.large_pool_size=33554432
standbydb.
oracle_base=‘/u01/app/oracle‘#ORACLE_BASE set from environment
standbydb.pga_aggregate_target=654311424
standbydb.
sga_target=956301312
standbydb.__shared_io_pool_size=0
standbydb.shared_pool_size=251658240
standbydb.
streams_pool_size=0
.audit_file_dest=‘/u01/app/oracle/admin/standbydb/adump‘
.audit_trail=‘db‘
.compatible=‘11.2.0.4.0‘
.control_files=‘/u01/app/oracle/oradata/standbydb/control01.ctl‘,‘/u01/app/oracle/fast_recovery_area/standbydb/control02.ctl‘
.db_block_size=8192
.db_domain=‘‘
.db_recovery_file_dest=‘/u01/app/oracle/fast_recovery_area‘
.db_recovery_file_dest_size=5218762752
.diagnostic_dest=‘/u01/app/oracle‘
.dispatchers=‘(PROTOCOL=TCP) (SERVICE=standbydbXDB)‘
.memory_target=1600126976
.open_cursors=300
.processes=150
.remote_login_passwordfile=‘EXCLUSIVE‘
*.undo_tablespace=‘UNDOTBS1‘
########for DG
DB_NAME=standbyd
DB_UNIQUE_NAME=standbydb01
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(standbydb01,standbydb02)‘ ### DG_CONFIG必须包含DG环境中主从库的DB_UNIQUE_NAME名称
LOG_ARCHIVE_DEST_1=
‘LOCATION=/u01/app/backup/archlog/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=standbydb01‘
LOG_ARCHIVE_DEST_2=
‘SERVICE=standbydb2 ASYNC ###service 为从库的tnsname
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=standbydb02‘
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVEFORMAT=%t%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=30
fal_server=standbydb2 ###为从库的tnsnames
STANDBY_FILE_MANAGEMENT=AUTO

3、在从库上配置init
standbydb.db_cache_size=603979776
standbydb.
java_pool_size=16777216
standbydb.large_pool_size=83886080
standbydb.
oracle_base=‘/u01/app/oracle‘#ORACLE_BASE set from environment
standbydb.pga_aggregate_target=654311424
standbydb.
sga_target=956301312
standbydb.__shared_io_pool_size=0
standbydb.shared_pool_size=234881024
standbydb.
streams_pool_size=0
.audit_file_dest=‘/u01/app/oracle/admin/standbydb/adump‘
.audit_trail=‘db‘
.compatible=‘11.2.0.4.0‘
.control_files=‘/u01/app/oracle/oradata/standbydb/standby01.ctl‘,‘/u01/app/oracle/fast_recovery_area/standbydb/ standby01.ctl ‘
.db_block_size=8192
.db_domain=‘‘
.db_name=standbyd
.db_recovery_file_dest=‘/u01/app/oracle/fast_recovery_area‘
.db_recovery_file_dest_size=5218762752
.diagnostic_dest=‘/u01/app/oracle‘
.dispatchers=‘(PROTOCOL=TCP) (SERVICE=standbydbXDB)‘
.memory_target=1600126976
.open_cursors=300
.processes=150
.remote_login_passwordfile=‘EXCLUSIVE‘
.undo_tablespace=‘UNDOTBS1‘
######for DG
DB_UNIQUE_NAME=standbydb02
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(standbydb01,standbydb02)‘ ### DG_CONFIG必须包含DG环境中主从库的DB_UNIQUE_NAME名称
LOG_ARCHIVE_DEST_1=
‘LOCATION=/u01/app/backup/archlog/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=standbydb02‘
LOG_ARCHIVE_DEST_2=
‘SERVICE=standbydb1 ASYNC ###service 为主库的tnsnames
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=standbydb01‘
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVEFORMAT=%t%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=standbydb1 ###为主库tnsnames
STANDBY_FILE_MANAGEMENT=AUTO

4、在主库上创建orapwd文件并传送到从库上
5、在主库上创建standby控制文件,并传送到从库init文件指定目录下
通过sql命令行创建
Sql>alter database create standby controlfile as ‘XXX‘;
或者通过rman创建
backup format=‘/u01/standby01.ctl‘ current controlfile for standby;
6、nomount从库数据库
Startup nomount pfile=‘/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initstandbydb.ora‘
7、在主库上创建RMAN CATALOG,并进行全备份

步骤1 Sql>create user rman identified by rman;
步骤2 Sql>grant recovery_catalogowner to rman;
步骤3 Rman target / catalog rman/rman
步骤4 Rman> create catalog;
步骤5 Rman> register database;
步骤6 Rman> Sql ‘ALTER SYSTEM ARCHIVE LOG CURRENT’;
步骤7 Rman> configure channel device type disk format ‘/u01/backup/Whole
%d%U‘;
步骤8 Rman>backup as compressed backupset database plus archivelog delete input format=‘/u01/backup/Whole
%d_%U‘ tag=‘Whole_bak‘;
通过rman 连接主库 、catalog库、standby数据库如下:
步骤9 $rman target sys/manager@standbydb1 catalog rman/rman@standbydb1 AUXILIARY
步骤10 sys/manager@standbydb2
注:1)如果需要把备份文件备份至指定位置需要执行步骤7,duplicate时也是读此目录。否则跳过。
2)将备份文件传递至从库,使从库能访问到备份文件.
8,创建standby数据库
1)主从库路径相同
如果主库与从库的数据文件和在线日志文件的路径相同则用如下命令创建
Rman>DUPLICATE TARGET DATABASE FOR STANDBY NOFILENAMECHECK;
2) 主从库路径不相同
如果主库与从库的数据文件和在线日志文件的路径不相同则可用如下方法中的一种创建
2.1)在从库init文件中配置DB_FILE_NAME_CONVERT和LOG_FILE_NAME_CONVERT,如果主库的数据文件路径为 +FAST ,在线日志文件路径为 +LOG ,从库的数据文件路径为 +FAST1 ,在线日志文件路径为 +LOG1,则参数设置为 DB_FILE_NAME_CONVERT=(’+FAST’,’+FAST1’), LOG_FILE_NAME_CONVERT=(’+LOG’,’+LOG1’);如果主库的数据文件路径为 /u01/data01/ ,在线日志文件路径为 /u01/log01/ ,从库的数据文件路径为 /u01/data02/ ,在线日志文件路径为 +LOG1,则参数设置为 DB_FILE_NAME_CONVERT=(’/u01/data01/’,’/u01/data02/’), LOG_FILE_NAME_CONVERT=(’/u01/log01/,’ /u01/log02/’);
创建standby数据库
Rman>DUPLICATE TARGET DATABASE FOR STANDBY;

2.2)通过set newname命令
Rman>RUN
{

set new file names for the datafiles

SET NEWNAME FOR DATAFILE 1 TO ‘?/dbs/standby_data_01.f‘;
SET NEWNAME FOR DATAFILE 2 TO ‘?/dbs/standby_data_02.f‘;
.
.
.

run the DUPLICATE command

DUPLICATE TARGET DATABASE FOR STANDBY;
}
2.3) 通过CONFIGURE AUXNAME命令
Rman> CONFIGURE AUXNAME FOR DATAFILE 1 TO ‘/oracle/auxfiles/aux_1.f‘;
Rman>CONFIGURE AUXNAME FOR DATAFILE 2 TO ‘/oracle/auxfiles/aux_2.f‘;
.
.
.
Rman>CONFIGURE AUXNAME FOR DATAFILE n TO ‘/oracle/auxfiles/aux_n.f‘;
分配至少一个auxiliary通道,并进行创建,如下:
Rman>RUN
{

allocate at least one auxiliary channel of type DISK or sbt

ALLOCATE AUXILIARY CHANNEL standby1 DEVICE TYPE DISK;
.
.
.

issue the DUPLICATE command

DUPLICATE TARGET DATABASE FOR STANDBY;
}
删除之前的配置,如下:

un-specify auxiliary names for the datafiles

Rman>CONFIGURE AUXNAME FOR DATAFILE 1 CLEAR;
Rman>CONFIGURE AUXNAME FOR DATAFILE 2 CLEAR;
.
.
.
Rman>CONFIGURE AUXNAME FOR DATAFILE n CLEAR;

通过RMAN创建dataguard(原创)

标签:ADG

原文地址:http://blog.51cto.com/13789500/2124656

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!