一 配置规划
名 称 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:Oracleproduct10.2.0db_1databasepwdtest1.ora’ password= entries=5
---创建从库控制文件
SQL> alter database create standby controlfile as ' D:oracleproduct10.2.0db_1oradatatest2control01.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:oracleproduct10.2.0oradatatest1control01.ctl','D:oracleproduct10.2.0oradatatest1control02.ctl','D:oracleproduct10.2.0oradatatest1control03.ctl'
LOG_ARCHIVE_DEST_1='LOCATION=D:oracleproduct10.2.0oradatatest1archive1 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:oracleproduct10.2.0oradatatest2','D:oracleproduct10.2.0oradatatest1'
LOG_FILE_NAME_CONVERT='D:oracleproduct10.2.0oradatatest2','D:oracleproduct10.2.0oradatatest1'
STANDBY_FILE_MANAGEMENT=AUTO
---用inittest1.ora生成spfiletest1.ora
Sql>shutdown immediate
Sql>startup pfile=’d:inittest1.ora’
Sql>create spfile=’D:oracleproduct10.2.0db_1dbsspfiletest1.ora’ from pfile
2 从库操作
---创建服务
oradim -NEW -SID test2
--- 创建密码文件
orapwd file=‘D:oracleproduct10.2.0db_1databasepwdtest2.ora password= entries=5
----拷贝相关文件
A $ORACLEBASEoradatatest1拷贝到$ORACLEBASEoradatatest2
日志文件,控制文件,归档文件除外
其中控制文件收主库操作中生成的文件复制成另外两个
B $ORACLEBASEadmintest1拷贝到$ORACLEBASEadmintest2
----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:oracleproduct10.2.0oradatatest2control01.ctl','D:oracleproduct10.2.0oradatatest2control02.ctl','D:oracleproduct10.2.0oradatatest2control03.ctl'
LOG_ARCHIVE_DEST_1='LOCATION=D:oracleproduct10.2.0oradatatest2archive2 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:oracleproduct10.2.0oradatatest1','D:oracleproduct10.2.0oradatatest2'
LOG_FILE_NAME_CONVERT='D:oracleproduct10.2.0oradatatest1','D:oracleproduct10.2.0oradatatest2'
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:oracleproduct10.2.0db_1)
(SID_NAME = test2)
)
)
SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = test1)
(ORACLE_HOME = D:oracleproduct10.2.0db_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;