ITPub博客

首页 > 数据库 > Oracle > ORACLE 10G DATAGUARD 建立

ORACLE 10G DATAGUARD 建立

原创 Oracle 作者:hayes575 时间:2010-04-10 14:17:02 0 删除 编辑

ORACLE 10G DATAGUARD 建立

一,主库与从库的oracle 版本必须一样,主库必须设在归档模式

二,强制主库为logging状态

Alter database force logging;

三,在主库与丛库中同时生成密码文件

Oracle用户登陆

$rm $ORACLE_HOME/dbs/orapw$ORACLE_SID

$orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle entries=4

四,在主库与丛库中设置相应环境变量

Oracle用户登陆

主库:

$vi /home/oracle/.bash_profile中设置

export ORACLE_SID=NB

export ORACLE_BASE=/opt/oracle

export ORACLE_HOME=/opt/oracle/product/10.2.0/NB

export NLS_LANG=AMERICAN_AMERICA.ZHT16BIG5

export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data

export PATH=$ORACLE_HOME/bin:$PATH:/sbin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib

丛库:

$vi /home/oracle/.bash_profile中设置

export ORACLE_SID=DHDG

export ORACLE_BASE=/opt/oracle

export ORACLE_HOME=/opt/oracle/product/10.2.0/dhstandby

export NLS_LANG=AMERICAN_AMERICA.ZHT16BIG5

export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data

export PATH=$ORACLE_HOME/bin:$PATH:/sbin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib

五,在从库中准备相应目录,如日志文件路径,归档路径,参数文件路径,数据文件准备存放路径等

Oracle用户登陆

$cd $ORACLE_BASE

$mkdir –p admin/dhstandby/adump

$mkdir –p admin/dhstandby/bdump

$mkdir –p admin/dhstandby/cdump

$mkdir –p admin/dhstandby/dpdump

$mkdir –p admin/dhstandby/udump

与主库建立同样的归档路径

$mkdir –p /data8/archive

六,主库与从库建立参数文件

在主库中生成pfile

$sqlplus ‘/as sysdba’

Create pfile=’/home/oracle/pfile.ora’ from spfile;

主库中pfile

将主库的pfile copy到从库中进行修改如下

从库与主库不一样的参数:

*.standby_archive_dest='/data8/standbyarch'

*.standby_file_management='AUTO'

*.fal_client='DHDG'

*.fal_server='NB'

还用控制文件路径,及各dump文件路径需要修改

七,对主库做一次全备份

在主库与从库中建立相同的备份路径

Oracle用户登录

$mkdir –p /data8/backup

$chmod 770 /data8/backup

做一次完整的RMAN热备份

$rman target/

Rman> backup database format=’/data8/backup/%U_%s.bak’;

Rman>sql”alter system archive log current”;

Rman>backup filesperset 10 archivelog all format=’/data8/backup/%U_%s.bak’;

通过scp传送相应的备份集到备用服务器

$scp /data8/backup/*.bak 172.16.20.116:/data8/backup/

八,配置网络连接

从库监听listener.ora

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = /opt/oracle/product/10.2.0/dhstandby)

(PROGRAM = extproc)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.20.116)(PORT = 1521))

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

)

)

从库tnsnames.ora

NB =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST=172.16.20.142)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = NB)

)

)

DHDG =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST=172.16.20.116)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = DHDG)

)

)

主库监听listener.ora

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = /opt/oracle/product/10.2.0/nb)

(PROGRAM = extproc)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.20.142)(PORT = 1521))

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

)

)

主库tnsnames.ora

NB =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST=172.16.20.142)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = NB)

)

)

DHDG =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST=172.16.20.116)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = DHDG)

)

)

九,在主库创建从库的控制文件

主库先关闭,然后使用修改的pfile文件使其处于mount状态下

Sql>shutdown immediate;

Sql>startup mount pfile=’/home/oracle/pfile.ora’;

Sql>alter database create standby controlfile as ‘创建的路径和文件名’;如:

alter database create standby controlfile as ‘/data8/backup/con01.ctl’;

使用scp传送到从库,然后复制该控制文件到参数指定的路径下,并按参数文件的指定个数复制多分

十,启动备用库

$sqlplus ‘/as sysdba’

Sql>startup nomount pfile=’/home/oracle/pfile.ora’;

Sql>alter database mount standby database;

传统是使用ARCH进程传输归档日志,图示如下:

8i以后可采用LGWr进程传输联机日志,图示如下

采用LGWr进程传输日志,必须建立备用日志,而且日志大小与主库一样,个数比主库多一个

首先建立备用日志

alter database add standby logfile

group 4 ('/opt/oracle/oradata/NB/standlog/stredo04.log') size 50M;

alter database add standby logfile

group 5 ('/opt/oracle/oradata/NB/standlog/stredo05.log') size 50M;

alter database add standby logfile

group 6 ('/opt/oracle/oradata/NB/standlog/stredo06.log') size 50M;

alter database add standby logfile

group 7 ('/opt/oracle/oradata/NB/standlog/stredo07.log') size 50M

使用RMAN进行恢复:

$rman target/

Rman>restore database;

Rman>restore archvielog all;

然后直接进入管理恢复状态:

$sqlplus ‘/as sysdba’

Sql>alter database recover managed standby database disconnect from session;

1ARCH方式传送日志时,如果主备库密码文件不一致,在重新设置密码文件后,必须重启主库才能使日志传送恢复正常。

2LGWR方式传送日志时,如果主备库密码文件不一致,在重新设置密码文件后,只需可以重启主库或重启备库就可使日志传送恢复正常

1、启动到管理模式

SQL>shutdown immediate

SQL>startup nomount pfile=?/dbs/inittbdbsdby.ora

SQL>alter database mount standby database

SQL>alter database recover managed standby database disconnect from session;

2、启动到只读方式

SQL>shutdown immediate

SQL>startup nomount pfile=?/dbs/inittbdbsdby.ora

SQL>alter database mount standby database

SQL>alter database open read only

3、如在管理恢复模式下到只读模式

SQL>recover managed standby database cancel;

SQL>alter database open read only;

这个时候,可以给数据库增加临时数据文件(这个在热备份的时候是没有备份过来的)如

alter tablespace temp add tempfile '/u01/oracle/oradata/tbdb/temp01.dbf' size 100M;

4、从只读方式到管理恢复方式

SQ>recover managed standby database disconnect from session;

[@more@]

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

下一篇: 没有了~
全部评论

注册时间:2010-06-15

  • 博文量
    4
  • 访问量
    20365