ORACLE10g R2【单实例FS→单实例FS】

本演示案例所用环境:

 

primary

standby

OS Hostname

pry

std

OS Version

RHEL5.8

RHEL5.8

DB Version

10.2.0.5

10.2.0.5

db_name

stephen

stephen

db_unique_name

stephen

standby

service_names

stephen

standby

instance_name

stephen

standby

Primary database configure

1.启用primary force logging

SQL> select force_logging from v$database;

SQL> alter database force logging;

2.配置redo传输认证

(1) tnsnames.ora

STEPHEN =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = stephen)

)

)

STANDBY =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = standby)

)

)

 

(2)tnsping命令解析网络服务名,命令须返回OK.

此时,standby端未配置监听,无法解析,可以standby配置后再测试。

$ tnsping standby

 

(3) 密码文件

若无密码文件,则创建密码文件。格式:orapw<ORACLE_SID>

cd $ORACLE_HOME/dbs

orapwd file=orapwstephen password=oracle force=y

3.添加standby logfiles

添加standby logfile 的要求:

(1) 确保主和备数据库上的日志文件大小是相同的

(2) 确定备库重做日志文件组的适当数目

Standby logfile数 = (每个线程的logfile数+1)* 线程数

(3) 检查create database时指定的MAXLOGFILES和MAXLOGMEMBERS参数,可以通过trace controlfile出来查看

(4) RAC环境创建standby logfile,指定thread#创建

每个thread的standby logfile数 = 每个thread的logfile数 + 1

检查当前环境的logfile:

set lines 200 pages 300

col member for a60

select a.thread#,a.group#,b.member,b.type,a.bytes/1024/1024 MB from v$log a,v$logfile b where a.group#=b.group#

union all

select a.thread#,a.group#,b.member,b.type,a.bytes/1024/1024 MB from v$standby_log a,v$logfile b where a.group#=b.group#;

根据查询的logfile 信息上文添加standby logfile的要求,添加合理的standby logfile,然后用上面的sql再次查看当前环境的logfile:

SQL> alter database add standby logfile

group 4 '/u01/oradata/stephen/redo04.log' size 50M,

group 5 '/u01/oradata/stephen/redo05.log' size 50M,

group 6 '/u01/oradata/stephen/redo06.log' size 50M,

group 7 '/u01/oradata/stephen/redo07.log' size 50M;

4.修改primary参数文件

备份spfile:

create pfile='/tmp/pfile.bak' from spfile;

修改以下参数,其中stephen,standby分别为primary,standby的db_unqiue_name/TNS-Alias,详见参数详解部分:

alter system set log_archive_config='dg_config=(stephen,standby)';

alter system set log_archive_dest_1='location=/u01/arch valid_for=(all_logfiles,all_roles) db_unique_name=stephen';

alter system set log_archive_dest_2='service=standby lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=standby';

alter system set log_archive_max_processes=30; #根据需求调整个数

确认以下参数默认值,如不为以下参数值,则修改:

alter system set remote_login_passwordfile=exclusive scope=spfile; #exclusive/shared

alter system set log_archive_dest_state_1=enable;

alter system set log_archive_dest_state_2=enable;

log_archive_format参数控制归档文件名称格式,默认值以.dbf结尾,为了与datafile区分,建议修改为.arc结尾:

alter system set log_archive_format='%t_%s_%r.arc' scope=spfile;

当primary切换为standby角色后,需要增加修改以下参数,建议配置:

alter system set fal_server=standby;

alter system set fal_client=stephen;

alter system set standby_file_management=auto;

# primary和standby的datafile和logfile存储路径不一样时,设定以下参数:

alter system set db_file_name_convert='/oradata/standby','/u01/oradata/stephen' scope=spfile;

alter system set log_file_name_convert='/oradata/standby','/u01/oradata/stephen' scope=spfile;

注:以上参数,指定spfile修改的,实例重启后生效。

5.打开归档模式

首先确认当前数据库是否是归档模式,如果不是,则打开归档模式。

archive log list;

shutdown immediate;

startup mount;

alter database archivelog;

archive log list;

alter database open;

6.备份primary database

可以使用之前的备份,但需要确保备份以来的归档没有丢失。

rman target / <<EOF

run{allocate channel c1 type disk;

allocate channel c2 type disk;

backup full database format '/backup/full_%U.bak' plus archivelog;

sql 'alter system switch logfile';

backup current controlfile for standby format '/backup/c_%U.bak';

release channel c1;

release channel c2;

}

EOF

Standby database configure

1.配置环境变量

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/10.2/db_1

export ORACLE_SID=standby

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib #不同平台变量名不一样

2.配置redo传输认证

(1) listener.ora

配置静态监听:

LISTENER =

(ADDRESS_LIST=

(ADDRESS=(PROTOCOL=tcp)(HOST=std)(PORT=1521))

)

SID_LIST_LISTENER=

(SID_LIST=

(SID_DESC=

(GLOBAL_DBNAME=standby)

(SID_NAME=standby)

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

)

)

启用监听:

lsnrctl start

lsnrctl status

 

(2) tnsnames.ora

STEPHEN =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = stephen)

)

)

STANDBY =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = standby)

)

)

 

(3) tnsping命令解析网络服务名,命令须返回OK.

$ tnsping stephen

...

OK (0 msec)

 

(4) 密码文件

使用主库的密码文件:

scp pry:$ORACLE_HOME/dbs/orapwstephen $ORACLE_HOME/dbs/orapwstandby

3.创建相关目录

mkdir -p $ORACLE_BASE/admin/standby/{adump,bdump,cdump,dpdump,pfile,udump,hdump}

mkdir -p /oradata/{standby,arch}

4.参数文件

用primary的pfile加以修改,以保证某些参数与primary保持一致,注意主备库内存的大小适当的调整内存相关参数。

scp pry:/tmp/pfile.bak $ORACLE_HOME/dbs/initstandby.ora

修改pfile为需要的standby pfile,并创建spfile.特别注意以下事例的参数设定:

*.audit_file_dest='/u01/app/oracle/admin/standby/adump'

*.background_dump_dest='/u01/app/oracle/admin/standby/bdump'

*.core_dump_dest='/u01/app/oracle/admin/standby/cdump'

*.user_dump_dest='/u01/app/oracle/admin/standby/udump'

*.control_files='/oradata/standby/control01.ctl'

*.log_archive_format='%t_%s_%r.arc'

*.log_archive_config='dg_config=(standby,stephen)'

*.log_a rchive_dest_1='location=/oradata/arch valid_for=(all_logfiles,all_roles) db_unique_name=standby'

*.log_a rchive_dest_2='service=stephen lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=stephen'

*.log_archive_dest_state_1='enable'

*.log_archive_dest_state_2='enable'

*.log_archive_max_processes=30  #根据需求调整个数

*.db_name='stephen'

*.db_unique_name='standby'

*.instance_name='standby'

*.service_names='standby'

*.fal_server='stephen'

*.fal_client='standby'

*.standby_file_management=auto

*.remote_login_passwordfile='EXCLUSIVE' #exclusive/shared

#主、备库日志文件和数据文件存放路径不一致,设定以下参数:

*.db_file_name_convert='/u01/oradata/stephen','/oradata/standby'

*.log_file_name_convert='/u01/oradata/stephen','/oradata/standby'

创建spfile:

create spfile from pfile;

5.恢复standby controlfile

SQL> startup nomount;

RMAN> restore standby controlfile from '/backup/c_05qlbira_1_1.bak';

6.恢复数据文件

(1)standby 与primary数据文件存放路径一致:

RMAN> sql 'alter database mount standby database';

run

{allocate channel c1 type disk;

allocate channel c2 type disk;

resotore database;

recover database;

release channel c1;

release channel c2;

}

(2) standby 与primary数据文件存放路径不一致:

查询primary database的数据文件信息:

set lines 300 pages 300

col name for a60

col member for a60

select file#,name from v$datafile

union all

select file#,name from v$tempfile;

启动standby到mount阶段,恢复数据文件:

RMAN> sql 'alter database mount standby database';

run

{set newname for datafile 1 to '/oradata/standby/system01.dbf';

set newname for datafile 2 to '/oradata/standby/sysaux01.dbf';

set newname for datafile 3 to '/oradata/standby/undotbs1.dbf';

set newname for datafile 4 to '/oradata/standby/user01.dbf';

set newname for tempfile 1 to '/oradata/standby/temp01.dbf';

restore database;

switch datafile all;

switch tempfile all;

recover database;

}

查看standby database log file:

set lines 200 pages 300

col member for a60

select a.thread#,a.group#,b.member,b.type,a.bytes/1024/1024 MB from v$log a,v$logfile b where a.group#=b.group#

union all

select a.thread#,a.group#,b.member,b.type,a.bytes/1024/1024 MB from v$standby_log a,v$logfile b where a.group#=b.group#;

7.应用日志

应用archive log:

recover managed standby database disconnect;

应用redo logfile:

recover managed standby database using current logfile disconnect;

取消应用日志:

recover managed standby database cancel;

8.观察日志传输

跟踪primary,standby database的alert log,观察是否有错误发生,也可以看到应用日志的相关信息。

确认standby是否应用日志:

--primary端多切几次日志,观察alert log信息。

alter system switch logfile;

alter system switch logfile;

--观察主备库日志序列号

archive log list;

--primary端查询v$archived_log视图,确认日志是否被应用:

set lines 300 pages 300

col name for a20

select name,dest_id,thread#,sequence#,standby_dest,applied,registrar,completion_time from v$archived_log

where standby_dest='YES'

order by thread#,sequence#;

--primary端查询primary,standby的最大日志序列号是否一致:

select 'Primary :' "DB Role",thread#,max(sequence#)

from v$archived_log

where standby_dest='NO'

group by thread#

union

select 'Standby :' "DB Role",thread#,max(sequence#)

from v$archived_log

where standby_dest='YES' and applied='YES'

group by thread#

order by thread#;

ORACLE10g R2【单实例 FS→单实例FS】的更多相关文章

  1. ORACLE10g R2【RAC+ASM→单实例FS】

    ORACLE10g R2[RAC+ASM→单实例FS] 10g R2 RAC+ASMà单实例FS的DG,建议禁用OMF. 本演示案例所用环境:   primary standby OS Hostnam ...

  2. ORACLE11g R2【RAC+ASM→单实例FS】

    ORACLE11g R2[RAC+ASM→单实例FS] 11g R2 RAC+ASMà单实例FS的DG,建议禁用OMF. 本演示案例所用环境:   primary standby OS Hostnam ...

  3. ORACLE11g R2【单实例 FS→单实例FS】

    ORACLE11g R2[单实例 FS→单实例FS] 本演示案例所用环境:   primary standby OS Hostname pry std OS Version RHEL6.5 RHEL6 ...

  4. [转]单例模式——C++实现自动释放单例类的实例

    [转]单例模式——C++实现自动释放单例类的实例 http://www.cnblogs.com/wxxweb/archive/2011/04/15/2017088.html http://blog.s ...

  5. Oracle 11g 单实例到单实例OGG同步实施文档-OGG initial load

    Oracle 11g 单实例到单实例OGG同步实施文档-OGG initial load 2018-06-07 00:514730原创GoldenGate 作者: leo 本文链接:https://w ...

  6. Oracle 11g 单实例到单实例OGG同步实施文档-RMAN 初始化

    Oracle 11g 单实例到单实例OGG同步实施文档-RMAN 初始化 2018-06-07 13:455170原创GoldenGate 作者: leo 本文链接:https://www.cndba ...

  7. Oracle 11g 单实例到单实例OGG同步实施文档-EXPDP初始化

    Oracle 11g 单实例到单实例OGG同步实施文档-EXPDP初始化 2018-06-07 00:446470原创GoldenGate 作者: leo 本文链接:https://www.cndba ...

  8. JavaScript 小实例 - 表单输入内容检测,对页面的增删改

    JavaScript 小实例 - 表单输入内容检测,对页面的增删改 效果体验地址:https://xpwi.github.io/js/JavaScript01/jsForm.html 功能: 1.向页 ...

  9. php常用表单验证类用法实例

    <?php /** * 页面作用:常用表单验证类 * 作 者:欣然随风 * QQ:276624915 */ class class_post { //验证是否为指定长度的字母/数字组合 func ...

随机推荐

  1. js中运算符优先级问题

    其实事情是这样的,最近看到不少朋友讨论一道据说不知道哪儿的笔试题目,题目如下: var a = {n:1}; var b = a; a.x = a = {n:2}; 请写出a.x的值. 当然通过运行, ...

  2. mysql 查看单个表每个索引的大小

    /*单个表每个索引的大小*/ SELECT sum(stat_value) pages, table_name part, index_name, concat(,),'M',' rows') * @ ...

  3. caioj 1065 动态规划入门(一维一边推3:合唱队形)

    就是最长上升子序列,但是要用n^2的算法. #include<cstdio> #include<algorithm> #define REP(i, a, b) for(int ...

  4. HDU 4786 Fibonacci Tree 生成树

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4786 题意:有N个节点(1 <= N <= 10^5),M条边(0 <= M <= ...

  5. 线段树 hdu3642 Get The Treasury

    不得不说,这是一题很经典的体积并.. 然而还是debug了2个多小时... 首先思路:按z的大小排序. 然后相当于扫描面一样,,从体积的最下方向上方扫描,遇到这个面 就将相应的两条线增加到set中,或 ...

  6. js---16原型链

    var p = {name:"sss"}; var c2 = Object.create(p,{age:32,salar:"eee"});//c2就继承了p的属 ...

  7. colorscheme-如何vim颜色风格

    我们vim默认的风格是黑底的,如果我们想要更换其他的风格,比如字体高亮的颜色.注释的颜色等.这时候我们就需要一个属性了,如下 colorscheme darkblue 这个属性的值,其实是在 /usr ...

  8. Impala通过JDBC方式访问

    不多说,直接上干货! • 配置: – impala.driver=org.apache.hive.jdbc.HiveDriver – impala.url=jdbc:hive2://node2:210 ...

  9. Whitening

    The goal of whitening is to make the input less redundant; more formally, our desiderata are that ou ...

  10. 二分图简单概念&&HDU 2063

    二分图: 二分图又称作二部图,是图论中的一种特殊模型. 设G=(V,E)是一个无向图,如果顶点V可分割为两个互不相交的子集(A,B),并且图中的每条边(i,j)所关联的两个顶点i和j分别属于这两个不同 ...