[20171221]利用rman实现2台机器文件拷贝.txt
[20171221]利用rman实现2台机器文件拷贝.txt
--//昨天使用rman duplicate建立dg,我看到执行如下代码:
RMAN> duplicate target database for standby from active database nofilenamecheck;
...
contents of Memory Script:
{
backup as copy reuse
targetfile '/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/orapwbook' auxiliary format
'/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/orapwbookdg' ;
}
--//是否通过这样的方式可以实现2台服务器之间文件拷贝呢?
1.环境:
SYS@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
2.先测试oracle的口令文件是否可以传输:
$ rlwrap rman target sys/oracle@book auxiliary sys/oracle@bookdg
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Dec 21 10:35:47 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: BOOK (DBID=1337401710)
connected to auxiliary database: BOOK (DBID=1337401710)
RMAN> backup as copy reuse targetfile '/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/orapwbook' auxiliary format '/tmp/orapwbookdg' ;
Starting backup at 2017-12-21 10:36:16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=106 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=119 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=132 device type=DISK
Finished backup at 2017-12-21 10:36:18
--//在备库检查发现
$ ls -l /tmp/orapwbookdg
-rw-r----- 1 oracle oinstall 1536 2017-12-21 10:36:17 /tmp/orapwbookdg
3.测试其它用户文件:
--//检查主库存在如下文件在/home/oracle,继续测试看看:
$ ls -l aaa.txt
-rw-r--r-- 1 oracle oinstall 54 2017-11-16 11:42:50 aaa.txt
RMAN> backup as copy reuse targetfile '/home/oracle/aaa.txt' auxiliary format '/tmp/aaa.txt.bookdg' ;
Starting backup at 2017-12-21 10:40:14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=106 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=119 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=132 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/21/2017 10:40:17
ORA-19505: failed to identify file "/home/oracle/aaa.txt"
ORA-27046: file size is not a multiple of logical block size
Additional information: 1
--//可以发现不行,文件大小必须是logical block size的整数倍.换一句话文件大小必须是512的倍数.
--//一些发行版本有fallocate可以给文件分配空间.
$ fallocate -l 512 aaa.txt
--//我的测试机器没有,我使用dd,需要加入512-54 = 458字节
$ dd if=/dev/zero of=aaa.txt seek=54 count=458 bs=1 conv=notrunc
458+0 records in
458+0 records out
458 bytes (458 B) copied, 0.00208456 seconds, 220 kB/s
--//再次提醒加入输入输出不要写反.写入onv=notrunc不管怎样都不会错,这样避免被切断,我个人每次使用dd都心存敬畏..因为1次差错....
--//注意这样写效率不高bs=1.(意味每次写1个字节,写458次),因为前面的seek参数对应54*1,
--//如果你反过来写count=1 bs=458 ,相当于在54*458偏移开始写入.利用这个特性实际上这样执行:
$ ls -l aaa.txt
-rw-r--r-- 1 oracle oinstall 54 2017-12-21 10:55:17 aaa.txt
$ dd if=/dev/zero of=aaa.txt seek=511 count=1 bs=1 conv=notrunc
1+0 records in
1+0 records out
1 byte (1 B) copied, 5.2118e-05 seconds, 19.2 kB/s
$ ls -l aaa.txt
-rw-r--r-- 1 oracle oinstall 512 2017-12-21 10:56:52 aaa.txt
RMAN> backup as copy reuse targetfile '/home/oracle/aaa.txt' auxiliary format '/tmp/aaa.txt.bookdg' ;
Starting backup at 2017-12-21 10:58:05
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
Finished backup at 2017-12-21 10:58:06
--//OK,现在拷贝过去了.
--//主库:
$ md5sum /home/oracle/aaa.txt
94a6edaabd20f62185e62037f2dbcb21 /home/oracle/aaa.txt
--//备库:
$ md5sum /tmp/aaa.txt.bookdg
94a6edaabd20f62185e62037f2dbcb21 /tmp/aaa.txt.bookdg
--//md5一样,说明没有问题.另外我的测试不使用reuse参数也会覆盖对面的文件.这点要特别注意!!
RMAN> backup as copy targetfile '/home/oracle/aaa.txt' auxiliary format '/tmp/aaa.txt.bookdg' ;
Starting backup at 2017-12-21 11:05:48
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
Finished backup at 2017-12-21 11:05:49
4.延伸测试:
--//是否这样可以实现备份:
RMAN> backup as backupset datafile 6 auxiliary format '/data/testtest/datafile6_%U' ;
Starting backup at 2017-12-21 11:21:00
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 12/21/2017 11:21:00
RMAN-06955: Network copies are only supported for image copies.
--//^_^,oracle不支持,报RMAN-06955: Network copies are only supported for image copies.
--//也就是做image copy应该没有问题.
RMAN> backup as copy datafile 6 auxiliary format '/data/backuptest/datafile6_%U' ;
Starting backup at 2017-12-21 11:28:22
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
output file name=/data/backuptest/datafile6_data_D-BOOK_I-1337401710_TS-TEA_FNO-6_fpsmm16m tag=TAG20171221T112822
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2017-12-21 11:28:23
RMAN> backup as copy datafile 6 auxiliary format '/data/backuptest/%b' ;
Starting backup at 2017-12-21 11:29:01
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
output file name=/data/backuptest/tea01.dbf tag=TAG20171221T112901
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2017-12-21 11:29:02
--//OK没有问题.
$ ls -l /data/backuptest
total 12328
-rw-r----- 1 oracle oinstall 6299648 2017-12-21 11:28:22 datafile6_data_D-BOOK_I-1337401710_TS-TEA_FNO-6_fpsmm16m
-rw-r----- 1 oracle oinstall 6299648 2017-12-21 11:29:01 tea01.dbf
$ dbv file=/data/backuptest/tea01.dbf
DBVERIFY: Release 11.2.0.4.0 - Production on Thu Dec 21 11:31:29 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBVERIFY - Verification starting : FILE = /data/backuptest/tea01.dbf
DBVERIFY - Verification complete
Total Pages Examined : 768
Total Pages Processed (Data) : 594
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 128
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 46
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 392434057 (3.392434057)
--//说明没有问题.注意这样备份在控制文件没有记录.
--//主库:
RMAN> list copy of datafile 6;
specification does not match any datafile copy in the repository
--//有点可惜的是11g不支持copy section size,也就是分段拷贝.12c支持,这样可以加快copy的速度.
--//参考链接:http://blog.itpub.net/267265/viewspace-1310778/
总结:
1.这样方式拷贝文件大小存在限制,必须是512的倍数.
2.提供另外一种手工方式建立备库的方式.
3.另外注意这样拷贝方式在控制文件没有记录.
4.注意文件覆盖问题.似乎数据文件copy不会覆盖,除非指定resue参数,参考后面测试:
5.补充测试:
RMAN> backup as copy database auxiliary format '/data/backuptest/%b' ;
Starting backup at 2017-12-21 11:39:12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
channel ORA_DISK_2: starting datafile copy
input datafile file number=00003 name=/mnt/ramdisk/book/undotbs01.dbf
channel ORA_DISK_3: starting datafile copy
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
output file name=/data/backuptest/system01.dbf tag=TAG20171221T113912
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:55
channel ORA_DISK_3: starting datafile copy
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
output file name=/data/backuptest/sysaux01.dbf tag=TAG20171221T113912
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:58
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
output file name=/data/backuptest/undotbs01.dbf tag=TAG20171221T113912
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:58
channel ORA_DISK_2: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
--//视乎文件存在不会覆盖..
RMAN-03009: failure of backup command on ORA_DISK_2 channel at 12/21/2017 11:40:12
ORA-17628: Oracle error 19505 returned by remote Oracle server
continuing other job steps, job failed will not be re-run
output file name=/data/backuptest/users01.dbf tag=TAG20171221T113912
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:17
output file name=/data/backuptest/example01.dbf tag=TAG20171221T113912
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:20
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_2 channel at 12/21/2017 11:40:12
ORA-17628: Oracle error 19505 returned by remote Oracle server
--//删除前面的备份在重新执行:
RMAN> backup as copy database auxiliary format '/data/backuptest/%b' ;
Starting backup at 2017-12-21 11:43:09
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
channel ORA_DISK_2: starting datafile copy
input datafile file number=00003 name=/mnt/ramdisk/book/undotbs01.dbf
channel ORA_DISK_3: starting datafile copy
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
output file name=/data/backuptest/sysaux01.dbf tag=TAG20171221T114309
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
output file name=/data/backuptest/undotbs01.dbf tag=TAG20171221T114309
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:01:06
channel ORA_DISK_2: starting datafile copy
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
output file name=/data/backuptest/system01.dbf tag=TAG20171221T114309
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:01:06
channel ORA_DISK_3: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
output file name=/data/backuptest/tea01.dbf tag=TAG20171221T114309
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:03
output file name=/data/backuptest/example01.dbf tag=TAG20171221T114309
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
output file name=/data/backuptest/users01.dbf tag=TAG20171221T114309
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:15
Finished backup at 2017-12-21 11:44:30
--//ok!!
RMAN> backup as copy datafile 6 auxiliary format '/data/backuptest/%b' ;
Starting backup at 2017-12-21 11:45:32
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/21/2017 11:45:33
ORA-17628: Oracle error 19505 returned by remote Oracle server
--//视乎不能覆盖.加入resue看看.
RMAN> backup reuse as copy datafile 6 auxiliary format '/data/backuptest/%b' ;
Starting backup at 2017-12-21 11:46:19
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
output file name=/data/backuptest/tea01.dbf tag=TAG20171221T114619
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2017-12-21 11:46:20
[20171221]利用rman实现2台机器文件拷贝.txt的更多相关文章
- Linux下 两台机器文件/文件夹 相互拷贝
Linux下 两台机器文件/文件夹 相互拷贝 设有两台机器 :A:*.101及 B:*.102. 把A下的.temp/var/a.txt拷贝到B机器的/text/目录下: 进入B机器:scp root ...
- linux一台机器文件传到另一台机器上
登录一台机器35.73: scp -P 端口 要传的文件 user@xxx.xxx.xxx.xxx:/目标文件夹/ 例子 :scp -r -P3561 /home/ismp/build/app/bec ...
- 第四课 Grid Control实验 GC Agent安装(第一台机器部署) 及卸载
3.GC Agent安装(第一台机器部署) 安装Agent 拷贝agent,现在ocm2机器上查找agent.linux 查找文件的方法: find ./ -name agent*linux 把ag ...
- 两台linux机器文件传输之scp
0.写在前面:一定要注意我们是否有源文件的读权限,是否有目标文件夹的写权限!没有的话要先把权限设置好! *.设置权限的方法:切换到有权限操作文件或文件夹的用户,利用chmod命令修改权限 1.安装: ...
- 利用Inotify和Rsync将webproject文件自己主动同步到多台应用server
背景:须要搭建一套跟线上一模一样的环境,用来预公布,这是当中的web分发的一个小模块的实现过程. 1 工具以及环境简单介绍 1.1,Inotify工具 Inotify,它是一个内核用于通知用户空间程序 ...
- linux利用ssh远程执行多台机器执行同样的命令
这篇文章主要介绍了ssh远程执行命令方法和Shell脚本实例,本文讲解了ssh执行远程操作方法和远程执行命令shell脚本示例,需要的朋友可以参考下 ssh执行远程操作命令格式代码如下: ssh -t ...
- Hexo博客系列(二)-在多台机器上利用Hexo发布博客
[原文链接]:https://www.tecchen.xyz/blog-hexo-env-02.html 我的个人博客:https://www.tecchen.xyz,博文同步发布到博客园. 由于精力 ...
- 利用Synergy在局域网内让Ubuntu和Windows 7两台机器共用一套键鼠。
一个主机可以连接多个显示器, 方便自己使用, 但是这只是一个系统分屏显示, 如果想用两台不同系统的电脑, 并且还不想老是在两套键鼠之间来回转换, 那么建议你可以用Synergy软件来实现多台电脑之间的 ...
- SCP,scp linux2台机器之间如何传输文件
关键词:scp 转自: http://blog.csdn.net/gatieme https://blog.csdn.net/gatieme/article/details/51673229 scp传 ...
随机推荐
- NFS客户端挂载
关于NFS挂载#卸载: umount -fl /挂载名称#重新挂载:mount -t nfs -o rw,noac 10.8.16.11:/vx/SJOA-APP /挂载名称 #mount –v查看当 ...
- gulp和grunt 分享ppt
gulp是前端开发过程中对代码进行构建的工具,是自动化项目的构建利器:她不仅能对网站资源进行优化,而且在开发过程中很多重复的任务能够使用正确的工具自动完成:使用她,我们不仅可以很愉快的编写代码,而且大 ...
- 关于JS的一些东西
1.声明Js代码域 1.在head标签中使用script声明js代码域 <head> .... <!--声明js代码域--> ...
- Spring Security使用报错 No bean named 'springSecurityFilterChain' is defined
今天配置spring security时,运行报出No bean named 'springSecurityFilterChain' is defined错误,报错信息如下 严重: Exception ...
- spring boot整合reids 然后实现缓存分页(方法之一) 以及RedisTemplate存到reids 里面get 就消失的坑
业务需求 首页 实现缓存分页 spring boot 整合redis (我的是2.0.3版本的) 在pom 文件写上依赖包即可 <dependency><!--依赖包--> ...
- SaltStack数据系统-Pillar详解
1:存储位置 存储在master端,存放需要提供给minion的信息 每个minion只能访问master分配给自己的(应用场景) 2:在centos7 salt 2015.5.10 (Lithium ...
- 一篇迟到的gulp文章,代码合并压缩,less编译
前言 这篇文章本应该在去年17年写的,但因为种种原因没有写,其实主要是因为懒(捂脸).gulp出来的时间已经很早了,16年的时候还很流行,到17年就被webpack 碾压下去了,不过由于本人接触gul ...
- 关于wepack的使用总结以及优化探讨
一.前言 不知不觉,webpack版本已经到4.0了.使用它也有很长一段时间了,回头看看,自己木有总结webpack方面的知识,现在有空起个头,主要是总结自己常用的配置和一下优化的探讨,以后有啥想法也 ...
- vue 使用mint-ui实现上拉加载和下拉刷新
解决了官网中下拉刷新存在的问题 <template> <div class="tmpl"> <nav-bar title="商品列表&quo ...
- AngularJS+Ionic开发-2.项目结构介绍
使用上篇博客<开发环境搭建>中的命令创建完成IonicHelloWorld项目,在VSCode中的左侧,显示该项目的结构信息,如下图所示: 1 .sourcesmaps文件夹 调试状态的j ...