本文共 4107 字,大约阅读时间需要 13 分钟。
SQL> alter database force logging; |
cd $ORACLE_HOME/dbs/ orapwd file=orapwdb1 password=123456 force=y |
alter system set log_archive_config='dg_config=(db1,standby)' scope=both; alter system set log_archive_dest_1='location=/u01/db1/arch' scope=both; alter system set db_unique_name='db1' scope=both; |
RMAN> connect target sys/123456 RMAN> backup database format='/oracle/rmanback/%d_%s.dbf' plus archivelog; [oracle@oracle rmanback]$ ls DB1_1.dbf DB1_2.dbf |
SQL>alter database create standby controlfile as '/oracle/rmanback/ctontrl01.ctl |
[oracle@oracle dbs]$ lsnrctl status LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 14-JUN-2009 02:54:29 Service "db1" has 1 instance(s). Instance "db1", status READY, has 1 handler(s) for this service... Service "db1_XPT" has 1 instance(s). Instance "db1", status READY, has 1 handler(s) for this service... The command completed successfully |
vi $ORACLE_HOME/network/admin/tnsnames.ora db1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.1)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = db1) standby = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.2)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = standby) ) ) |
# 环境变量设成与主库一样 # 只安装软件不安装库 ./runInstaller –silent –responseFile /tmp/installoracle.rsp |
mkdir –p $ORACLE_BASE/admin/ cd $ORACLE_BASE/admin/ORACLE_SID mkdir adump bdump cdump dpdump udump |
cd $ORACLE_HOME/dbs/ orapwd file=orapwSID password=123456 force=y # 注要密码要与主库的一样 , 否则会归档失败 |
db_name = standby shared_pool_size = 120M undo_management = AUTO undo_tablespace = undotbs sga_max_size = 200M sga_target = 160M db_2k_cache_size = 4M standby_file_management=AUTO fal_server='db1' fal_client='standby' log_archive_dest_1='location=/u01/app/oracle/product/10.2.0/dbs/arch' log_archive_dest_2='SERVICE=db1 REOPEN=300' log_archive_dest_state_1='ENABLE' log_archive_dest_state_2='ENABLE' |
scp /oracle/rmanback/*.dbf root@192.168.18.2:/oracle/rmanback/ scp /oracle/rmanback/*.ctl root@192.168.18.2:/oracle/oracle/oradata/standby/ |
SQL>connect / as sysdba connnpcted to an idle instance. SQL>startup nomount pfile=$ORACLE_HOME/dbs/initstandby.ora SQL>alter database mount standby database; |
tnsping db1 tnsping standby SQL> sqlplus sys/123456@db1 SQL> sqlplus sys/123456@standby |
RMAN>connect target / connected to target database:TEST(DBID=788075692) RMAN> restore database |
SQL>recover managed standby database disconnect from session; # 如果有需要 应 用的日志并想手工 应 用,可以运行如下命 令 SQL>recover automatic standby database; |
SQL> alter system switch logfile |
SQL> select max(sequence#) from v$archived_log; MAX(SEQUENCE#) -------------- 17 |
SQL> select sequence# ,applied from v$archived_log order by sequence#; SEQUENCE# APP --------------------- --- 15 YES 16 YES 17 YES |
SQL> create spfile from pfile; SQL> shutdown immedaite SQL> startup mount SQL> alter database recover managed standby database disconnect from session; SQL> alter database open read only; |