准备工作:
1.启用归档
在主库上的每个节点都要设置,注:在一台机器设置归档时其他的节点实例都要关闭
sqlplus /nolog
SQL>conn /as sysdba
SQL > alter system set log_archive_dest_1 = "location="
SQL > alter system set log_archive_format='arch_%t_%s_%r.arc' scope=spfile;
SQL > shutdown immediate
SQL> alter database archivelog;
Database altered.
SQL> archive log start
Statement processed.
SQL> alter database open
Database altered.
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +ARCH/arch2/
SQL> show parameter archive_start[@more@]2.设置主库的强行日志处理:(每个节点都执行)
SQL> ALTER DATABASE FORCE LOGGING;
3.建立备份目录(主备同时建立)
mkdir -p /backup/databackup/
chown -R oracle.oinstall /backup
备份主库数据
3.1 备份spfile文件
SQL> CREATE PFILE='/backup/databackup/standby.ora' FROM SPFILE;
3.2 rman到处主库的数据文件及控制文件
rman target /
RMAN> backup device type disk format '/backup/databackup/%U' database plus archivelog;
RMAN> backup device type disk format '/backup/databackup/%U' current controlfile for standby;
3.3将主库的listener.ora, tnsnames.ora文件复制到/backup/databackup/
cd $ORACLE_HOME/network/admin/*.ora /backup/databackup/
4.在备库下建立数据库的文件存放目录:
cd $ORACLE_BASE
mkdir -p admin/rac/bdump
mkdir -p admin/rac/cdump
mkdir -p admin/rac/udump
mkdir -p admin/rac/adump
mkdir -p admin/rac/dpdump
mkdir -p admin/rac/hdump
5.将备份的数据从主库拷贝到standby机上
5.1 scp -rp /backup/databackup/*
5.2 将standby上的listener.ora, tnsnames.ora 拷贝到主机
scp -rp $ORACLE_BASE
6.备机上执行一下操作
6.1 备机上合并listener.ora, tnsnames.ora
cat /backup/databackup/listener.ora >> $ORACLE_HOME/network/admin/listener.ora
cat /backup/databackup/tnsnames.ora >> $ORACLE_HOME/network/admin/tnsnames.ora
6.2 主机上合并listener.ora, tnsnames.ora
cat $ORACLE_BASE/listener.ora >> $ORACLE_HOME/network/admin/listener.ora
cat $ORACLE_BASE/tnsnames.ora >> $ORACLE_HOME/network/admin/tnsnames.ora
6.3备机上建立密码文件
cd $ORACLE_HOME/dbs
orapwd file=orapw$ORACLE_SID password=oracle entries=5
6.4 将spfie文件复制到$ORACLE_HOME/dbs下
cp /backup/databackup/standby.ora $ORACLE_HOME/dbs/initstandby.ora
6.5修改其中参数,删除有关集群的参数并添加standby设置参数,相见如下
*.audit_file_dest='/oracle/oracle/admin/rac/adump'
*.background_dump_dest='/oracle/oracle/admin/rac/bdump'
*.compatible='10.2.0.2.0'
*.control_files='+SDATA/rac/controlfile/Current.257.607694417','+SDATA/rac/controlfile/backup.258.607694417'
*.core_dump_dest='/oracle/oracle/admin/rac/cdump'
*.db_block_size=8192
*.db_create_file_dest='+SDATA'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='RAC'
*.db_recovery_file_dest='+SDATA'
*.db_recovery_file_dest_size=2147483648
*.instance_name='standby'
*.job_queue_processes=10
*.log_archive_dest_1='location=+SARCH'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='arch_%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=520093696
*.processes=150
*.remote_login_passwordfile='exclusive'
*.sga_target=1073741824
*.thread=1
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS2'
*.user_dump_dest='/oracle/oracle/admin/rac/udump'
*.db_file_name_convert='+DATA','+SDATA'
*.standby_file_management=auto
*.fal_server='RAC'
*.fal_client='STANDBY'
*.service_names='rac'
*.standby_archive_dest='+SARCH'
6.6 在ASM磁盘组中添加目录:
export ORACLE_SID=+ASM
sqlplus /nolog
SQL>conn /as sysdba
SQL> alter diskgroup sdata add directory '+SDATA/RAC';
6.7建立spfile文件
export ORACLE_SID=standby
sqlplus /nolog
SQL>conn /as sysdba
SQL> CREATE SPFILE='+SDATA/spfilestandby.ora FROM PFILE='$ORACLE_HOME/dbs/initstandby.ora';
6.7倒入数据到数据库
sqlplus /nolog
SQL>conn /as sysdba
SQL> STARTUP NOMOUNT
rman target auxiliary /
RMAN> duplicate target database for standby;
6.8 启动standby
SQL>startup nomount
SQL>alter database mount standby database;
SQL>recover automatic standby database;
SQL>alter database recover managed standby database disconnect from session;
注:如果遇到不能识别控制文件的现象,在asm的卷中找到相应的? 7.在主库上分别设置归档路径 (每个节点?
7.在主库上分别设置归?
SQL>alter system set log_archive_de
SQL>alter system se
SQL>alter system set log_archive_de贾葱?
观察alter日志,如果归档正常,说明stst_2='SERVICE=standby REOPEN=180' scope=both;
8.失败切换: st_state_2=enable scope=both;
预先设置好init参数文件,去掉其中的standby参数
SQL>alter database recover managed standby database finish force;
SQL>alter database commit to switchover to primary;
SQL>alter database open;
如果start之前有过read only open,需要restart备库,关闭数据库,应用参数文件,重新启动
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7319461/viewspace-928336/,如需转载,请注明出处,否则将追究法律责任。