主库:192.168.38.71
实例名:orcl
数据库名:orcl
备库:192.168.38.71
实例名:standby1
数据库名:standby1
select force_logging from v$database;
alter database force logging;
archive log list;
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
alter system set log_archive_config= 'dg_config=(orcl,standby1)';
alter system set log_archive_dest_1= 'location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=orcl';
alter system set log_archive_dest_2= 'service=standby1 async valid_for=(online_logfile,primary_role) db_unique_name=standby1';
alter system set log_archive_dest_state_1 = enable;
alter system set log_archive_dest_state_2 = enable;
shutdown immeidate
startup
alter database create standby controlfile as 'D:/control01.ctl';
shutdown immediate
配置文件:D:/INITorcl.ORA
密码文件:%ORACLE_HOME%/database/PWDorcl.ora
备库controlfile:D:/control01.ctl
全库备份文件:*.dbf、*.log,注意表空间
shutdown immediate
startup nomount;
alter system set log_archive_config= 'dg_config=(orcl,standby1)';
alter system set log_archive_dest_1= 'location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=standby1';
alter system set log_archive_dest_2= 'service=orcl async valid_for=(online_logfile,primary_role) db_unique_name=orcl';
alter system set log_archive_dest_state_1 = enable;
alter system set log_archive_dest_state_2 = enable;
alter system set standby_file_management=auto
set echo on
ALTER DATABASE ADD STANDBY LOGFILE
'C:\APP\DOLLY\ORADATA\ORCL\srl01.log'
SIZE 52428800
/
ALTER DATABASE ADD STANDBY LOGFILE
'C:\APP\DOLLY\ORADATA\ORCL\srl02.log'
SIZE 52428800
/
ALTER DATABASE ADD STANDBY LOGFILE
'C:\APP\DOLLY\ORADATA\ORCL\srl03.log'
SIZE 52428800
/
ALTER DATABASE ADD STANDBY LOGFILE
'C:\APP\DOLLY\ORADATA\ORCL\srl04.log'
SIZE 52428800
/
create pfile='D:/INITstandby1.ORA' from spfile;
*.db_name='orcl'
*.db_unique_name='standby1'
*.db_file_name_convert='c:\app\dolly\oradata\orcl','c:\app\smsrv1\oradata\standby1'
*.log_file_name_convert='c:\app\dolly\oradata\orcl','c:\app\smsrv1\oradata\standby1'
shutdown abort
create spfile from pfile='D:/INITstandby1.ORA';
startup mount;
alter database recover managed standby database using current logfile disconnect from session;
startup
alter system switch logfile;
SELECT STATUS,DESTINATION, ERROR FROM V$ARCHIVE_DEST;
select max(sequence#) from v$archived_log;
alter database recover managed standby database cancel;
alter database open;
alter database recover managed standby database using current logfile disconnect from session;
select open_mode from v$database;
--备库关闭
alter database recover managed standby database cancel;
shutdown immediate;
select * from v$flash_recovery_area_usage; --查看空间占用率
select * from v$recovery_file_dest; --查看归档日志的存放地址;
如果大家有什么不懂的,可以私信我