[20171221]利用rman實現2台機器文件拷貝.txt

来源:http://www.cnblogs.com/lfree/archive/2017/12/21/8079454.html
-Advertisement-
Play Games

[20171221]利用rman實現2台機器文件拷貝.txt--//昨天使用rman duplicate建立dg,我看到執行如下代碼:RMAN> duplicate target database for standby from active database nofilenamecheck;.. ...


[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



您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 最近因為要學習Python,於是把放在家裡接了一年灰的樹莓派又給搜出來了,剛買那會也搗鼓了好一陣子, 基本操作都學會了,但現在又忘光了,只能又從頭開始搞了,首先第一個要解決的是怎麼把文件從電腦傳輸到樹莓派 ,記得以前是在Windows上傳的,直接在網上下載了一個軟體,filezilla,打開輸入板卡 ...
  • 通過啟用屏幕共用來開啟遠程桌面登錄,開啟後需要關閉encryption,否則會出現無法連接的情況。關閉encryption可以使用系統配置工具dconf來完成。所以先安裝dconf-editor。 更新源並安裝系統配置工具(不更新源無法進行安裝) 1、查看系統版本 2、添加更新源,更新源內容可以從網 ...
  • 一、環境 VMware12 Pro CentOS-6.7-i386-bin-DVD1 jdk-8u151-linux-i586 二、詳細安裝步驟 前提:需要卸載自己Linux上的jdk rpm -qa | grep jdk 會顯示你所有包含jdk這個字元串的安裝包 rpm -e --nodeps 對 ...
  • 目錄 一、概述 二、MySQL安裝 三、安裝成功驗證 四、NavicatforMySQL下載及使用 一、概述 MySQL版本:5.7.17 下載地址:http://rj.baidu.com/soft/detail/12585.html?ald 客戶端工具:NavicatforMySQL 綠色版下載地 ...
  • 項目需要定時備份資料庫,以下是自己的操作筆記 1.檢查磁碟空間 這是我當前linux伺服器的情況,至於為什麼是這樣子,我也不清楚(我是半路接過來的,無奈) 根據上面的信息,我就把備份文件放在/dev目錄下麵 2.創建備份目錄 3.創建備份shell命令 輸入如下內容 對備份進行壓縮 註意: 把 us ...
  • 在增量部署系統的時候, 經常需要提供增量修改的腳本, 如果是修改存儲過程或者自定義函數, 那還是很好改的, 不用擔心表功能收到影響. 如果是改欄位呢? 首先不知道欄位是不是已經在系統裡面, 沒有的話, 需要新增上去, 有的話, 需不需要修改? 其次, 腳本如果報錯, 是否會重覆執行一下腳本? 會不會 ...
  • 目的: 增加約束 創建索引 使用CREATE TABLE語句創建索引 創建函數索引 刪除列和將列置為UNUSED 平臺FLASHBACK閃回操作 創建臨時表 創建和使用外部表 ALTER TABLE語句 -增加列 -修改已存在的列 -定義列的預設值 -刪除列 語法 ALTER TABLE table ...
  • MySQL5.7單實例二進位包安裝方法 一、環境 OS: CentOS release 6.9 (Final)MySQL: mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz 說明:類似的操作系統也可以的。為了方便起見,涉及到的操作,均可以直接粘貼複製,比較直觀快捷 ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...