Linux下 数据文件 效验问题
?
?????? Linux 下,不同服務(wù)器之前的數(shù)據(jù)copy是很常見的操作。 常見的copy命令有scp 和cp。 但是對于一些重要的文件,如數(shù)據(jù)庫的備份文件,在copy之后,我們還需要對copy之后的文件進行一下效驗, 以免在copy過程中的丟失。 造成無法恢復(fù)數(shù)據(jù)。
?
常見的效驗有如下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發(fā)明,經(jīng)MD2、MD3和MD4發(fā)展而來。
Message-Digest泛指字節(jié)串(Message)的Hash變換,就是把一個任意長度的字節(jié)串變換成一定長的大整數(shù)。這種變換只與字節(jié)的值有關(guān),與字符集或編碼方式無關(guān)。
MD5將任意長度的“字節(jié)串”變換成一個128bit的大整數(shù),并且它是一個不可逆的字節(jié)串變換算法,換句話說就是,即使你看到源程序和算法描述,也無法將一個MD5的值變換回原始的字符串,從數(shù)學原理上說,是因為原始的字節(jié)串有無窮多個,這有點象不存在反函數(shù)的數(shù)學函數(shù)。
MD5的典型應(yīng)用是對一段Message(字節(jié)串)產(chǎn)生fingerprint(指紋),以防止被“篡改”。舉個例子,你將一段話寫在一個叫 readme.txt文件中,并對這個readme.txt產(chǎn)生一個MD5的值并記錄在案,然后你可以傳播這個文件給別人,別人如果修改了文件中的任何內(nèi)容,你對這個文件重新計算MD5時就會發(fā)現(xiàn)。如果再有一個第三方的認證機構(gòu),用MD5還可以防止文件作者的“抵賴”,這就是所謂的數(shù)字簽名應(yīng)用。
MD5還廣泛用于加密和解密技術(shù)上,在很多操作系統(tǒng)中,用戶的密碼是以MD5值(或類似的其它算法)的方式保存的, 用戶Login的時候,系統(tǒng)是把用戶輸入的密碼計算成MD5值,然后再去和系統(tǒng)中保存的MD5值進行比較,而系統(tǒng)并不“知道”用戶的密碼是什么。
一些黑客破獲這種密碼的方法是一種被稱為“跑字典”的方法。有兩種方法得到字典,一種是日常搜集的用做密碼的字符串表,另一種是用排列組合方法生成的,先用MD5程序計算出這些字典項的MD5值,然后再用目標的MD5值在這個字典中檢索。
即使假設(shè)密碼的最大長度為8,同時密碼只能是字母和數(shù)字,共26+26+10=62個字符,排列組合出的字典的項數(shù)則是P(62,1)+P (62,2)….+P(62,8),那也已經(jīng)是一個很天文的數(shù)字了,存儲這個字典就需要TB級的磁盤組,而且這種方法還有一個前提,就是能獲得目標賬戶的密碼MD5值的情況下才可以。
?
2.2 一個簡單的演示:
?
[root@singledb backup]# which md5sum
/usr/bin/md5sum
?
創(chuàng)建一個文件
[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
?
他們的值不一樣了,從這個值,可以判斷文件有沒有變化。
?
關(guān)于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
網(wǎng)上資源: http://tianlesoftware.download.csdn.net
相關(guān)視頻:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx
DBA1 群:62697716(滿); DBA2 群:62697977(滿)
DBA3 群:62697850?? DBA 超級群:63306533;????
聊天 群:40132017
--加群需要在備注說明Oracle表空間和數(shù)據(jù)文件的關(guān)系,否則拒絕申請
轉(zhuǎn)載于:https://www.cnblogs.com/tianlesoftware/archive/2010/12/22/3609864.html
總結(jié)
以上是生活随笔為你收集整理的Linux下 数据文件 效验问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 软件开发人员真的了解SQL索引吗(索引使
- 下一篇: 第一阶段测试计划