當前位置:首頁 » 安全設置 » 如何設置自動同步網路
擴展閱讀
qq密碼保護電腦 2024-11-24 19:07:00

如何設置自動同步網路

發布時間: 2024-10-07 08:56:43

㈠ 鐢佃剳緗戠粶鍚屾ュ備綍璁劇疆

銆涓銆佸噯澶囨湇鍔″櫒

銆銆鐢變簬MySQL涓嶅悓鐗堟湰涔嬮棿鐨(浜岃繘鍒舵棩蹇)binlog鏍煎紡鍙鑳戒細涓嶄竴鏍鳳紝鍥犳ゆ渶濂界殑鎼閰嶇粍鍚堟槸Master鐨凪ySQL鐗堟湰鍜孲lave鐨勭増鏈鐩稿悓鎴栬呮洿浣庯紝Master鐨勭増鏈鑲瀹氫笉鑳介珮浜嶴lave鐗堟湰銆

銆銆鏈鏂囦腑錛屾垜浠鍋囪句富鏈嶅姟鍣(浠ヤ笅綆縐癕aster)鍜屼粠鏈嶅姟鍣(浠ヤ笅綆縐癝lave)鐨勭増鏈閮芥槸5.0.15錛屾搷浣滅郴緇熸槸Linux Ubuntu 5.0.x銆

銆銆鍋囪懼悓姝Master鐨勪富鏈哄悕涓猴細rep1錛孲lave涓繪満鍚嶄負錛歳ep2錛2涓狹ySQL鐨刡asedir鐩褰曢兘鏄/usr/local/mysql錛宒atadir閮芥槸錛/usr/local/MySQL/data銆

銆銆浜屻佽劇疆鍚屾ユ湇鍔″櫒

銆銆1銆佽劇疆鍚屾Master

銆銆姣忎釜鍚屾ユ湇鍔″櫒閮藉繀欏昏懼畾涓涓鍞涓鐨勭紪鍙鳳紝鍚﹀垯鍚屾ュ氨涓嶈兘姝e父榪愯屼簡銆傛帴涓嬫潵寮濮嬩慨鏀 my.cnf錛屽炲姞浠ヤ笅鍑犺岋細

銆銆server-id = 1

銆銆log-bin

銆銆set-variable=binlog-ignore-db=MySQL

銆銆鐒跺悗鍦∕aster涓婂炲姞涓涓璐﹀彿涓撻棬鐢ㄤ簬鍚屾ワ紝濡備笅錛

銆銆MySQL>GRANT REPLICATION SLAVE ON *.* TO rep@rep2 IDENTIFIED BY 'rep';

銆銆濡傛灉鎯寵佸湪Slave涓婃湁鏉冮檺鎵ц "LOAD TABLE FROM MASTER" 鎴 "LOAD DATA FROM MASTER" 璇鍙ョ殑璇濓紝蹇呴』鎺堜簣鍏ㄥ矓鐨 FILE 鍜 SELECT 鏉冮檺錛

銆銆MySQL>GRANT FILE,SELECT,REPLICATION SLAVE ON *.* TO rep@rep2 IDENTIFIED BY 'rep';

銆銆絎涓夎岃〃紺轟笉璁板綍鏁版嵁搴揗ySQL鐨勬洿鏂版棩蹇楋紝榪欏氨閬垮厤浜哅aster涓婄殑鏉冮檺璁劇疆絳夎鍚屾ュ埌Slave涓婏紝濡傛灉瀵硅繖鏂歸潰娌℃湁闄愬埗錛屽氨鍙浠ヤ笉璁劇疆榪欎釜鍙傛暟銆

銆銆鎺ヤ笅鏉ュ囦喚Master涓婄殑鏁版嵁錛岄栧厛鎵ц屽備笅SQL璇鍙ワ細

銆銆MySQL>FLUSH TABLES WITH READ LOCK;

銆銆涓嶈侀鍑鴻繖涓緇堢錛屽惁鍒欒繖涓閿佸氨涓嶇敓鏁堜簡錛涙帴鐫瀵煎嚭鏁版嵁錛屽彲浠ョ洿鎺ユ墦鍖呭帇緙╂暟鎹鏂囦歡錛屼篃鍙浠ヤ嬌鐢∕ySQLmp宸ュ叿鏉ュ仛錛屾帹鑽愬墠鑰呯殑鏂規硶錛岃繖鏍鋒洿涓哄揩鎹風畝渚褲

銆銆root$cd /usr/local/MySQL

銆銆root$tar zcf data.tar.gz ./data (鍦ㄨ繖閲屼篃鍙鑳芥槸 "var" 絳夊叾瀹冨疄闄呭瓨鏀炬暟鎹鏂囦歡鐨勭洰褰曪紝鏍規嵁瀹炴儏鑰屽畾)

銆銆鐒跺悗灝嗚繖浜涙暟鎹鎷瘋礉鍒癝lave鏈嶅姟鍣ㄤ笂錛岃В寮錛岃劇疆濂芥g『鐨勬潈闄愬強灞炰富絳夛紱涔嬪悗錛屾墽琛 "UNLOCK TABLES" 璇鍙ユ潵閲婃斁閿併

銆銆2銆佽劇疆Slave

銆銆淇鏀筸y.cnf錛屽炲姞濡備笅鍑犺岋細

銆銆server-id = 2

銆銆master-host = rep1 #涓繪湇鍔″櫒鍚

銆銆master-user = rep #鍚屾ヨ處鎴峰悕錛岄粯璁ゆ槸test

銆銆master-password = rep #鍚屾ュ笎鎴峰瘑鐮侊紝榛樿ゆ槸絀

銆銆master-port = 3306 #涓繪湇鍔″櫒鐨 TCP/IP 絝鍙e彿錛岄粯璁ゆ槸3306

銆銆set-variable=replicate-ignore-db=MySQL #鐣ヨ繃鍚屾ョ殑鏁版嵁搴撳悕錛屽傛灉鏈夊氫釜錛岃瘋劇疆澶氭

銆銆set-variable=replicate-do-db=yejr #鎯寵佸悓姝ョ殑鏁版嵁搴撳悕錛屽傛灉鏈夊氫釜錛岃瘋劇疆澶氭

銆銆鎺ヤ笅鏉ュ湪Slave涓婃楠屼竴涓嬫槸鍚﹁兘姝g『榪炴帴鍒癕aster涓婏紝騫朵笖鍏峰囩浉搴旂殑鏉冮檺銆

銆銆root$MySQL -hrep1 -urep -prep

銆銆MySQL>SHOW GRANTS;

銆銆+------------------------------------------------- --------------------------------------------------- ----------------------------------+

銆銆 Grants for rep@rep2

銆銆+------------------------------------------------- --------------------------------------------------- ----------------------------------+

銆銆 GRANT SELECT, FILE, REPLICATION SLAVE ON *.* TO 'rep'@'rep2' IDENTIFIED BY PASSWORD '*'

銆銆+------------------------------------------------- --------------------------------------------------- ----------------------------------+

銆銆鐜板湪錛屽彲浠ュ惎鍔⊿lave浜嗐傚惎鍔ㄦ垚鍔熷悗錛岀櫥褰昐lave錛屾煡鐪嬩竴涓嬪悓姝ョ姸鎬侊細

銆銆MySQL -hlocalhost -uroot

銆銆MySQL>SHOW SLAVE STATUS\G

銆銆*************************** 1. row ***************************

銆銆Slave_IO_State: Waiting for master to send event

銆銆Master_Host: rep1

銆銆Master_User: rep

銆銆Master_Port: 3306

銆銆Connect_Retry: 60

銆銆Master_Log_File: binlog.000001

銆銆Read_Master_Log_Pos: 98

銆銆Relay_Log_File: relay.000003

銆銆Relay_Log_Pos: 232

銆銆Relay_Master_Log_File: binlog.000001

銆銆Slave_IO_Running: Yes

銆銆Slave_SQL_Running: Yes

銆銆Replicate_Do_DB:

銆銆Replicate_Ignore_DB:

銆銆Replicate_Do_Table:

銆銆Replicate_Ignore_Table:

銆銆Replicate_Wild_Do_Table:

銆銆Replicate_Wild_Ignore_Table:

銆銆Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 98 Relay_Log_Space: 232 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 1 row in set (0.00 sec) 鍙浠ョ湅鍒幫紝Slave_IO_Running 鍜 Slave_SQL_Running 涓ゅ垪鐨勫奸兘涓 "Yes"錛岃繖琛ㄦ槑 Slave 鐨 I/O 鍜 SQL 綰跨▼閮藉湪姝e父榪愯屻

銆銆鑷蟲わ紝鍚屾ヨ懼畾鎴愬姛銆
璋㈣阿鍙傝

怎麼設置電腦時間自動同步網路時間

點開電腦右下角的時間,裡面有個Internet時間,裡面有個自動同步,前面小方框勾選,確定即可