日期:2014-05-16  浏览次数:20803 次

锛堣浆杞斤級MySQL鐨刲og-bin鐨勬棩蹇楀姛鑳?

瑁卪ysql,杩愯涓€娈垫椂闂村悗锛屽湪mysql鐩綍涓嬪嚭鐜颁竴鍫嗙被浼糾ysql-bin.000***锛屼粠mysql-bin.000001寮€濮嬩竴鐩存帓鍒椾笅鏉ワ紝鑰屼笖鍗犵敤浜嗗ぇ閲忕‖鐩樼┖闂达紝楂樿揪鍑犲崄涓狦. 瀵逛簬杩欎簺瓒呭ぇ绌洪棿鍗犵敤閲忕殑鏂囦欢鎴戜滑搴旇鎬庝箞鍔炲憿?

閭d箞mysql鏁版嵁搴撴枃浠跺す涓殑mysql-bin.00001鏄粈涔堟枃浠讹紵

mysql-bin.000001銆乵ysql-bin.000002绛夋枃浠舵槸鏁版嵁搴撶殑鎿嶄綔鏃ュ織锛屼緥濡俇PDATE涓€涓〃锛屾垨鑰匘ELETE涓€浜涙暟鎹紝鍗充娇璇ヨ鍙ユ病鏈夊尮閰嶇殑鏁版嵁锛岃繖涓懡浠や篃浼氬瓨鍌ㄥ埌鏃ュ織鏂囦欢涓紝杩樺寘鎷瘡涓鍙ユ墽琛岀殑鏃堕棿锛屼篃浼氳褰曡繘鍘荤殑銆?/div>


杩欎簺褰㈠mysql-bin.00001鐨勬枃浠朵富瑕佹槸鐢ㄦ潵鍋氫粈涔堢殑鍛?

1锛氭暟鎹仮澶?
濡傛灉浣犵殑鏁版嵁搴撳嚭闂浜嗭紝鑰屼綘涔嬪墠鏈夎繃澶囦唤锛岄偅涔堝彲浠ョ湅鏃ュ織鏂囦欢锛屾壘鍑烘槸鍝釜鍛戒护瀵艰嚧浣犵殑鏁版嵁搴撳嚭闂浜嗭紝鎯冲姙娉曟尳鍥炴崯澶便€?

2锛氫富浠庢湇鍔″櫒涔嬮棿鍚屾鏁版嵁
涓绘湇鍔″櫒涓婃墍鏈夌殑鎿嶄綔閮藉湪璁板綍鏃ュ織涓紝浠庢湇鍔″櫒鍙互鏍规嵁璇ユ棩蹇楁潵杩涜锛屼互纭繚涓や釜鍚屾銆?/div>


濡傛灉涓嶆兂瑕佽繖浜涙枃浠跺簲璇ユ€庝箞鍋氬憿?

1锛氬彧鏈変竴涓猰ysql鏈嶅姟鍣紝閭d箞鍙互绠€鍗曠殑娉ㄩ噴鎺夎繖涓€夐」灏辫浜嗐€?
vi /etc/my.cnf鎶婇噷闈㈢殑 log-bin 杩欎竴琛屾敞閲婃帀锛岄噸鍚痬ysql鏈嶅姟鍗冲彲銆?

2锛氬鏋滀綘鐨勭幆澧冩槸涓讳粠鏈嶅姟鍣紝閭d箞灏遍渶瑕佸仛浠ヤ笅鎿嶄綔浜嗐€?
A锛氬湪姣忎釜浠庡睘鏈嶅姟鍣ㄤ笂锛屼娇鐢⊿HOW SLAVE STATUS鏉ユ鏌ュ畠姝e湪璇诲彇鍝釜鏃ュ織銆?
B锛氫娇鐢⊿HOW MASTER LOGS鑾峰緱涓绘湇鍔″櫒涓婄殑涓€绯诲垪鏃ュ織銆?
C锛氬湪鎵€鏈夌殑浠庡睘鏈嶅姟鍣ㄤ腑鍒ゅ畾鏈€鏃╃殑鏃ュ織锛岃繖涓槸鐩爣鏃ュ織锛屽鏋滄墍鏈夌殑浠庡睘鏈嶅姟鍣ㄦ槸鏇存柊鐨勶紝灏辨槸娓呭崟涓婄殑鏈€鍚庝竴涓棩蹇椼€?
D锛氭竻鐞嗘墍鏈夌殑鏃ュ織锛屼絾鏄笉鍖呮嫭鐩爣鏃ュ織锛屽洜涓轰粠鏈嶅姟鍣ㄨ繕瑕佽窡瀹冨悓姝ャ€?/div>



绠€鍗曞湴璇?杩欎簺MySQL鐩綍涓嬬殑褰㈠mysql-bin.000***鐨勬枃浠舵椂MySQL鐨勪簨鍔℃棩蹇椼€?

鍒犻櫎澶嶅埗鏈嶅姟鍣ㄥ凡缁忔嬁璧扮殑binlog鏄畨鍏ㄧ殑锛屼竴鑸潵璇寸綉缁滅姸鍐靛ソ鐨勬椂鍊欙紝淇濈暀鏈€鏂扮殑閭d竴涓冻浠ャ€?

(缂虹偣鏄皢鏃犳硶浣挎暟鎹簱鎭㈠鍏堝墠鐨勭姸鎬?