博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[20170703]关于参数db_file_name_convert
阅读量:5999 次
发布时间:2019-06-20

本文共 6553 字,大约阅读时间需要 21 分钟。

[20170703]关于参数db_file_name_convert.txt

--//如果建立dataguard时,如果主库与备库的数据文件存在路径不一致.需要使用到参数:

--//db_file_name_convert,log_file_name_convert.

--//摘录官方的一个链接:

DB_FILE_NAME_CONVERT is useful for creating a duplicate database for recovery purposes. It converts the filename of a

new datafile on the primary database to a filename on the standby database. If you add a datafile to the primary
database, you must add a corresponding file to the standby database. When the standby database is updated, this
parameter converts the datafile name on the primary database to the datafile name on the standby database. The file on
the standby database must exist and be writable, or the recovery process will halt with an error.

If you specify an odd number of strings (the last string has no corresponding replacement string), an error is signalled

during startup. If the filename being converted matches more than one pattern in the pattern/replace string list, the
first matched pattern takes effect. There is no limit on the number of pairs that you can specify in this parameter
(other than the hard limit of the maximum length of multivalue parameters).

Set the value of this parameter to two strings. The first string is the pattern found in the datafile names on the

primary database. The second string is the pattern found in the datafile names on the standby database.

You can also use DB_FILE_NAME_CONVERT to rename the datafiles in the clone control file when setting up a clone database

during tablespace point-in-time recovery.

--//实际上可以理解为一个映射表,假如在主库建立增加建立一个数据文件,文件路径根据转换参数替换为实际的备库的文件路径.

--//当然参数standby_file_management=auto的情况下.
--//对于已经在备库的文件,这种转换是无效的.别人问的问题,实际上自己测试就很容易理解.
--//通过例子来说明:

1.环境:

SYS@bookdg> @ &r/ver
BANNER
----------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

--//为了测试方便我使用pfile,这样操作方面一些.我的测试环境2个参数定义如下:

SYS@book> @ &r/hide name_convert

NAME                   DESCRIPTION                                                     DEFAULT_VALUE SESSION_VALUE          SYSTEM_VALUE
---------------------- --------------------------------------------------------------- ------------- ---------------------- ----------------------
db_file_name_convert   datafile name convert patterns and strings for standby/clone db FALSE         /mnt/ramdisk/book, /mn /mnt/ramdisk/book, /mn
                                                                                                     t/ramdisk/book         t/ramdisk/book

log_file_name_convert  logfile name convert patterns and strings for standby/clone db  FALSE         /mnt/ramdisk/book, /mn /mnt/ramdisk/book, /mn

                                                                                                     t/ramdisk/book         t/ramdisk/book

SYS@bookdg> show parameter standby_file_management

NAME                    TYPE   VALUE
----------------------- ------ ------
standby_file_management string AUTO

--//因为我的测试环境很简单,缺省2个是一样,修改不一样看看.修改备库的参数文件.

2.建立测试环境:

--//在备库启动到nomount:
SYS@bookdg> startup nomount
ORACLE instance started.

Total System Global Area  634732544 bytes

Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes

SYS@bookdg> create pfile='/tmp/bookdg.ora' from spfile ;

File created.

--//注解,并修改如下:

#*.log_file_name_convert='/mnt/ramdisk/book','/mnt/ramdisk/book'
#*.db_file_name_convert='/mnt/ramdisk/book','/mnt/ramdisk/book'
*.log_file_name_convert='/mnt/ramdisk/','/mnt/diskram'
*.db_file_name_convert='/mnt/ramdisk/','/mnt/diskram'

--//并且建立目录(在备库主机上).

# mkdir /mnt/diskram
# chown oracle:oinstall /mnt/diskram/book
$ mkdir -p /home/oracle/aux/mnt/ramdisk/book
$ mkdir -p /home/oracle/aux/mnt/diskram/book

--//重新启动备库,并且使用参数文件 /tmp/bookdg.ora.

SYS@bookdg> shutdown immediate ;
ORA-01507: database not mounted
ORACLE instance shut down.

SYS@bookdg> startup nomount pfile='/tmp/bookdg.ora'

ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes

SYS@bookdg> alter database mount standby database ;

Database altered.

SYS@bookdg> select * from v$dbfile ;

     FILE# NAME
---------- ----------------------------------------
         4 /mnt/ramdisk/book/users01.dbf
         3 /mnt/ramdisk/book/undotbs01.dbf
         2 /mnt/ramdisk/book/sysaux01.dbf
         1 /mnt/ramdisk/book/system01.dbf
         5 /mnt/ramdisk/book/example01.dbf
         6 /mnt/ramdisk/book/tea01.dbf
6 rows selected.

--//你可以发现对于已经建立的数据文件并不存在转化.不知道讨论者认为要移动文件才有效,实际上对于已经建立的文件是不需要再转化

--//的.
--//打开日志应用看看.
SYS@bookdg> alter database recover managed standby database using current logfile disconnect ;
Database altered.

SYS@bookdg> @ &r/dg/dg

PROCESS       PID STATUS       CLIENT_P GROUP# THREAD#  SEQUENCE#     BLOCK#     BLOCKS DELAY_MINS
--------- ------- ------------ -------- ------ ------- ---------- ---------- ---------- ----------
ARCH        26785 CONNECTED    ARCH     N/A          0          0          0          0          0
ARCH        26789 CONNECTED    ARCH     N/A          0          0          0          0          0
RFS         26842 IDLE         UNKNOWN  N/A          0          0          0          0          0
RFS         26836 IDLE         ARCH     N/A          0          0          0          0          0
RFS         26840 IDLE         UNKNOWN  N/A          0          0          0          0          0
RFS         26838 IDLE         LGWR     3            1        697         10          1          0
ARCH        26791 CLOSING      ARCH     4            1        695          1        154          0
ARCH        26787 CLOSING      ARCH     6            1        696      22528        182          0
MRP0        26802 APPLYING_LOG N/A      N/A          1        697         10     102400          0
9 rows selected.
--//可以发现日志从主库传输并应用.

3.在主库建立数据库文件看看.

ALTER TABLESPACE TEA

  ADD DATAFILE '/home/oracle/aux/mnt/ramdisk/book/tea02.dbf'
  SIZE 5M
  AUTOEXTEND OFF;

--//正常我的理解在备库上应该建立的数据文件在/home/oracle/aux/mnt/diskdisk/book/tea01.dbf,测试看看自己的理解是否正确.

$ mkdir -p  /home/oracle/aux/mnt/ramdisk/book

ALTER TABLESPACE TEA

  ADD DATAFILE '/home/oracle/aux/mnt/ramdisk/book/tea02.dbf'
  SIZE 5M
  AUTOEXTEND OFF;

--//注意我在备库的转化表:(注意里面的斜线.我故意这样做的^_^)

*.log_file_name_convert='/mnt/ramdisk/','/mnt/diskram'
*.db_file_name_convert='/mnt/ramdisk/','/mnt/diskram'

--//检查备库日志:

Recovery created file /home/oracle/aux/mnt/diskrambook/tea02.dbf
Successfully added datafile 7 to media recovery
Datafile #7: '/home/oracle/aux/mnt/diskrambook/tea02.dbf'

--//注意看提示,实际上在备库建立的文件是/home/oracle/aux/mnt/diskrambook/tea02.dbf.在备库执行:

$ mkdir -p /home/oracle/aux/mnt/diskrambook/

SYS@bookdg> select * from v$dbfile ;

     FILE# NAME
---------- ----------------------------------------------
         4 /mnt/ramdisk/book/users01.dbf
         3 /mnt/ramdisk/book/undotbs01.dbf
         2 /mnt/ramdisk/book/sysaux01.dbf
         1 /mnt/ramdisk/book/system01.dbf
         5 /mnt/ramdisk/book/example01.dbf
         6 /mnt/ramdisk/book/tea01.dbf
         7 /home/oracle/aux/mnt/diskrambook/tea02.dbf
7 rows selected.

$ ls -l /home/oracle/aux/mnt/diskrambook/

total 5140
-rw-r-----  1 oracle oinstall 5251072 2017-07-05 09:14:09 tea02.dbf

--//我在主库建立的数据文件是/home/oracle/aux/mnt/ramdisk/book/tea02.dbf.

SYS@book> select REPLACE('/home/oracle/aux/mnt/ramdisk/book/tea02.dbf','/mnt/ramdisk/','/mnt/diskram') c50 from dual;

C50
--------------------------------------------------
/home/oracle/aux/mnt/diskrambook/tea02.dbf

--//可以看出oracle在备库就是一个简单的替换,再次提醒大家注意一些细节问题.比如里面的斜线.

转载地址:http://iskmx.baihongyu.com/

你可能感兴趣的文章
卡巴斯基手机安全软件:让遗失手机远离“短信门”
查看>>
“人大艺术学院”“赵雅芝中文网”等网站被挂马
查看>>
C#之解决 未处理的“System.InvalidOperationException”类型的异常出现在 System.dll中......
查看>>
C++类模版学习笔记
查看>>
【LabVIEW技巧】工厂模式_简单工厂
查看>>
页面的Tab选项卡 简单实例
查看>>
FTP传输协议的应用详解
查看>>
r语言ggplot2误差棒图快速指南
查看>>
python之处理异常
查看>>
c++中的虚函数
查看>>
遍历form表单里面的表单元素,取其value
查看>>
PHP TP框架基础
查看>>
directive ngChecked
查看>>
面试110道题
查看>>
python 08 文件操作
查看>>
uiwebview 清缓存。,mark
查看>>
强势解决:windows 不能在本地计算机中起动Tomcat参考特定错误代码1
查看>>
IDEA中Junit使用注意事项
查看>>
java程序员面试进阶准备
查看>>
Cordova插件中JavaScript代码与Java的交互细节介绍
查看>>