首页 > 代码库 > Linux 安装oracle10g 配置dataguard 介绍和步骤

Linux 安装oracle10g 配置dataguard 介绍和步骤

Linux 安装oracle10g 配置dataguard 介绍和步骤
 
DataGuard是甲骨文推出的一种高可用性数据库方案,在Oracle 8i之前被称为Standby Database。从Oracle 9i开始,正式更名为Data Guard。它是在主节点与备用节点间通过日志同步来保证数据的同步,可以实现数据库快速切换与灾难性恢复。Data Guard只是在软件上对数据库进行设置,并不需要额外购买任何组件。用户能够在对主数据库影响很小的情况下,实现主备数据库的同步。而主备机之间的数据差异只限于在线日志部分,因此被不少企业用作数据容灾解决方案。(以上是度娘解释,本人理解 dataguard设计之初为异地容灾,他的应急切换能提供很好的高可用,但同时对外服务还是只有一台pridb,所以性能未有所提高)此次配置为dataguard物理备库最大性能模式。
 
1)linux操作系统安装并安装oracle10g软件
ps:主库安装数据库软件并建库,备库只需要安装oracle软件不需要建库
         以下主库简称pridb备库stydb
 
linux安装oracle10g传送门:http://blog.csdn.net/w63667329/article/details/7890172
 
本次环境:
pridb 172.25.56.149
stydb 172.25.56.150
 
2)pridb配置
 
1.查看是否开启归档模式(由于dataguard高性能需要运用到archivelog恢复stydb,所以必须开启)
archive log list
如果没有开启 需将数据库打至mount模式后开启
alter database archivelog;
alter database force logging;(开启强制归档,有时候由于语句not logging 可能未生成redolog)
生成standby controlfile
alter database create standby controlfile as ‘/u01/temp/standbycontrolfile.ctl‘;
 
 
2.查询pridb如下文件位置
 
datafile (select name from v$datafile;)
redologfile (select member from v$logfile;
controlfile (show parameter control_files)
spfile (show parameter spfile)
 
 
3.关闭主库shutdown immediate
 
4.把datafile standbycontrolfile redologfile spfile listener.ora tnsnames.ora passwdfile拷贝至备库相应位置(如果没有相应文件夹,新建同名文件夹)
scp/u01/oradata/WILLSON/ oracle@172.25.56.150:/u01/oradata/
scp standbycontrolfile.ctl oracle@172.25.56.150:/u01/oradata/
scp listener.ora tnsnames.ora oracle@172.25.56.150:/u01/product/10.2.0/db_1/network/admin/
scp orapwWILLSON spfileWILLSON.ora oracle@172.25.56.150:/u01/product/10.2.0/db_1/dbs/
scp -r WILLSON/ oracle@172.25.56.150:/u01/admin/
 
5.配置pridb角色,配置归档日志地址,配置切换模式
 
alter system set log_archive_config=‘DG_CONFIG=(pridb,stydb)‘;
 
alter system set db_unique_name=‘pridb‘ scope=spfile;
 
shutdown immediate;
 
startup mount;
 
alter system set log_archive_dest_1=‘LOCATION=/u01/oradata/archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=pridb‘;
 
alter system set log_archive_dest_2=‘SERVICE=stydb VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLES) DB_UNIQUE_NAME=stydb‘;
 
alter system set log_archive_dest_state_1=‘enable‘;
 
alter system set log_archive_dest_state_2=‘enable‘;
 
 
alter system set FAL_CLIENT=‘pridb‘;
 
 
alter system set FAL_SERVER=‘stydb‘;
 
 
alter system set standby_archive_dest=‘/u01/oradata/archivelog‘;
 
 
alter system set standby_file_management=‘auto‘;
 
 
6.配置监听
 
[oracle@localhost admin]$ more listener.ora 
# listener.ora Network Configuration File: /u01/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.


SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
           (SID_NAME = WILLSON)
           (ORACLE_HOME = /u01/product/10.2.0/db_1)
    )


  )




LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.56.149)(PORT = 1521))
    )
  )
 
 
 
[oracle@localhost admin]$ moretnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.


WILLSON =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.56.149)(PORT = 1521))
    (CONNECT_DATA =http://www.mamicode.com/
      (SERVER = DEDICATED)
      (SERVICE_NAME = WILLSON)
    )
  )


pridb =
       (DESCRIPTION =
         (ADDRESS_LIST =
           (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.56.149)(PORT = 1521))
         )
         (CONNECT_DATA =http://www.mamicode.com/
           (SERVER = DEDICATED)
           (SERVICE_NAME = WILLSON)
         )
       )
     
stydb =
       (DESCRIPTION =
         (ADDRESS_LIST =
           (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.56.150)(PORT = 1521))
         )
         (CONNECT_DATA =http://www.mamicode.com/
           (SERVER = DEDICATED)
           (SERVICE_NAME = WILLSON)
         )
       )




EXTPROC_CONNECTION_DATA =http://www.mamicode.com/
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =http://www.mamicode.com/
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )
 
 
 
3)stydb配置

 

1.启动备库至mount状态(如果失败查看初始化参数文件和控制文件是否更新)

startup mount;

 

2.配置备库参数

 

alter system set log_archive_config=‘DG_CONFIG=(pridb,stydb)‘;

 

alter system set db_unique_name=‘stydb‘scope=spfile;

 

shutdown immediate

 

startup mount

 

alter system set log_archive_dest_1=‘LOCATION=/u01/oradata/archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=stydb‘;

 

alter system set log_archive_dest_2=‘SERVICE=pridb VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLES) DB_UNIQUE_NAME=pridb‘;

 
alter system set log_archive_dest_state_1=‘enable‘;
 
 
alter system set log_archive_dest_state_2=‘enable‘;
 
 
alter system set FAL_CLIENT=‘stydb‘;
 
alter system set FAL_SERVER=‘pridb‘;
 
alter system set standby_archive_dest=‘/u01/oradata/archivelog‘;
 
alter system set standby_file_management=‘auto‘;
 
 
alter database force logging;
 
shutdown immediate
 
3.配置监听
[oracle@localhost admin]$ morelistener.ora 
# listener.ora Network Configuration File: /u01/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.


SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
           (SID_NAME = WILLSON)
           (ORACLE_HOME = /u01/product/10.2.0/db_1)
    )


  )




LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.56.150)(PORT = 1521))
    )
  )


[oracle@localhost admin]$ more tnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.


WILLSON =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.56.150)(PORT = 1521))
    (CONNECT_DATA =http://www.mamicode.com/
      (SERVER = DEDICATED)
      (SERVICE_NAME = WILLSON)
    )
  )


pridb =
       (DESCRIPTION =
         (ADDRESS_LIST =
           (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.56.149)(PORT = 1521))
         )
         (CONNECT_DATA =http://www.mamicode.com/
           (SERVER = DEDICATED)
           (SERVICE_NAME = WILLSON)
         )
       )
     
stydb =
       (DESCRIPTION =
         (ADDRESS_LIST =
           (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.56.150)(PORT = 1521))
         )
         (CONNECT_DATA =http://www.mamicode.com/
           (SERVER = DEDICATED)
           (SERVICE_NAME = WILLSON)
         )
       )




EXTPROC_CONNECTION_DATA =http://www.mamicode.com/
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =http://www.mamicode.com/
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )
 
 
 
 
4)测试配置
pridb:
 
alter database open;
 
select open_mode,database_role from v$database;
 
OPEN_MODE   DATABASE_ROLE
----------              ----------------
READ WRITE   PRIMARY
 
stydb
 
startup;
 
alter database recover managed standby database disconnect;
 
select open_mode,database_role from v$database;
 
OPEN_MODE  DATABASE_ROLE
----------             ----------------
MOUNTED       PHYSICAL STANDBY
 
 
同步测试:
pridb:
select sequence#,applied from v$archived_log;
stydb:
select sequence#,applied from v$archived_log;
 
 
就此oracle dataguard for linux 配置完成了,dataguard切换测试另有传送门:http://blog.csdn.net/w63667329/article/details/7900270

Linux 安装oracle10g 配置dataguard 介绍和步骤