配置前准备
服务器环境
1、VMware Workstation Pro搭建的两台虚拟机,操作系统为Windows Server 2012 R2 ,数据库为Oracle 11g/
2、主库ip为192.168.43.130 备库ip为192.168.43.129
3、在安装oracle时,主库安装数据库,备库只安装软件
4、oracle安装的路径在E盘,具体安装路径是E:\app\Administrator\,实例名是orcl
5、数据文件放在E:\app\Administrator\oradata\orcl文件夹下
6、归档日志文件放在E:\app\interlib\log文件夹下,自己创建E:\app\interlib\log文件夹
配置过程
主库的配置
在主库上启动数据库到mount模式,开启归档模式与force logging
在DOS窗口执行下面代码:
sqlplus / as sysdba
SQL>shutdown immediate;
SQL>startup mount;
修改为归档模式
SQL>alter database archivelog;
SQL>alter database open;
设置强制归档模式
SQL> alter database force logging;
查看命令:select log_mode,force_logging from v$database ;
查看是否归档命令:Archive log list ;
查看当前日志文件组
SQL>select * from v$logfile order by group#;
为备用库创建日志文件(文件大小和现有的大小需要保持一致)
SQL>alter database add standby logfile group 4 (‘E:\app\Administrator\oradata\orcl\REDO04.LOG’) size 50m;
SQL>alter database add standby logfile group 5 (‘E:\app\Administrator\oradata\orcl\REDO05.LOG’) size 50m;
SQL>alter database add standby logfile group 6 (‘E:\app\Administrator\oradata\orcl\REDO06.LOG’) size 50m;
再次查询
SQL>select * from v$logfile order by group#;
多出三组日志文件,备用日志就建好了
创建standby控制文件
SQL>alter database create standby controlfile as ‘E:\app\interlib\standby.ctl’;
创建参数文件
SQL>create pfile=‘E:\app\interlib\initora.ora’ from spfile;
编辑initora.ora参数文件
以下内容使用自动生成的
orcl.__db_cache_size=310378496
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__oracle_base=‘E:\app\Administrator’#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=310378496
orcl.__sga_target=528482304
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=201326592
orcl.__streams_pool_size=0
*.audit_file_dest=‘E:\app\Administrator\admin\orcl\adump’
*.audit_trail=‘db’
*.compatible=‘11.2.0.0.0’
*.control_files=‘E:\app\Administrator\oradata\orcl\control01.ctl’,‘E:\app\Administrator\fla