首页 > 代码库 > Oracle 11.2.0.4.0 dataguard部署和日常维护(2)

Oracle 11.2.0.4.0 dataguard部署和日常维护(2)

1. primary库设置dataguard相关参数

  1.1. 强制primay库在任何状态下必须记录日志

SYS@userdata>select FORCE_LOGGING from v$database;

FORCE_LOG
---------
NO

SYS@userdata>alter database force logging;

Database altered.

SYS@userdata>select FORCE_LOGGING from v$database;

FORCE_LOG
---------
YES

 

  1.2. 设置primay库在归档模式

SYS@userdata>shutdown immediate;
SYS@userdata>startup mount;
SYS@userdata>alter database archivelog;
SYS@userdata>alter database open;
SYS@userdata>archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     2
Next log sequence to archive   4
Current log sequence           4

 

 

  1.3. 设置primary和standby库的tnsnames

$ cat $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

userdata1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ec2t-userdata-01)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = userdata)
    )
  )

userdata2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ec2t-userdata-02)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = userdata)
    )
  )

 

  1.4. 根据spfile创建可更新的pfile文件

SYS@userdata>create pfile=/home/oracle/pfile.ora from spfile;

File created.

 

  1.5. 更新pfile文件,添加dataguard相关参数

$ mkdir /u01/app/oracle/arch
$ cat /home/oracle/pfile.ora
userdata.__db_cache_size=620756992
userdata.__java_pool_size=16777216
userdata.__large_pool_size=33554432
userdata.__oracle_base=/u01/app/oracle#ORACLE_BASE set from environment
userdata.__pga_aggregate_target=620756992
userdata.__sga_target=905969664
userdata.__shared_io_pool_size=0
userdata.__shared_pool_size=218103808
userdata.__streams_pool_size=0
*.audit_file_dest=/u01/app/oracle/admin/userdata/adump
*.audit_trail=db
*.compatible=11.2.0.4.0
*.control_files=/u01/app/oracle/oradata/userdata/control01.ctl,/u01/app/oracle/fast_recovery_area/userdata/control02.ctl
*.db_block_size=8192
*.db_domain=‘‘
*.db_name=userdata
*.db_recovery_file_dest=/u01/app/oracle/fast_recovery_area
*.db_recovery_file_dest_size=4294967296
*.diagnostic_dest=/u01/app/oracle
*.dispatchers=(PROTOCOL=TCP) (SERVICE=userdataXDB)
*.java_jit_enabled=FALSE
*.memory_target=1526726656
*.open_cursors=600
*.processes=600
*.remote_login_passwordfile=EXCLUSIVE
*.undo_tablespace=UNDOTBS1
*.db_unique_name=userdata1
*.log_archive_config=DG_CONFIG=(userdata1,userdata2)
*.log_archive_dest_1=location=/u01/app/oracle/arch
*.log_archive_dest_2=SERVICE=userdata2 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=userdata2
*.log_archive_dest_state_1=ENABLE
*.log_archive_dest_state_2=ENABLE
*.standby_file_management=AUTO
*.fal_client=userdata1
*.fal_server=userdata2‘

 

 

  1.5. 导入新的参数文件,使dataguard配置生效

SYS@userdata>shutdown immediate;
SYS@userdata>create spfile from pfile=/home/oracle/pfile.ora;
SYS@userdata>startup;

 

2. standby库设置dataguard相关参数

3. 对primary库做备份

4. 传输备份到standby库

5. 还原standby库

6. 创建standby联机日志

7. 开启stanby库恢复进程

8.primary库归档,查看dataguard数据同步是否成功

Oracle 11.2.0.4.0 dataguard部署和日常维护(2)