{"id":143,"date":"2015-03-02T10:25:14","date_gmt":"2015-03-02T01:25:14","guid":{"rendered":"http:\/\/vicsfactory.com\/?p=143"},"modified":"2017-02-01T10:49:19","modified_gmt":"2017-02-01T01:49:19","slug":"%e3%83%a1%e3%82%a4%e3%83%b3%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e3%82%bb%e3%82%ab%e3%83%b3%e3%83%89%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e3%81%ab%e8%87%aa-2","status":"publish","type":"post","link":"https:\/\/vicsfactory.com\/?p=143","title":{"rendered":"\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fc\u306e\u30c7\u30fc\u30bf\u3092\u30bb\u30ab\u30f3\u30c9\u30b5\u30fc\u30d0\u30fc\u306b\u81ea\u52d5\u30d0\u30c3\u30af\u30a2\u30c3\u30d7(MySQL\u7de8)"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>\u6bce\u65e5\u5348\u524d2\u6642\u306b\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fc\u306etest\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30b5\u30fc\u30d0\u30fc\u5185\u3067\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3092\u53d6\u308a\u30012\u664215\u5206\u306b\u3053\u306e\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30c7\u30fc\u30bf\u3092\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u5185\u306e\u30bb\u30ab\u30f3\u30c9\u30b5\u30fc\u30d0\u30fc\u306brsync\u3067\u30b3\u30d4\u30fc\u3057\u3001\u3055\u3089\u306b2\u664230\u5206\u306b\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30c7\u30fc\u30bf\u304b\u3089\u30bb\u30ab\u30f3\u30c9\u30b5\u30fc\u30d0\u30fc\u306etest\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u5fa9\u5143\u3059\u308b\u3002<\/p>\n<p>\u4f8b\uff1a<br \/>\n\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fcIP\u30a2\u30c9\u30ec\u30b9\uff1a192.168.1.100<br \/>\n\u30bb\u30ab\u30f3\u30c9\u30b5\u30fc\u30d0\u30fcIP\u30a2\u30c9\u30ec\u30b9\uff1a192.168.1.200<br \/>\n\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3059\u308b\u30c7\u30fc\u30bf\uff1a<br \/>\n\/var\/lib\/mysql\/test<\/p>\n<p>\u25cf\u6e96\u5099<\/p>\n<p>\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fc\u306b\u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u304b\u3089root\u3067SSH\u30ed\u30b0\u30a4\u30f3\u51fa\u6765\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u304a\u304f\u3002<\/p>\n<p>1.\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fc\u306e\u8a2d\u5b9a<\/p>\n<p>\u25cfMySQL\u30c7\u30fc\u30bf\u3092\u81ea\u52d5\u30d0\u30c3\u30af\u30a2\u30c3\u30d7<\/p>\n<p>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\uff1atest<br \/>\n\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u5148\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\uff1a\/root\/sqlbackup\/<\/p>\n<p>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u5148\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210<br \/>\n# mkdir sqlbackup<\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u81ea\u52d5\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30b9\u30af\u30ea\u30d7\u30c8\u4f5c\u6210<br \/>\n[root@server1 ~]# vi testdump.sh<br \/>\n#! \/bin\/sh<br \/>\nmysqldump test -u root -p\u30d1\u30b9\u30ef\u30fc\u30c9 &#8211;default-character-set=binary &gt; \/root\/sqlbackup\/testdump.sql<\/p>\n<p>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u5b9f\u884c\u6a29\u9650\u4ed8\u4e0e<br \/>\n# chmod 700 testdump.sh<\/p>\n<p>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30b9\u30af\u30ea\u30d7\u30c8\u5b9f\u884c<br \/>\n# .\/testdump.sh<\/p>\n<p>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u78ba\u8a8d<br \/>\n# ls sqlbackup<\/p>\n<p>testdump.sql\u304c\u3042\u308c\u3070OK<\/p>\n<p>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30b9\u30af\u30ea\u30d7\u30c8\u3092cron.d\u306b\u767b\u9332\u3057\u3066\u3001\u6bce\u65e5\u5348\u524d2\u6642\u306b\u81ea\u52d5\u5b9f\u884c<br \/>\n# echo &#8220;0 2 * * * root \/root\/testdump.sh&#8221; &gt; \/etc\/cron.d\/testdump<\/p>\n<p>2.\u30bb\u30ab\u30f3\u30c9\u30b5\u30fc\u30d0\u30fc\u306e\u8a2d\u5b9a<\/p>\n<p>rsync\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3002<br \/>\n# yum install rsync<\/p>\n<p>\u9375\u306e\u4f5c\u6210<br \/>\n# ssh-keygen -t rsa<br \/>\n\u7a7a\u30a8\u30f3\u30bf\u30fc\u00d73\u56de\u3067\u7d42\u4e86<\/p>\n<p>\u516c\u958b\u9375\u3092\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fc\u306b\u30b3\u30d4\u30fc<br \/>\n# scp \/root\/.ssh\/id_rsa.pub root@192.168.1.100:\/root\/<br \/>\nroot@192.168.1.100&#8217;s password:\u3000\u2192\u3000root\u306epassword\u5165\u529b<\/p>\n<p>3.\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fc\u306e\u8a2d\u5b9a<\/p>\n<p>.ssh\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3001\u30b3\u30d4\u30fc\u3055\u308c\u305fid_rsa.pub\u3092authorized_keys\u306b\u30ea\u30cd\u30fc\u30e0<br \/>\n# mkdir .ssh<br \/>\n# cat id_rsa.pub &gt;&gt; \/root\/.ssh\/authorized_keys<\/p>\n<p>authorized_keys\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u306e\u5909\u66f4<br \/>\n# chmod 600 \/root\/.ssh\/authorized_keys<\/p>\n<p>\u4ee5\u4e0a\u3067rsync\u306e\u8a2d\u5b9a\u5b8c\u4e86\u3002<\/p>\n<p>4.\u30bb\u30ab\u30f3\u30c9\u30b5\u30fc\u30d0\u30fc\u306e\u8a2d\u5b9a<\/p>\n<p>\u25cf\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fc\u306etestdump.sql\u3092\u30bb\u30ab\u30f3\u30c9\u30b5\u30fc\u30d0\u30fc\u306b\u81ea\u52d5\u30b3\u30d4\u30fc<\/p>\n<p>\u30b3\u30d4\u30fc\u5148\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4f5c\u6210<br \/>\n# mkdir sqlbackup<\/p>\n<p>\u81ea\u52d5\u30b3\u30d4\u30fc\u30b9\u30af\u30ea\u30d7\u30c8\u4f5c\u6210<br \/>\n# vi testcopy.sh<br \/>\n#! \/bin\/sh<br \/>\nRSYNC=&#8217;rsync -avz -e ssh &#8211;delete&#8217;<br \/>\n$RSYNC 192.168.100.100:\/root\/sqlbackup\/testdump.sql \/root\/sqlbackup\/testdump.sql<\/p>\n<p>\u81ea\u52d5\u30b3\u30d4\u30fc\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u5b9f\u884c\u6a29\u9650\u4ed8\u4e0e<br \/>\n# chmod +x testcopy.sh<\/p>\n<p>\u81ea\u52d5\u30b3\u30d4\u30fc\u30b9\u30af\u30ea\u30d7\u30c8\u5b9f\u884c\u30c6\u30b9\u30c8<br \/>\n# .\/testcopy.sh<\/p>\n<p>\/root\/sqlbackup\/\u306btestdump.sql\u304c\u3042\u308c\u3070OK<\/p>\n<p>\u81ea\u52d5\u30b3\u30d4\u30fc\u30b9\u30af\u30ea\u30d7\u30c8\u81ea\u52d5\u5b9f\u884c\u5316\uff08\u6bce\u65e5\u5348\u524d2\u664215\u5206\u306b\u5b9f\u884c\uff09<br \/>\n# echo &#8220;15 2 * * * root \/root\/testcopy.sh&#8221; &gt; \/etc\/cron.d\/testcopy<\/p>\n<p>\u25cf\u30b3\u30d4\u30fc\u3057\u305f\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30c7\u30fc\u30bf\u3092MySQL\u306b\u81ea\u52d5\u5fa9\u5143<\/p>\n<p>\u81ea\u52d5\u5fa9\u5143\u30b9\u30af\u30ea\u30d7\u30c8\u4f5c\u6210<br \/>\n# vi restore.sh<br \/>\n#! \/bin\/bash<br \/>\nmysql -u root -p\u30d1\u30b9\u30ef\u30fc\u30c9 test &#8211;default-character-set=binary &lt; \/root\/sqlbackup\/testdump.sql<\/p>\n<p>\u81ea\u52d5\u5fa9\u5143\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u5b9f\u884c\u6a29\u9650\u4ed8\u4e0e<br \/>\n# chmod +x restore.sh<\/p>\n<p>\u81ea\u52d5\u5fa9\u5143\u30b9\u30af\u30ea\u30d7\u30c8\u5b9f\u884c\u30c6\u30b9\u30c8<br \/>\n# .\/restore.sh<\/p>\n<p>mysql\u30b3\u30de\u30f3\u30c9\u7b49\u3092\u4f7f\u3063\u3066\u3001\u30b3\u30d4\u30fc\u3057\u305f\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fc\u306eMySQL\u30c7\u30fc\u30bf\u304c\u30bb\u30ab\u30f3\u30c9\u30b5\u30fc\u30d0\u30fc\u306eMySQL\u306b\u5fa9\u5143\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d<\/p>\n<p>\u5fa9\u5143\u30b9\u30af\u30ea\u30d7\u30c8\u81ea\u52d5\u5b9f\u884c\u5316<br \/>\n# echo &#8220;30 2 * * * root \/root\/restore.sh&#8221; &gt; \/etc\/cron.d\/restore<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u6bce\u65e5\u5348\u524d2\u6642\u306b\u30e1\u30a4\u30f3\u30b5\u30fc\u30d0\u30fc\u306etest\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30b5\u30fc\u30d0\u30fc\u5185\u3067\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3092\u53d6\u308a\u30012\u664215\u5206\u306b\u3053\u306e\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30c7\u30fc\u30bf\u3092\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u5185\u306e\u30bb\u30ab\u30f3\u30c9\u30b5\u30fc\u30d0\u30fc\u306brsync\u3067\u30b3\u30d4\u30fc\u3057\u3001\u3055\u3089\u306b2\u664230\u5206\u306b\u30d0\u30c3\u30af\u30a2\u30c3\u30d7 &hellip; <a href=\"https:\/\/vicsfactory.com\/?p=143\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/vicsfactory.com\/index.php?rest_route=\/wp\/v2\/posts\/143"}],"collection":[{"href":"https:\/\/vicsfactory.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vicsfactory.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vicsfactory.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vicsfactory.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=143"}],"version-history":[{"count":4,"href":"https:\/\/vicsfactory.com\/index.php?rest_route=\/wp\/v2\/posts\/143\/revisions"}],"predecessor-version":[{"id":216,"href":"https:\/\/vicsfactory.com\/index.php?rest_route=\/wp\/v2\/posts\/143\/revisions\/216"}],"wp:attachment":[{"href":"https:\/\/vicsfactory.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vicsfactory.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vicsfactory.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}