六、建立物理备库二(主机vmthree)
6.1 建立密码文件
格式一定是要用orapw<SID>,密码和主库一样。
$ $ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=iamwangnc force=y
6.2 在备库上建spfile并启动备库
$ sqlplus '/as sysdba'
SQL> create spfile from pfile='/orahome/backup/initLOGSTDBY.ora';
SQL> startup nomount;
SQL> alter database mount standby database;
SQL> exit
6.3 备库做rman恢复
11g里可用rman直接在远程复制一个数据库,无需备份和恢复。
$ rman target /
RMAN> restore database;
RMAN> exit
6.4 启动监听并确保在主备库间能互相tnsping通
$ lsnrctl start
$ tnsping db_wending
$ tnsping db_logstdby
$ lsnrctl status (确保备库监听LOGSTDBY实例成功)
主库(vmone):
$ tnsping db_logstdby
$ tnsping db_wending
$ lsnrctl status (确保主库监听WENDING实例成功)
6.6 主库增加归档目的地参数并归档测试(vmone)
$ sqlplus '/as sysdba'
SQL> alter system set log_archive_dest_3='SERVICE=db_logstdby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=LOGSTDBY' scope=both;
SQL> alter system set log_archive_dest_state_3='ENABLE' scope=both;
SQL> alter system archive log current;
6.7 在备库上检查日志是否都从主库传送过来并启动redo apply
SQL> host ls -l /orahome/arch/LOGSTDBY
此时会发现主库建备库控制文件前产生的归档文件未传送过来,这是正常的。
如果归档日志一个都没传送过来,则在主库上检查归档目的地设置是否有错(vmone):
SQL> select dest_id,dest_name,error from v$archive_dest;
如果日志能成功传送,则在备库上开始应用日志(vmthree):
SQL> recover managed standby database disconnect;
此时备库的alert日志文件可能会有如下错误信息:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/orahome/oradata/LOGSTDBY/redo3.log'
ORA-27037: unable to obtain file status
不用管,只看后面的归档文件是否成功完成了媒体恢复。
6.8 查询备库信息
SQL> select name,database_role,db_unique_name,open_mode,protection_mode,protection_level,switchover_status,supplemental_log_data_pk,supplemental_log_data_ui from v$database;
NAME DATABASE_ROLE DB_UNIQUE_NAME OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS SUP SUP
-------- ---------------- ------------------------------ ---------- -------------------- -------------------- -------------------- --- ---
ORCLDB PHYSICAL STANDBY LOGSTDBY MOUNTED MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE NOT ALLOWED NO NO
查询日志应用情况(或者查看alert日志文件):
SQL> SELECT name, applied, REGISTRAR, CREATOR, THREAD#, SEQUENCE#, FIRST_CHANGE#, NEXT_CHANGE#, first_time, next_time FROM V$ARCHIVED_LOG order by SEQUENCE#;
查看备库日志信息:
SQL> select * from v$dataguard_status;
到此物理备库创建完毕!
--End--
from:http://hi.baidu.com/edeed/blog/item/142addc45eea9bcc39db491f.html