Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1134186
  • 博文数量: 276
  • 博客积分: 10077
  • 博客等级: 上将
  • 技术积分: 2513
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-24 20:31
文章分类

全部博文(276)

文章存档

2020年(1)

2015年(5)

2012年(2)

2011年(6)

2010年(7)

2009年(224)

2008年(31)

我的朋友

分类: Oracle

2009-09-02 17:38:53

为一个RAC搭建standby和单节点搭建方法基本一致,我们可以把RAC看成是一个单节点的数据库,只需要保证所有节点的日志能传送到备库即可。
 
1)Physical Standby: force logging
ALTER DATABASE FORCE LOGGING;
 
2)Physical Standby:create standby control file
>alter database create standby controlfile as '/orclbak/control01.ctl';
 
3)backup & copy
+backup pysical standby database.
run
{
allocate channel c1 device type disk format '/orclbak/%U' connect ;
allocate channel c2 device type disk format '/orclbak/%U' connect ;
backup database format='/orclbak/%U';
backup archivelog all delete all input;
}
+copy pwd file, backup file to standby host.
++node1
scp /orclbak/*  192.168.179.13:/orclbak/
++node2
scp /orclbak/*  192.168.179.13:/orclbak/
4)change init file & tnsnames.ora
+primary init file
*.DB_UNIQUE_NAME='primary'
*.log_archive_config='DG_CONFIG=(primary,standby)'
*.LOG_ARCHIVE_FORMAT=ARC%S_%R.%T
*.log_archive_dest_1='location=/ora10g/arc/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=primary'
*.LOG_ARCHIVE_DEST_2='SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.FAL_SERVER=standby
*.FAL_CLIENT=primary
*.STANDBY_FILE_MANAGEMENT=AUTO
*.DB_FILE_NAME_CONVERT='/oradata/','/dev/raw/'
*.LOG_FILE_NAME_CONVERT='/oradata/','/dev/raw/'
RACDB1.local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.179.11)(PORT = 1521))'
RACDB2.local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.179.12)(PORT = 1521))'
###############################################
alter system set DB_UNIQUE_NAME='primary' SCOPE=SPFILE sid='*';
alter system set log_archive_config='DG_CONFIG=(primary,standby)' SCOPE=SPFILE sid='*';
alter system set LOG_ARCHIVE_FORMAT='%t_%s_%r.dbf' SCOPE=SPFILE sid='*';
alter system set log_archive_dest_1='location=/ora10g/arc/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=primary' SCOPE=SPFILE sid='*';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby' SCOPE=SPFILE sid='*';
alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE SCOPE=SPFILE sid='*';
alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE SCOPE=SPFILE sid='*';
alter system set FAL_SERVER=standby SCOPE=SPFILE sid='*';
alter system set FAL_CLIENT=primary SCOPE=SPFILE sid='*';
alter system set STANDBY_FILE_MANAGEMENT=AUTO SCOPE=SPFILE sid='*';
alter system set DB_FILE_NAME_CONVERT='/oradata/','/dev/raw/' SCOPE=SPFILE sid='*';
alter system set local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.179.11)(PORT = 1521))' SID = 'racdb1';
alter system set local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.179.12)(PORT = 1521))' SID = 'racdb2';
################################################
 
====================
关闭所有实例
注意:修改以上参数后,必须把所有实例都关闭。否则在启动实例的时候可能会导致错误:
或crs_stop -f 关闭服务
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              92276304 bytes
Database Buffers          188743680 bytes
Redo Buffers                2973696 bytes
ORA-00600: internal error code, arguments: [kccsbck_first], [2], [694169950],
[], [], [], [], []
====================
 
+standby init file
*.compatible='10.2.0.1.0'
*.db_name='RACDB'
*.instance_name='racdb1'
*.remote_login_passwordfile='EXCLUSIVE'
*.audit_file_dest='/ora10g/admin/RACDB/adump'
*.background_dump_dest='/ora10g/admin/RACDB/bdump'
*.core_dump_dest='/ora10g/admin/RACDB/cdump'
*.user_dump_dest='/ora10g/admin/RACDB/udump'
*.control_files='/oradata/control01.ctl','/oradata/control02.ctl','/oradata/control03.ctl'
*.cursor_sharing='exact'
*.db_files=100
*.db_block_size=8192
*.db_file_multiblock_read_count=16
*.job_queue_processes=0
*.processes=3000
*.sessions=3000
*.transactions=1000
*.open_cursors=100
*.sort_area_size=102400
*.sga_max_size=285212672
*.sga_target=285212672
*.shared_pool_reserved_size=41943024
*.pga_aggregate_target=265865472
*.workarea_size_policy='auto'
*.query_rewrite_enabled='TRUE'
*.query_rewrite_integrity='TRUSTED'
*.star_transformation_enabled='FALSE'
*.timed_statistics=TRUE
*.undo_management='AUTO'
*.undo_retention=10800
*.fast_start_mttr_target=300
*.fast_start_parallel_rollback='false'

*.DB_UNIQUE_NAME='standby'
*.log_archive_config='DG_CONFIG=(primary,standby)'
*.LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf
*.log_archive_dest_1='location=/ora10g/arc/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'
*.LOG_ARCHIVE_DEST_2='SERVICE=primary LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=primary'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.FAL_SERVER=primary
*.FAL_CLIENT=standby
*.STANDBY_FILE_MANAGEMENT=AUTO
*.DB_FILE_NAME_CONVERT='/dev/raw/','/oradata/'
*.LOG_FILE_NAME_CONVERT='/dev/raw/','/oradata/'
 

+tnsname.ora for both
PRIMARY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = primary)
    )
    (FAILOVER_MODE =
      (TYPE = SELECT)
      (METHOD = BASIC)
      (RETRIES = 180)
      (DELAY = 5)
      )
  )

STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.179.13)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = RACDB1)
      (SERVER = DEDICATED)
    )
  )
 

 

5)start standby database
>startup mount;
 
alter database rename file '/dev/raw/raw3' to '/oradata/redo1_1.ora';
alter database rename file '/dev/raw/raw4' to '/oradata/redo1_2.ora';
alter database rename file '/dev/raw/raw5' to '/oradata/redo2_1.ora';
alter database rename file '/dev/raw/raw6' to '/oradata/redo2_2.ora';
 
>RMAN
run{
allocate channel ch0 type disk;
set newname for datafile 3 to '/oradata/sysaux01.dbf';
set newname for datafile 1 to '/oradata/system01.dbf';
set newname for datafile 2 to '/oradata/undotbs01.dbf';
set newname for datafile 4 to '/oradata/undotbs02.dbf';
set newname for datafile 5 to '/oradata/users01.dbf';
restore database;
switch datafile all;
restore archivelog all;
release channel ch0;
}
 
 
#开始recover
>alter database recover managed standby database disconnect from session;
#只读状态打开standby库
>alter database recover managed standby database cancel;
>alter datbase open;
 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
实验过程中用到的部分命令.
# /etc/init.d/init.crs stop
# /etc/init.d/init.crs start
$/ora10g/product/10.2.0/crs_1/bin/srvctl start nodeapps -n node2
$/ora10g/product/10.2.0/crs_1/bin/srvctl stop nodeapps -n node1
$/ora10g/product/10.2.0/crs_1/bin/crs_stat -t
$/ora10g/product/10.2.0/crs_1/bin/srvctl stop db -d racdb
$/ora10g/product/10.2.0/crs_1/bin/srvctl start db -d racdb
$/ora10g/product/10.2.0/crs_1/bin/srvctl start inst -d racdb -i racdb1 -o mount
$/ora10g/product/10.2.0/crs_1/bin/srvctl start inst -d racdb -i racdb2 -o mount
 
参考
阅读(1314) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~