在Oracle database 12中,甲骨文给DG引入了一个新特性【Far Sync】,用以解决远距离的数据传输延迟,也就是DG中,我们常说的GAP。
大致的实现方法是,在DG的主备节点之间创建一个【虚】实例,之所以称之为【虚】,是因为这个实例仅仅只有:
1. 参数文件
2. 控制文件
3. 密码文件

对,你没看错,该实例,没有数据文件。

官方的说明:
1. A far sync instance manages a control file, receives redo into standby redo logs (SRLs), and archives those SRLs to local archived redo logs, but that is where the similarity with standbys ends.

2. A far sync instance does not have user data files, cannot be opened for access, cannot run redo apply, and can never function in the primary role or be converted to any type of standby database.

Oracle官方,对于该实例的具体说明在下面的链接中:
1. https://docs.oracle.com/database/121/SBYDB/create_fs.htm#SBYDB5416
2. http://www.oracle.com/technetwork/database/availability/farsync-2267608.pdf

由于该链接是全英文的,所以我会按照官方文档的提示,在自己的环境中将这个新特性实现一遍,当然了,你看到的会是中文版,并且有详细的实验日志以及命令过程的笔记。

——————————————
架构脑图:

——————————————

首先,说明一下我的环境:

主库:
10.158.1.96,dg12c1

Far Sync:
10.158.1.98,dg12c3

备库:
10.158.1.97,dg12c2

数据库实例:lenka
监听器端口:1521

db_unique_name / TNSNAMES:
1. dg12c1,lenka_primary
2. dg12c2,lenka_standby
3. dg12c3,lenka_fsi

变量指向的路径:
log_archive_dest_1,/oradata/archivelog

——————————————
此外,在我的环境中 1 / 2 的ADG已经是做好了的。
因此对于下面的配置来说,只需要改变参数即可。

关于12c ADG的配置,可以参考我以前的笔记(在本网站就可以搜索到)。
——————————————

主:
创建针对FSI(Far Sync Instance)的控制文件。

[oracle@dg12c1 ~]$ ps -ef | grep pmon
oracle   11718     1  0 17:47 ?        00:00:01 ora_pmon_lenka
oracle   15760 14843  0 21:09 pts/1    00:00:00 grep --color=auto pmon
[oracle@dg12c1 ~]$ 
[oracle@dg12c1 ~]$ env | grep SID
ORACLE_SID=lenka
[oracle@dg12c1 ~]$ 
[oracle@dg12c1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon Oct 30 21:09:43 2017

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
lenka            OPEN

SQL> 
SQL> select name,database_role from v$database;

NAME      DATABASE_ROLE
--------- ----------------
LENKA     PRIMARY

SQL> 
SQL> !ls -ltr /home/oracle/backup
total 0

SQL> alter database create far sync instance controlfile as '/home/oracle/backup/lenka_far_sync.ctl';

Database altered.

SQL> 
SQL> !ls -ltr /home/oracle/backup
total 18448
-rw-r----- 1 oracle oinstall 18890752 Oct 30 21:12 lenka_far_sync.ctl

SQL> 

创建主库的PFILE:

SQL> show parameter pfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/12/db_
                                                 1/dbs/spfilelenka.ora
SQL> 
SQL> create pfile='/home/oracle/backup/lenka_pfile_primary.ora' from spfile;

File created.

SQL> !ls -ltr /home/oracle/backup
total 18452
-rw-r----- 1 oracle oinstall 18890752 Oct 30 21:12 lenka_far_sync.ctl
-rw-r--r-- 1 oracle oinstall     1815 Oct 30 21:14 lenka_pfile_primary.ora

SQL> !cat /home/oracle/backup/lenka_pfile_primary.ora
lenka.__data_transfer_cache_size=0
lenka.__db_cache_size=1811939328
lenka.__inmemory_ext_roarea=0
lenka.__inmemory_ext_rwarea=0
lenka.__java_pool_size=16777216
lenka.__large_pool_size=33554432
lenka.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
lenka.__pga_aggregate_target=838860800
lenka.__sga_target=2516582400
lenka.__shared_io_pool_size=134217728
lenka.__shared_pool_size=503316480
lenka.__streams_pool_size=0
*.archive_lag_target=900
*.audit_file_dest='/u01/app/oracle/admin/lenka/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_files='/u01/app/oracle/oradata/lenka/control01.ctl','/u01/app/oracle/oradata/lenka/control02.ctl'
*.db_block_size=8192
*.db_name='lenka'
*.db_unique_name='lenka_primary'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=lenkaXDB)'
*.enable_pluggable_database=true
*.fal_client='LENKA_FSI'
*.fal_server='lenka_standby'
*.local_listener='LISTENER_LENKA'
*.log_archive_config='dg_config=(lenka_primary,lenka_standby,lenka_fsi)'
*.log_archive_dest_1='location=/u01/app/oracle/product/12/db_1/dbs/arch valid_for=(all_logfiles,all_roles) db_unique_name=lenka_primary'
*.log_archive_dest_2='service=lenka_fsi valid_for=(online_logfiles,primary_role) lgwr sync affirm max_failure=1 alternate=log_archive_dest_3 db_unique_name=lenka_fsi'
*.log_archive_dest_3='service=lenka_standby valid_for=(online_logfiles,primary_role) async alternate=log_Archive_dest_2 db_unique_name=lenka_standby'
*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_dest_state_3='ALTERNATE'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=799m
*.processes=320
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=2395m
*.standby_file_management='auto'
*.undo_tablespace='UNDOTBS1'

SQL> 

参数文件:主库

[oracle@dg12c1 backup]$ cat lenka_pfile_primary.ora 
lenka.__data_transfer_cache_size=0
lenka.__db_cache_size=1811939328
lenka.__inmemory_ext_roarea=0
lenka.__inmemory_ext_rwarea=0
lenka.__java_pool_size=16777216
lenka.__large_pool_size=33554432
lenka.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
lenka.__pga_aggregate_target=838860800
lenka.__sga_target=2516582400
lenka.__shared_io_pool_size=134217728
lenka.__shared_pool_size=503316480
lenka.__streams_pool_size=0

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

*.audit_file_dest='/u01/app/oracle/admin/lenka/adump'
*.audit_trail='db'

*.compatible='12.2.0'
*.db_block_size=8192

*.control_files='/u01/app/oracle/oradata/lenka/control01.ctl','/u01/app/oracle/oradata/lenka/control02.ctl'

*.enable_pluggable_database=true

*.nls_language='AMERICAN'
*.nls_territory='AMERICA'

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

*.fal_client=''
*.fal_server='lenka_standby'

*.db_name='lenka'
*.db_unique_name='lenka_primary'

*.archive_lag_target=900

*.log_archive_config='dg_config=(lenka_primary,lenka_fsi,lenka_standby)'

*.log_archive_dest_1='location=/oradata/archivelog valid_for=(online_logfiles,primary_roles) db_unique_name=lenka_primary'
*.log_archive_dest_2='service=lenka_fsi valid_for=(online_logfiles,primary_role) sync affirm max_failure=1 alternate=log_archive_dest_3 db_unique_name=lenka_fsi'
*.log_archive_dest_3='service=lenka_standby valid_for=(online_logfiles,primary_role) async alternate=log_archive_dest_2 db_unique_name=lenka_standby'

*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'
*.log_archive_dest_state_3='alternate'

*.standby_file_management='auto'

*.open_cursors=300
*.processes=320

*.pga_aggregate_target=799m
*.sga_target=2395m

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_tablespace='UNDOTBS1'

[oracle@dg12c1 backup]$ 

参数文件:Far Sync

[oracle@dg12c1 backup]$ cat lenka_pfile_farsync.ora 
lenka.__data_transfer_cache_size=0
lenka.__db_cache_size=1811939328
lenka.__inmemory_ext_roarea=0
lenka.__inmemory_ext_rwarea=0
lenka.__java_pool_size=16777216
lenka.__large_pool_size=33554432
lenka.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
lenka.__pga_aggregate_target=838860800
lenka.__sga_target=2516582400
lenka.__shared_io_pool_size=134217728
lenka.__shared_pool_size=503316480
lenka.__streams_pool_size=0

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

*.audit_file_dest='/u01/app/oracle/admin/lenka/adump'
*.audit_trail='db'

*.compatible='12.2.0'
*.db_block_size=8192

*.control_files='/u01/app/oracle/oradata/lenka/control01.ctl','/u01/app/oracle/oradata/lenka/control02.ctl'

*.enable_pluggable_database=true

*.nls_language='AMERICAN'
*.nls_territory='AMERICA'

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

*.fal_client='lenka_fsi'
*.fal_server='lenka_primary'

*.db_name='lenka'
*.db_unique_name='lenka_fsi'

*.archive_lag_target=900

*.log_archive_config='dg_config=(lenka_primary,lenka_fsi,lenka_standby)'

*.log_archive_dest_1='location=/oradata/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=lenka_fsi'
*.log_archive_dest_2='service=lenka_standby async valid_for=(standby_logfiles,standby_role) db_unique_name=lenka_standby'

*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'

*.standby_file_management='auto'

*.open_cursors=300
*.processes=320

*.pga_aggregate_target=799m
*.sga_target=2395m

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_tablespace='UNDOTBS1'

[oracle@dg12c1 backup]$ 

参数文件:备库

[oracle@dg12c1 backup]$ cat lenka_pfile_standby.ora 
lenka.__data_transfer_cache_size=0
lenka.__db_cache_size=1811939328
lenka.__inmemory_ext_roarea=0
lenka.__inmemory_ext_rwarea=0
lenka.__java_pool_size=16777216
lenka.__large_pool_size=33554432
lenka.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
lenka.__pga_aggregate_target=838860800
lenka.__sga_target=2516582400
lenka.__shared_io_pool_size=134217728
lenka.__shared_pool_size=503316480
lenka.__streams_pool_size=0

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

*.audit_file_dest='/u01/app/oracle/admin/lenka/adump'
*.audit_trail='db'

*.compatible='12.2.0'
*.db_block_size=8192

*.control_files='/u01/app/oracle/oradata/lenka/control01.ctl','/u01/app/oracle/oradata/lenka/control02.ctl'

*.enable_pluggable_database=true

*.nls_language='AMERICAN'
*.nls_territory='AMERICA'

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

*.fal_client=''
*.fal_server='lenka_fsi','lenka_primary'

*.db_name='lenka'
*.db_unique_name='lenka_standby'

*.archive_lag_target=900

*.log_archive_config='dg_config=(lenka_primary,lenka_fsi,lenka_standby)'

*.log_archive_dest_1='location=/oradata/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=lenka_standby'
*.log_archive_dest_2='service=lenka_primary async valid_for=(online_logfiles,primary_role) db_unique_name=lenka_primary'

*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'

*.standby_file_management='auto'

*.open_cursors=300
*.processes=320

*.pga_aggregate_target=799m
*.sga_target=2395m

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_tablespace='UNDOTBS1'

[oracle@dg12c1 backup]$ 

将密码文件,传送到FarSYNC以及Standby:

[oracle@dg12c1 ~]$ cd $ORACLE_HOME/dbs
[oracle@dg12c1 dbs]$ 
[oracle@dg12c1 dbs]$ ls -ltr | grep orapw
-rw-r----- 1 oracle oinstall      3584 Oct 12 16:54 orapwlenka
[oracle@dg12c1 dbs]$ 
[oracle@dg12c1 dbs]$ scp orapwlenka dg12c2:$ORACLE_HOME/dbs/
oracle@dg12c2's password: 
orapwlenka                                                                                                             100% 3584     3.5KB/s   00:00    
[oracle@dg12c1 dbs]$ 
[oracle@dg12c1 dbs]$ scp orapwlenka dg12c3:$ORACLE_HOME/dbs/
oracle@dg12c3's password: 
orapwlenka                                                                                                             100% 3584     3.5KB/s   00:00    
[oracle@dg12c1 dbs]$ 

——————————
创建:Far SYNC

将前面创建的针对Far SYNC的控制文件拷贝到Far SYNC服务器:
主库操作:

[oracle@dg12c1 dbs]$ cd ~/backup/
[oracle@dg12c1 backup]$ ls -ltr
total 18460
-rw-r----- 1 oracle oinstall 18890752 Oct 30 21:12 lenka_far_sync.ctl
-rw-r--r-- 1 oracle oinstall     1786 Oct 30 21:25 lenka_pfile_primary.ora
-rw-r--r-- 1 oracle oinstall     1726 Oct 30 21:31 lenka_pfile_farsync.ora
-rw-r--r-- 1 oracle oinstall     1551 Oct 30 21:35 lenka_pfile_standby.ora
[oracle@dg12c1 backup]$ 
[oracle@dg12c1 backup]$ scp lenka_far_sync.ctl dg12c3:/software/backup_data
oracle@dg12c3's password: 
lenka_far_sync.ctl                                                                                                     100%   18MB  18.0MB/s   00:00    
[oracle@dg12c1 backup]$ 

将前面创建的Far SYNC的参数文件,放置到Far SYNC的指定目录中:
主库操作:

[oracle@dg12c1 backup]$ scp lenka_pfile_farsync.ora dg12c3:$ORACLE_HOME/dbs
oracle@dg12c3's password: 
lenka_pfile_farsync.ora                                                                                                100% 1726     1.7KB/s   00:00    
[oracle@dg12c1 backup]$ 

Far SYNC,重命名:

[oracle@dg12c3 ~]$ cd $ORACLE_HOME/dbs
[oracle@dg12c3 dbs]$ ls -ltr
total 48
-rw-r--r-- 1 oracle oinstall 3079 May 15  2015 init.ora
-rw-r----- 1 oracle oinstall   24 Oct 30 17:12 lkLENKA_FSI
-rw-r--r-- 1 oracle oinstall 1530 Oct 30 17:19 initlenka.ora
-rw-r----- 1 oracle oinstall 8192 Oct 30 18:42 dr1lenka_fsi.dat
-rw-r----- 1 oracle oinstall 8192 Oct 30 18:42 dr2lenka_fsi.dat
-rw-rw---- 1 oracle oinstall 1544 Oct 30 18:53 hc_lenka.dat
-rw-r----- 1 oracle oinstall 4608 Oct 30 18:53 spfilelenka.ora
-rw-r----- 1 oracle oinstall 3584 Oct 30 21:38 orapwlenka
-rw-r--r-- 1 oracle oinstall 1726 Oct 30 21:42 lenka_pfile_farsync.ora
[oracle@dg12c3 dbs]$ 
[oracle@dg12c3 dbs]$ cp lenka_pfile_farsync.ora initlenka.ora
[oracle@dg12c3 dbs]$ ls -ltr | grep initlenka
-rw-r--r-- 1 oracle oinstall 1726 Oct 30 21:44 initlenka.ora
[oracle@dg12c3 dbs]$ 

FAR SYNC:启动数据库到NOMOUNT

[oracle@dg12c3 dbs]$ env | grep SID
ORACLE_SID=lenka
[oracle@dg12c3 dbs]$ 
[oracle@dg12c3 dbs]$ ps -ef | grep pmon
oracle   24396 24157  0 21:50 pts/1    00:00:00 grep --color=auto pmon
[oracle@dg12c3 dbs]$ 
[oracle@dg12c3 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon Oct 30 21:50:48 2017

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

Connected to an idle instance.

SQL> startup pfile='/u01/app/oracle/product/12/db_1/dbs/initlenka.ora' nomount;
ORACLE instance started.

Total System Global Area 2516582400 bytes
Fixed Size                  8795904 bytes
Variable Size             687868160 bytes
Database Buffers         1811939328 bytes
Redo Buffers                7979008 bytes
SQL> 
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@dg12c3 dbs]$ 

FAR SYNC:恢复控制文件

[oracle@dg12c3 dbs]$ ls -ltr /software/backup_data/
total 18448
-rw-r----- 1 oracle oinstall 18890752 Oct 30 21:41 lenka_far_sync.ctl
[oracle@dg12c3 dbs]$ 
[oracle@dg12c3 dbs]$ rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Mon Oct 30 21:51:26 2017

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

connected to target database: LENKA (not mounted)

RMAN> restore controlfile from '/software/backup_data/lenka_far_sync.ctl';

Starting restore at 30-OCT-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=/u01/app/oracle/oradata/lenka/control01.ctl
output file name=/u01/app/oracle/oradata/lenka/control02.ctl
Finished restore at 30-OCT-17

RMAN> 

RMAN> exit


Recovery Manager complete.
[oracle@dg12c3 dbs]$ 

Far SYNC:打开数据库MOUNT:

[oracle@dg12c3 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon Oct 30 21:53:28 2017

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> 
SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
lenka            STARTED

SQL> 
SQL> alter database mount;

Database altered.

SQL> 
SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
lenka            MOUNTED

SQL> select name,database_role from v$database;

NAME      DATABASE_ROLE
--------- ----------------
LENKA     FAR SYNC

SQL> 
SQL> select protection_mode,database_role,protection_level,open_mode from v$database;

PROTECTION_MODE      DATABASE_ROLE    PROTECTION_LEVEL     OPEN_MODE
-------------------- ---------------- -------------------- --------------------
MAXIMUM PERFORMANCE  FAR SYNC         MAXIMUM PERFORMANCE  MOUNTED

SQL> 

Far SYNC:创建SPFILE

SQL> show parameter pfile; 

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string
SQL>              
SQL> create spfile from pfile;

File created.

SQL>

——————————————
备库:
由于开始本文之前,我的备库其实已经是做好了的。
所以,这一部分的配置没有那么的详细,仅仅是涉及到参数的修改而已。

主库端将前面写好的关于备库端的参数文件拷贝到备库端服务器上:

主库操作:

[root@dg12c1 ~]# su - oracle
Last login: Mon Oct 30 20:19:22 CST 2017 on pts/1
[oracle@dg12c1 ~]$ 
[oracle@dg12c1 ~]$ scp backup/lenka_pfile_standby.ora dg12c2:/software/backup/
oracle@dg12c2's password: 
lenka_pfile_standby.ora                                                                                                100% 1551     1.5KB/s   00:00    
[oracle@dg12c1 ~]$ 

备库端:
备份原参数文件:

[oracle@dg12c2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon Oct 30 22:13:24 2017

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> create pfile from spfile;            

File created.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> 
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@dg12c2 ~]$ 
[oracle@dg12c2 ~]$ cd $ORACLE_HOME/dbs
[oracle@dg12c2 dbs]$ ls -ltr
total 7508
-rw-r--r-- 1 oracle oinstall    3079 May 15  2015 init.ora
-rw-r--r-- 1 oracle oinstall    1685 Oct 15 12:50 pfile_standby.ora
-rw-r----- 1 oracle oinstall      24 Oct 15 13:06 lkLENKA_STANDBY
-rw-r----- 1 oracle oinstall   81920 Oct 15 13:12 arch1_12_957199704.dbf
-rw-r----- 1 oracle oinstall 7414272 Oct 15 13:12 arch1_13_957199704.dbf
-rw-r----- 1 oracle oinstall    1536 Oct 15 13:12 arch1_14_957199704.dbf
-rw-r----- 1 oracle oinstall  141312 Oct 15 13:16 arch1_15_957199704.dbf
-rw-r--r-- 1 oracle oinstall    1631 Oct 30 17:03 initlenka.ora_orig_20171030
-rw-r----- 1 oracle oinstall    4608 Oct 30 18:40 spfilelenka.ora
-rw-r----- 1 oracle oinstall    3584 Oct 30 21:41 orapwlenka
-rw-r--r-- 1 oracle oinstall    1630 Oct 30 22:13 initlenka.ora
-rw-rw---- 1 oracle oinstall    1544 Oct 30 22:13 hc_lenka.dat
drwxr-xr-x 2 oracle oinstall    4096 Oct 30 22:13 arch
[oracle@dg12c2 dbs]$ 
[oracle@dg12c2 dbs]$ cp initlenka.ora initlenka.ora_orig_201710301
[oracle@dg12c2 dbs]$ ls -ltr
total 7512
-rw-r--r-- 1 oracle oinstall    3079 May 15  2015 init.ora
-rw-r--r-- 1 oracle oinstall    1685 Oct 15 12:50 pfile_standby.ora
-rw-r----- 1 oracle oinstall      24 Oct 15 13:06 lkLENKA_STANDBY
-rw-r----- 1 oracle oinstall   81920 Oct 15 13:12 arch1_12_957199704.dbf
-rw-r----- 1 oracle oinstall 7414272 Oct 15 13:12 arch1_13_957199704.dbf
-rw-r----- 1 oracle oinstall    1536 Oct 15 13:12 arch1_14_957199704.dbf
-rw-r----- 1 oracle oinstall  141312 Oct 15 13:16 arch1_15_957199704.dbf
-rw-r--r-- 1 oracle oinstall    1631 Oct 30 17:03 initlenka.ora_orig_20171030
-rw-r----- 1 oracle oinstall    4608 Oct 30 18:40 spfilelenka.ora
-rw-r----- 1 oracle oinstall    3584 Oct 30 21:41 orapwlenka
-rw-r--r-- 1 oracle oinstall    1630 Oct 30 22:13 initlenka.ora
-rw-rw---- 1 oracle oinstall    1544 Oct 30 22:13 hc_lenka.dat
drwxr-xr-x 2 oracle oinstall    4096 Oct 30 22:13 arch
-rw-r--r-- 1 oracle oinstall    1630 Oct 30 22:14 initlenka.ora_orig_201710301
[oracle@dg12c2 dbs]$ 

以新的参数文件启动:

[oracle@dg12c2 dbs]$ ps -ef | grep pmon
oracle    9303  7846  0 22:17 pts/0    00:00:00 grep --color=auto pmon
[oracle@dg12c2 dbs]$ 
[oracle@dg12c2 dbs]$ env | grep SID
ORACLE_SID=lenka
[oracle@dg12c2 dbs]$ 
[oracle@dg12c2 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon Oct 30 22:17:20 2017

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

Connected to an idle instance.

SQL> create spfile from pfile='/software/backup/lenka_pfile_standby.ora';

File created.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 2516582400 bytes
Fixed Size                  8795904 bytes
Variable Size             687868160 bytes
Database Buffers         1811939328 bytes
Redo Buffers                7979008 bytes
Database mounted.
SQL> 
SQL> select name,database_role from v$database;

NAME      DATABASE_ROLE
--------- ----------------
LENKA     PHYSICAL STANDBY

SQL> alter database open;

Database altered.

SQL> select name,database_role,open_mode from v$database;

NAME      DATABASE_ROLE    OPEN_MODE
--------- ---------------- --------------------
LENKA     PHYSICAL STANDBY READ ONLY

SQL> 
SQL> alter database recover managed standby database using current logfile disconnect from session;

Database altered.

SQL> 

——————————
Oracle Listener与TNS的配置:

主:

[oracle@dg12c1 dbs]$ cd $ORACLE_HOME/network/admin
[oracle@dg12c1 admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora
[oracle@dg12c1 admin]$ 
[oracle@dg12c1 admin]$ cat listener.ora 
# listener.ora Network Configuration File: /u01/app/oracle/product/12/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER = 
 (SID_LIST =
   (SID_DESC = 
       (GLOBAL_DBNAME = lenka)
       (ORACLE_HOME = /u01/app/oracle/product/12/db_1)
       (SID_NAME=lenka)
   )
 )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dg12c1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

[oracle@dg12c1 admin]$ 
[oracle@dg12c1 admin]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 31-OCT-2017 18:08:48

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg12c1)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                30-OCT-2017 13:39:11
Uptime                    1 days 4 hr. 29 min. 37 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/dg12c1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg12c1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=dg12c1)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/lenka_primary/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "5b56c20e0585469de05360019e0ae7dd" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
Service "5cbdc88c09370cd0e05360019e0af681" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
Service "lenka" has 1 instance(s).
  Instance "lenka", status UNKNOWN, has 1 handler(s) for this service...
Service "lenkaXDB" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
Service "lenka_primary" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
Service "lenkapdb" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
Service "pdb01" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@dg12c1 admin]$ 

Far SYNC:

[oracle@dg12c3 dbs]$ cat $ORACLE_HOME/network/admin/listener.ora

LISTENER = 
  (DESCRIPTION_LIST = 
   (DESCRIPTION = 
     (ADDRESS = (PROTOCOL = TCP)(HOST = 10.158.1.98)(PORT = 1521))
     (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
   )
  )

SID_LIST_LISTENER = 
  (SID_LIST=
    (SID_DESC = 
       (GLOBAL_DB_NAME = lenka_fsi)
       (ORACLE_HOME = /u01/app/oracle/product/12/db_1)
       (SID_NAME = lenka)
    )
  )
[oracle@dg12c3 dbs]$ 
[oracle@dg12c3 dbs]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 31-OCT-2017 18:08:27

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.158.1.98)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                30-OCT-2017 16:56:00
Uptime                    1 days 1 hr. 12 min. 29 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/dg12c3/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.158.1.98)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "lenka" has 1 instance(s).
  Instance "lenka", status UNKNOWN, has 1 handler(s) for this service...
Service "lenka_fsi" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@dg12c3 dbs]$ 

备:

[oracle@dg12c2 dbs]$ cat $ORACLE_HOME/network/admin/listener.ora
SID_LIST_LISTENER = 
 (SID_LIST =
   (SID_DESC = 
       (GLOBAL_DBNAME = lenka)
       (ORACLE_HOME = /u01/app/oracle/product/12/db_1)
       (SID_NAME=lenka)
   )
 )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dg12c2)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

[oracle@dg12c2 dbs]$ 
[oracle@dg12c2 dbs]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 31-OCT-2017 18:11:27

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg12c2)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                30-OCT-2017 17:11:27
Uptime                    1 days 0 hr. 59 min. 59 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/dg12c2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg12c2)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=dg12c2)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/lenka_standby/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "5b56c20e0585469de05360019e0ae7dd" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
Service "5cbdc88c09370cd0e05360019e0af681" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
Service "lenka" has 1 instance(s).
  Instance "lenka", status UNKNOWN, has 1 handler(s) for this service...
Service "lenkaXDB" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
Service "lenka_standby" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
Service "lenkapdb" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
Service "pdb01" has 1 instance(s).
  Instance "lenka", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@dg12c2 dbs]$ 

TNS的部分都是一样的:

[oracle@dg12c1 admin]$ cat tnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

LISTENER_LENKA =
  (ADDRESS = (PROTOCOL = TCP)(HOST = dg12c1)(PORT = 1521))


LENKA =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dg12c1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = lenka)
    )
  )


lenka_primary = 
  (DESCRIPTION = 
    (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.158.1.96)(PORT = 1521))
    )
    (CONNECT_DATA =
       (SERVICE_NAME=lenka)
    )
  )

lenka_standby = 
  (DESCRIPTION = 
    (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.158.1.97)(PORT = 1521))
    )
    (CONNECT_DATA =
       (SERVICE_NAME=lenka)
    )
  )

lenka_fsi = 
  (DESCRIPTION = 
    (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.158.1.98)(PORT = 1521))
    )
    (CONNECT_DATA =
       (SERVICE_NAME=lenka_fsi)
    )
  )
[oracle@dg12c1 admin]$ 

启动Far SYNC的时候注意:
1. 首先,启动主库和备库
2. 备库打开DG同步
3. 最后将Far SYNC启动到MOUNT阶段

Far SYNC启动后,观察日志,你可能会发现这样的告警:

2017-10-31T18:11:02.074083+08:00
ARCH: Attempting destination LOG_ARCHIVE_DEST_2 network reconnect (16477)
ARCH: Destination LOG_ARCHIVE_DEST_2 network reconnect abandoned
krsg_gap_ping: Error 16477 when pinging lenka_standby (Process:TT00) (PID:6405)

这个时候,你查看数据库的DG状态,会是如下的样子:

SQL> set linesize 400
SQL> 
SQL> select * from v$dataguard_config;

DB_UNIQUE_NAME                 PARENT_DBUN                    DEST_ROLE         CURRENT_SCN     CON_ID
------------------------------ ------------------------------ ----------------- ----------- ----------
lenka_primary                  NONE                           PRIMARY DATABASE      5220075          0
lenka_standby                  lenka_primary                  PHYSICAL STANDBY      5219885          0
lenka_fsi                      UNKNOWN                        UNKNOWN                     0          0

SQL> 

其实不用太在意这个报错,…
如果,主库增加了新的日志,那么,等待一段时间后,会出现Far SYNC与主库建立了连接的记录:

2017-10-31T18:15:12.340287+08:00
Primary database is in MAXIMUM PERFORMANCE mode
RFS[1]: Assigned to RFS process (PID:6461)
RFS[1]: No standby redo logfiles created for T-1 
RFS[1]: Opened log for T-1.S-205 dbid 2000990868 branch 957199704
2017-10-31T18:15:13.849499+08:00
Errors in file /u01/app/oracle/diag/rdbms/lenka_fsi/lenka/trace/lenka_rfs_6463.trc:
ORA-19527: physical standby redo log must be renamed
ORA-00312: online log 4 thread 0: '/u01/app/oracle/oradata/lenka/standby_redo_01.log'
2017-10-31T18:15:13.849985+08:00
Errors in file /u01/app/oracle/diag/rdbms/lenka_fsi/lenka/trace/lenka_rfs_6463.trc:
ORA-19527: physical standby redo log must be renamed
ORA-00312: online log 5 thread 0: '/u01/app/oracle/oradata/lenka/standby_redo_02.log'
2017-10-31T18:15:13.850440+08:00
Errors in file /u01/app/oracle/diag/rdbms/lenka_fsi/lenka/trace/lenka_rfs_6463.trc:
ORA-19527: physical standby redo log must be renamed
ORA-00312: online log 6 thread 0: '/u01/app/oracle/oradata/lenka/standby_redo_03.log'
2017-10-31T18:15:13.850840+08:00
Errors in file /u01/app/oracle/diag/rdbms/lenka_fsi/lenka/trace/lenka_rfs_6463.trc:
ORA-19527: physical standby redo log must be renamed
ORA-00312: online log 7 thread 0: '/u01/app/oracle/oradata/lenka/standby_redo_04.log'
RFS[2]: Assigned to RFS process (PID:6463)
RFS[2]: Opened log for T-1.S-204 dbid 2000990868 branch 957199704
2017-10-31T18:15:14.015986+08:00
Archived Log entry 14 added for thread 1 sequence 204 rlc 957199704 ID 0x7744b494 LAD2 :


2017-10-31T18:16:16.467431+08:00
FAL[server]: Can't identify FAL client, null string supplied
2017-10-31T18:16:19.297249+08:00
Archived Log entry 15 added for thread 1 sequence 205 rlc 957199704 ID 0x7744b494 LAD2 :
RFS[1]: No standby redo logfiles created for T-1 
RFS[1]: Opened log for T-1.S-206 dbid 2000990868 branch 957199704
2017-10-31T18:17:14.455477+08:00
FAL[server]: Can't identify FAL client, null string supplied

这时候再查看DG的状态:

SQL> select * from v$dataguard_config;

DB_UNIQUE_NAME                 PARENT_DBUN                    DEST_ROLE         CURRENT_SCN     CON_ID
------------------------------ ------------------------------ ----------------- ----------- ----------
lenka_primary                  NONE                           PRIMARY DATABASE      5220963          0
lenka_fsi                      lenka_primary                  FAR SYNC INSTANCE     5220680          0
lenka_standby                  lenka_fsi                      PHYSICAL STANDBY      5220680          0

SQL> 

去检查Far SYNC的日志目录,会发现也有记录了:

SQL> !ls -ltr /oradata/archivelog
total 1492
-rw-r----- 1 oracle oinstall 1369088 Oct 31 17:57 1_195_957199704.dbf
-rw-r----- 1 oracle oinstall  128000 Oct 31 18:01 1_196_957199704.dbf
-rw-r----- 1 oracle oinstall    6656 Oct 31 18:01 1_197_957199704.dbf
-rw-r----- 1 oracle oinstall    1536 Oct 31 18:01 1_198_957199704.dbf
-rw-r----- 1 oracle oinstall    1536 Oct 31 18:01 1_199_957199704.dbf
-rw-r----- 1 oracle oinstall    1536 Oct 31 18:02 1_200_957199704.dbf
-rw-r----- 1 oracle oinstall    1024 Oct 31 18:02 1_201_957199704.dbf

SQL> 
SQL> 
SQL> !ls -ltr /oradata/archivelog
total 1568
-rw-r----- 1 oracle oinstall   1369088 Oct 31 17:57 1_195_957199704.dbf
-rw-r----- 1 oracle oinstall    128000 Oct 31 18:01 1_196_957199704.dbf
-rw-r----- 1 oracle oinstall      6656 Oct 31 18:01 1_197_957199704.dbf
-rw-r----- 1 oracle oinstall      1536 Oct 31 18:01 1_198_957199704.dbf
-rw-r----- 1 oracle oinstall      1536 Oct 31 18:01 1_199_957199704.dbf
-rw-r----- 1 oracle oinstall      1536 Oct 31 18:02 1_200_957199704.dbf
-rw-r----- 1 oracle oinstall      1024 Oct 31 18:02 1_201_957199704.dbf
-rw-r----- 1 oracle oinstall     59392 Oct 31 18:15 1_204_957199704.dbf
-rw-r----- 1 oracle oinstall 209715712 Oct 31 18:15 1_205_957199704.dbf

SQL> 

这样,Far SYNC 就搭建好了。

——————————
此外,Far SYNC的日志中,你也可能会看到这样的报错:

2017-10-31T17:57:46.146154+08:00
Primary database is in MAXIMUM PERFORMANCE mode
RFS[1]: Assigned to RFS process (PID:6168)
RFS[1]: No standby redo logfiles created for T-1 
RFS[1]: Opened log for T-1.S-196 dbid 2000990868 branch 957199704
2017-10-31T17:57:48.304089+08:00
Errors in file /u01/app/oracle/diag/rdbms/lenka_fsi/lenka/trace/lenka_rfs_6170.trc:
ORA-19527: physical standby redo log must be renamed
ORA-00312: online log 4 thread 0: '/u01/app/oracle/oradata/lenka/standby_redo_01.log'
2017-10-31T17:57:48.304508+08:00
Errors in file /u01/app/oracle/diag/rdbms/lenka_fsi/lenka/trace/lenka_rfs_6170.trc:
ORA-19527: physical standby redo log must be renamed
ORA-00312: online log 5 thread 0: '/u01/app/oracle/oradata/lenka/standby_redo_02.log'
2017-10-31T17:57:48.304786+08:00
Errors in file /u01/app/oracle/diag/rdbms/lenka_fsi/lenka/trace/lenka_rfs_6170.trc:
ORA-19527: physical standby redo log must be renamed
ORA-00312: online log 6 thread 0: '/u01/app/oracle/oradata/lenka/standby_redo_03.log'
2017-10-31T17:57:48.305204+08:00
Errors in file /u01/app/oracle/diag/rdbms/lenka_fsi/lenka/trace/lenka_rfs_6170.trc:
ORA-19527: physical standby redo log must be renamed
ORA-00312: online log 7 thread 0: '/u01/app/oracle/oradata/lenka/standby_redo_04.log'
RFS[2]: Assigned to RFS process (PID:6170)
RFS[2]: Opened log for T-1.S-195 dbid 2000990868 branch 957199704
2017-10-31T17:57:49.480200+08:00
Archived Log entry 1 added for thread 1 sequence 195 rlc 957199704 ID 0x7744b494 LAD2 :

因为Convert的参数没有设置,… 但是,它们并不会影响 Far SYNC的同步机制。

——————————————————
Done。

说点什么

avatar

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒