7. 在initorcl.ora添加以下内容:
*.log_archive_format='%T%S%r.ARC'
*.DB_UNIQUE_NAME='primary'
*.log_archive_config='DG_CONFIG=(primary,standby)'
*.log_archive_dest_1='location=D:/oracle/product/10.2.0/oradata/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=primary'
*.log_archive_dest_2='SERVICE=standby arch ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby'
*.STANDBY_FILE_MANAGEMENT=AUTO
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.FAL_SERVER='standby'
*.FAL_CLIENT='primary'
关闭数据库,在用initorcl.ora重启,并创建spfile文件
SQL>startup pfile='$ORACLE_HOME/database/initorcl.ora'
SQL>create spfile from pfile='$ORACLE_HOME/database/initorcl.ora'
8.
A. 拷贝数据文件,参数文件,控制文件,密码文件到备库上
initorcl.ora参数文件,PWDorcl.ora密码文件考到$ORACLE_HOME/database下的,
controlbak.ctl 考到$ORACLE_base/oradata/orcl/下,并分别重命名为control01.ctl,control01.ctl,control01.ctl
数据文件考到$ORACLE_base/oradata/orcl/下
B. 用Rman拷贝,不用停机
$ rman target /
RMAN> backup full format 'D:/FULL_%d_%T_%s.bak' database include current controlfile for standby;
RMAN> sql 'alter system archive log current';
RMAN> Backup ArchiveLog all format='D:/arch_%d_%T_%s.bak';
备份完后将备份文件拷到standby上同样的目录,强调:同样的目录,在standby进行rman 恢复即可
9. 启动主数据库
SQL>startup
---------------------------------------------------------------------
Standy操作:
1. 用oradim工具创建备库orcl实例
oradim.exe -new -sid orcl -startmode m
oradim.exe -edit -sid orcl -startmode a
2. 创建备库存放数据文件和后台跟踪目录
$ORACLE_BASE/ORADATA/ORCL
$ORACLE_BASE/admin/orcl
$ORACLE_BASE/admin/orcl/adump
$ORACLE_BASE/admin/orcl/bdump
$ORACLE_BASE/admin/orcl/cdump
$ORACLE_BASE/admin/orcl/dpdump
$ORACLE_BASE/admin/orcl/pfile
$ORACLE_BASE/admin/orcl/udump
$ORACLE_BASE/admin/orcl/
3. 添加"备用联机日志文件"
SQL>startup mount
先查看日志文件位置:
SQL>select * from v$logfile;
在添加:
SQL> alter database add standby logfile group 4 ('D:/ORACLE/PRODUCT/10.2.0/ORADATA/ORCL/redo04.log') size 50m;
SQL> alter database add standby logfile group 5 ('D:/ORACLE/PRODUCT/10.2.0/ORADATA/ORCL/redo05.log') size 50m;
SQL> alter database add standby logfile group 6 ('D:/ORACLE/PRODUCT/10.2.0/ORADATA/ORCL/redo06.log') size 50m;
SQL> alter database add standby logfile group 7 ('D:/ORACLE/PRODUCT/10.2.0/ORADATA/ORCL/redo07.log') size 50m;
4. 在备库创建监听和配置tnsnams.ora
listener.ora配置如下:
# listener.ora Network Configuration File: D:/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = D:/oracle/product/10.2.0/db_1)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.85.3.44)(PORT = 1521))
)
)
tnsnames.ora配置如下:
# tnsnames.ora Network Configuration File: D:/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
primary =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.85.3.44)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
standby =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.85.3.43)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
5. 测试主备之间网络连通
primary:
C:>lsnrctl start
C:>tnsping standby
standby
C:>lsnrctl start
C:>tnsping primary
6. 配置备库初始化参数
编辑$ORACLE_HOME/database目录下的initorcl.ora添加以下内容
*.log_archive_format='%T%S%r.ARC'
*.DB_UNIQUE_NAME='standby'
*.log_archive_config='DG_CONFIG=(primary,standby)'
*.log_archive_dest_1='location=D:/oracle/product/10.2.0/oradata/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'
*.log_archive_dest_2='SERVICE=primary arch ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=primary'
*.STANDBY_FILE_MANAGEMENT=AUTO
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.FAL_SERVER='primary'
*.FAL_CLIENT='standby'
更多信息请查看 java进阶网 http://www.javady.com