1、开启强制归档
alter database force logging;
2、开启归档SQL> alter system set db_recovery_file_dest_size=5g;
SQL> alter system set db_recovery_file_dest='C:\app\Administrator\archive';
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;
3. alter system set standby_file_management='auto';
如果设置为auto,主库增删文件dbf 表空间等会相应地自动在备库做出修改(结合convert参数);
如果设置为manual,当在primary删除表空间或数据文件,执行drop tablespace .. including contents and datafiles,
standby 只是在控制文件中将该文件删除,还需要手动将物理文件删除
4 添加log
alter database add standby logfile group 4 '/opt/oracle/app/oradata/orcl/' size 50m;
alter database add standby logfile group 5 '/opt/oracle/app/oradata/orcl/' size 50m;
alter database add standby logfile group 6 '/opt/oracle/app/oradata/orcl/' size 50m;
alter database add standby logfile group 7 '/opt/oracle/app/oradata/orcl/' size 50m;
5.主库参数文件
DB_UNIQUE_NAME='einvo'
必须和备库不一样,该值必须同时存在于LOG_ARCHIVE_CONFIG与LOG_ARCHIVE_DEST_n参数中,DG间才能互相通信
LOG_ARCHIVE_CONFIG='DG_CONFIG=(
einvo
,einvo
dg)'- 该参数通过DG_CONFIG属性罗列同一个Data Guard中所有DB_UNIQUE_NAME(含primary db及standby db),以逗号分隔。
主库和备库相同 CONTROL_FILES='/opt/oracle/app/oradata/orcl/control01.ctl', '/opt/oracle/app/oracle/fast_recovery_area/orcl/control02.ctl'
LOG_ARCHIVE_DEST_1= 'LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=
einvo
'- 归档文件的生成路径,location代表本地机上,service指明在另一台机器上。
LOG_ARCHIVE_DEST_2= 'SERVICE=
SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=
LGWReinvo_
dg
'einvo
dg
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
- EXCLUSIVE:(默认值)独占模式使用密码文件,官档中提到了“only one instance of one database”使用exclusive方式,在数据库中是可以执行对于sysdba用户的增加,修改,删除动作的,同样也可以修改sysdba用户的密码,这些更改会记录到密码文件中去。
LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
- 指定归档文件格式,这里在主备端应保持一样的格式。
%t -thread number
%s -log sequence number
%r -resetlogs ID - 一下两个参数备库上相反
FAL_SERVER=
einvo_
dg- FAL_CLIENT=
einvo
- 主库设置,主要是切换后使用。
- 备库设置,主要是备库发生gap。次参数来从主库fal_server取日志用的
- FAL_SERVER = Oracle_Net_service_name
DB_FILE_NAME_CONVERT='/opt/oracle/app/oradata','/opt/oracle/app/oradata'
- 对备库起作用,主库文件夹传到备库相应文件中
LOG_FILE_NAME_CONVERT='/opt/oracle/app/oradata/orcl/','/opt/oracle/app/oradata/einvodg/'
/opt/oracle/app/oradata/orcl/users01.dbf
/opt/oracle/app/oradata/orcl/undotbs01.dbf
/opt/oracle/app/oradata/orcl/sysaux01.dbf
/opt/oracle/app/oradata/orcl/system01.dbf
/opt/oracle/app/oradata/SAAS_BASIC_TBS_01.dbf
/opt/oracle/app/oradata/SAAS_BASIC_INDEX_TBS_01.dbf
/opt/oracle/app/oradata/SAAS_BUS_TBS_01.dbf
/opt/oracle/app/oradata/SAAS_BUS_INDEX_TBS_01.dbf
/opt/oracle/app/oradata/SAAS_BUS_TBS_2021_01.dbf
/opt/oracle/app/oradata/SAAS_BUS_TBS_2022_01.dbf
/opt/oracle/app/oradata/SAAS_BUS_TBS_2023_01.dbf
/opt/oracle/app/oradata/SAAS_BUS_INDEX_TBS_2021_01.dbf
/opt/oracle/app/oradata/SAAS_BUS_INDEX_TBS_2022_01.dbf
/opt/oracle/app/oradata/SAAS_BUS_INDEX_TBS_2023_01.dbf
/opt/oracle/app/oradata/orcl/redo03.log
/opt/oracle/app/oradata/orcl/redo02.log
/opt/oracle/app/oradata/orcl/redo01.log
标签:opt,11g,dg,app,dbf,orcl,oradata,oracle,搭建
From: https://www.cnblogs.com/zzg520/p/16964438.html