倒数第二堂,Configuring Data Guard,DG配置,这里开始除了大量需要操作需要去记,我个人认为是没啥难度。
host01与host02配置tnsname:
PROD5H1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host01)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PROD5)
)
)
PROD5H2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host02)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PROD5)
)
)
lsnrctl reload
主库配置:
sqlplus sys/oracle
alter system set db_unique_name=PROD5H1 scope=spfile;
shut immediate;
startup mount;
alter database archivelog;
alter database force logging;
alter database flashback on; --用于快速失败转移
alter system set local_listener='';
alter system set standby_file_management=auto;
alter database add standby logfile; --注意需要与redo日志组大小一致
alter database add standby logfile;
alter database add standby logfile;
alter database add standby logfile;
alter database add standby logfile;
alter database open;
shut immediate;
startup
alter system switch logfile;
create pfile='/home/oracle/scripts/initPROD5.ora' from spfile;
修改备库参数文件并传输至备库:
db_unique_name='PROD5H2';
scp /home/oracle/scripts/initPROD5.ora host02:/u01/app/oracle/product/19.0.0/dbhome_1/dbs
host02操作:
mkdir /u01/app/oracle/oradata/PROD5
mkdir /u01/app/oracle/fast_recovery_area/PROD5
mkdir /u01/app/oracle/admin/PROD5/adump -p
# 根据参数文件目录创建其他前面题目变更了的目录
orapwd file=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/orapwPROD5 force=y password=oracle ignorecase=y
# 从主库拷贝亦可
export ORACLE_SID=PROD5
sqlplus / as sysdba
create spfile from pfile;
startup nomount
创建物理备库:
rman target sys/oracle@prod5h1 auxiliary sys/oracle@prod5h2
duplicate target database for standby nofilenamecheck from active database;
sqlplus sys/oracle@prod5h1 as sysdba
alter system set dg_broker_start=true;
sqlplus sys/oracle@prod5h2 as sysdba
alter system set dg_broker_start=true;
dgmgrl sys/oracle@prod5h1
create configuration dg1 as primary database is prod5h1 connect identifier is prod5h1;
add database prod5h2 as connect identifier is prod5h2;
enable configuration;
show configuration;
edit database prod5h1 set property logxptmode=sync;
edit database prod5h2 set property logxptmode=sync;
disable configuration;
enable configuration;
最小化临时表redo:
sqlplus sys/oracle@prod5h1 as sysdba
alter system set temp_undo_enabled=true;
快照备库:
dgmgrl sys/oracle@prod5h1
convert database prod5h2 to snapshot standby;
-- 根据题目执行测试脚本
convert database prod5h2 to physical standby;
备库可读:
sqlplus sys/oracle@prod5h2 as sysdba
alter database open;
alter database recover managed standby database using current logfile disconnect;
降低增量备份压力:
sqlplus sys/oracle@prod5h1 as sysdba
alter database enable block change tracking using file '/u01/app/oracle/blockprod5.txt';
rman target sys/oracle@prod5h1
configure backup optimization on;
sqlplus sys/oracle@prod5h2 as sysdba
alter database enable block change tracking using file '/u01/app/oracle/blockprod5.txt';
rman target sys/oracle@prod5h2
configure backup optimization on;
配置日志删除策略:
rman target sys/oracle@prod5h1
configure archivelog deletion policy to applied on all standby;
rman target sys/oracle@prod5h2
configure archivelog deletion policy to applied on all standby;
自动切换相关配置:
dgmgrl sys/oracle@prod5h1
edit database prod5h1 set property FastStartFailoverTarget='prod5h2';
edit configuration set protection mode as MaxAvailability;
enable fast_start failover;
edit database prod5h1 set property TransportLagThreshold=30;
edit database prod5h2 set property TransportLagThreshold=30;
edit database prod5h1 set property ApplyLagThreshold=45;
edit database prod5h2 set property ApplyLagThreshold=45;
执行主备切换:
dgmgrl sys/oracle@prod5h1
switchover to prod5h2;
DG配置看似命令较多,其实还是挺简单的,尤其是使用dg broker协助配置,很多操做都被简化了,通过show database prod5h1 verbose也可以不用背那些复杂参数即可找到参数名,切换就更为方便了。
当然除了命令行,使用EMCC也能创建备库,这里就不做展示了。
老规矩,知道写了些啥。