日期:2014-05-16 浏览次数:20352 次
1,确保数据库归档状态
SQL> select log_mode from v$database; LOG_MODE ------------ ARCHIVELOG
SQL> ALTER DATABASE FORCE LOGGING; Database altered.
SQL> alter database add standby logfile '/oracle/app/oracle/oradata/hrdbprim/redo11.log' size 50m; Database altered.
SQL> alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(hrdbprim,standby)'; System altered. SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=/oracle/app/oracle/oradata/hrdbprim/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=hrdbprim'; System altered. SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby'; System altered. SQL> alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE; System altered. SQL> alter system set FAL_SERVER=standby; System altered. SQL> alter system set FAL_CLIENT=standby; System altered. SQL> alter system set DB_FILE_NAME_CONVERT='/oracle/app/oracle/oradata/hrdbprim/','+DATA/standby/datafile/' scope=spfile; System altered. SQL> alter system set LOG_FILE_NAME_CONVERT='/oracle/app/oracle/oradata/hrdbprim/','+DATA/standby/onlinelog/' scope=spfile; System altered.二、修改sql*net相关文件,确保网络环境准备,确保互相tnsping通
listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = standby)
(ORACLE_HOME = /oracle/app/oracle/product/11.2.0/db_1)
(SID_NAME = standby3)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.4.124.235)(PORT = 1521))
)
tnsnames.ora
hrdbprim =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.4.124.239)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = hrdbprim)
)
)
standby =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.4.124.235)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = standby)(UR=A)
)
)
三、创建standby数据库
1,password密码文件;既可以从primary复制改名,也可以重新生成一个,主要要保持sys口令一致,这里采用复制方式
sftp ...
mv orapwhrdbprim orapwstandby
2,新建pfile文件,注意pfile要放在$ORACLE_HOME/dbs目录,否则启动时需要指定pfile文件,注意启动时必须使用pfile文件启动,否者无法复制
vi initstandby3.ora
DB_NAME=standby
DB_UNIQUE_NAME=standby
*.audit_file_dest='/oracle/app/oracle/admin/standby/adump'
*.control_files='+DATA/standby/controlfile/control01.ctl','+FRA/standby/controlfile/control02.ctl'
*.db_create_file_dest='+DATA'
*.db_block_size=8192
*.db_recovery_file_dest='+FRA'
*.db_recovery_file_dest_size=10G
3,创建相关目录,用来放datafile和trace file
mkdir -p /oracle/app/oracle/ad