为了测试在同一台服务器上建立了DATA GUARD环境。
主库状态正常,也存在可用的备份,下面设置主库的FORCE LOGGING和相关的初始化参数:
SQL> alter database force logging;
Database altered.
修改主库的初始化参数:
SQL> alter system set log_archive_config = 'DG_CONFIG=(primary,standby)';
System altered.
SQL> alter system set log_archive_dest_1 = 'LOCATION=/data/oradata/primary/archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=primary';
System altered.
SQL> alter system set log_archive_dest_2 = 'SERVICE=standby LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby';
System altered.
SQL> alter system set fal_server = standby;
System altered.
SQL> alter system set fal_client = primary;
System altered.
SQL> alter system set standby_file_management = auto;
System altered.
在主库建立STANDBY_LOGFILE:
SQL> select group#, thread#, sequence#, bytes/1024/1024 from v$log;
GROUP# THREAD# SEQUENCE# BYTES/1024/1024
---------- ---------- ---------- ---------------
1 1 4 500
2 1 5 500
3 1 3 500
SQL> select member from v$logfile;
MEMBER
------------------------------------------------------------------------------------
/data/oradata/primary/redo01.log
/data/oradata/primary/redo02.log
/data/oradata/primary/redo03.log
SQL> alter database add standby logfile '/data/oradata/primary/standby_redo01.log' size500m;
Database altered.
SQL> alter database add standby logfile '/data/oradata/primary/standby_redo02.log' size500m;
Database altered.
SQL> alter database add standby logfile '/data/oradata/primary/standby_redo03.log' size500m;
Database altered.
SQL> alter database add standby logfile '/data/oradata/primary/standby_redo04.log' size500m;
Database altered.
对于STANDBY LOGFILE应该比REDO LOGFILE多一组。
下面创建STANDBY数据库需要的目录结构:
SQL> host mkdir -p /data/oradata/standby/archivelog
SQL> host mkdir -p /opt/ora10g/admin/standby/bdump
SQL> host mkdir /opt/ora10g/admin/standby/cdump
SQL> host mkdir /opt/ora10g/admin/standby/adump
SQL> host mkdir /opt/ora10g/admin/standby/udump
创建STANDBY数据库需要的初始化文件:
SQL> create pfile='/home/oracle/initstandby.ora' from spfile;
File created.
编辑初始化文件,修改相关的路径,设置对应standby数据库的初始化参数:
[oracle@yans1 ~]$ vi initstandby.ora
primary.__db_cache_size=1644167168
primary.__java_pool_size=16777216
primary.__large_pool_size=16777216
primary.__shared_pool_size=452984832
primary.__streams_pool_size=0
*.audit_file_dest='/opt/ora10g/admin/standby/adump'
*.audit_trail='NONE'
*.background_dump_dest='/opt/ora10g/admin/standby/bdump'