一 配置规划 名 称 IP 监听 端 口 SID db_name db_unique_name service name 主机 127.0.0.1 Listener1 1521 test1
一 配置规划
名 称 IP 监听 端 口 SID db_name db_unique_name service name
主机
127.0.0.1
Listener1
1521 test1 test1 test1 test1备机
127.0.0.1
Listener12
1522 test2 test1 test1 test1二 具体步骤
1 主库操作
---确认主库在归档模式
Sql>archive log list
更改:
sql>startup mount
sql>Alter database archive log
---置为FORCE LOGGING 模式
Sql>alter database force logging;
---创建主库密码文件
orapwd file=’D:\Oracle\product\10.2.0\db_1\database\pwdtest1.ora’ password= entries=5
---创建从库控制文件
SQL> alter database create standby controlfile as ' D:\oracle\product\10.2.0\db_1\oradata\test2\control01.ctl ';
---创建主库二进制参数文件
Sql>create pfile=’d:\inittest1.ora’ from spfile;
---更改主库的二进制参数文件
添加
DB_NAME=test1
DB_UNIQUE_NAME=test1
LOG_ARCHIVE_CONFIG='DG_CONFIG=(test1,test2)'
*.compatible='10.2.0.1.0'
*.control_files='D:\oracle\product\10.2.0\oradata\test1\control01.ctl','D:\oracle\product\10.2.0\oradata\test1\control02.ctl','D:\oracle\product\10.2.0\oradata\test1\control03.ctl'
LOG_ARCHIVE_DEST_1='LOCATION=D:\oracle\product\10.2.0\oradata\test1\archive1 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=test1'
#LOG_ARCHIVE_DEST_2='SERVICE=test2 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=test2'
LOG_ARCHIVE_DEST_2='SERVICE=test2 DB_UNIQUE_NAME=test2'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
#LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=test2
FAL_CLIENT=test1
DB_FILE_NAME_CONVERT='D:\oracle\product\10.2.0\oradata\test2\','D:\oracle\product\10.2.0\oradata\test1\'
LOG_FILE_NAME_CONVERT='D:\oracle\product\10.2.0\oradata\test2\','D:\oracle\product\10.2.0\oradata\test1\'
STANDBY_FILE_MANAGEMENT=AUTO
---用inittest1.ora生成spfiletest1.ora
Sql>shutdown immediate
Sql>startup pfile=’d:\inittest1.ora’
Sql>create spfile=’D:\oracle\product\10.2.0\db_1\dbs\spfiletest1.ora’ from pfile
2 从库操作
---创建服务
oradim -NEW -SID test2
--- 创建密码文件
orapwd file=‘D:\oracle\product\10.2.0\db_1\database\pwdtest2.ora password= entries=5
----拷贝相关文件
A $ORACLEBASE\oradata\test1\拷贝到$ORACLEBASE\oradata\test\2
日志文件,,控制文件,归档文件除外
其中控制文件收主库操作中生成的文件复制成另外两个
B $ORACLEBASE\admin\test1\拷贝到$ORACLEBASE\admin\test2\
----COPY inittest1.ora inittest2.ora
----更改inittest2.ora
DB_NAME=test1
DB_UNIQUE_NAME=test2
LOG_ARCHIVE_CONFIG='DG_CONFIG=(test1,test2)'
*.compatible='10.2.0.1.0'
*.control_files='D:\oracle\product\10.2.0\oradata\test2\control01.ctl','D:\oracle\product\10.2.0\oradata\test2\control02.ctl','D:\oracle\product\10.2.0\oradata\test2\control03.ctl'
LOG_ARCHIVE_DEST_1='LOCATION=D:\oracle\product\10.2.0\oradata\test2\archive2 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=test2'
#LOG_ARCHIVE_DEST_2='SERVICE=test2 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=test1'
LOG_ARCHIVE_DEST_2='SERVICE=test1 DB_UNIQUE_NAME=test1'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
#LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=test1
FAL_CLIENT=test2
DB_FILE_NAME_CONVERT='D:\oracle\product\10.2.0\oradata\test1\','D:\oracle\product\10.2.0\oradata\test2\'
LOG_FILE_NAME_CONVERT='D:\oracle\product\10.2.0\oradata\test1\','D:\oracle\product\10.2.0\oradata\test2\'
STANDBY_FILE_MANAGEMENT=AUTO
3 配置主从监听
LISTENER2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.69)(PORT = 1522))
)
LISTENER1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.69)(PORT = 1521))
)
SID_LIST_LISTENER2 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = test2)
(ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
(SID_NAME = test2)
)
)
SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = test1)
(ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
(SID_NAME = test1)
)
)
4 配置主从TNSNAMES.ORA
TEST1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ltan.epoa.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test1)
)
)
TEST2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ltan.epoa.com)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test2)
)
)
5 启用redo应用
Sql>startup mount pfile=’d:\inittest2.ora’
SQL> alter database recover managed standby database disconnect from session;