一、环境部署
Primary | Standby | |
DB Version | 12.2.0.1.0 | 12.2.0.1.0 |
Hostname | oradbvm1 | oradbvm2s |
HOST IP | 192.168.127.135 | 192.168.127.139 |
DB_NAME | orcl | orcl |
DB_UNIQUE_NAME | orcl | orclstd(service name,) |
Service name | orcl | orclstd |
Instance_Name | cdb1 | cdb1std |
DB Listener | 1538 | 1538 |
DB Storage | FileSystem | FileSystem |
DB files | /u01/app/oracle/oradata/orcl/ | /u01/app/oracle/oradata/orcl/ |
LOG files | /u01/app/oracle/oradata/orcl/ | /u01/app/oracle/oradata/orcl/ |
ORACLE_HOME | /u01/app/oracle/product/12.1.0.2/dbhome_1 | /u01/app/oracle/product/12.1.0.2/dbhome_1 |
OS | CentOS Linux release 8.5.2111 |
Red Hat Enterprise Linux release 8.6 (Ootpa)
|
2、在主库增加standby redologfile文件(如果redo log有N组,standby redo log则需要N+1组。)
主库查询确认组数
select group#,thread#,members,status from v$log;
set lines 200 set pages 1000 select GROUP#,THREAD#,SEQUENCE#,BYTES/1024 as Size_KB,BLOCKSIZE,MEMBERS,ARCHIVED,status,FIRST_CHANGE#,FIRST_TIME,NEXT_CHANGE#,NEXT_TIME,CON_ID from v$log;
增加standbylogfile:
alter database add standby logfile group 4 '/oradata01/orcl/stb_redolog/stdredo1.log' size 100m; alter database add standby logfile group 5 '/oradata01/orcl/stb_redolog/stdredo2.log' size 100m; alter database add standby logfile group 6 '/oradata01/orcl/stb_redolog/stdredo3.log' size 100m; alter database add standby logfile group 7 '/oradata01/orcl/stb_redolog/stdredo4.log' size 100m;
确认logfile:
set lines 200 set pages 1000 col TYPE for a7 col MEMBER for a100 col IS_RECOVERY_DEST_FILE for a15 select * from v$logfile;
在备库oracle用户创建归档目录,数据目录并设置权限(参照主库设置),以oracle用户创建
查看主库归档目录:
SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination /oradata01/archlog Oldest online log sequence 92 Next log sequence to archive 94 Current log sequence 94
查看主库数据目录:
SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /u01/app/oracle/oradata/orcl/system01.dbf /u01/app/oracle/oradata/orcl/pdbseed/system01.dbf /u01/app/oracle/oradata/orcl/sysaux01.dbf /u01/app/oracle/oradata/orcl/pdbseed/sysaux01.dbf /u01/app/oracle/oradata/orcl/undotbs01.dbf /u01/app/oracle/oradata/orcl/pdbseed/undotbs01.dbf /u01/app/oracle/oradata/orcl/users01.dbf /u01/app/oracle/oradata/orcl/cdb1pdb/system01.dbf /u01/app/oracle/oradata/orcl/cdb1pdb/sysaux01.dbf /u01/app/oracle/oradata/orcl/cdb1pdb/undotbs01.dbf /u01/app/oracle/oradata/orcl/cdb1pdb/users01.dbf /u01/app/oracle/oradata/orcl/users02.dbf /u01/app/oracle/oradata/orcl/users03.dbf 13 rows selected.
查看Log file:
set lines 200 set pages 1000 col TYPE for a7 col MEMBER for a100 col IS_RECOVERY_DEST_FILE for a15 select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_RECOVERY_DES CON_ID
---------- ------- ------- ---------------------------------------------------------------------------------------------------- --------------- ----------
1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO 0
2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO 0
3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO 0
4 STANDBY /oradata01/orcl/stb_redolog/stdredo1.log NO 0
5 STANDBY /oradata01/orcl/stb_redolog/stdredo2.log NO 0
6 STANDBY /oradata01/orcl/stb_redolog/stdredo3.log NO 0
7 STANDBY /oradata01/orcl/stb_redolog/stdredo4.log NO 0
查看控制文件:
SQL> select name from v$controlfile; NAME -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /u01/app/oracle/oradata/orcl/control01.ctl /u01/app/oracle/oradata/orcl/control02.ctl
从库上创建:
归档路径:
/oradata01/archlog
数据文件和日志文件
/u01/app/oracle/oradata/orcl/
/u01/app/oracle/oradata/orcl/pdbseed/
/u01/app/oracle/oradata/orcl/cdb1pdb/
/oradata01/orcl/stb_redolog/
控制文件:
/u01/app/oracle/oradata/orcl/
- 在主库已开启归档模式下修改如下参数
-
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(orcl,orclstd)' alter system set log_archive_dest_1='LOCATION=/oradata01/archlog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl' scope=spfile; alter system set LOG_ARCHIVE_DEST_2='SERVICE=orclstd LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orclstd' scope=both alter system set fal_client='orcl' scope=both --这个参数只是对standby有效,但也可以在primary库设置这两个参数,以方便switchover或failover时primary库转变为standby角色。FAL_CLIENT = StandbyDB,也可以理解为本节点(Standby)的TNS name。 alter system set FAL_SERVER='orclstd' scope=both --这个参数只是对standby有效,但也可以在primary库设置这两个参数,以方便switchover或failover时primary库转变为standby角色。FAL_SERVER = PrimaryDB,也可以理解为另外一节点(主节点)的TNS name。 alter system set standby_file_management=AUTO scope=both alter system set DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/stdorcl/','/u01/app/oracle/oradata/orcl/' scope=spfile sid='*'; -- 这里目录结构一样,因此没有设置 alter system set LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/stdorcl/','/u01/app/oracle/oradata/orcl/' scope=spfile sid='*'; alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*'; alter system set remote_login_passwordfile='EXCLUSIVE' scope=spfile; alter system set PARALLEL_EXECUTION_MESSAGE_SIZE=8192 scope=spfile;
参数解析:
LOG_ARCHIVE_CONFIG:列出主备库上的DB_UNIQUE_NAME 参数。默认情况下,定义该参数能确保主备库数据库能够互相识别对方 LOG_ARCHIVE_DEST_1:本地归档路径。Primary与Standby需要定义各自的归档路径 LOG_ARCHIVE_DEST_2:设置redo log的传输方式(sync or async)以及传输目标(即standby apply node),当前节点设置的均为另一端数据库的db_unique_name,并且其中的service的值需要与tnsnames.ora别名相同。 FAL_CLIENT:(Fetch Archive Log)用来解决归档裂缝,定义的客户端(获取日志的客户端),参数取自Oracle Net Service Name FAL_SERVER:当主库转为备库的时候此参数会生效。通过网络向FAL_CLIENT发送缺失的日志,参数取自Oracle Net Service Name上述例子当rac转为备库时,会向std获取redo或者归档应用。 STANDBY_FILE_MANAGEMENT:当主库转为备库的时候此参数会生效。用来控制是否自动将Primary数据库增加表空间或数据文件的改动,传播到物理Standby数据库。AUTO:如果该参数值设置为AUTO,则Primary数据库执行的表空间创建操作也会被传播到物理Standby数据库上执行。 MANUAL:如果设置为MANUAL或未设置任何值(默认值是MANUAL),需要手工复制新创建的数据文件到物理Standby服务器。 DB_FILE_NAME_CONVERT:当主库转为备库的时候此参数会生效。主数据库和备用数据库的数据文件转换目录对映(如果两数据库的目录结构不一样),如果有多个对映,逐一指明对映关系。注意: primary上的该参数仅在主备switch over后生效,格式应保持一致 LOG_FILE_NAME_CONVERT:当主库转为备库的时候此参数会生效。定义主备log文件的存放路径转换
编辑主库以及备库的tnsnames.ora文件
orcl = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oradbvm1)(PORT = 1538)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) ) orclstd = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oradbvm2s)(PORT = 1538)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orclstd) ) )
在主库上生成备库的参数文件
create pfile from spfile
将主库的参数文件,密码文件拷贝到备库
scp initcdb1.ora 192.168.127.139:/u01/app/oracle/product/12.1.0.2/dbhome_1/dbs scp orapwcdb1 192.168.127.139:/u01/app/oracle/product/12.1.0.2/dbhome_1/dbs
备库上的密码文件需要改成备库对应的密码文件
[oracle@oradbvm2s dbs]$ mv orapwcdb1 orapwcdb1std
在备库上更改参数文件
注意修改参数文件的名字,为standby的sid.
[oracle@oradbvm2s dbs]$ cat initcdb1std.ora cdb1.__data_transfer_cache_size=0 cdb1.__db_cache_size=754974720 cdb1.__inmemory_ext_roarea=0 cdb1.__inmemory_ext_rwarea=0 cdb1.__java_pool_size=16777216 cdb1.__large_pool_size=33554432 cdb1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment cdb1.__pga_aggregate_target=402653184 cdb1.__sga_target=1174405120 cdb1.__shared_io_pool_size=67108864 cdb1.__shared_pool_size=285212672 cdb1.__streams_pool_size=0 *.audit_file_dest='/u01/app/oracle/admin/orcl/adump' *.compatible='12.2.0' *.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/oradata/orcl/control02.ctl' *.db_block_size=8192 *.db_name='orcl' *.db_unique_name='orclstd' *.db_recovery_file_dest_size=17179869184 *.db_recovery_file_dest='/oradata/flash_recovery_area' *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=cdb1XDB)' *.enable_pluggable_database=true *.fal_client='orclstd' *.fal_server='orcl' *.log_archive_config='DG_CONFIG=(orcl,orclstd)' *.log_archive_dest_1='LOCATION=/oradata01/archlog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orclstd' *.log_archive_dest_2='SERVICE=orcl LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl' *.log_archive_format='%t_%s_%r.dbf' *.nls_language='AMERICAN' *.nls_territory='AMERICA' *.open_cursors=300 *.pga_aggregate_target=371m *.processes=300 *.remote_login_passwordfile='EXCLUSIVE' *.sga_target=1112m *.standby_file_management='AUTO' *.undo_tablespace='UNDOTBS1'
在备库增加静态监听
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orclstd ) (ORACLE_HOME = /u01/app/oracle/product/12.1.0.2/dbhome_1 ) (SID_NAME =cdb1std ) ) )
在备库使用修改的参数文件启动备库数据库
startup nomount;
主库进入rman模式(或者备份进入rman模式)
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER NOFILENAMECHECK;
或者
run{ allocate channel c1 type disk; allocate channel c2 type disk; allocate channel c3 type disk; allocate AUXILIARY channel c4 type disk; allocate AUXILIARY channel c5 type disk; allocate AUXILIARY channel c6 type disk; DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER NOFILENAMECHECK; release channel c1; release channel c2; release channel c3; release channel c4; release channel c5; release channel c6; }
在备库上创建spfile文件
aa
标签:12c,log,DG,app,oracle,orcl,oradata,Oracle,u01 From: https://www.cnblogs.com/chunchun868/p/16962725.html