Linux下 数据文件 效验问题
?
?????? Linux 下,不同服務器之前的數據copy是很常見的操作。 常見的copy命令有scp 和cp。 但是對于一些重要的文件,如數據庫的備份文件,在copy之后,我們還需要對copy之后的文件進行一下效驗, 以免在copy過程中的丟失。 造成無法恢復數據。
?
常見的效驗有如下2種方式:
?
1. 比較文件大小
用ll或者ls 命令分別查看一下copy之前和copy之后的文件大小。
[root@singledb backup]# ll
total 639820
-rw-r----- 1 oracle oinstall? 18150400 Dec? 7 19:50 arch_0hluu1q6_1_1_20101207
-rw-r----- 1 oracle oinstall?? 9810432 Dec? 7 19:50 arch_0iluu1q7_1_1_20101207
-rw-r----- 1 oracle oinstall???? 32256 Dec? 7 19:50 arch_0jluu1qu_1_1_20101207
-rw-r----- 1 oracle oinstall? 15335424 Dec? 7 19:50 ctl_file_0kluu1sf_1_1_20101207
-rw-r----- 1 oracle oinstall 371933184 Dec? 7 19:54 orcl_0eluu1aa_1_1_20101207
-rw-r----- 1 oracle oinstall 223895552 Dec? 7 19:56 orcl_0fluu1ac_1_1_20101207
-rw-r----- 1 oracle oinstall? 15335424 Dec? 7 19:56 orcl_0gluu1ks_1_1_20101207
[root@singledb backup]# ls -lrt
total 639820
-rw-r----- 1 oracle oinstall? 18150400 Dec? 7 19:50 arch_0hluu1q6_1_1_20101207
-rw-r----- 1 oracle oinstall???? 32256 Dec? 7 19:50 arch_0jluu1qu_1_1_20101207
-rw-r----- 1 oracle oinstall?? 9810432 Dec? 7 19:50 arch_0iluu1q7_1_1_20101207
-rw-r----- 1 oracle oinstall? 15335424 Dec? 7 19:50 ctl_file_0kluu1sf_1_1_20101207
-rw-r----- 1 oracle oinstall 371933184 Dec? 7 19:54 orcl_0eluu1aa_1_1_20101207
-rw-r----- 1 oracle oinstall 223895552 Dec? 7 19:56 orcl_0fluu1ac_1_1_20101207
-rw-r----- 1 oracle oinstall? 15335424 Dec? 7 19:56 orcl_0gluu1ks_1_1_20101207
?
?
2. 使用md5sum命令
2.1 ?MD5 效驗介紹
MD5的全稱是Message-Digest Algorithm 5,在90年代初由MIT的計算機科學實驗室和RSA Data Security Inc發明,經MD2、MD3和MD4發展而來。
Message-Digest泛指字節串(Message)的Hash變換,就是把一個任意長度的字節串變換成一定長的大整數。這種變換只與字節的值有關,與字符集或編碼方式無關。
MD5將任意長度的“字節串”變換成一個128bit的大整數,并且它是一個不可逆的字節串變換算法,換句話說就是,即使你看到源程序和算法描述,也無法將一個MD5的值變換回原始的字符串,從數學原理上說,是因為原始的字節串有無窮多個,這有點象不存在反函數的數學函數。
MD5的典型應用是對一段Message(字節串)產生fingerprint(指紋),以防止被“篡改”。舉個例子,你將一段話寫在一個叫 readme.txt文件中,并對這個readme.txt產生一個MD5的值并記錄在案,然后你可以傳播這個文件給別人,別人如果修改了文件中的任何內容,你對這個文件重新計算MD5時就會發現。如果再有一個第三方的認證機構,用MD5還可以防止文件作者的“抵賴”,這就是所謂的數字簽名應用。
MD5還廣泛用于加密和解密技術上,在很多操作系統中,用戶的密碼是以MD5值(或類似的其它算法)的方式保存的, 用戶Login的時候,系統是把用戶輸入的密碼計算成MD5值,然后再去和系統中保存的MD5值進行比較,而系統并不“知道”用戶的密碼是什么。
一些黑客破獲這種密碼的方法是一種被稱為“跑字典”的方法。有兩種方法得到字典,一種是日常搜集的用做密碼的字符串表,另一種是用排列組合方法生成的,先用MD5程序計算出這些字典項的MD5值,然后再用目標的MD5值在這個字典中檢索。
即使假設密碼的最大長度為8,同時密碼只能是字母和數字,共26+26+10=62個字符,排列組合出的字典的項數則是P(62,1)+P (62,2)….+P(62,8),那也已經是一個很天文的數字了,存儲這個字典就需要TB級的磁盤組,而且這種方法還有一個前提,就是能獲得目標賬戶的密碼MD5值的情況下才可以。
?
2.2 一個簡單的演示:
?
[root@singledb backup]# which md5sum
/usr/bin/md5sum
?
創建一個文件
[root@singledb backup]# touch tianlesoftware.dba
?
查看MD5 值
[root@singledb backup]# md5sum tianlesoftware.dba????????????????
d41d8cd98f00b204e9800998ecf8427e? tianlesoftware.dba
?
將MD5值保存到某個文件
[root@singledb backup]# md5sum tianlesoftware.dba? > tianlesoftware.md5
?
修改tianlesoftware.dba 文件
[root@singledb backup]# cat tianlesoftware.dba
I AM DBA!
?
查看修改之后的MD5值
[root@singledb backup]# md5sum tianlesoftware.dba
f040ad46d094e8295533585474d33b50? tianlesoftware.dba
?
他們的值不一樣了,從這個值,可以判斷文件有沒有變化。
?
關于MD5SUM命令的更多用法,參考幫助:
[root@singledb backup]# man md5sum
MD5SUM(1)??????????????????????? User Commands?????????????????????? MD5SUM(1)
?
NAME
?????? md5sum - compute and check MD5 message digest
?
SYNOPSIS
?????? md5sum [OPTION] [FILE]...
?
DESCRIPTION
?????? Print? or? check? MD5? (128-bit)? checksums.? With no FILE, or when FILE is -, read
?????? standard input.
?
?????? -b, --binary
????????????? read in binary mode
?
?????? -c, --check
????????????? read MD5 sums from the FILEs and check them
?
?????? -t, --text
????????????? read in text mode (default)
?
?? The following two options are useful only when verifying checksums:
?????? --status
????????????? dona€?t output anything, status code shows success
?
?????? -w, --warn
????????????? warn about improperly formatted checksum lines
?
?????? --help display this help and exit
?
?????? --version
????????????? output version information and exit
?
?????? The sums are computed as described in RFC 1321.? When checking, the input should be
?????? a? former? output of this program.? The default mode is to print a line with check-
?????? sum, a character indicating type (a€?*a€? for binary, a€? a€? for text), and name for? each
?????? FILE.
?
AUTHOR
?????? Written by Ulrich Drepper, Scott Miller, and David Madore.
?
REPORTING BUGS
?????? Report bugs to <bug-coreutils@gnu.org>.
?
COPYRIGHT
?????? Copyright ?? 2006 Free Software Foundation, Inc.
?????? This? is? free? software.? You may redistribute copies of it under the terms of the
?????? GNU General Public License? <http://www.gnu.org/licenses/gpl.html>.?? There? is? NO
?????? WARRANTY, to the extent permitted by law.
?
SEE ALSO
?????? The? full? documentation for md5sum is maintained as a Texinfo manual.? If the info
?????? and md5sum programs are properly installed at your site, the command
?
????????????? info md5sum
?
?????? should give you access to the complete manual.
?
md5sum 5.97??????????????????????? July 2009???????? ????????????????MD5SUM(1)
[root@singledb backup]#
?
?
?
?
?
------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
網上資源: http://tianlesoftware.download.csdn.net
相關視頻:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx
DBA1 群:62697716(滿); DBA2 群:62697977(滿)
DBA3 群:62697850?? DBA 超級群:63306533;????
聊天 群:40132017
--加群需要在備注說明Oracle表空間和數據文件的關系,否則拒絕申請
轉載于:https://www.cnblogs.com/tianlesoftware/archive/2010/12/22/3609864.html
總結
以上是生活随笔為你收集整理的Linux下 数据文件 效验问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 软件开发人员真的了解SQL索引吗(索引使
- 下一篇: 第一阶段测试计划