oracle19c cdb rac to rac adg部署方案

oracle19c cdb rac to rac adg部署方案

基础环境信息:

主备库:

密码

sys/system所有初始化密码为:oracle

oracle版本

oracle19.5.0.0.0

操作系统

centos7.6x64 最小化安装

最低配置建议

cpu 2c mem 8g swap 8g

/ 50G

3个1G共享磁盘asm-crs1/2/3

3个10G共享磁盘asm-data1-3(不安装mgmt,如果安装则需要再加单独50G盘)

/etc/hosts

/etc/hosts内容:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

####orcl#####

#public

192.168.52.150             rac1

192.168.52.151             rac2

#vip

192.168.52.152             rac1-vip

192.168.52.153             rac2-vip

#priv

192.168.161.150    rac1-priv

192.168.161.151    rac2-priv

#scan

192.168.52.154     rac-scan

 

####dgorcl#####

#public

192.168.52.160             dgrac1

192.168.52.161             dgrac2

#vip

192.168.52.162             dgrac1-vip

192.168.52.163             dgrac2-vip

#priv

192.168.161.160    dgrac1-priv

192.168.161.161    dgrac2-priv

#scan

192.168.52.164     dgrac-scan

 

主库:

 

节点1

节点2

主机名

rac1

rac2

public ip

192.168.52.150

192.168.52.151

private ip

192.168.161.150

192.168.161.151

vip

192.168.52.152

192.168.52.153

scan-ip

192.168.161.154

数据库名

db_name orcl

db_unique_name orcl

SQL> show pdbs;       

  CON_ID CON_NAME                       OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

         2 PDB$SEED                       READ ONLY  NO

         4 PDBORCL                        READ WRITE NO

备库:

 

节点1

节点2

主机名

dgrac1

dgrac2

public ip

192.168.52.160

192.168.52.161

private ip

192.168.161.162

192.168.161.163

vip

192.168.52.160

192.168.52.161

scan-ip

192.168.161.164

数据库名

db_name orcl

db_unique_name dgorcl

1.主库:生成参数

SQL> create pfile='/home/oracle/o.txt' from spfile;

 

File created.

 

SQL> !cat /home/oracle/o.txt

orcl2.__data_transfer_cache_size=0

orcl1.__data_transfer_cache_size=0

orcl1.__db_cache_size=1644167168

orcl2.__db_cache_size=1677721600

orcl2.__inmemory_ext_roarea=0

orcl1.__inmemory_ext_roarea=0

orcl2.__inmemory_ext_rwarea=0

orcl1.__inmemory_ext_rwarea=0

orcl2.__java_pool_size=0

orcl1.__java_pool_size=0

orcl2.__large_pool_size=16777216

orcl1.__large_pool_size=16777216

orcl1.__oracle_base='/oracle/app/oracle'#ORACLE_BASE set from environment

orcl2.__oracle_base='/oracle/app/oracle'#ORACLE_BASE set from environment

orcl2.__pga_aggregate_target=822083584

orcl1.__pga_aggregate_target=822083584

orcl2.__sga_target=2466250752

orcl1.__sga_target=2466250752

orcl2.__shared_io_pool_size=117440512

orcl1.__shared_io_pool_size=117440512

orcl1.__shared_pool_size=671088640

orcl2.__shared_pool_size=637534208

orcl2.__streams_pool_size=0

orcl1.__streams_pool_size=0

orcl2.__unified_pga_pool_size=0

orcl1.__unified_pga_pool_size=0

*.adg_redirect_dml=TRUE

*.audit_file_dest='/oracle/app/oracle/admin/orcl/adump'

*.audit_trail='none'

*.cluster_database=true

*.compatible='19.0.0'

*.control_files='+DATA/ORCL/CONTROLFILE/current.265.1026902749'

*.db_block_size=8192

*.db_create_file_dest='+DATA'

*.db_name='orcl'

*.db_recovery_file_dest_size=10737418240

*.db_recovery_file_dest='+DATA'

*.db_unique_name='orcl'

*.dg_broker_config_file1='+DATA/orcl/dr3orcl.dat'

*.dg_broker_config_file2='+DATA/orcl/dr4orcl.dat'

*.dg_broker_start=TRUE

*.diagnostic_dest='/oracle/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'

*.enable_pluggable_database=true

*.fal_server=''

family:dw_helper.instance_mode='read-only'

orcl1.instance_number=1

orcl2.instance_number=2

*.local_listener='-oraagent-dummy-'

*.log_archive_config='nodg_config'

*.log_archive_dest_1='location=+DATA'

*.log_archive_dest_2=''

*.log_archive_dest_state_2='ENABLE'

*.nls_language='AMERICAN'

*.nls_territory='AMERICA'

*.open_cursors=300

*.pga_aggregate_target=780m

*.processes=320

*.remote_login_passwordfile='exclusive'

*.resource_manager_plan='DEFAULT_CDB_PLAN'

*.sga_target=2340m

*.standby_file_management='AUTO'

orcl2.thread=2

orcl1.thread=1

*.undo_tablespace='UNDOTBS1'

orcl2.undo_tablespace='UNDOTBS2'

orcl1.undo_tablespace='UNDOTBS1'

*.log_file_name_convert='+DATA','+DATA'

*.db_file_name_convert='+DATA','+DATA'

 

参数当中

2.备库:准备参数:

两个节点oracle用户执行:mkdir -p /oracle/app/oracle/admin/dgorcl/adump

 

*.adg_redirect_dml=TRUE

*.audit_file_dest='/oracle/app/oracle/admin/dgorcl/adump'

*.audit_trail='none'

*.cluster_database=true

*.compatible='19.0.0'

*.control_files='+DATA/ORCL/CONTROLFILE/current.265.1026902749'#这个文件在恢复后会被自动替换掉,所以不用管

*.db_block_size=8192

*.db_create_file_dest='+DATA'

*.db_name='orcl'

*.db_recovery_file_dest_size=10737418240

*.db_recovery_file_dest='+DATA'

*.db_unique_name='dgorcl'

*.diagnostic_dest='/oracle/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'

*.enable_pluggable_database=true

*.fal_server=''

family:dw_helper.instance_mode='read-only'

orcl1.instance_number=1

orcl2.instance_number=2

*.local_listener='-oraagent-dummy-'

*.log_archive_config='nodg_config'

*.log_archive_dest_1='location=+DATA'

*.log_archive_dest_2=''

*.log_archive_dest_state_2='ENABLE'

*.nls_language='AMERICAN'

*.nls_territory='AMERICA'

*.open_cursors=300

*.pga_aggregate_target=780m

*.processes=320

*.remote_login_passwordfile='exclusive'

*.resource_manager_plan='DEFAULT_CDB_PLAN'

*.sga_target=2340m

*.standby_file_management='AUTO'

orcl2.thread=2

orcl1.thread=1

orcl2.undo_tablespace='UNDOTBS2'

orcl1.undo_tablespace='UNDOTBS1'

*.log_file_name_convert='+DATA','+DATA'

*.db_file_name_convert='+DATA','+DATA'

 

3.备库:启动nomount状态

[oracle@dgrac1 ~]$ sqlplus /nolog

 

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 6 11:22:31 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

 

SQL> conn /as sysdba

Connected to an idle instance.

SQL> startup nomount pfile='/home/oracle/adg.txt';

ORACLE instance started.

 

Total System Global Area 2466250400 bytes

Fixed Size                  9137824 bytes

Variable Size             603979776 bytes

Database Buffers         1845493760 bytes

Redo Buffers                7639040 bytes

SQL> exit

 

4.主库:准备密码文件

[grid@rac1 ~]$ srvctl config database -d orcl

Database unique name: orcl

Database name: orcl

Oracle home: /oracle/app/oracle/product/19c/dbhome_1

Oracle user: oracle

Spfile: +DATA/ORCL/PARAMETERFILE/spfile.287.1026905945

Password file: +DATA/ORCL/PASSWORD/pwdorcl.269.1026902735

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Server pools:

Disk Groups: DATA

Mount point paths:

Services:

Type: RAC

Start concurrency:

Stop concurrency:

OSDBA group: dba

OSOPER group: oper

Database instances: orcl1,orcl2

Configured nodes: rac1,rac2

CSS critical: no

CPU count: 0

Memory target: 0

Maximum memory: 0

Default network number for database services:

Database is administrator managed

[grid@rac1 ~]$ asmcmd pwcopy +DATA/ORCL/PASSWORD/pwdorcl.269.1026902735 /home/grid/orapworcl1

copying +DATA/ORCL/PASSWORD/pwdorcl.269.1026902735 -> /home/grid/orapworcl1

 

[grid@rac1 ~]$ pwd

/home/grid

拷贝到dgrac1节点:

[grid@rac1 ~]$ scp orapworcl1 dgrac1:/home/grid/

The authenticity of host 'dgrac1 (192.168.52.160)' can't be established.

ECDSA key fingerprint is SHA256:xpJNeZwdOi6mRKZkQOaAL0N+tViUh1GuZlBDhnLYelg.

ECDSA key fingerprint is MD5:9c:74:bd:93:4b:26:f6:dc:6d:69:a0:2e:c6:2a:23:be.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'dgrac1,192.168.52.160' (ECDSA) to the list of known hosts.

grid@dgrac1's password:

orapworcl1

5.备库:将密码文件放到节点1的dbs下:

[oracle@dgrac1 admin]$ cd $ORACLE_HOME/dbs

[oracle@dgrac1 dbs]$ ls -lt|head

total 131848

-rw-rw---- 1 oracle asmadmin     1544 Mar  6 11:25 hc_orcl1.dat

-rw-r----- 1 oracle asmadmin  2097152 Mar  6 10:13 id_orcl1.dat

-rw-r----- 1 oracle asmadmin 20119552 Mar  5 10:57 c-1554683481-20200305-00

-rw-r----- 1 oracle asmadmin 20004864 Mar  5 10:57 snapcf_orcl1.f

-rw-r----- 1 oracle asmadmin 20119552 Mar  4 23:24 c-1554683481-20200304-04

-rw-r----- 1 oracle asmadmin     3584 Mar  4 22:55 spfileorcl1.ora

-rw-r----- 1 oracle asmadmin   133120 Mar  4 22:33 arch2_16_1026902745.dbf

-rw-r----- 1 oracle asmadmin   169472 Mar  4 22:33 arch1_43_1026902745.dbf

-rw-r----- 1 oracle asmadmin   428544 Mar  4 22:27 arch1_42_1026902745.dbf

[oracle@dgrac1 dbs]$ ls -lt pw*

-rw-r----- 1 oracle oinstall 2048 Nov 19 11:59 pwdcisdb1bak

[oracle@dgrac1 dbs]$ exit

logout

[root@dgrac1 ~]# su - oracle

Last login: Fri Mar  6 11:25:00 CST 2020 on pts/0

[oracle@dgrac1 ~]$ cd $ORACLE_HOME/dbs

[oracle@dgrac1 dbs]$ pwd

/oracle/app/oracle/product/19c/dbhome_1/dbs

[oracle@dgrac1 dbs]$ exit

logout

[root@dgrac1 ~]# cp /home/grid/orapworcl1 /oracle/app/oracle/product/19c/dbhome_1/dbs/

[root@dgrac1 ~]# chown oracle:asmadmin /oracle/app/oracle/product/19c/dbhome_1/dbs/orapworcl1

[root@dgrac1 ~]# ls -l /oracle/app/oracle/product/19c/dbhome_1/dbs/orapworcl1

-rw-r----- 1 oracle asmadmin 2048 Mar  6 11:37 /oracle/app/oracle/product/19c/dbhome_1/dbs/orapworcl1

 

此时备库还是连接不上,监听没有数据的实例名:

[oracle@dgrac1 ~]$ lsnrctl status

 

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 06-MAR-2020 11:44:49

 

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

 

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production

Start Date                06-MAR-2020 11:43:10

Uptime                    0 days 0 hr. 1 min. 38 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /oracle/app/19c/grid/network/admin/listener.ora

Listener Log File         /oracle/app/grid/diag/tnslsnr/dgrac1/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.52.160)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.52.162)(PORT=1521)))

Services Summary...

Service "+ASM" has 1 instance(s).

  Instance "+ASM1", status READY, has 1 handler(s) for this service...

Service "+ASM_CRS" has 1 instance(s).

  Instance "+ASM1", status READY, has 1 handler(s) for this service...

Service "+ASM_DATA" has 1 instance(s).

  Instance "+ASM1", status READY, has 1 handler(s) for this service...

The command completed successfully

[oracle@dgrac1 ~]$ sqlplus sys/oracle@dgorcl as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 6 11:44:55 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

 

ERROR:

ORA-12514: TNS:listener does not currently know of service requested in connect

descriptor

 

 

Enter user-name: ^C

[oracle@dgrac1 ~]$

 

 

6.主备库:oracle用户下调整所有节点的tnsnames.ora内容:

[oracle@rac1 admin]$ cat tnsnames.ora

# tnsnames.ora.dgrac1 Network Configuration File: /oracle/app/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora.dgrac1

# Generated by Oracle configuration tools.

 

PDBDGORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgrac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = pdborcl)

    )

  )

 

PDBORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = pdborcl)

    )

  )

 

ORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

 

DGORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgrac1-vip)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = dgorcl)

    )

  )

 

指定备库节点1的dgrac1-vip为恢复主机点,等恢复完成后再还原为dgrac-scan。

务必将修改好的tnsname.ora拷贝到其它主备的所有节点上。

 

[oracle@dgrac1 admin]$ scp tnsnames.ora dgrac2:$ORACLE_HOME/network/admin/

tnsnames.ora                                                                                                                                                        100%  881    51.7KB/s   00:00   

[oracle@dgrac1 admin]$ scp tnsnames.ora rac2:$ORACLE_HOME/network/admin/

The authenticity of host 'rac2 (192.168.52.151)' can't be established.

ECDSA key fingerprint is SHA256:0o1bl6augRCMplUh4hZzkJp6uQQpZmMWeaPyVQvpl80.

ECDSA key fingerprint is MD5:f0:24:21:d9:10:7c:87:18:2b:df:3e:ff:af:df:e3:e9.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'rac2,192.168.52.151' (ECDSA) to the list of known hosts.

oracle@rac2's password:

tnsnames.ora                                                                                                                                                        100%  881   574.7KB/s   00:00   

[oracle@dgrac1 admin]$ scp tnsnames.ora rac1:$ORACLE_HOME/network/admin/

The authenticity of host 'rac1 (192.168.52.150)' can't be established.

ECDSA key fingerprint is SHA256:xpJNeZwdOi6mRKZkQOaAL0N+tViUh1GuZlBDhnLYelg.

ECDSA key fingerprint is MD5:9c:74:bd:93:4b:26:f6:dc:6d:69:a0:2e:c6:2a:23:be.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'rac1,192.168.52.150' (ECDSA) to the list of known hosts.

oracle@rac1's password:

tnsnames.ora                                                                                                                                                        100%  881   772.9KB/s   00:00   

 

 

7.备库节点1:grid用户下调整节点1监听

只在备库节点1操作增加如下静态监听即可:

[grid@dgrac1 admin]$ cat listener.ora

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = dgorcl)

      (ORACLE_HOME = /oracle/app/oracle/product/19c/dbhome_1)

      (SID_NAME = orcl1)

    )

  )

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER))

    )

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = dgrac-scan)(PORT = 1521))

    )

  )

 

LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))))            # line added by Agent

LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1))))                # line added by Agent

ASMNET1LSNR_ASM=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=ASMNET1LSNR_ASM))))              # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_ASMNET1LSNR_ASM=ON               # line added by Agent

VALID_NODE_CHECKING_REGISTRATION_ASMNET1LSNR_ASM=SUBNET         # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON                # line added by Agent

VALID_NODE_CHECKING_REGISTRATION_LISTENER_SCAN1=OFF             # line added by Agent - Disabled by Agent because REMOTE_REGISTRATION_ADDRESS is set

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

VALID_NODE_CHECKING_REGISTRATION_LISTENER=SUBNET                # line added by Agent

8.备库:节点1重启监听:

[grid@dgrac1 admin]$ srvctl stop scan_listener

[grid@dgrac1 admin]$ srvctl stop listener

[grid@dgrac1 admin]$ srvctl start scan_listener

[grid@dgrac1 admin]$ srvctl start listener

 

[grid@dgrac1 admin]$ lsnrctl status

 

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 06-MAR-2020 13:51:21

 

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production

Start Date                06-MAR-2020 13:41:17

Uptime                    0 days 0 hr. 10 min. 3 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /oracle/app/19c/grid/network/admin/listener.ora

Listener Log File         /oracle/app/grid/diag/tnslsnr/dgrac1/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.52.160)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.52.162)(PORT=1521)))

Services Summary...

Service "+ASM" has 1 instance(s).

  Instance "+ASM1", status READY, has 1 handler(s) for this service...

Service "+ASM_CRS" has 1 instance(s).

  Instance "+ASM1", status READY, has 1 handler(s) for this service...

Service "+ASM_DATA" has 1 instance(s).

  Instance "+ASM1", status READY, has 1 handler(s) for this service...

Service "dgorcl" has 1 instance(s).

  Instance "orcl1", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

检查确认监听状态是否存在红色部分内容。

9.主备库:测试联通性

[oracle@rac1 admin]$ cat tnsnames.ora

# tnsnames.ora.dgrac1 Network Configuration File: /oracle/app/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora.dgrac1

# Generated by Oracle configuration tools.

 

PDBDGORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgrac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = pdborcl)

    )

  )

 

PDBORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = pdborcl)

    )

  )

 

ORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

 

DGORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgrac1-vip)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = dgorcl)

    )

  )

 

主节点测试:

[oracle@rac1 admin]$ sqlplus sys/oracle@orcl as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 6 14:02:32 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.5.0.0.0

 

SQL> exit

Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.5.0.0.0

[oracle@rac1 admin]$ sqlplus sys/oracle@dgorcl as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 6 14:02:38 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.5.0.0.0

 

SQL> exit

Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.5.0.0.0

备节点测试:

[oracle@rac1 admin]$ ssh dgrac1

oracle@dgrac1's password:

Last login: Fri Mar  6 12:07:05 2020

[oracle@dgrac1 ~]$ sqlplus sys/oracle@orcl as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 6 14:03:03 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.5.0.0.0

 

SQL> exit

Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.5.0.0.0

[oracle@dgrac1 ~]$ sqlplus sys/oracle@dgorcl as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 6 14:03:07 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.5.0.0.0

 

SQL>

10.备库:执行恢复

 

[oracle@dgrac1 ~]$ nohup ./cdbdg.sh &

[1] 68990

[oracle@dgrac1 ~]$ nohup: ignoring input and appending output to 鈥榥ohup.out鈥

 

[oracle@dgrac1 ~]$

[oracle@dgrac1 ~]$

[oracle@dgrac1 ~]$ tail -f cdb-rman-20200306-1209.log

RMAN-03002: failure of Duplicate Db command at 03/06/2020 12:09:37

RMAN-05501: aborting duplication of target database

RMAN-03015: error occurred in stored script Memory Script

RMAN-03009: failure of backup command on cl1 channel at 03/06/2020 12:09:37

ORA-17627: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor –此处报错是因为之前tnsnames.ora没有拷贝到主库的节点引起

ORA-17629: Cannot connect to the remote database server

 

RMAN>

 

Recovery Manager complete.

 

 

 

^C

[1]+  Exit 1                  nohup ./cdbdg.sh

[oracle@dgrac1 ~]$

[oracle@dgrac1 ~]$

[oracle@dgrac1 ~]$

[oracle@dgrac1 ~]$ cat cdbdg.sh

rman target sys/oracle@orcl auxiliary sys/oracle@dgorcl log /home/oracle/cdb-rman-`date +%Y%m%d-%H%M`.log <

run

{

allocate channel cl1 type disk;

allocate auxiliary channel c1 type disk;

duplicate target database for standby from active database nofilenamecheck;

release channel c1;

release channel cl1;

}

EOF

 

[oracle@dgrac1 admin]$ rman target sys/oracle@orcl auxiliary sys/oracle@dgorcl

 

Recovery Manager: Release 19.0.0.0.0 - Production on Fri Mar 6 13:44:18 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORCL (DBID=1554683481)

connected to auxiliary database: ORCL (not mounted)

 

RMAN> run

2> {

3> allocate channel cl1 type disk;

4> allocate auxiliary channel c1 type disk;

5> duplicate target database for standby from active database nofilenamecheck;

6> release channel c1;

7> release channel cl1;

8> }

 

using target database control file instead of recovery catalog

allocated channel: cl1

channel cl1: SID=307 instance=orcl1 device type=DISK

 

allocated channel: c1

channel c1: SID=33 instance=orcl1 device type=DISK

 

Starting Duplicate Db at 2020-03-06 13:44:27

 

contents of Memory Script:

{

   backup as copy reuse

   passwordfile auxiliary format  '/oracle/app/oracle/product/19c/dbhome_1/dbs/orapworcl1'   ;

}

executing Memory Script

 

Starting backup at 2020-03-06 13:44:27

released channel: cl1

released channel: c1

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of Duplicate Db command at 03/06/2020 13:44:27

RMAN-05501: aborting duplication of target database

RMAN-03015: error occurred in stored script Memory Script

RMAN-03009: failure of backup command on cl1 channel at 03/06/2020 13:44:27

ORA-17627: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

ORA-17629: Cannot connect to the remote database server

 

RMAN> exit

 

上述报错是因为主库的两个节点tnsnames.ora没有和备库节点1的文件同步。导致主库连接不了备库。

 

恢复记录如下:

 

[oracle@dgrac1 admin]$ rman target sys/oracle@orcl auxiliary sys/oracle@dgorcl

 

Recovery Manager: Release 19.0.0.0.0 - Production on Fri Mar 6 13:51:29 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORCL (DBID=1554683481)

connected to auxiliary database: ORCL (not mounted)

 

RMAN> run

{

allocate channel cl1 type disk;

allocate auxiliary channel c1 type disk;

duplicate target database for standby from active database nofilenamecheck;

release channel c1;

release channel cl1;

}

 

using target database control file instead of recovery catalog

allocated channel: cl1

channel cl1: SID=76 instance=orcl2 device type=DISK

 

allocated channel: c1

channel c1: SID=252 instance=orcl1 device type=DISK

 

Starting Duplicate Db at 2020-03-06 13:51:39

 

contents of Memory Script:

{

   backup as copy reuse

   passwordfile auxiliary format  '/oracle/app/oracle/product/19c/dbhome_1/dbs/orapworcl1'   ;

}

executing Memory Script

 

Starting backup at 2020-03-06 13:51:40

Finished backup at 2020-03-06 13:51:43

 

contents of Memory Script:

{

   sql clone "alter system set  control_files =

  ''+DATA/DGORCL/CONTROLFILE/current.361.1034344305'' comment=

 ''Set by RMAN'' scope=spfile";

   restore clone from service  'orcl' standby controlfile;

}

executing Memory Script

 

sql statement: alter system set  control_files =   ''+DATA/DGORCL/CONTROLFILE/current.361.1034344305'' comment= ''Set by RMAN'' scope=spfile

 

Starting restore at 2020-03-06 13:51:44

 

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: restoring control file

channel c1: restore complete, elapsed time: 00:00:04

output file name=+DATA/DGORCL/CONTROLFILE/current.269.1034344307

Finished restore at 2020-03-06 13:51:50

 

contents of Memory Script:

{

   sql clone 'alter database mount standby database';

}

executing Memory Script

 

sql statement: alter database mount standby database

RMAN-05529: warning: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.

 

contents of Memory Script:

{

   set newname for tempfile  1 to

 "+DATA";

   set newname for tempfile  2 to

 "+DATA";

   set newname for tempfile  4 to

 "+DATA";

   switch clone tempfile all;

   set newname for datafile  1 to

 "+DATA";

   set newname for datafile  2 to

 "+DATA";

   set newname for datafile  3 to

 "+DATA";

   set newname for datafile  4 to

 "+DATA";

   set newname for datafile  5 to

 "+DATA";

   set newname for datafile  6 to

 "+DATA";

   set newname for datafile  7 to

 "+DATA";

   set newname for datafile  8 to

 "+DATA";

   set newname for datafile  14 to

 "+DATA";

   set newname for datafile  15 to

 "+DATA";

   set newname for datafile  16 to

 "+DATA";

   set newname for datafile  17 to

 "+DATA";

   set newname for datafile  18 to

 "+DATA";

   restore

   from  nonsparse   from service

 'orcl'   clone database

   ;

   sql 'alter system archive log current';

}

executing Memory Script

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

renamed tempfile 1 to +DATA in control file

renamed tempfile 2 to +DATA in control file

renamed tempfile 4 to +DATA in control file

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

Starting restore at 2020-03-06 13:51:57

 

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00001 to +DATA

channel c1: restore complete, elapsed time: 00:00:36

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00002 to +DATA

channel c1: restore complete, elapsed time: 00:00:15

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00003 to +DATA

channel c1: restore complete, elapsed time: 00:00:35

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00004 to +DATA

channel c1: restore complete, elapsed time: 00:00:15

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00005 to +DATA

channel c1: restore complete, elapsed time: 00:00:26

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00006 to +DATA

channel c1: restore complete, elapsed time: 00:00:15

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00007 to +DATA

channel c1: restore complete, elapsed time: 00:00:07

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00008 to +DATA

channel c1: restore complete, elapsed time: 00:00:01

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00014 to +DATA

channel c1: restore complete, elapsed time: 00:00:16

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00015 to +DATA

channel c1: restore complete, elapsed time: 00:00:15

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00016 to +DATA

channel c1: restore complete, elapsed time: 00:00:15

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00017 to +DATA

channel c1: restore complete, elapsed time: 00:00:15

channel c1: starting datafile backup set restore

channel c1: using network backup set from service orcl

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00018 to +DATA

channel c1: restore complete, elapsed time: 00:00:01

Finished restore at 2020-03-06 13:55:29

 

sql statement: alter system archive log current

 

contents of Memory Script:

{

   switch clone datafile all;

}

executing Memory Script

 

datafile 1 switched to datafile copy

input datafile copy RECID=14 STAMP=1034344531 file name=+DATA/DGORCL/DATAFILE/system.374.1034344317

datafile 2 switched to datafile copy

input datafile copy RECID=15 STAMP=1034344531 file name=+DATA/DGORCL/998DDBCF1D91E20FE0539634A8C06305/DATAFILE/system.375.1034344353

datafile 3 switched to datafile copy

input datafile copy RECID=16 STAMP=1034344531 file name=+DATA/DGORCL/DATAFILE/sysaux.377.1034344369

datafile 4 switched to datafile copy

input datafile copy RECID=17 STAMP=1034344531 file name=+DATA/DGORCL/998DDBCF1D91E20FE0539634A8C06305/DATAFILE/sysaux.379.1034344403

datafile 5 switched to datafile copy

input datafile copy RECID=18 STAMP=1034344531 file name=+DATA/DGORCL/DATAFILE/undotbs1.381.1034344419

datafile 6 switched to datafile copy

input datafile copy RECID=19 STAMP=1034344531 file name=+DATA/DGORCL/998DDBCF1D91E20FE0539634A8C06305/DATAFILE/undotbs1.287.1034344445

datafile 7 switched to datafile copy

input datafile copy RECID=20 STAMP=1034344531 file name=+DATA/DGORCL/DATAFILE/undotbs2.265.1034344459

datafile 8 switched to datafile copy

input datafile copy RECID=21 STAMP=1034344531 file name=+DATA/DGORCL/DATAFILE/users.272.1034344467

datafile 14 switched to datafile copy

input datafile copy RECID=22 STAMP=1034344531 file name=+DATA/DGORCL/A0044C1C44692EE6E0539634A8C0A37C/DATAFILE/system.266.1034344469

datafile 15 switched to datafile copy

input datafile copy RECID=23 STAMP=1034344531 file name=+DATA/DGORCL/A0044C1C44692EE6E0539634A8C0A37C/DATAFILE/sysaux.267.1034344483

datafile 16 switched to datafile copy

input datafile copy RECID=24 STAMP=1034344531 file name=+DATA/DGORCL/A0044C1C44692EE6E0539634A8C0A37C/DATAFILE/undotbs1.376.1034344499

datafile 17 switched to datafile copy

input datafile copy RECID=25 STAMP=1034344531 file name=+DATA/DGORCL/A0044C1C44692EE6E0539634A8C0A37C/DATAFILE/undo_2.378.1034344513

datafile 18 switched to datafile copy

input datafile copy RECID=26 STAMP=1034344531 file name=+DATA/DGORCL/A0044C1C44692EE6E0539634A8C0A37C/DATAFILE/users.380.1034344529

Finished Duplicate Db at 2020-03-06 14:02:49

 

released channel: c1

 

released channel: cl1

 

RMAN>

 

RMAN>

 

RMAN> exit

 

 

Recovery Manager complete.

[oracle@dgrac1 admin]$

 

11.备库:将参数pfile文件恢复到asm中

[root@dgrac1 ~]# su - oracle

Last login: Fri Mar  6 14:02:57 CST 2020 from rac1 on pts/2

[oracle@dgrac1 ~]$ sqlplus /nolog

 

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 6 14:05:55 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

 

SQL> conn /as sysdba

Connected.

SQL> create pfile='/home/oracle/r.txt' from spfile;

 

File created.

 

SQL> show parameter pfile;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string      /oracle/app/oracle/product/19c

                                                 /dbhome_1/dbs/spfileorcl1.ora

SQL> select status from v$instance;

 

STATUS

------------

MOUNTED

 

SQL> !cat /home/oracle/r.txt

orcl1.__data_transfer_cache_size=0

orcl1.__db_cache_size=1845493760

orcl1.__inmemory_ext_roarea=0

orcl1.__inmemory_ext_rwarea=0

orcl1.__java_pool_size=0

orcl1.__large_pool_size=16777216

orcl1.__oracle_base='/oracle/app/oracle'#ORACLE_BASE set from environment

orcl1.__pga_aggregate_target=822083584

orcl1.__sga_target=2466250752

orcl1.__shared_io_pool_size=0

orcl1.__shared_pool_size=587202560

orcl1.__streams_pool_size=0

orcl1.__unified_pga_pool_size=0

*.adg_redirect_dml=TRUE

*.audit_file_dest='/oracle/app/oracle/admin/orcl/adump'

*.audit_trail='none'

*.cluster_database=true

*.compatible='19.0.0'

*.control_files='+DATA/DGORCL/CONTROLFILE/current.269.1034344307'#Restore Controlfile

*.db_block_size=8192

*.db_create_file_dest='+DATA'

*.db_file_name_convert='+DATA','+DATA'

*.db_name='orcl'

*.db_recovery_file_dest_size=10737418240

*.db_recovery_file_dest='+DATA'

*.db_unique_name='dgorcl'

*.dg_broker_config_file1='+DATA/dgorcl/dr1dgorcl.dat'

*.dg_broker_config_file2='+DATA/dgorcl/dr2dgorcl.dat'

*.dg_broker_start=TRUE

*.diagnostic_dest='/oracle/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'

*.enable_pluggable_database=true

*.fal_server=''

family:dw_helper.instance_mode='read-only'

orcl1.instance_number=1

orcl2.instance_number=2

*.local_listener='-oraagent-dummy-'

*.log_archive_config='nodg_config'

*.log_archive_dest_1='location=+DATA'

*.log_archive_dest_2=''

*.log_archive_dest_state_2='ENABLE'

*.log_file_name_convert='+DATA','+DATA'

*.nls_language='AMERICAN'

*.nls_territory='AMERICA'

*.open_cursors=300

*.pga_aggregate_target=780m

*.processes=320

*.remote_login_passwordfile='exclusive'

*.resource_manager_plan='DEFAULT_CDB_PLAN'

*.sga_target=2340m

*.standby_file_management='AUTO'

orcl2.thread=2

orcl1.thread=1

orcl2.undo_tablespace='UNDOTBS2'

orcl1.undo_tablespace='UNDOTBS1'

 

SQL>

去掉划掉的信息后,执行:

SQL> create spfile='+DATA' from pfile='/home/oracle/r.txt';

 

File created.

检查spfile路径:

[root@dgrac1 ~]# su - grid

Last login: Fri Mar  6 14:06:42 CST 2020

[grid@dgrac1 ~]$ ls

a.txt  orapworcl1

[grid@dgrac1 ~]$ asmcmd

ASMCMD> lsdg

State    Type    Rebal  Sector  Logical_Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name

MOUNTED  NORMAL  N         512             512   4096  4194304      3072     2100             1024             538              0             Y  CRS/

MOUNTED  EXTERN  N         512             512   4096  4194304     32768    23056                0           23056              0             N  DATA/

ASMCMD> cd data

ASMCMD> ls

DGORCL/

ASMCMD> cd dgorcl

ASMCMD> ls

998DDBCF1D91E20FE0539634A8C06305/

A0044C1C44692EE6E0539634A8C0A37C/

CONTROLFILE/

DATAFILE/

ONLINELOG/

PARAMETERFILE/

ASMCMD> cd para*

ASMCMD> pwd

+data/dgorcl/PARAMETERFILE

ASMCMD> ls

spfile.403.1034345285

 

12.备库:将密码文件恢复到asm中

 

asmcmd pwcopy /oracle/app/oracle/product/19c/dbhome_1/dbs/orapworcl1 +DATA/DGORCL/orapworcl

 

ASMCMD> pwcopy /oracle/app/oracle/product/19c/dbhome_1/dbs/orapworcl1 +DATA/DGORCL/orapworcl

copying /oracle/app/oracle/product/19c/dbhome_1/dbs/orapworcl1 -> +DATA/DGORCL/orapworcl

ASMCMD> ls -l +DATA/DGORCL/orapworcl

Type      Redund  Striped  Time             Sys  Name

PASSWORD  UNPROT  COARSE   MAR 06 14:00:00  N    orapworcl => +DATA/DB_UNKNOWN/PASSWORD/pwddb_unknown.402.1034345499

 

13.备库:添加rac资源

在备库节点1使用oracle用户操作:

[oracle@dgrac1 ~]$ srvctl add database -db dgorcl -dbname orcl -oraclehome /oracle/app/oracle/product/19c/dbhome_1 -dbtype RAC -role PHYSICAL_STANDBY

[oracle@dgrac1 ~]$

[oracle@dgrac1 ~]$ srvctl add instance -db dgorcl -instance orcl1 -node dgrac1

[oracle@dgrac1 ~]$ srvctl add instance -db dgorcl -instance orcl2 -node dgrac2

[oracle@dgrac1 ~]$srvctl modify database -db dgorcl -spfile '+data/dgorcl/parameterfile/spfile.403.1034345285' -pwfile '+DATA/DGORCL/orapworcl' -diskgroup DATA

参数文件为11节中生成的文件名称。

 

 

[oracle@dgrac1 ~]$ srvctl config database -d dgorcl

Database unique name: dgorcl

Database name: orcl

Oracle home: /oracle/app/oracle/product/19c/dbhome_1

Oracle user: oracle

Spfile: +data/dgorcl/parameterfile/spfile.403.1034345285

Password file: +DATA/DGORCL/orapworcl

Domain:

Start options: open

Stop options: immediate

Database role: PHYSICAL_STANDBY

Management policy: AUTOMATIC

Server pools:

Disk Groups: DATA

Mount point paths:

Services:

Type: RAC

Start concurrency:

Stop concurrency:

OSDBA group: dba

OSOPER group: oper

Database instances: orcl1,orcl2

Configured nodes: dgrac1,dgrac2

CSS critical: no

CPU count: 0

Memory target: 0

Maximum memory: 0

Default network number for database services:

Database is administrator managed

 

14.主备库:还原备库dgrac1上的监听listener.ora和所有主备库上的tnsnames.ora

 

[grid@dgrac1 admin]$ cat listener.ora

LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))))            # line added by Agent

LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1))))                # line added by Agent

ASMNET1LSNR_ASM=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=ASMNET1LSNR_ASM))))              # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_ASMNET1LSNR_ASM=ON               # line added by Agent

VALID_NODE_CHECKING_REGISTRATION_ASMNET1LSNR_ASM=SUBNET         # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON                # line added by Agent

VALID_NODE_CHECKING_REGISTRATION_LISTENER_SCAN1=OFF             # line added by Agent - Disabled by Agent because REMOTE_REGISTRATION_ADDRESS is set

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

VALID_NODE_CHECKING_REGISTRATION_LISTENER=SUBNET                # line added by Agent

 

[oracle@dgrac1 admin]$ cat tnsnames.ora

# tnsnames.ora.dgrac1 Network Configuration File: /oracle/app/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora.dgrac1

# Generated by Oracle configuration tools.

 

PDBDGORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgrac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = pdborcl)

    )

  )

 

PDBORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = pdborcl)

    )

  )

 

ORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

 

DGORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgrac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = dgorcl)

    )

  )

 

[oracle@dgrac1 admin]$ scp tnsnames.ora dgrac2:$ORACLE_HOME/network/admin/

tnsnames.ora                                                                                                                                                        100%  881     1.3MB/s   00:00   

[oracle@dgrac1 admin]$ scp tnsnames.ora rac2:$ORACLE_HOME/network/admin/

oracle@rac2's password:

tnsnames.ora                                                                                                                                                        100%  881     1.1MB/s   00:00   

[oracle@dgrac1 admin]$ scp tnsnames.ora rac1:$ORACLE_HOME/network/admin/

oracle@rac1's password:

tnsnames.ora                                                                                                                                                        100%  881     1.3MB/s   00:00   

还原后grid用户重启备库dgrac1节点1监听:

su - grid

srvctl stop listener

srvctl stop scan_listener

srvctl start listener

srvctl start scan_listener

15.备库:重启数据库到mount状态

[grid@dgrac1 ~]$ srvctl stop database -d dgorcl -o immediate

PRCC-1016 : dgorcl was already stopped

[grid@dgrac1 ~]$ srvctl start database -d dgorcl -o mount

[grid@dgrac1 ~]$ crsctl stat res -t

--------------------------------------------------------------------------------

Name           Target  State        Server                   State details      

--------------------------------------------------------------------------------

Local Resources

--------------------------------------------------------------------------------

ora.LISTENER.lsnr

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

ora.chad

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

ora.net1.network

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

ora.ons

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

--------------------------------------------------------------------------------

Cluster Resources

--------------------------------------------------------------------------------

ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        ONLINE  OFFLINE                               STABLE

ora.CRS.dg(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.DATA.dg(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.LISTENER_SCAN1.lsnr

      1        ONLINE  ONLINE       dgrac2                   STABLE

ora.asm(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   Started,STABLE

      2        ONLINE  ONLINE       dgrac2                   Started,STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.asmnet1.asmnetwork(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.cvu

      1        ONLINE  ONLINE       dgrac1                   STABLE

ora.dgorcl.db

      1        ONLINE  INTERMEDIATE dgrac1                   Mounted (Closed),HOM

                                                             E=/oracle/app/oracle

                                                             /product/19c/dbhome_

                                                             1,STABLE

      2        ONLINE  INTERMEDIATE dgrac2                   Mounted (Closed),HOM

                                                             E=/oracle/app/oracle

                                                             /product/19c/dbhome_

                                                             1,STABLE

ora.dgrac1.vip

      1        ONLINE  ONLINE       dgrac1                   STABLE

ora.dgrac2.vip

      1        ONLINE  ONLINE       dgrac2                   STABLE

ora.qosmserver

      1        ONLINE  ONLINE       dgrac1                   STABLE

ora.scan1.vip

      1        ONLINE  ONLINE       dgrac2                   STABLE

 

 

16.主备库:配置dg_borker

主库:

alter system set dg_broker_start=false scope=both sid='*';

ALTER SYSTEM SET DG_BROKER_CONFIG_FILE1 = '+DATA/orcl/dr1orcl.dat' SCOPE=BOTH sid='*';

ALTER SYSTEM SET DG_BROKER_CONFIG_FILE2 = '+DATA/orcl/dr2orcl.dat' SCOPE=BOTH sid='*';

alter system set dg_broker_start=true scope=both sid='*';

备库:

alter system set dg_broker_start=false scope=both sid='*';

ALTER SYSTEM SET DG_BROKER_CONFIG_FILE1 = '+DATA/dgorcl/dr1dgorcl.dat' SCOPE=BOTH sid='*';

ALTER SYSTEM SET DG_BROKER_CONFIG_FILE2 = '+DATA/dgorcl/dr2dgorcl.dat' SCOPE=BOTH sid='*';

alter system set dg_broker_start=true scope=both sid='*';

 

然后在主库节点操作即可:

[oracle@rac1 ~]$ dgmgrl sys/oracle@orcl

DGMGRL for Linux: Release 19.0.0.0.0 - Production on Fri Mar 6 14:36:39 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

 

Welcome to DGMGRL, type "help" for information.

Connected to "orcl"

Connected as SYSDBA.

DGMGRL> show configuration;

ORA-16596: member not part of the Oracle Data Guard broker configuration

 

Configuration details cannot be determined by DGMGRL

DGMGRL> create configuration adg as primary database is orcl connect identifier is orcl;

Configuration "adg" created with primary database "orcl"

DGMGRL> add database dgorcl as CONNECT IDENTIFIER IS dgorcl MAINTAINED AS PHYSICAL;

Database "dgorcl" added

DGMGRL> edit database 'dgorcl' set state='apply-on';

Error: ORA-16555: member is not active

 

Failed.

DGMGRL> ENABLE CONFIGURATION;

Enabled.

DGMGRL> show configuration;

 

Configuration - adg

 

  Protection Mode: MaxPerformance

  Members:

  orcl   - Primary database

    Warning: ORA-16905: The member was not enabled yet.

 

    dgorcl - Physical standby database

      Warning: ORA-16809: multiple warnings detected for the member

 

Fast-Start Failover:  Disabled

 

Configuration Status:

WARNING   (status updated 65 seconds ago)

 

DGMGRL> show configuration;

 

Configuration - adg

 

  Protection Mode: MaxPerformance

  Members:

  orcl   - Primary database

    dgorcl - Physical standby database

 

Fast-Start Failover:  Disabled

 

Configuration Status:

SUCCESS   (status updated 24 seconds ago)

 

DGMGRL> show configuration verbose;

 

Configuration - adg

 

  Protection Mode: MaxPerformance

  Members:

  orcl   - Primary database

    dgorcl - Physical standby database

      Warning: ORA-16809: multiple warnings detected for the member

 

  Properties:

    FastStartFailoverThreshold      = '30'

    OperationTimeout                = '30'

    TraceLevel                      = 'USER'

    FastStartFailoverLagLimit       = '30'

    CommunicationTimeout            = '180'

    ObserverReconnect               = '0'

    FastStartFailoverAutoReinstate  = 'TRUE'

    FastStartFailoverPmyShutdown    = 'TRUE'

    BystandersFollowRoleChange      = 'ALL'

    ObserverOverride                = 'FALSE'

    ExternalDestination1            = ''

    ExternalDestination2            = ''

    PrimaryLostWriteAction          = 'CONTINUE'

    ConfigurationWideServiceName    = 'orcl_CFG'

 

Fast-Start Failover:  Disabled

 

Configuration Status:

WARNING

 

DGMGRL> show configuration;

 

Configuration - adg

 

  Protection Mode: MaxPerformance

  Members:

  orcl   - Primary database

    dgorcl - Physical standby database

      Warning: ORA-16809: multiple warnings detected for the member

 

Fast-Start Failover:  Disabled

 

Configuration Status:

WARNING   (status updated 23 seconds ago)

 

DGMGRL> show configuration;

 

Configuration - adg

 

  Protection Mode: MaxPerformance

  Members:

  orcl   - Primary database

    dgorcl - Physical standby database

      Warning: ORA-16809: multiple warnings detected for the member

 

Fast-Start Failover:  Disabled

 

Configuration Status:

WARNING   (status updated 19 seconds ago)

 

DGMGRL> show configuration;

 

Configuration - adg

 

  Protection Mode: MaxPerformance

  Members:

  orcl   - Primary database

    dgorcl - Physical standby database

      Warning: ORA-16809: multiple warnings detected for the member

一般是v$standby_log检查是否配置备用日志,此处已经有,所以观察alert日志,发现后续自动完成,无需处理。

 

Fast-Start Failover:  Disabled

 

Configuration Status:

WARNING   (status updated 25 seconds ago)

 

DGMGRL> show database dgorcl

 

Database - dgorcl

 

  Role:               PHYSICAL STANDBY

  Intended State:     APPLY-ON

  Transport Lag:      0 seconds (computed 1 second ago)

  Apply Lag:          0 seconds (computed 1 second ago)

  Average Apply Rate: 205.00 KByte/s

  Real Time Query:    OFF

  Instance(s):

    orcl1

    orcl2 (apply instance)

 

Database Status:

SUCCESS

 

DGMGRL> show configuration;

 

Configuration - adg

 

  Protection Mode: MaxPerformance

  Members:

  orcl   - Primary database

    dgorcl - Physical standby database

 

Fast-Start Failover:  Disabled

 

Configuration Status:

SUCCESS   (status updated 54 seconds ago)

 

DGMGRL>

DGMGRL>                   

DGMGRL>

DGMGRL>

DGMGRL> show configuration;

 

Configuration - adg

 

  Protection Mode: MaxPerformance

  Members:

  orcl   - Primary database

    dgorcl - Physical standby database

 

Fast-Start Failover:  Disabled

 

Configuration Status:

SUCCESS   (status updated 75 seconds ago)

 

DGMGRL>

 

DGMGRL> show database dgorcl;

 

Database - dgorcl

 

  Role:               PHYSICAL STANDBY

  Intended State:     APPLY-ON

  Transport Lag:      0 seconds (computed 1 second ago)

  Apply Lag:          0 seconds (computed 1 second ago)

  Average Apply Rate: 104.00 KByte/s

  Real Time Query:    OFF –此时是没有实时查询的

  Instance(s):

    orcl1

    orcl2 (apply instance)

 

Database Status:

SUCCESS

 

DGMGRL> show database orcl;

 

Database - orcl

 

  Role:               PRIMARY

  Intended State:     TRANSPORT-ON

  Instance(s):

    orcl1

    orcl2

 

Database Status:

SUCCESS

 

新窗口检查alert日志:

[oracle@dgrac1 trace]$ tail -f drcorcl1.log

2020-03-06T14:37:32.533+08:00                      DMON: Executing SQL [ALTER SYSTEM REGISTER]

2020-03-06T14:37:32.533+08:00                      SQL [ALTER SYSTEM REGISTER] Executed successfully

2020-03-06T14:37:32.533+08:00                      DMON: SCI harvested (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.52.162)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=dgorcl_DGMGRL)(INSTANCE_NAME=orcl1)(SERVER=DEDICATED)))

2020-03-06T14:37:42.918+08:00

Starting redo apply services...

Starting redo apply services...

2020-03-06T14:37:46.960+08:00

Starting redo apply services...

2020-03-06T14:38:00.123+08:00

Updated broker configuration file available, loading from "+DATA/dgorcl/dr1dgorcl.dat"

^C

[oracle@dgrac1 trace]$ tail -f alert_orcl1.log

.... (PID:4220): Managed Standby Recovery starting Real Time Apply

2020-03-06T14:45:26.706496+08:00

ALTER SYSTEM SET _ipddb_enable=TRUE SCOPE=MEMORY SID='orcl1';

2020-03-06T14:47:07.958171+08:00

db_recovery_file_dest_size of 10240 MB is 19.83% used. This is a

user-specified limit on the amount of space that will be used by this

database for recovery-related files, and does not reflect the amount of

space available in the underlying filesystem or ASM diskgroup.

2020-03-06T14:47:19.524828+08:00

ALTER SYSTEM SET _ipddb_enable=TRUE SCOPE=MEMORY SID='orcl1';

^C

 

如果需要启用failover那么需要启用flashback database:

启用闪回恢复区:

*.db_recovery_file_dest_size=10737418240

*.db_recovery_file_dest='+DATA'

select flashback_on from v$database;

得到的值有两种情况:YES 或者 NO,分别表示开启和关闭。

如果需要打开或关闭,需要在mount状态下使用下面的命令:

alter database flashback on;

操作参考:

[oracle@dgrac1 ~]$ srvctl stop database -d dgorcl -o immediate

[oracle@dgrac1 ~]$ srvctl start database -d dgorcl -o mount

[oracle@dgrac1 ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 6 15:44:22 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.5.0.0.0

 

SQL> show parameter dg;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

adg_account_info_tracking            string      LOCAL

adg_redirect_dml                     boolean     TRUE

cell_offloadgroup_name               string

dg_broker_config_file1               string      +DATA/dgorcl/dr1dgorcl.dat

dg_broker_config_file2               string      +DATA/dgorcl/dr2dgorcl.dat

dg_broker_start                      boolean     TRUE

inmemory_adg_enabled                 boolean     TRUE

SQL> show parameter recover;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_recovery_file_dest                string      +DATA

db_recovery_file_dest_size           big integer 10G

db_unrecoverable_scn_tracking        boolean     TRUE

recovery_parallelism                 integer     0

remote_recovery_file_dest            string

SQL> select flashback_on from v$database;

 

FLASHBACK_ON

------------------

NO

 

SQL> alter database flashback on;

 

Database altered.

 

SQL> select force_logging from v$database;

 

FORCE_LOGGING

---------------------------------------

YES

 

SQL> alter database force logging;

alter database force logging

*

ERROR at line 1:

ORA-12920: database is already in force logging mode

 

 

SQL> select flashback_on from v$database;

 

FLASHBACK_ON

------------------

YES

 

SQL> exit

Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.5.0.0.0

[oracle@dgrac1 ~]$ srvctl stop database -d dgorcl -o immediate

[oracle@dgrac1 ~]$ srvctl start database -d dgorcl

[oracle@dgrac1 ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 6 15:50:44 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.5.0.0.0

 

SQL> select flashback_on from v$database;

 

FLASHBACK_ON

------------------

YES

 

SQL>

 

17.备库:启用adg实时同步查询:

重启备库rac到open状态即可。

[oracle@dgrac1 ~]$ crsctl stat res -t

--------------------------------------------------------------------------------

Name           Target  State        Server                   State details      

--------------------------------------------------------------------------------

Local Resources

--------------------------------------------------------------------------------

ora.LISTENER.lsnr

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

ora.chad

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

ora.net1.network

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

ora.ons

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

--------------------------------------------------------------------------------

Cluster Resources

--------------------------------------------------------------------------------

ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        ONLINE  OFFLINE                               STABLE

ora.CRS.dg(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.DATA.dg(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.LISTENER_SCAN1.lsnr

      1        ONLINE  ONLINE       dgrac2                   STABLE

ora.asm(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   Started,STABLE

      2        ONLINE  ONLINE       dgrac2                   Started,STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.asmnet1.asmnetwork(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.cvu

      1        ONLINE  ONLINE       dgrac1                   STABLE

ora.dgorcl.db

      1        ONLINE  INTERMEDIATE dgrac1                   Mounted (Closed),HOM

                                                             E=/oracle/app/oracle

                                                             /product/19c/dbhome_

                                                             1,STABLE

      2        ONLINE  INTERMEDIATE dgrac2                   Mounted (Closed),HOM

                                                             E=/oracle/app/oracle

                                                             /product/19c/dbhome_

                                                             1,STABLE

ora.dgrac1.vip

      1        ONLINE  ONLINE       dgrac1                   STABLE

ora.dgrac2.vip

      1        ONLINE  ONLINE       dgrac2                   STABLE

ora.qosmserver

      1        ONLINE  ONLINE       dgrac1                   STABLE

ora.scan1.vip

      1        ONLINE  ONLINE       dgrac2                   STABLE

--------------------------------------------------------------------------------

[oracle@dgrac1 ~]$ srvctl stop database -d dgorcl -o immediate

[oracle@dgrac1 ~]$ srvctl start database -d dgorcl

[oracle@dgrac1 ~]$ crsctl stat res -t

--------------------------------------------------------------------------------

Name           Target  State        Server                   State details      

--------------------------------------------------------------------------------

Local Resources

--------------------------------------------------------------------------------

ora.LISTENER.lsnr

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

ora.chad

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

ora.net1.network

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

ora.ons

               ONLINE  ONLINE       dgrac1                   STABLE

               ONLINE  ONLINE       dgrac2                   STABLE

--------------------------------------------------------------------------------

Cluster Resources

--------------------------------------------------------------------------------

ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        ONLINE  OFFLINE                               STABLE

ora.CRS.dg(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.DATA.dg(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.LISTENER_SCAN1.lsnr

      1        ONLINE  ONLINE       dgrac2                   STABLE

ora.asm(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   Started,STABLE

      2        ONLINE  ONLINE       dgrac2                   Started,STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.asmnet1.asmnetwork(ora.asmgroup)

      1        ONLINE  ONLINE       dgrac1                   STABLE

      2        ONLINE  ONLINE       dgrac2                   STABLE

      3        OFFLINE OFFLINE                               STABLE

ora.cvu

      1        ONLINE  ONLINE       dgrac1                   STABLE

ora.dgorcl.db

      1        ONLINE  ONLINE       dgrac1                   Open,Readonly,HOME=/

                                                             oracle/app/oracle/pr

                                                             oduct/19c/dbhome_1,S

                                                             TABLE

      2        ONLINE  ONLINE       dgrac2                   Open,Readonly,HOME=/

                                                             oracle/app/oracle/pr

                                                             oduct/19c/dbhome_1,S

                                                             TABLE

ora.dgrac1.vip

      1        ONLINE  ONLINE       dgrac1                   STABLE

ora.dgrac2.vip

      1        ONLINE  ONLINE       dgrac2                   STABLE

ora.qosmserver

      1        ONLINE  ONLINE       dgrac1                   STABLE

ora.scan1.vip

      1        ONLINE  ONLINE       dgrac2                   STABLE

--------------------------------------------------------------------------------

[oracle@dgrac1 ~]$

 

GMGRL> show configuration;

 

Configuration - adg

 

  Protection Mode: MaxPerformance

  Members:

  orcl   - Primary database

    dgorcl - Physical standby database

 

Fast-Start Failover:  Disabled

 

Configuration Status:

SUCCESS   (status updated 61 seconds ago)

 

DGMGRL> show database dgorcl;

 

Database - dgorcl

 

  Role:               PHYSICAL STANDBY

  Intended State:     APPLY-ON

  Transport Lag:      0 seconds (computed 1 second ago)

  Apply Lag:          0 seconds (computed 1 second ago)

  Average Apply Rate: 52.00 KByte/s

  Real Time Query:    ON

  Instance(s):

    orcl1

    orcl2 (apply instance)

 

Database Status:

SUCCESS

 

DGMGRL> show database orcl;

 

Database - orcl

 

  Role:               PRIMARY

  Intended State:     TRANSPORT-ON

  Instance(s):

    orcl1

    orcl2

 

Database Status:

SUCCESS

 

DGMGRL> show database verbose dgorcl;

 

Database - dgorcl

 

  Role:               PHYSICAL STANDBY

  Intended State:     APPLY-ON

  Transport Lag:      0 seconds (computed 1 second ago)

  Apply Lag:          0 seconds (computed 1 second ago)

  Average Apply Rate: 48.00 KByte/s

  Active Apply Rate:  644.00 KByte/s

  Maximum Apply Rate: 650.00 KByte/s

  Real Time Query:    ON

  Instance(s):

    orcl1

    orcl2 (apply instance)

 

  Properties:

    DGConnectIdentifier             = 'dgorcl'

    ObserverConnectIdentifier       = ''

    FastStartFailoverTarget         = ''

    PreferredObserverHosts          = ''

    LogShipping                     = 'ON'

    RedoRoutes                      = ''

    LogXptMode                      = 'ASYNC'

    DelayMins                       = '0'

    Binding                         = 'optional'

    MaxFailure                      = '0'

    ReopenSecs                      = '300'

    NetTimeout                      = '30'

    RedoCompression                 = 'DISABLE'

    PreferredApplyInstance          = ''

    ApplyInstanceTimeout            = '0'

    ApplyLagThreshold               = '30'

    TransportLagThreshold           = '30'

    TransportDisconnectedThreshold  = '30'

    ApplyParallel                   = 'AUTO'

    ApplyInstances                  = '0'

    StandbyFileManagement           = ''

    ArchiveLagTarget                = '0'

    LogArchiveMaxProcesses          = '0'

    LogArchiveMinSucceedDest        = '0'

    DataGuardSyncLatency            = '0'

    LogArchiveTrace                 = '0'

    LogArchiveFormat                = ''

    DbFileNameConvert               = ''

    LogFileNameConvert              = ''

    ArchiveLocation                 = ''

    AlternateLocation               = ''

    StandbyArchiveLocation          = ''

    StandbyAlternateLocation        = ''

    InconsistentProperties          = '(monitor)'

    InconsistentLogXptProps         = '(monitor)'

    LogXptStatus                    = '(monitor)'

    SendQEntries                    = '(monitor)'

    RecvQEntries                    = '(monitor)'

    HostName(*)

    StaticConnectIdentifier(*)

    TopWaitEvents(*)

    SidName(*)

    (*) - Please check specific instance for the property value

 

  Log file locations(*):

    (*) - Check specific instance for log file locations.

 

Database Status:

SUCCESS

 

DGMGRL> show database verbose orcl;

 

Database - orcl

 

  Role:               PRIMARY

  Intended State:     TRANSPORT-ON

  Instance(s):

    orcl1

    orcl2

 

  Properties:

    DGConnectIdentifier             = 'orcl'

    ObserverConnectIdentifier       = ''

    FastStartFailoverTarget         = ''

    PreferredObserverHosts          = ''

    LogShipping                     = 'ON'

    RedoRoutes                      = ''

    LogXptMode                      = 'ASYNC'

    DelayMins                       = '0'

    Binding                         = 'optional'

    MaxFailure                      = '0'

    ReopenSecs                      = '300'

    NetTimeout                      = '30'

    RedoCompression                 = 'DISABLE'

    PreferredApplyInstance          = ''

    ApplyInstanceTimeout            = '0'

    ApplyLagThreshold               = '30'

    TransportLagThreshold           = '30'

    TransportDisconnectedThreshold  = '30'

    ApplyParallel                   = 'AUTO'

    ApplyInstances                  = '0'

    StandbyFileManagement           = ''

    ArchiveLagTarget                = '0'

    LogArchiveMaxProcesses          = '0'

    LogArchiveMinSucceedDest        = '0'

    DataGuardSyncLatency            = '0'

    LogArchiveTrace                 = '0'

    LogArchiveFormat                = ''

    DbFileNameConvert               = ''

    LogFileNameConvert              = ''

    ArchiveLocation                 = ''

    AlternateLocation               = ''

    StandbyArchiveLocation          = ''

    StandbyAlternateLocation        = ''

    InconsistentProperties          = '(monitor)'

    InconsistentLogXptProps         = '(monitor)'

    LogXptStatus                    = '(monitor)'

    SendQEntries                    = '(monitor)'

    RecvQEntries                    = '(monitor)'

    HostName(*)

    StaticConnectIdentifier(*)

    TopWaitEvents(*)

    SidName(*)

    (*) - Please check specific instance for the property value

 

  Log file locations(*):

    (*) - Check specific instance for log file locations.

 

Database Status:

SUCCESS

 

DGMGRL>

 

此时主备库的监听状态:

主节点1:

oracle19c cdb rac to rac adg部署方案_第1张图片

 

备节点1:

oracle19c cdb rac to rac adg部署方案_第2张图片

 

测试数据同步:

[oracle@dgrac1 ~]$ sqlplus pdbadmin/pdbadmin@pdborcl

 

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 6 15:07:20 2020

Version 19.5.0.0.0

 

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

 

Last Successful login time: Thu Mar 05 2020 17:33:19 +08:00

 

Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.5.0.0.0

 

SQL> select * from test;

 

        ID

----------

         1

 

SQL> insert into test values(2);

 

1 row created.

 

SQL> commit;

 

Commit complete.

 

SQL> select * from test;

 

        ID

----------

         2

         1

 

SQL> conn pdbadmin/pdbadmin@pdbdgorcl

Connected.

SQL> select * from test;

 

        ID

----------

         2

         1

 

SQL> insert into test values(3);

 

1 row created.

 

SQL> commit;

 

Commit complete.

 

SQL> select * from test;

 

        ID

----------

         2

         1

         3

 

SQL> conn pdbadmin/pdbadmin@pdborcl

Connected.

SQL> set timing on

SQL> set time on

15:08:19 SQL> select * from test;

 

        ID

----------

         2

         1

         3

 

Elapsed: 00:00:00.00

15:08:23 SQL> insert into test values(4);

 

1 row created.

 

Elapsed: 00:00:00.00

15:08:27 SQL> commit;

 

Commit complete.

 

Elapsed: 00:00:00.00

15:08:29 SQL> conn pdbadmin/pdbadmin@pdbdgorcl

Connected.

15:08:35 SQL> select * from test;

 

        ID

----------

         2

         1

         3

         4

 

Elapsed: 00:00:00.01

15:08:38 SQL> insert into test values(5);

 

1 row created.

 

Elapsed: 00:00:01.21

15:08:50 SQL> commit;

 

Commit complete.

 

Elapsed: 00:00:01.08

15:08:53 SQL> conn pdbadmin/pdbadmin@pdborcl

Connected.

15:08:59 SQL> select * from test;

 

        ID

----------

         2

         1

         3

         4

         5

 

Elapsed: 00:00:00.01

15:09:02 SQL> conn /as sysdba

Connected.

15:09:06 SQL> show parameter dm;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

adg_redirect_dml                     boolean     TRUE

dml_locks                            integer     2208

15:09:09 SQL> conn sys/oracle@orcl as sysdba

Connected.

15:09:25 SQL> show parameter dml;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

adg_redirect_dml                     boolean     TRUE

dml_locks                            integer     2208

15:09:32 SQL>  conn sys/oracle@dgorcl as sysdba

Connected.

15:09:39 SQL> show parameter dml;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

adg_redirect_dml                     boolean     TRUE

dml_locks                            integer     2208

15:09:44 SQL> show parameter name;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cdb_cluster_name                     string

cell_offloadgroup_name               string

db_file_name_convert                 string      +DATA, +DATA

db_name                              string      orcl

db_unique_name                       string      dgorcl

global_names                         boolean     FALSE

instance_name                        string      orcl2

lock_name_space                      string

log_file_name_convert                string      +DATA, +DATA

pdb_file_name_convert                string

processor_group_name                 string

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

service_names                        string      dgorcl

15:09:48 SQL>

18.主备库:dg_borker进行switchover切换测试

主库切换一般2-3分钟可用,备库在5-7分钟恢复open。

任意节点执行下面操作均可:

dgmgrl sys/oracle@orcl 或 dgmgrl sys/oracle@dgorcl

DGMGRL> switchover to dgorcl;

Performing switchover NOW, please wait...

Operation requires a connection to database "dgorcl"

Connecting ...

Connected to "dgorcl"

Connected as SYSDBA.

New primary database "dgorcl" is opening...

Oracle Clusterware is restarting database "orcl" ...

Connected to "orcl"

Connected to "orcl"

Switchover succeeded, new primary is "dgorcl"

 

DGMGRL> show configuration;

 

Configuration - adg

 

  Protection Mode: MaxPerformance

  Members:

  dgorcl - Primary database

    orcl   - Physical standby database

 

Fast-Start Failover:  Disabled

 

Configuration Status:

SUCCESS   (status updated 25 seconds ago)

 

DGMGRL> show database orcl;

 

Database - orcl

 

  Role:               PHYSICAL STANDBY

  Intended State:     APPLY-ON

  Transport Lag:      0 seconds (computed 1 second ago)

  Apply Lag:          0 seconds (computed 1 second ago)

  Average Apply Rate: 3.00 KByte/s

  Real Time Query:    ON

  Instance(s):

    orcl1 (apply instance)

    orcl2

 

Database Status:

SUCCESS

 

DGMGRL> show database dgorcl;

 

Database - dgorcl

 

  Role:               PRIMARY

  Intended State:     TRANSPORT-ON

  Instance(s):

    orcl1

    orcl2

 

Database Status:

SUCCESS

 

DGMGRL>

再反向切换:

DGMGRL> switchover to orcl;

Performing switchover NOW, please wait...

Operation requires a connection to database "orcl"

Connecting ...

Connected to "orcl"

Connected as SYSDBA.

New primary database "orcl" is opening...

Oracle Clusterware is restarting database "dgorcl" ...

Connected to "dgorcl"

Connected to "dgorcl"

Switchover succeeded, new primary is "orcl"

DGMGRL> show database dgorcl;

 

Database - dgorcl

 

  Role:               PHYSICAL STANDBY

  Intended State:     APPLY-ON

  Transport Lag:      0 seconds (computed 4 seconds ago)

  Apply Lag:          0 seconds (computed 1 second ago)

  Average Apply Rate: 4.00 KByte/s

  Real Time Query:    ON

  Instance(s):

    orcl1 (apply instance)

    orcl2

 

Database Status:

SUCCESS

 

DGMGRL>  show database orcl;

 

Database - orcl

 

  Role:               PRIMARY

  Intended State:     TRANSPORT-ON

  Instance(s):

    orcl1

    orcl2

 

Database Status:

SUCCESS

 

DGMGRL> show configuration;

 

Configuration - adg

 

  Protection Mode: MaxPerformance

  Members:

  orcl   - Primary database

    dgorcl - Physical standby database

 

Fast-Start Failover:  Disabled

 

Configuration Status:

SUCCESS   (status updated 24 seconds ago)

 

DGMGRL>

检查alert_*日志截图:

oracle19c cdb rac to rac adg部署方案_第3张图片oracle19c cdb rac to rac adg部署方案_第4张图片oracle19c cdb rac to rac adg部署方案_第5张图片

 

测试数据同步:

15:14:35 SQL> conn pdbadmin/pdbadmin@pdborcl

Connected.

15:14:40 SQL> select * from test;

 

        ID

----------

         2

         1

         3

         4

         5

 

Elapsed: 00:00:00.02

15:14:44 SQL> insert into test values(5);

 

1 row created.

 

Elapsed: 00:00:10.72

15:15:13 SQL> commit;

 

Commit complete.

 

Elapsed: 00:00:01.05

15:15:18 SQL> conn pdbadmin/pdbadmin@pdbdgorcl

Connected.

15:15:26 SQL> select * from test;

 

        ID

----------

         2

         1

         3

         4

         5

         5

 

6 rows selected.

 

Elapsed: 00:00:00.00

15:15:30 SQL> insert into test values(6);

 

1 row created.

 

Elapsed: 00:00:00.00

15:15:35 SQL> commit;

 

Commit complete.

 

Elapsed: 00:00:00.01

15:15:36 SQL> conn pdbadmin/pdbadmin@pdborcl

Connected.

15:15:43 SQL> select * from test;

 

        ID

----------

         2

         1

         3

         4

         5

         5

         6

 

7 rows selected.

 

Elapsed: 00:00:00.03

15:15:47 SQL>

反向再切换后的测试:

15:15:47 SQL> conn pdbadmin/pdbadmin@pdborcl

Connected.

15:20:51 SQL> insert into test values(6);

 

1 row created.

 

Elapsed: 00:00:00.10

15:20:54 SQL> commit;

 

Commit complete.

 

Elapsed: 00:00:00.06

15:20:57 SQL> conn pdbadmin/pdbadmin@pdbdgorcl

ERROR:

ORA-01109: database not open

 

 

Warning: You are no longer connected to ORACLE.

15:21:06 SQL> select * from test;

SP2-0640: Not connected

15:21:10 SQL> conn pdbadmin/pdbadmin@pdbdgorcl

ERROR:

ORA-01109: database not open

 

 

15:21:17 SQL> conn pdbadmin/pdbadmin@pdbdgorcl

ERROR:

ORA-01109: database not open

 

 

15:21:27 SQL> conn pdbadmin/pdbadmin@pdbdgorcl

ERROR:

ORA-01109: database not open

 

 

15:21:29 SQL> conn pdbadmin/pdbadmin@pdbdgorcl

ERROR:

ORA-01109: database not open

 

 

15:21:31 SQL> conn pdbadmin/pdbadmin@pdbdgorcl

ERROR:

ORA-01109: database not open

 

15:21:45 SQL>  conn pdbadmin/pdbadmin@pdbdgorcl

ERROR:

ORA-01109: database not open

 

 

15:21:49 SQL>  conn pdbadmin/pdbadmin@pdbdgorcl

ERROR:

ORA-01109: database not open

 

 

15:21:57 SQL> conn pdbadmin/pdbadmin@pdbdgorcl

ERROR:

ORA-01109: database not open

 

 

15:23:27 SQL>

15:25:50 SQL> conn pdbadmin/pdbadmin@pdbdgorcl

Connected.

15:25:56 SQL> select * from test;

 

        ID

----------

         2

         1

         6

         3

         4

         5

         5

         6

 

8 rows selected.

 

Elapsed: 00:00:01.36

15:26:05 SQL> insert into test values(7);

       

1 row created.

 

Elapsed: 00:00:05.64

15:26:20 SQL> commit;

 

Commit complete.

 

Elapsed: 00:00:01.61

15:26:24 SQL> conn pdbadmin/pdbadmin@pdborcl

Connected.

15:26:30 SQL> select * from test;

 

        ID

----------

         2

         7

         1

         6

         3

         4

         5

         5

         6

 

9 rows selected.

 

Elapsed: 00:00:00.01

15:26:43 SQL>

 

 

你可能感兴趣的:(oracle19c)