Dataguard物理备库创建

 

数据库

操作系统

Ip

Service_name

db_unique_name

备注

Oracle11gr2

RHEL5.5

192.168.9.172

yfzx

yfzx

Primary DB

Oracle11gr2

RHEL5.5

192.168.9.162

Stydb

Stydb

Physical

Standby DB

 

服务器要求:服务器内存大小必须相同

安装前准备:备库仅需安装好数据库软件即可,无需创建database

listener.ora 、tnsnames.ora、   sqlnet.ora 按默认配置即可,切勿修改~

主库操作—

1、 切换数据库至归档模式

Startup mount

Alter database archivelog;

 

2、 创建归档日志目录:

mkdir –p /u01/app/oracle/archive

 

3、 主库参数设置:

DB_NAME=yfzx

DB_UNIQUE_NAME= yfzx

LOG_ARCHIVE_CONFIG='DG_CONFIG=(YFZX,STYDB)'

CONTROL_FILES='/u01/app/oracle/oradata/yfzx/control01.ctl ', '/u01/app/oracle/flash_recovery_area/yfzx/control02.ctl '

LOG_ARCHIVE_DEST_1= 'LOCATION=/u01/app/oracle/archive

                        VALID_FOR=(ALL_LOGFILES,ALL_ROLES)

                        DB_UNIQUE_NAME=yfzx'

LOG_ARCHIVE_DEST_2='SERVICE=stydb

                        VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

                        DB_UNIQUE_NAME=stydb'

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE

LOG_ARCHIVE_FORMAT=' %t_%s_%r.arc'

LOG_ARCHIVE_MAX_PROCESSES=30

FAL_SERVER=stydb

FAL_CLIENT=yfzx

DB_FILE_NAME_CONVERT=' /u01/app/oracle/oradata/stydb',

                                                     '/u01/app/oracle/oradata/yfzx'

LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/stydb',

                                                        '/u01/app/oracle/oradata/yfzx'

 STANDBY_FILE_MANAGEMENT=auto

 

4、 主库强制logging

SQL> alter database force logging;

 

5、 主库上创建备库standby日志

Standby组数:(logfile组数+1)*线程,创建目录与联机日志相同。

 

alter database add standby logfile group 7 '/u01/app/oracle/oradata/yfzx/sby_redo07.rdo' size 500m;

alter database add standby logfile group 8 '/u01/app/oracle/oradata/yfzx/sby_redo08.rdo' size 500m;

alter database add standby logfile group 9 '/u01/app/oracle/oradata/yfzx/sby_redo09.rdo' size 500m;

alter database add standby logfile group 10 '/u01/app/oracle/oradata/yfzx/sby_redo10.rdo' size 500m;

alter database add standby logfile group 11 '/u01/app/oracle/oradata/yfzx/sby_redo11.rdo' size 500m;

alter database add standby logfile group 12 '/u01/app/oracle/oradata/yfzx/sby_redo12.rdo' size 500m;

alter database add standby logfile group 13 '/u01/app/oracle/oradata/yfzx/sby_redo13.rdo' size 500m;

alter database add standby logfile group 14 '/u01/app/oracle/oradata/yfzx/sby_redo14.rdo' size 500m;

 

6、 在主、备库服务器上的 listener.ora 文件中创建一个条目:

 

主库:

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = orcl)

      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)

      (SID_NAME = yfzx)

    )

  )

 

LISTENER =

  (DESCRIPTION =

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

  )

 

 

备库:

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = stydb)

      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)

      (SID_NAME = stydb)

    )

  )

 

LISTENER =

  (DESCRIPTION =

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

  )

 

 

~

7、 重新载入监听器使之生效。

lsnrctl stop

lsnrctl start

 

8、 在主、备库上创建tnsnames.ora 条目

 

STYDB=

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SID = stydb)

    )

  )

 

YFZX =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SID = yfzx)

    )

  )

 


 

 

9、 在备库上的 Oracle Home/dbs 目录中,创建一个仅含一行的 initstydb.ora 文件:

db_name=stydb

 

10、         在备库创建备库目录

         mkdir –p /u01/app/oracle/archive                                        ---创建归档目录

         mkdir -p /u01/app/oracle/admin/stydb/adump                ---创建adump

mkdir -p /u01/app/oracle/oradata/stydb                            ---创建数据存放目录

mkdir -p /u01/app/oracle/flash_recovery_area/stydb  ---创建控制文件目录

 

11、         在主库上,在 $ORACLE_HOME/dbs 目录下通常命名为 orapwyfzx。如果没有该文件(可能性很小),则创建一个。然后将文件复制到备库的 $ORACLE_HOME/dbs 下。将其复制到新文件 orapwstydb。这将确保主数据库的 sysdba 连接口令也可应用到备用数据库。

 

12、         在备库上,以 NOMOUNT 状态启动实例 备库。

SQL> sqlplus / as sysdba

SQL> startup nomount

 

13、          主库执行rman脚本

rman target sys/ej-oracle@yfzx auxiliary sys/ej-oracle@stydb

run

{

allocate channel c1 type disk;

allocate auxiliary channel s1 type disk;

duplicate target database for standby from active database dorecover spfile

parameter_value_convert 'yfzx','stydb'

set db_name='yfzx'

 set db_unique_name='stydb'

set log_archive_config='dg_config=(yfzx,stydb)'

set control_files='/u01/app/oracle/oradata/stydb/control01.ctl',

                              '/u01/app/oracle/flash_recovery_area/stydb/control02.ctl'

set db_file_name_convert='/u01/app/oracle/oradata/yfzx','/u01/app/oracle/oradata/stydb'

set log_file_name_convert='/u01/app/oracle/oradata/yfzx','/u01/app/oracle/oradata/stydb'

set log_archive_format='stydb_%t_%s_%r.arc'

 set fal_client='stydb'

 set fal_server='yfzx'

 set standby_file_management='AUTO'

set  LOG_ARCHIVE_DEST_1= 'LOCATION=/u01/app/oracle/archive

                                                     VALID_FOR=(ALL_LOGFILES,ALL_ROLES)

                                    DB_UNIQUE_NAME=stydb'

set  log_archive_dest_2='service=orcL ASYNC 

valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE)

  db_unique_name=yfzx'

  set LOG_ARCHIVE_DEST_STATE_1='ENABLE'

 set log_archive_dest_state_2='enable'

set REMOTE_LOGIN_PASSWORDFILE='EXCLUSIVE'

set STANDBY_FILE_MANAGEMENT='AUTO'

set db_recovery_file_dest= '/u01/app/oracle/flash_recovery_area';

sql channel c1 "alter system archive log current";

sql channel s1 "alter database recover managed standby database using current logfile disconnect";

}

注:如果这一步RMAN失败之后,需要先关掉数据库,然后删除spfile,并将库启动到nomount状态再重新开始用RMAN进行Duplicate Database。

 

如果日志无法传输,对standby database 进行手动应用archive log ,

recover managed standby database cancel;

recover automatic standby database;--cancel

recover managed standby database disconnect from session;

 

 

阅读更多
个人分类: Oracle
上一篇Dataguard逻辑备库创建
下一篇ORACLE 9I DATAGUARD实施和维护总结
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭