ORACLE 12C DataGuard 搭建

一、主库全备份
rman target /
run {
backup as compressed backupset filesperset 1 format ‘/home/oracle/dg/full_db_%d_%s_%t’ database ;
}

二、备份控制文件
sql>alter database create standby controlfile as ‘/home/oracle/dg/control01.ctl’;
三、备份参数文件
sql>create pfile=’/home/oracle/dg/initorcl.ora’ from spfile;
四、启动force_logging
sql>alter database force logging;
sql>select FORCE_LOGGING from v$database;

密码 居然在asm里边 好恶心
srvctl config database -d oriepay 查看密码在哪里啊 在哪里

主库

alter system set log_archive_dest_2=‘service=orcl_dg valid_for=(online_logfiles,primary_role) lgwr async NOAFFIRM db_unique_name=orcl_dg’ scope=both sid=’’;
alter system set log_archive_dest_state_2=enable scope=both sid=’
’;
alter system set log_archive_config=‘dg_config=(orcl_rac,orcl_dg)’ scope=both sid=’*’;

配置tns 主库 到 备库 互通 ok

++++++++++++++++++++++++++++++++++++++++++++=
备库
编辑参数文件
orcl.__data_transfer_cache_size=0
orcl.__db_cache_size=29595009024
orcl.__inmemory_ext_roarea=0
orcl.__inmemory_ext_rwarea=0
orcl.__java_pool_size=402653184
orcl.__large_pool_size=671088640
*.__oracle_base=’/oracle/app/oracle’#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=3221225472
orcl.__sga_target=34359738368
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=3623878656
orcl.__streams_pool_size=0
*._gc_policy_time=0
*._optimizer_dsdir_usage_control=0
*._optimizer_gather_feedback=FALSE
*._optimizer_nlj_hj_adaptive_join=FALSE
*._optimizer_strans_adaptive_pruning=FALSE
*._optimizer_use_feedback=FALSE
*._px_adaptive_dist_method=‘OFF’
*.audit_file_dest=’/oracle/app/oracle/admin/orcl/adump’
*.audit_trail=‘NONE’
*.compatible=‘12.2.0’
*.control_files=’/oracle/app/oracle/oradata/orcl/control01.ctl’,’/oracle/app/oracle/oradata/orcl/control02.ctl’
*.db_block_size=8192
*.db_file_name_convert=’+MGMT/orcl/’,’/oracle/app/oracle/oradata/orcl/’
*.db_name=‘orcl’
*.db_unique_name=‘orcl_dg’
*.deferred_segment_creation=FALSE
*.diagnostic_dest=’/oracle/app/oracle’
*.fal_client=‘orcl_dg’
*.fal_server=‘orcl’
*.local_listener=’-oraagent-dummy-’
*.log_archive_config=‘dg_config=(orcl_rac,orcl_dg)’
*.log_archive_dest_1=‘location=/oracle/app/oracle/oradata/orcl/arch/’
*.log_archive_dest_2=’’
*.log_archive_dest_state_2=‘DEFER’
*.log_archive_max_processes=5
*.log_file_name_convert=’+DATA3/orcl/ONLINELOG/’,’/oracle/app/oracle/oradata/orcl/’,’+MGMT/orcl/ONLINELOG/’,’/oracle/app/oracle/oradata/orcl/’
*.nls_language=‘AMERICAN’
*.nls_territory=‘AMERICA’
*.open_cursors=300
*.optimizer_adaptive_plans=FALSE
*.pga_aggregate_target=3221225472
*.processes=1500
*.remote_login_passwordfile=‘exclusive’
*.service_names=‘orcl’
*.sga_max_size=34359738368
*.sga_target=34359738368
*.standby_file_management=‘AUTO’
*.undo_tablespace=‘UNDOTBS1’

二、copy controlfile
恢复控制文件
三、alter database mount
四、恢复数据库
run
{
configure device type disk parallelism 4;
restore database;
}

备库
alter system set service_names=‘orcl’ scope=both;
alter system set fal_server=‘orcl_rac’ scope=both sid=’’;
alter system set fal_client=‘orcl_dg’ scope=both sid=’
’;
.db_file_name_convert=’+MGMT/orcl/’,’/oracle/oradata/orcl/’,’+DATA/orcl/tempfile’,’/oracle/oradata/orcl/’*****
.log_file_name_convert=’+DATA/orcl/onlinelog/’,’/oracle/oradata/orcl/’*****
*.log_archive_max_processes=30
*.standby_file_management=‘AUTO’
*.undo_tablespace=‘UNDOTBS1’
*.db_unique_name=‘orcl_dg’
*.service_names=‘orcl’

remote_listener=‘racscan:1521’ ####要删掉的

##################
alter database add standby logfile thread 1 group 31 ‘/oracle/app/oracle/oradata/storage/orcl/redo31s.log’ size 1G;
alter database add standby logfile thread 1 group 32 ‘/oracle/app/oracle/oradata/storage/orcl/redo32s.log’ size 1G;
alter database add standby logfile thread 1 group 33 ‘/oracle/app/oracle/oradata/storage/orcl/redo33s.log’ size 1G;
alter database add standby logfile thread 1 group 34 ‘/oracle/app/oracle/oradata/storage/orcl/redo34s.log’ size 1G;
alter database add standby logfile thread 1 group 35 ‘/oracle/app/oracle/oradata/storage/orcl/redo35s.log’ size 1G;
alter database add standby logfile thread 2 group 41 ‘/oracle/app/oracle/oradata/storage/orcl/redo41s.log’ size 1G;
alter database add standby logfile thread 2 group 42 ‘/oracle/app/oracle/oradata/storage/orcl/redo42s.log’ size 1G;
alter database add standby logfile thread 2 group 43 ‘/oracle/app/oracle/oradata/storage/orcl/redo43s.log’ size 1G;
alter database add standby logfile thread 2 group 44 ‘/oracle/app/oracle/oradata/storage/orcl/redo44s.log’ size 1G;
alter database add standby logfile thread 2 group 45 ‘/oracle/app/oracle/oradata/storage/orcl/redo45s.log’ size 1G;

只读打开
alter database open read only;
密码 居然在asm里边 好恶心
srvctl config database -d orcl查看密码在哪里啊 在哪里

SELECT * FROM V$DATAGUARD_STATUS;

select process,status from v$managed_standby;

select process,status,client_process,thread#,sequence# from v$managed_standby;

    6.1 如果启动归档应用
         sql>alter database recover managed standby database disconnect from session;  
    6.2 如果启动实时应用
         ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE disconnect from session;
             

7) 取消应用的命令如下: 
    ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
	
	
	alter database clear logfile group 31;
	alter database clear logfile group 32;
	alter database clear logfile group 33;
	alter database clear logfile group 34;
	alter database clear logfile group 24;
	alter database clear logfile group 21;
	alter database clear logfile group 22;
	alter database clear logfile group 23;

你可能感兴趣的:(oracle)