标签:网络 protoc tar syn ESS 日志 auto ram 监听
Oracle DG 搭建
1、 环境
OS IP hostname db_name DB_UNIQUE_NAME
主库 RHEL 5.4 192.168.12.20 edgzrip1.oracle.com PROD1 PROD1
备库 RHEL 5.4 192.168.12.30 edgzrip2.oracle.com PROD1 DG
2、 设置主库开启归档
SQL> alter database archivelog;
Database altered.
3、 设置主库开启强制记录日志
SQL> alter database force logging;
Database altered.
4、 查询主库归档模式及日志强制记录
SQL> select log_mode,force_logging from v$database;
LOG_MODE FOR
------------ ---
ARCHIVELOG YES
5、 添加standby log
SQL> alter database add standby logfile group 4 ‘/u01/app/oracle/oradata/PROD1/standby04.log‘ size 50m;
Database altered.
SQL> alter database add standby logfile group 5 ‘/u01/app/oracle/oradata/PROD1/standby05.log‘ size 50m;
Database altered.
SQL> alter database add standby logfile group 6 ‘/u01/app/oracle/oradata/PROD1/standby06.log‘ size 50m;
Database altered.
SQL> alter database add standby logfile group 7 ‘/u01/app/oracle/oradata/PROD1/standby07.log‘ size 50m;
Database altered.
6、 主库创建pfile
SQL> create pfile from spfile;
File created.
7、 传送pfile到备库
[root@edgzrip1 dbs]# scp initPROD1.ora edgzrip2:/u01/app/oracle/product/11.2.0/db_1/dbs/initDG.ora
root@edgzrip2‘s password:
initPROD1.ora
8、 修改spfile
在spfile追加以下参数
DB_UNIQUE_NAME=PROD1
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(PROD1,DG)‘
LOG_ARCHIVE_DEST_1=‘LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PROD1‘
LOG_ARCHIVE_DEST_2= ‘SERVICE=DG ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DG‘
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
FAL_SERVER=DG
DB_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/DG‘,‘/u01/app/oracle/oradata/PROD1‘
LOG_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/DG‘,‘/u01/app/oracle/oradata/PROD1‘
STANDBY_FILE_MANAGEMENT=AUTO
9、 使用新的spfile启动主库,并创建新的spfile
Startup pfile=’/u01/app/oracle/product/11.2.0/db_1/dbs/initPROD1.ora’
Create spfile from pfile;
10、 传送密码文件orapwPROD1到备库
[root@edgzrip1 dbs]# scp orapwPROD1 edgzrip2:/u01/app/oracle/product/11.2.0/db_1/dbs/ orapwDG
11、 修改备库参数文件initDG.ora
追加以下参数:
DB_UNIQUE_NAME=DG
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(DG,PROD1)‘
LOG_ARCHIVE_DEST_1=‘LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=DG‘
LOG_ARCHIVE_DEST_2= ‘SERVICE=PROD1 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD1‘
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
FAL_SERVER=PROD1
DB_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/PROD1‘,‘/u01/app/oracle/oradata/DG‘
LOG_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/PROD1‘,‘/u01/app/oracle/oradata/DG‘
STANDBY_FILE_MANAGEMENT=AUTO
12、 在备库创建相应目录
Mkdir –p /u01/app/oracle/oradata/DG
Mkdir –p /u01/app/oracle/fast_recovery_area/DG
Mkdir –p /u01/app/oracle/admin/DG/{a,dp}dump
13、 使用备库pfile创建spfile,并启动到nomount状态
[oracle@edgzrip2-DG ~]$ sqlplus / as sysdba
Create spfile from pfile;
Startup nomount
14、 配置主库备库网络
主库listener.ora:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = PROD1.us.oracle.com)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = PROD1)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip1.oracle.com)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
主库tnsnames.ora:
PROD1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip1.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = PROD1.us.oracle.com)
)
)
DG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip2.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = DG.us.oracle.com)
)
)
备库listener.ora:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = DG.us.oracle.com)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = DG)
)
)
备库tnsnames.ora:
PROD1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip1.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = PROD1.us.oracle.com)
)
)
DG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip2.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = DG.us.oracle.com)
)
)
测试主备库网络:
启动主备库监听:lsnrctl start
主库:
[oracle@edgzrip1-PROD1 admin]$ tnsping prod1
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 26-AUG-2019 19:52:18
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip1.oracle.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = PROD1.us.oracle.com)))
OK (10 msec)
[oracle@edgzrip1-PROD1 admin]$ tnsping dg
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 26-AUG-2019 19:52:25
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip2.oracle.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DG.us.oracle.com)))
OK (0 msec)
备库:
[oracle@edgzrip2-DG admin]$ tnsping prod1
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 26-AUG-2019 19:55:22
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip1.oracle.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = PROD1.us.oracle.com)))
OK (10 msec)
[oracle@edgzrip2-DG admin]$ tnsping dg
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 26-AUG-2019 19:55:26
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip2.oracle.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DG.us.oracle.com)))
OK (10 msec)
确认主备库网络无问题
15、 备库登录rman
[oracle@edgzrip2-DG admin]$ rman target sys/oracle@prod1 auxiliary sys/oracle@dg
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Aug 26 19:56:30 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD1 (DBID=2202819890)
connected to auxiliary database: PROD1 (started)
RMAN>
16、 执行duplicate
RMAN> duplicate target database for standby from active database nofilenamecheck dorecovery;
17、 Duplicate完成后,在备库启用实时日志应用
SQL> alter database recover managed standby database using current logfile disconnect from session;
标签:网络 protoc tar syn ESS 日志 auto ram 监听
原文地址:https://www.cnblogs.com/orcl-2018/p/11415227.html