日期:2014-05-16 浏览次数:20563 次
建立数据库:环境要求
OS 版本一样;
Oracle 版本必须一样,同时安装目录结构建议做成一样,以免发生不必要的错误;
开始安装oracle时,在primary 和 standby 上都装上instance, 要求安装的 SID都必须一样。
shutdown冷备.
将primary和standby都置为archive log 状态:
Startup mount
alter database archivelog;
alter system archive log start
分别修改primary和standby 库的配置文件。
两数据库的配置:
配置priamry listener.ora
# LISTENER.ORA Network Configuration File: d:\oracle\ora92\network\admin\listener.ora
# Generated by Oracle configuration tools.
LISTENER =
?? (DESCRIPTION_LIST =
(DESCRIPTION =
?? (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(DESCRIPTION =
?? (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.72.219)(PORT = 1521))
)
?? )
SID_LIST_LISTENER =
?? (SID_LIST =
(SID_DESC =
?? (SID_NAME = PLSExtProc)
?? (ORACLE_HOME = D:\oracle\ora92)
?? (PROGRAM = extproc)
)
(SID_DESC =
?? (GLOBAL_DBNAME = epg)
?? (ORACLE_HOME = D:\oracle\ora92)
?? (SID_NAME = gdepg)
)
?? )
配置从standby listner.ora 文件:
# LISTENER.ORA Network Configuration File: d:\oracle\ora92\network\admin\listener.ora
# Generated by Oracle configuration tools.
LISTENER =
?? (DESCRIPTION_LIST =
(DESCRIPTION =
?? (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(DESCRIPTION =
?? (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.72.218)(PORT = 1521))
)
?? )
SID_LIST_LISTENER =
?? (SID_LIST =
(SID_DESC =
?? (SID_NAME = PLSExtProc)
?? (ORACLE_HOME = D:\oracle\ora92)
?? (PROGRAM = extproc)
)
(SID_DESC =
?? (GLOBAL_DBNAME = epg)
?? (ORACLE_HOME = D:\oracle\ora92)
?? (SID_NAME = gdepg)
)
?? )
配置主primary?? 的tnsnames.ora
(必须保证这里面只有两项,primary和standby的两个。同时建议用 “Net Manager” 来操作自动产生配置文件。否则会发生莫名其妙的问题。)
# TNSNAMES.ORA Network Configuration File: d:\oracle\ora92\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
STANDBY =
?? (DESCRIPTION =
(ADDRESS_LIST =
?? (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.72.218)(PORT = 1521))
)
(CONNECT_DATA =
?? (SERVICE_NAME = gdepg)
)
?? )
PRIMARY =
?? (DESCRIPTION =
(ADDRESS_LIST =
?? (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.72.219)(PORT = 1521))
)
(CONNECT_DATA =
?? (SERVICE_NAME = gdepg)
)
?? )
配置从 standby 的 tnsnames.ora 文件
# TNSNAMES.ORA Network Configuration File: d:\oracle\ora92\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
PRIMARY =
?? (DESCRIPTION =
(ADDRESS_LIST =
?? (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.72.219)(PORT = 1521))
)
(CONNECT_DATA =
?? (SERVICE_NAME = gdepg)
)
?? )
STANDBY =
?? (DESCRIPTION =
(ADDRESS_LIST =
?? (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.72.218)(PORT = 1521))
)
(CONNECT_DATA =
?? (SERVICE_NAME = gdepg)
)
?? )
完成后执行
C:\>tnsping standby
C:\>tnsping primary
来检测配置是否有问题。
lsnrctl start;
Lsnrctl status
配置primary 的pfile 即 init.ora.2272006143433
###########################################
# Cache and I/O
###########################################
db_block_size=8192
db_cache_size=335544320
db_file_multiblock_read_count=16
log_archive_start = true
log_archive_dest_1 = "location=d:\oracle\Arch mandatory REOPEN=2"
log_archive_dest_state_1 = enable
log_archive_dest_2 = "service=standby mandatory reopen=15"
log_archive_dest_state_2 = enable
log_archive_min_succeed_dest=1
log_archive_format=ARC%S.%T
配置 standby 的 pfile 文件 init.ora
与primary有所不同:最好的配置方式是从primary上 copy过来,然后做相对修改:
control_files=("d:\oracle\oradata\gdepg\standby01.ctl")
###########################################
# Cache and I/O
###########################################
db_block_size=8192
db_cache_size=335544320
db_file_multiblock_read_count=16
log_archive_dest_state_1 = enable
log_archive_dest_state_2 = enable
lo