- 部署 Active Data Guard 远同步以保护 Oracle Database@Azure 区域中的数据
- 部署 Active Data Guard 远同步实例
部署 Active Data Guard 远同步实例
在每个区域的 OCI 计算虚拟机上部署 Active Data Guard 远同步实例,确保各区域零数据丢失。
- 创建远同步控制文件。
从主数据库为远同步实例创建控制文件。
SQL> alter database create far sync instance controlfile as '/home/oracle/controlfs.ctl';
将新创建的控制文件复制到远同步实例主机。
scp -p controlfs.ctl farsync-toronto:/u01/app/oracle/oradata/fstor/controlfs/ scp -p controlfs.ctl farsync-sydney:/u01/app/oracle/oradata/fssyd/controlfs/
- 复制口令文件。
使用远同步实例的名称将主数据库的密码文件复制到远同步实例主机。在此示例中,多伦多区域中的远同步实例将命名为
FSTOR
。因此,口令文件的名称为orapwFSTOR
。#check the location of the password file SQL> select file_name from v$passwordfile_info; #as grid user, copy the file from ASM to the local filesystem asmcmd -p cp +DATAC2/DB_TORONTO/PASSWORD/pwddb_toronto.421.1185102507 /home/grid/orapw #as root user, change the owner of the password file to oracle user cp /home/grid/orapw /home/oracle/ chown oracle:oinstall /home/oracle/orapw #copy the files to the Far Sync instance hosts using the new names "orapwFSTOR" and "orapwFSSYD" scp -p /home/oracle/orapw farsync-toronto:/u01/app/oracle/product/19c/dbhome_1/dbs/orapwFSTOR scp -p /home/oracle/orapw farsync-sydney:/u01/app/oracle/product/19c/dbhome_1/dbs/orapwFSSYD
- 创建参数文件。
为远同步实例从主数据库创建参数文件,将其复制到远同步实例主机,并调整参数以反映远同步实例的参数值和目录路径。
或者,您也可以从远同步实例主机(例如,在多伦多区域)上的新参数文件开始。
#create a parameter file vi /u01/app/oracle/product/19c/dbhome_1/dbs/init_FSTOR.ora *.db_name='DBTOR' *.db_unique_name='FSTOR' *.compatible='19.0.0' *.control_files='/u01/app/oracle/oradata/fstor/controlfs/controlfs.ctl' *.diagnostic_dest='/u01/app/oracle/oradata/fstor/diag/' *.core_dump_dest='/u01/app/oracle/oradata/fstor/coredump/' *.audit_file_dest='/u01/app/oracle/oradata/fstor/audit/' *.audit_trail='DB' *.db_recovery_file_dest='/u01/app/oracle/oradata/fstor/fra/' *.db_recovery_file_dest_size=250g *.dg_broker_config_file1='/u01/app/oracle/oradata/fstor/dg_broker/fstor_01.dat' *.dg_broker_config_file2='/u01/app/oracle/oradata/fstor/dg_broker/fstor_02.dat' *.dg_broker_start=TRUE*.dispatchers='(PROTOCOL=TCP) (SERVICE=FSTORXDB)' *.standby_file_management='AUTO' #start the instance with the parameter file export ORACLE_SID=FSTOR sqlplus / as sysdba startup pfile='/u01/app/oracle/product/19c/dbhome_1/dbs/init_FSTOR.ora' nomount; #create an spfile create spfile='/u01/app/oracle/product/19c/dbhome_1/dbs/spfileFSTOR.ora' from pfile='/u01/app/oracle/product/19c/dbhome_1/dbs/init_FSTOR.ora'; #restart the instance with the spfile shutdown immediate; startup mount; select name, db_unique_name, database_role, open_mode from v$database;
在悉尼地区:
#create a parameter file vi /u01/app/oracle/product/19c/dbhome_1/dbs/init_FSSYD.ora *.db_name='DBTOR' *.db_unique_name='FSSYD' *.compatible='19.0.0' *.control_files='/u01/app/oracle/oradata/fssyd/controlfs/controlfs.ctl' *.diagnostic_dest='/u01/app/oracle/oradata/fssyd/diag/' *.core_dump_dest='/u01/app/oracle/oradata/fssyd/coredump/' *.audit_file_dest='/u01/app/oracle/oradata/fssyd/audit/' *.audit_trail='DB' *.db_recovery_file_dest='/u01/app/oracle/oradata/fssyd/fra/' *.db_recovery_file_dest_size=250g *.dg_broker_config_file1='/u01/app/oracle/oradata/fssyd/dg_broker/fssyd_01.dat' *.dg_broker_config_file2='/u01/app/oracle/oradata/fssyd/dg_broker/fssyd_02.dat' *.dg_broker_start=TRUE *.dispatchers='(PROTOCOL=TCP) (SERVICE=FSSYDXDB)' *.standby_file_management='AUTO' #start the instance with the parameter file export ORACLE_SID=FSSYD sqlplus / as sysdba startup pfile='/u01/app/oracle/product/19c/dbhome_1/dbs/init_FSSYD.ora' nomount; #create an spfile create spfile='/u01/app/oracle/product/19c/dbhome_1/dbs/spfileFSSYD.ora' from pfile='/u01/app/oracle/product/19c/dbhome_1/dbs/init_FSSYD.ora'; #restart the instance with the spfile shutdown immediate; startup mount; select name, db_unique_name, database_role, open_mode from v$database;
- 创建数据库监听程序。
在远同步主机上,创建并启动数据库监听程序。
在多伦多地区:
vi $ORACLE_HOME/network/admin/listener.ora LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = farsync-toronto.hubsubnettoront.hubvcntoronto.oraclevcn.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) ) lsnrctl start lsnrctl services
在悉尼地区:
vi $ORACLE_HOME/network/admin/listener.ora LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = farsync-sydney.hubsubnetsydney.hubvcnsydney.oraclevcn.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) ) lsnrctl start lsnrctl services
- 将主 TNS 条目和备用 TNS 条目添加到远同步主机。
vi $ORACLE_HOME/network/admin/tnsnames.ora DB_TORONTO= (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=vmc1ca-4vzoi-scan.ocidbdelegated.ocivnoffsitedb.oraclevcn.com)(PORT=1521)) (CONNECT_DATA= (SERVER=DEDICATED) (SERVICE_NAME=db_toronto.ocidbdelegated.ocivnoffsitedb.oraclevcn.com) ) ) DB_SYDNEY= (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=abvmc1auseh-glcfo-scan.ociabvnet5subn.ociabvirtualne.oraclevcn.com)(PORT=1521)) (CONNECT_DATA= (SERVER=DEDICATED) (SERVICE_NAME=db_sydney.ociabvnet5subn.ociabvirtualne.oraclevcn.com) ) )
- 将远同步 TSN 条目添加到主数据库和备用数据库主机。
将远同步实例的 TNS 连接字符串添加到主数据库主机和备用数据库主机(Exadata VM 集群的所有主机)上的
tnsname.ora
文件。vi $ORACLE_HOME/network/admin/dbtor/tnsnames.ora FSTOR = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = farsync-toronto)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = FSTOR) ) ) FSSYD = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = farsync-sydney)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = FSSYD) ) ) #test the connectivity sqlplus SYS@FSTOR as sysdba show parameter instance_name sqlplus SYS@FSSYD as sysdba show parameter instance_name #if the connection fails, make sure port 1521 is open on the Far Sync instance hosts sudo firewall-cmd --permanent --add-port=1521/tcp sudo firewall-cmd --reload
- 将远同步实例添加到 Active Data Guard 配置并启用该配置。
在连接到主数据库时,使用 Active Data Guard 中介将远同步实例添加到现有的 Active Data Guard 配置。
dgmgrl SYS as sysdba DGMGRL> ADD FAR_SYNC FSTOR AS CONNECT IDENTIFIER IS FSTOR; DGMGRL> ENABLE FAR_SYNC fstor; DGMGRL> ADD FAR_SYNC FSSYD AS CONNECT IDENTIFIER IS FSSYD; DGMGRL> ENABLE FAR_SYNC fssyd;
- 编辑活动 Data Guard 中介的 RedoRoutes 属性。
使用 Active Data Guard 中介的 RedoRoutes 属性将主数据库配置为在 FastSync 模式下将重做传输到本地远同步实例,在远同步实例中将重做转发到 ASYNC 模式下的远程备用数据库。
EDIT DATABASE 'db_toronto' SET PROPERTY RedoRoutes = '( LOCAL : ( fstor FASTSYNC PRIORITY=1, db_sydney ASYNC PRIORITY=2 ))'; EDIT FAR_SYNC 'fstor' SET PROPERTY RedoRoutes = '( db_toronto : db_sydney ASYNC )'; EDIT DATABASE 'db_sydney' SET PROPERTY RedoRoutes = '( LOCAL : ( fssyd FASTSYNC PRIORITY=1, db_toronto ASYNC PRIORITY=2 ))'; EDIT FAR_SYNC 'fssyd' SET PROPERTY RedoRoutes = '( db_sydney : db_toronto ASYNC )';
现在会相应地设置主实例、备用实例和远同步实例的数据库log_archive_dest_n
参数。 - 更改 Active Data Guard 配置保护模式。
将 Active Data Guard 配置的保护模式增大为 "Maximum Availability"。
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
- 检查 Active Data Guard 配置。
检查该配置。
DGMGRL> show configuration Configuration - dbtor_dgconf Protection Mode: MaxAvailability Members: db_toronto - Primary database fstor - Far sync instance db_sydney - Physical standby database Members Not Receiving Redo: fssyd - Far sync instance Fast-Start Failover: Disabled Configuration Status: SUCCESS (status updated 57 seconds ago)
注意:
开始时,远程远同步实例将显示警告 "Warning: ORA-16789: standby redo logs configured wrongly"(警告:ORA-16789:备用重做日志配置不正确),直到它首次收到重做数据(在角色切换之后),或者临时更改重做路由配置以将数据发送到远程远同步实例。检查切换后的配置。
DGMGRL> show configuration Configuration - dbtor_dgconf Protection Mode: MaxAvailability Members: db_sydney - Primary database fssyd - Far sync instance db_toronto - Physical standby database Members Not Receiving Redo: fstor - Far sync instance Fast-Start Failover: Disabled Configuration Status: SUCCESS (status updated 54 seconds ago)