ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle DataGuard部署

oracle DataGuard部署

原创 Linux操作系统 作者:wangsir_918 时间:2011-07-18 09:22:32 0 删除 编辑

一、简述

详见oracle培训文档《Oracle Dataguard & GoldenGate - for ZTE》等   

二、安装前准备

2.1测试环境信息

PRIMARY64SUSE LINUX Enterprise Server 9 (x86_64) root/hatest

STANDBY64SUSE LINUX Enterprise Server 9 (x86_64) root/hatest

 

    PRIMARYSIDZXIN  IP:10.42.109.17  64bit oracle10.2.0.5  

    STANDBYSIDZXIN  IP:10.42.109.16  64bit oracle10.2.0.5

 

PRIMARYdb_unique_name=zxinpri

STANDBYdb_unique_name=zxinstdby

2.2 创建DBinstance

    在操作系统、oracle软件安装完成之后;分别在主备机上,通过crdb10g.sh脚本创建DB、实例,及其常用的平台用户等。

 

三、主机配置

3.1 开启强制归档

SQL>alter database force logging;

Database altered.

 

3.2 创建Standby Log

SQL> alter database add standby logfile group 4

('/zxindata/oracle/redolog/stdbyredo1.dbf') size 200M;

 

SQL> alter database add standby logfile group 5

('/zxindata/oracle/redolog/stdbyredo2.dbf') size 200M;

 

SQL> alter database add standby logfile group 6

('/zxindata/oracle/redolog/stdbyredo3.dbf') size 200M;  

 

3.3 添加初始参数

参数文件路径:/home/oracle/zxindbf/zxin/define/initzxin.ora

可以直接修改配置文件:

db_unique_name=zxinpri

log_archive_config='dg_config=(zxinpri,zxinstdby)'

log_archive_dest_2=

'SERVICE=zxinstdby ARCH

VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

DB_UNIQUE_NAME=zxinstdby'

log_archive_dest_state_2=enable

FAL_SERVER=zxinstdby

FAL_CLIENT=zxinpri

standby_file_management=auto

 

3.4 Listener.oratnsname.ora设置

    修改$ORACLE_HOME/network/admin目录下的listener.oratnsname.ora文件红色为修改部分):

1listener.ora

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = /home/oracle/oracle10g)

      (PROGRAM = extproc)

    )

    (SID_DESC =

      (GLOBAL_DBNAME = zxinpri)

      (ORACLE_HOME = /home/oracle/oracle10g)

      (SID_NAME = zxin)

    )

  )

2tnsname.ora

修改server_namedb_unique_name值:

ZXIN =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.42.109.17(PORT = 1522))

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = zxinpri)

    )

  )

 

zx=

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.42.109.17(PORT = 1522))

    )

    (CONNECT_DATA =

      (SERVER       = DEDICATED)

      (SERVICE_NAME = zxinpri)

    )

  )

 

EXTPROC_CONNECTION_DATA =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

    )

    (CONNECT_DATA =

      (SID = PLSExtProc)

      (PRESENTATION = RO)

    )

  )

同时,添加连接备机的连接串:

zxin_stdby =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.42.109.16)(PORT = 1522))

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = zxin_stdby)

    )

  )

 

3.5 生成密码文件

    oracle用户登录,执行如下:

oracle@Geye2-DB24:~> cd $ORACLE_HOME/dbs

oracle@Geye2-DB24:~/oracle10g/dbs>orapwd file='$ORACLE_HOME/dbs/orapwzxin' password=change_on_install entries=100 force=y;

 

3.6 创建standby控制文件

    将数据库启动到mount状态并执行如下:

ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/home/oracle/stdbyctl01.ctl';

    并将控制文件ftpstandby上。

 

3.7 对主机进行冷备份

    Shutdown数据库,将/zxindata目录打包,并ftp到备机上。

 

四、备机配置

4.1生成密码文件

    oracle用户登录,执行如下

oracle@Geye2-DB24:~> cd $ORACLE_HOME/dbs

oracle@Geye2-DB24:~/oracle10g/dbs>orapwd file='$ORACLE_HOME/dbs/orapwzxin' password=change_on_install entries=100 force=y;

    密码要与主机一致,与sys密码一致。

 

4.2冷备份恢复

    删除备机上的/zxindata目录,将主机上的冷备文件解压到/跟目录下。 

 

4.3 修改备库系统参数文件

    参数文件路径:/home/oracle/zxindbf/zxin/define/initzxin.ora

    在最后添加如下内容:

db_unique_name='zxinstdby'

FAL_CLIENT='zxinstdby'

FAL_SERVER='zxinpri'

log_archive_config='dg_config=(zxinpri,zxinstdby)'

log_archive_dest_2='SERVICE=zxinpri

arch valid_for=(online_logfiles,primary_role)

db_unique_name= zxinpri'

log_archive_dest_state_2=enable

 

4.4 修改备机listener.oratnsname.ora

目录在$ORACLE_HOME/network/admin下,修改完毕后重启监听。

1) 修改listener.ora,引入GLOBAL_DBNAME

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = /home/oracle/oracle10g)

      (PROGRAM = extproc)

    )

    (SID_DESC =

      (GLOBAL_DBNAME = zxinstdby)

      (ORACLE_HOME = /home/oracle/oracle10g)

      (SID_NAME = zxin)

    )

  )

 

2) 修改tnsname.ora

ü  将全部连接字符串的SERVICE_NAMEzxin改为zxinstdby

ZXIN =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.42.109.16)(PORT = 1522))

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = zxinstdby)

    )

  )

 

zx=

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.42.109.16)(PORT = 1522))

    )

    (CONNECT_DATA =

      (SERVER       = DEDICATED)

      (SERVICE_NAME = zxinstdby)

    )

  )

ü  添加连接字符串

zxinpri =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.42.109.17)(PORT = 1522))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = zxinpri)

    )

)

 

4.5 修改初始参数文件,是备机使用standby控制文件

    在备机的/home/oracle/zxindbf/zxin/define/ initzxin.ora中的control_files项,指向主机生成的standby控制文件:stdbyctl01.ctl,你也可以拷贝多份。

4.6 使备库startup mount

SQL>STARTUP MOUNT;

 

4.6 启动备库重做应用模式

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM  SESSION;

此时,备库进入接受主库归档文件并应用

 

五、灾难切换

故名思意,灾难切换是指在主库遭遇不可抗拒外力干扰(如地震,火灾,暴乱),无法为业务系统提供服务的情况下,由备库接管主库任务。在DG环境中,一旦备库接管主库,则原有灾备环境被清除。对原来主库的恢复,需要从原有备库中提取数据文件或备份文件。  

备库提升为主库,执行如下步骤:

Ø  强行停止备库当前的  RFS 进程(注意,要保证此时在mount状态)

SQL> alter database recover managed standby database finish force;

Database altered.

Ø  提升物理standbyPrimary

SQL> alter database commit to switchover to primary;

Database altered.

Ø  重启数据库,转换为主库

SQL> shutdown immediate

ORA-01507: database not mounted

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area  822083584 bytes

Fixed Size                  1222096 bytes

Variable Size             159386160 bytes

Database Buffers          654311424 bytes

Redo Buffers                7163904 bytes

Database mounted.

Database opened.

Ø  检查新主库的配置,角色为PRIMARY,打开方式为READ WRITE

SQL> select DATABASE_ROLE from v$database;

DATABASE_ROLE

----------------

PRIMARY

SQL> select open_mode, protection_mode , switchover_status  from v$database;

OPEN_MODE  PROTECTION_MODE      SWITCHOVER_STATUS

----------       --------------------              --------------------

READ WRITE  MAXIMUM PERFORMANCE  NOT ALLOWED

至此,完成备库提升主库的操作。

Ø  关闭新主库的远程归档

SQL> alter system set LOG_ARCHIVE_DEST_STATE_2=DEFER;

System altered.

SQL>shutdown immediate;

SQL>startup

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25801738/viewspace-702433/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: RAC 应用修改
请登录后发表评论 登录
全部评论

注册时间:2011-07-18

  • 博文量
    40
  • 访问量
    79173