创建DG《大话 Oracle Grid》

本文整理自张晓明的《大话Oracle Grid》
环境准备:

主库:10.107.173.11
备库:10.107.173.12

系统初始化略,主库安装Oracle软件和实例,备库只安装Oracle软件略,可以参考我的文章Centos7.x静默安装11gR2

备库配置好静态监听,主库备库写好tns文件,主库密码文件scp到备库
主备库tns文件如下:

tnspri=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.107.173.11)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pridb)
    )
  )

tnsstd=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.107.173.12)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = stddb)
    )
  )

主库:

alter system set db_unique_name = 'pridb' scope=spfile;
shu immediate;
startup;
show parameter name;
db_unique_name                       string      pridb

主备都执行(测试):

sqlplus sys/oracle@tnspri as sysdba
sqlplus sys/oracle@tnsstd as sysdba

配置Primary数据库到Standby数据库的归档

alter system set log_archive_dest_2='service=tnsstd LGWR ASYNC valid_for=(online_logfiles,primary_role) db_unique_name=stddb' scope=both;
alter system set log_archive_config='dg_config=(pridb,stddb)' scope=both;
alter system set standby_file_management=auto scope=both;
alter system set fal_client=tnspri scope=both;
alter system set fal_server=tnsstd scope=both;

主库:

create pfile from spfile;

备库创建主库参数文件中的目录路径
Standby准备参数文件

db_name='prod'
db_unique_name='stddb'

备库:

startup nomount;
rman target sys/oracle@tnspri auxiliary sys/oracle@tnsstd
run {
duplicate target database
for standby
from active database nofilenamecheck
spfile
 set 'db_unique_name'='stddb'
 set log_archive_dest_2='service=tnspri LGWR ASYNC valid_for=(online_logfiles,primary_role) db_unique_name=pridb'
 set fal_client='tnsstd'
 set fal_server='tnspri'
 ;
 }

Standby进入恢复状态

alter database recover managed standby database disconnect from session;

进入只读状态

alter database recover managed standby database cancel;
alter database open;
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY
alter database recover managed standby database disconnect from session;
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY WITH APPLY
上一篇:【DFS】【剪枝】【DG特长生2011】民生问题


下一篇:2021-05-20