- 论坛徽章:
- 0
|
:wink:
target: active physical standby database
db_name: orcl
host1 instance_name rcl
host2 instance_name rcl2
环境:
--host1
name dev.sh.com
ip 10.1.1.14
--host2
name shared_disk
ip 10.1.1.15
准备:
host1 : rdbms+db
host2 : rdbms
配置监听,tnsnames.ora
cd $ORACLE_HOME/network/admin
cp -v ./sample/listener.ora .
cp -v ./sample/tnsnames.ora .
--node2
vi listener.ora
LISTENER =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=10.1.1.15)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=orcl)
(SID_NAME=orcl2)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
)
)
--node1,node2都要有
vi tnsnames.ora
orcl =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = tcp)(HOST = 10.1.1.14)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
)
orcl2=
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = tcp)(HOST = 10.1.1.15)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
)
---以下操作都在host1上
--校验service_name,db_name,instance_name,db_unique_name
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string orcl
db_unique_name string ORCL
global_names boolean FALSE
instance_name string orcl
lock_name_space string
log_file_name_convert string
service_names string ORCL
SQL>
--校验service_name与监听里的service是否一致
SQL> ho lsnrctl status
--校验文件的存放路径.如果有多路径存在,在node2上建立相对应的目录
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/mytest01.dbf
/u01/app/oracle/oradata/orcl/mytest02.dbf
/u01/app/oracle/oradata/orcl/mytest03.dbf
/u01/app/oracle/oradata/orcl/mytest04.dbf
--校验文件的存放路径.如果有多路径存在,在node2上建立相对应的目录
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/redo03.log
/u01/app/oracle/oradata/orcl/redo02.log
/u01/app/oracle/oradata/orcl/redo01.log
SQL> alter sysetm set service_names=orcl scope=spfile;
SQL> alter system set db_unique_name=orcl scope=spfile;
SQL> alter system set log_archive_config='dg_config=(orcl,orcl2)';
SQL> alter system set log_archive_dest_1='location=/home/oracle/archivelog/orcl valid_for=(all_logfiles,all_roles) db_unique_name=orcl';
SQL> alter system set log_archive_dest_state_2=defer;
SQL> alter system set log_archive_dest_2='service=orcl2 valid_for=(all_logfiles,primary_roles) db_unique_name=orcl2';
--根据spfile里指定的路径,相应的在host2上建立(db的路径无变化)
--host2
---准备接收的archivelog目录
[oracle@shared_disk dbs]$ mkdir -pv /home/oracle/archivelog/orcl2
[oracle@shared_disk dbs]$ mkdir -pv /home/oracle/archivelog/orcl
--orcl2的控制文件存放点1\存放点2
[oracle@shared_disk ~]$ mkdir -pv /u01/app/oracle/oradata/orcl2/
[oracle@shared_disk ~]$ mkdir -pv /u01/app/oracle/flash_recovery_area/orcl2/
--audit database的路径必须要有
[oracle@shared_disk dbs]$ mkdir -pv /u01/app/oracle/admin/orcl2/adump
--host2
cd $ORACLE_HOME/dbs
orapwd file=orapworcl2 password=oracle
rman target /
startup nomount
然后退出
--host1,host2都可以使用以下rman脚本
[oracle@dev admin]$ rman target sys/oracle@orcl auxiliary sys/oracle@orcl2
run{
allocate channel c1 type disk;
allocate auxiliary channel stdby type disk;
duplicate target database for standby from active database
dorecover
spfile
parameter_value_convert 'orcl','orcl2'
set db_unique_name='orcl2'
set log_archive_dest_1='location=/home/oracle/archivelog/orcl2 valid_for=(all_logfiles,all_roles) db_unique_name=orcl2'
set log_archive_dest_2='service=orcl valid_for=(online_logfiles,primary_roles) db_unique_name=orcl'
nofilenamecheck;
}
--host2
SQL> alter database open read only;
SQL> select OPEN_MODE,PROTECTION_MODE from v$database;
OPEN_MODE PROTECTION_MODE
-------------------- --------------------
READ ONLY MAXIMUM AVAILABILITY
SQL> show parameter standby
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
standby_archive_dest string ?/dbs/arch
standby_file_management string MANUAL -->一定为manual
SQL> alter database add standby logfile '/u01/app/oracle/oradata/standbylog/stdlog01.log' size 50m
SQL> alter database add standby logfile '/u01/app/oracle/oradata/standbylog/stdlog02.log' size 50m;
SQL> alter database add standby logfile '/u01/app/oracle/oradata/standbylog/stdlog03.log' size 50m
SQL> alter database add standby logfile '/u01/app/oracle/oradata/standbylog/stdlog04.log' size 50m
--node2 进入恢复模式
SQL> alter database recover managed standby database disconnect from session;
--host1 打开archivelog_dest_2
SQL> alter system set log_archive_dest_state_2=enable;
--观察host1,host2的alter.log
host1:
...
Fri Oct 05 15:17:55 2012
Thread 1 advanced to log sequence 130 (LGWR switch)
Current log# 1 seq# 130 mem# 0: /u01/app/oracle/oradata/orcl/redo01.log
Fri Oct 05 15:17:55 2012
Archived Log entry 190 added for thread 1 sequence 129 ID 0x4ed30028 dest 1:
Fri Oct 05 15:17:55 2012
LNS: Standby redo logfile selected for thread 1 sequence 130 for destination LOG_ARCHIVE_DEST_2
....
host2:
...
Fri Aug 31 07:09:27 2012
Archived Log entry 7 added for thread 1 sequence 129 ID 0x4ed30028 dest 1:
Fri Aug 31 07:09:27 2012
RFS[1]: Selected log 4 for thread 1 sequence 130 dbid 1322421032 branch 794640298
Fri Aug 31 07:09:28 2012
Media Recovery Log /home/oracle/archivelog/orcl2/1_129_794640298.dbf
Media Recovery Waiting for thread 1 sequence 130 (in transit)
... |
|