{"id":2994,"date":"2014-03-02T06:24:06","date_gmt":"2014-03-02T06:24:06","guid":{"rendered":"http:\/\/blog.hmouse.tk\/?p=2994"},"modified":"2015-07-15T18:20:57","modified_gmt":"2015-07-15T10:20:57","slug":"mysql%e9%97%ae%e9%a2%98%e9%9b%86%e9%94%a6","status":"publish","type":"post","link":"https:\/\/www.hmouse.cn\/?p=2994","title":{"rendered":"mysql\u95ee\u9898\u96c6\u9526"},"content":{"rendered":"<p>&nbsp;<\/p>\n<\/p>\n<style type=\"text\/css\"><!--\nbody{\n    margin: 0 auto;\n    font-family: georgia, palatino, serif;\n    color: #444444;\n    line-height: 1;\n    max-width: 960px;\n    padding: 5px;\n}\nh1, h2, h3, h4 {\n    color: #111111;\n    font-weight: 400;\n}\nh1, h2, h3, h4, h5, p {\n    margin-bottom: 16px;\n    padding: 0;\n}\nh1 {\n    font-size: 28px;\n}\nh2 {\n    font-size: 22px;\n    margin: 20px 0 6px;\n}\nh3 {\n    font-size: 21px;\n}\nh4 {\n    font-size: 18px;\n}\nh5 {\n    font-size: 16px;\n}\na {\n    color: #0099ff;\n    margin: 0;\n    padding: 0;\n    vertical-align: baseline;\n}\na:hover {\n    text-decoration: none;\n    color: #ff6600;\n}\na:visited {\n    color: purple;\n}\nul, ol {\n    padding: 0;\n    margin: 0;\n}\nli {\n    line-height: 24px;\n    margin-left: 44px;\n}\nli ul, li ul {\n    margin-left: 24px;\n}\np, ul, ol {\n    font-size: 14px;\n    line-height: 20px;\n    max-width: 540px;\n}\npre {\n    padding: 0px 24px;\n    max-width: 800px;\n    white-space: pre-wrap;\n}\ncode {\n    font-family: consolas, monaco, andale mono, monospace;\n    line-height: 1.5;\n    font-size: 13px;\n}\naside {\n    display: block;\n    float: right;\n    width: 390px;\n}\nblockquote {\n    border-left:.5em solid #eee;\n    padding: 0 2em;\n    margin-left:0;\n    max-width: 476px;\n}\nblockquote  cite {\n    font-size:14px;\n    line-height:20px;\n    color:#bfbfbf;\n}\nblockquote cite:before {\n    content: '2014 \ufffd0A0';\n}\n\nblockquote p {  \n    color: #666;\n    max-width: 460px;\n}\nhr {\n    width: 540px;\n    text-align: left;\n    margin: 0 auto 0 0;\n    color: #999;\n}\n\nbutton,\ninput,\nselect,\ntextarea {\n  font-size: 100%;\n  margin: 0;\n  vertical-align: baseline;\n  *vertical-align: middle;\n}\nbutton, input {\n  line-height: normal;\n  *overflow: visible;\n}\nbutton::-moz-focus-inner, input::-moz-focus-inner {\n  border: 0;\n  padding: 0;\n}\nbutton,\ninput[type=\"button\"],\ninput[type=\"reset\"],\ninput[type=\"submit\"] {\n  cursor: pointer;\n  -webkit-appearance: button;\n}\ninput[type=checkbox], input[type=radio] {\n  cursor: pointer;\n}\n\/* override default chrome &#038; firefox settings *\/\ninput:not([type=\"image\"]), textarea {\n  -webkit-box-sizing: content-box;\n  -moz-box-sizing: content-box;\n  box-sizing: content-box;\n}\n\ninput[type=\"search\"] {\n  -webkit-appearance: textfield;\n  -webkit-box-sizing: content-box;\n  -moz-box-sizing: content-box;\n  box-sizing: content-box;\n}\ninput[type=\"search\"]::-webkit-search-decoration {\n  -webkit-appearance: none;\n}\nlabel,\ninput,\nselect,\ntextarea {\n  font-family: \"Helvetica Neue\", helvetica, arial, sans-serif;\n  font-size: 13px;\n  font-weight: normal;\n  line-height: normal;\n  margin-bottom: 18px;\n}\ninput[type=checkbox], input[type=radio] {\n  cursor: pointer;\n  margin-bottom: 0;\n}\ninput[type=text],\ninput[type=password],\ntextarea,\nselect {\n  display: inline-block;\n  width: 210px;\n  padding: 4px;\n  font-size: 13px;\n  font-weight: normal;\n  line-height: 18px;\n  height: 18px;\n  color: #808080;\n  border: 1px solid #ccc;\n  -webkit-border-radius: 3px;\n  -moz-border-radius: 3px;\n  border-radius: 3px;\n}\nselect, input[type=file] {\n  height: 27px;\n  line-height: 27px;\n}\ntextarea {\n  height: auto;\n}\n\n\/* grey out placeholders *\/\n:-moz-placeholder {\n  color: #bfbfbf;\n}\n::-webkit-input-placeholder {\n  color: #bfbfbf;\n}\n\ninput[type=text],\ninput[type=password],\nselect,\ntextarea {\n  -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;\n  -moz-transition: border linear 0.2s, box-shadow linear 0.2s;\n  transition: border linear 0.2s, box-shadow linear 0.2s;\n  -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\n  -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\n  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\n}\ninput[type=text]:focus, input[type=password]:focus, textarea:focus {\n  outline: none;\n  border-color: rgba(82, 168, 236, 0.8);\n  -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\n  -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\n  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\n}\n\n\/* buttons *\/\nbutton {\n  display: inline-block;\n  padding: 4px 14px;\n  font-family: \"Helvetica Neue\", helvetica, arial, sans-serif;\n  font-size: 13px;\n  line-height: 18px;\n  -webkit-border-radius: 4px;\n  -moz-border-radius: 4px;\n  border-radius: 4px;\n  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\n  -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\n  background-color: #0064cd;\n  background-repeat: repeat-x;\n  background-image: -khtml-gradient(linear, left top, left bottom, from(#049cdb), to(#0064cd));\n  background-image: -moz-linear-gradient(top, #049cdb, #0064cd);\n  background-image: -ms-linear-gradient(top, #049cdb, #0064cd);\n  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #049cdb), color-stop(100%, #0064cd));\n  background-image: -webkit-linear-gradient(top, #049cdb, #0064cd);\n  background-image: -o-linear-gradient(top, #049cdb, #0064cd);\n  background-image: linear-gradient(top, #049cdb, #0064cd);\n  color: #fff;\n  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);\n  border: 1px solid #004b9a;\n  border-bottom-color: #003f81;\n  -webkit-transition: 0.1s linear all;\n  -moz-transition: 0.1s linear all;\n  transition: 0.1s linear all;\n  border-color: #0064cd #0064cd #003f81;\n  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);\n}\nbutton:hover {\n  color: #fff;\n  background-position: 0 -15px;\n  text-decoration: none;\n}\nbutton:active {\n  -webkit-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\n  -moz-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\n  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\n}\nbutton::-moz-focus-inner {\n  padding: 0;\n  border: 0;\n}\n\n\/* CSS stylesheet is based on Kevin Burke's Markdown.css project (http:\/\/kevinburke.bitbucket.org\/markdowncss) *\/\n--><\/style>\n<p>&nbsp;<\/p>\n<h6>################################mysql<\/h6>\n<p>\u4e3b\u5907\u6570\u636e\u5e93<br \/>http:\/\/www.cnblogs.com\/hustcat\/archive\/2009\/12\/19\/1627525.html<\/p>\n<p>SET PASSWORD FOR &#8216;root&#8217;@&#8217;localhost&#8217; = PASSWORD(&#8216;ceshi160&#8217;);<br \/>GRANT REPLICATION SLAVE, REPLICATION CLIENT ON <em>.<\/em> TO repl@&#8217;192.168.0.%&#8217; IDENTIFIED BY &#8216;ceshi160&#8217;;<br \/>grant all privileges on cmm.* to &#8216;cmmw&#8217;@&#8217;192.168.0.%&#8217; identified by &#8216;cmmw123&#8217;;<br \/>grant select on cmm.* to &#8216;cmmr&#8217;@&#8217;192.168.0.%&#8217; identified by &#8216;cmmr123&#8217;;<br \/>flush privileges;<\/p>\n<p>grant select on <em>.<\/em> to &#8216;monitor&#8217;@&#8217;192.168.30.21&#8217; identified by &#8216;monitor&#8217;;<br \/>flush privileges;<\/p>\n<p>grant all privileges on <em>.<\/em> to &#8216;monitor&#8217;@&#8217;192.168.30.21&#8217; identified by &#8216;monitor&#8217;;<br \/>flush privileges;<\/p>\n<p>Starting MySQL (Percona Server). ERROR! The server quit without updating PID file (\/data\/mysqldata\/localhost.localdomain.pid).<br \/>google\u4e86\u4e0b \uff0c\u95ee\u9898\u53ef\u80fd\u7684\u539f\u56e0\u6709\u591a\u79cd\uff0c\u5177\u4f53\u4ec0\u4e48\u539f\u56e0\u6700\u597d\u7684\u529e\u6cd5\u662f\u5148\u67e5\u770b\u4e0b\u9519\u8bef\u65e5\u5fd7\uff1a<\/p>\n<p>1.\u53ef\u80fd\u662f\/usr\/local\/mysql\/data\/rekfan.pid\u6587\u4ef6\u6ca1\u6709\u5199\u7684\u6743\u9650<br \/>\u89e3\u51b3\u65b9\u6cd5 \uff1a\u7ed9\u4e88\u6743\u9650\uff0c\u6267\u884c \u201cchown -R mysql:mysql \/var\/data\u201d \u201cchmod -R 755 \/usr\/local\/mysql\/data\u201d \u7136\u540e\u91cd\u65b0\u542f\u52a8mysqld\uff01<\/p>\n<p>2.\u53ef\u80fd\u8fdb\u7a0b\u91cc\u5df2\u7ecf\u5b58\u5728mysql\u8fdb\u7a0b<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u7528\u547d\u4ee4\u201cps -ef|grep mysqld\u201d\u67e5\u770b\u662f\u5426\u6709mysqld\u8fdb\u7a0b\uff0c\u5982\u679c\u6709\u4f7f\u7528\u201ckill -9 \u8fdb\u7a0b\u53f7\u201d\u6740\u6b7b\uff0c\u7136\u540e\u91cd\u65b0\u542f\u52a8mysqld\uff01<\/p>\n<p>3.\u53ef\u80fd\u662f\u7b2c\u4e8c\u6b21\u5728\u673a\u5668\u4e0a\u5b89\u88c5mysql\uff0c\u6709\u6b8b\u4f59\u6570\u636e\u5f71\u54cd\u4e86\u670d\u52a1\u7684\u542f\u52a8\u3002<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u53bbmysql\u7684\u6570\u636e\u76ee\u5f55\/data\u770b\u770b\uff0c\u5982\u679c\u5b58\u5728mysql-bin.index\uff0c\u5c31\u8d76\u5feb\u628a\u5b83\u5220\u9664\u6389\u5427\uff0c\u5b83\u5c31\u662f\u7f6a\u9b41\u7978\u9996\u4e86\u3002\u672c\u4eba\u5c31\u662f\u4f7f\u7528\u7b2c\u4e09\u6761\u65b9\u6cd5\u89e3\u51b3\u7684 \uff01http:\/\/blog.rekfan.com\/?p=186<\/p>\n<p><!--more-->4.mysql\u5728\u542f\u52a8\u65f6\u6ca1\u6709\u6307\u5b9a\u914d\u7f6e\u6587\u4ef6\u65f6\u4f1a\u4f7f\u7528\/etc\/my.cnf\u914d\u7f6e\u6587\u4ef6\uff0c\u8bf7\u6253\u5f00\u8fd9\u4e2a\u6587\u4ef6\u67e5\u770b\u5728[mysqld]\u8282\u4e0b\u6709\u6ca1\u6709\u6307\u5b9a\u6570\u636e\u76ee\u5f55(datadir)\u3002<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u8bf7\u5728[mysqld]\u4e0b\u8bbe\u7f6e\u8fd9\u4e00\u884c\uff1adatadir = \/usr\/local\/mysql\/data <\/p>\n<p>5.skip-federated\u5b57\u6bb5\u95ee\u9898<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u68c0\u67e5\u4e00\u4e0b\/etc\/my.cnf\u6587\u4ef6\u4e2d\u6709\u6ca1\u6709\u6ca1\u88ab\u6ce8\u91ca\u6389\u7684skip-federated\u5b57\u6bb5\uff0c\u5982\u679c\u6709\u5c31\u7acb\u5373\u6ce8\u91ca\u6389\u5427\u3002<\/p>\n<p>6.\u9519\u8bef\u65e5\u5fd7\u76ee\u5f55\u4e0d\u5b58\u5728<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u4f7f\u7528\u201cchown\u201d \u201cchmod\u201d\u547d\u4ee4\u8d4b\u4e88mysql\u6240\u6709\u8005\u53ca\u6743\u9650<\/p>\n<p>7.selinux\u60f9\u7684\u7978\uff0c\u5982\u679c\u662fcentos\u7cfb\u7edf\uff0c\u9ed8\u8ba4\u4f1a\u5f00\u542fselinux<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u5173\u95ed\u5b83\uff0c\u6253\u5f00\/etc\/selinux\/config\uff0c\u628aSELINUX=enforcing\u6539\u4e3aSELINUX=disabled\u540e\u5b58\u76d8\u9000\u51fa\u91cd\u542f\u673a\u5668\u8bd5\u8bd5\u3002<\/p>\n<p>mysql MYI\u6587\u4ef6\u4e22\u5931\u5982\u4f55\u4fee\u590d [\u590d\u5236\u94fe\u63a5]<\/p>\n<p>MYI \u6587\u4ef6\u662f\u7d22\u5f15\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u5373\u4f7f\u662f\u5220\u9664\u4e86\uff0c\u8fd8\u53ef\u4ee5\u6839\u636eMYD\u4ee5\u53cafrm\u6587\u4ef6\u6765\u6062\u590d\u3002<br \/>\u6240\u4ee5\uff0c\u5f53\u4f60\u5907\u4efd\u6570\u636e\u5e93\u65f6\uff0c\u5982\u679c\u60f3\u7701\u7a7a\u95f4\uff0c\u90a3\u4e48\u5c31\u53bb\u6389*MYI\u5427\u3002<br \/>MYI\u6062\u590d\u53ef\u4ee5\u8fd9\u6837\u64cd\u4f5c\uff1a<br \/>\u9996\u5148\u8fdb\u5165mysql\u547d\u4ee4\u884c<br \/>\u6267\u884c\u547d\u4ee4<br \/>mysql&gt; repair table tablename USE_FRM;<br \/>\u590d\u5236\u4ee3\u7801<br \/>\u8fd9\u6837\u5c31\u53ef\u4ee5\u6062\u590dMYI\u6587\u4ef6\u4e86\u3002<\/p>\n<p>mysql Copying to tmp table \u6162<br \/>\u54e6\uff0c\u539f\u6765\u662f\u8fd9\u6837\u7684\uff0c\u5982\u679c\u67e5\u8be2\u8d85\u51fa\u4e86tmp<em>table<\/em>size\u7684\u9650\u5236\uff0c\u90a3\u4e48mysql\u7528\/tmp\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\uff0c\u7136\u540e\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002<br \/>set global tmp<em>table<\/em>size=509715200 (500M)<\/p>\n<p>mysql \u5361\u6b7b \u5927\u90e8\u5206\u7ebf\u7a0b\u957f\u65f6\u95f4\u5904\u4e8esending data\u7684\u72b6\u6001<br \/>\u628aquery_cache\u51cf\u5c0f\u5230\u9ed8\u8ba4\u503c 16M\uff0c\u628a\u4e00\u4e9b\u4e0d\u600e\u4e48\u53d8\u52a8\u7684\u6570\u636e\uff0c\u505a\u4e86\u9759\u6001\u5316\u3002\u60ca\u5947\u7684\u53d1\u73b0\uff0c12\u5929\u8fc7\u53bb\u4e86\uff0c\u6ca1\u518d\u51fa\u8fc7\u95ee\u9898&#8230;&#8230;<\/p>\n<p>\u4fee\u590d\u8868<br \/>mysql&gt; REPAIR TABLE mytable;<\/p>\n<p>\u547d\u4ee4\u6765\u4fee\u590d<br \/>mysqlcheck -A -r -c -p<\/p>\n<p>\u4e3b\u7ad9\u6ce8\u518c\u95ee\u9898<br \/>grant all privileges on livehelp_host.* to &#8216;flashchat&#8217;@&#8217;216.158.78.234&#8217; identified by &#8216;dj7ad62zz&#8217;;<\/p>\n<p>ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log<\/p>\n<p>\u5728\u53e6\u5916\u4e00\u53f0\u4e0a\u6267\u884c\u4e5f\u662f\u4e00\u6837\u63d0\u793a\u8fd9\u4e2a\u9519\u8bef\u3002 \u7f51\u4e0a\u67e5\u4e86\u4e00\u4e9b\u8d44\u6599\uff0c\u53d1\u73b0\u5927\u6982\u6709\u4e24\u79cd\u65b9\u6cd5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c1.\u662f\u6e05\u7406mysql\u7684\u76f8\u5173\u65e5\u5fd7\uff1b2.\u662freset slave \uff1b\u4f46\u662f\u6e05\u7406\u65e5\u5fd7\u7684\u65b9\u6cd5\u6709\u70b9\u590d\u6742\uff0c\u4f7f\u7528\u7b2c2\u79cd\u65b9\u6cd5\u6bd4\u8f83\u65b9\u4fbf\u3002<\/p>\n<p>mysql&gt; slave stop;<\/p>\n<p>mysql&gt; reset slave;<\/p>\n<p>mysql&gt; change master to master<em>host=&#8217;172.17.2.10&#8242;,master<\/em>user=&#8217;sync&#8217;,master<em>password=&#8217;123456&#8242;,master<\/em>log<em>file=&#8217;updatelog.000004&#8242;,master<\/em>log_pos=106;<\/p>\n<p>mysql&gt; slave start;<\/p>\n<p>\u53e6\u5916\u4e00\u53f0\u4e5f\u6309\u7167\u8fd9\u79cd\u65b9\u6cd5\u6267\u884c\uff0c\u8f7b\u677e\u641e\u5b9a\u3002\u914d\u7f6e\u5b8c\u6210\u67e5\u770bmysql\u4e3b\u4ece\u540c\u6b65\u72b6\u6001\u6b63\u5e38\uff01<\/p>\n<p>&#8216;Could not find first log file name in binary log index file&#8217; from master when reading data from binary log<\/p>\n<p>\u56e0\u4e3a\u540c\u6b65\u7684bin-log \u6709\u95ee\u9898<\/p>\n<p>\u5148\u505c\u6b62slave \u7684 \u540c\u6b65<\/p>\n<p>stop slave;<\/p>\n<p>\u67e5\u770b\u4e3b\u5e93\u7684\u72b6\u6001<\/p>\n<p>show master status;<br \/>flush logs;<\/p>\n<p>\u518d\u6b21 show master status;<\/p>\n<p>mysql&gt; mysql&gt; show master status;<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>| File | Position | Binlog<em>Do<\/em>DB | Binlog<em>Ignore<\/em>DB |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>| mysql-bin.000256 | 284 | 123flashchat4 | |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>1 row in set (0.00 sec)<\/p>\n<p>\u4ece\u5e93 \u6839\u636e\u8fd9\u4e2a\u4fe1\u606f\u53bb\u540c\u6b65<\/p>\n<p>CHANGE MASTER TO MASTER_HOST=&#8217;216.158.73.10&#8242;,<\/p>\n<pre><code>MASTER_USER='repl',\n\nMASTER_PASSWORD='topcmm888',\n\nMASTER_LOG_FILE='mysql-bin.000256',\n<\/code><\/pre>\n<p>MASTER<em>LOG<\/em>POS=284;<\/p>\n<p>show slave status G<br \/>\u5373\u53ef<\/p>\n<p>\u663e\u793a\u8be6\u7ec6\u4fe1\u606f<br \/>show variables;<\/p>\n<p>\u64cd\u4f5c\u65e5\u5fd7\uff1a<br \/>http:\/\/www.cnblogs.com\/cocos\/archive\/2010\/12\/22\/1913557.html<\/p>\n<p>mysql \u89e3\u51b3\u4e00\u4e2a\u5947\u602a\u7684\u95ee\u9898\uff0c\u8be6\u89c1\u6b63\u6587 2013-05-09 10:23:17<br \/>\u5206\u7c7b\uff1a Mysql\/postgreSQL<br \/>\u9519\u8bef\u65e5\u5fd7\u62a5\u9519\u5982\u4e0b\uff1a<\/p>\n<p>130508 16:30:53 mysqld<em>safe Starting mysqld daemon with databases from \/data\/mysql<br \/>130508 16:30:54 [Warning] The syntax &#8216;&#8211;log-slow-queries&#8217; is deprecated and will be removed in a future release. Please use &#8216;&#8211;slow-query-log&#8217;\/&#8217;&#8211;slow-query-log-file&#8217; instead.<br \/>130508 16:30:54 InnoDB: The InnoDB memory heap is disabled<br \/>130508 16:30:54 InnoDB: Mutexes and rw<\/em>locks use GCC atomic builtins<br \/>130508 16:30:54 InnoDB: Compressed tables use zlib 1.2.3<br \/>130508 16:30:54 InnoDB: Initializing buffer pool, size = 500.0M<br \/>130508 16:30:54 InnoDB: Completed initialization of buffer pool<br \/>130508 16:30:54 InnoDB: highest supported file format is Barracuda.<br \/>InnoDB: Log scan progressed past the checkpoint lsn 27219795678<br \/>130508 16:30:54 InnoDB: Database was not shut down normally!<br \/>InnoDB: Starting crash recovery.<br \/>InnoDB: Reading tablespace information from the .ibd files&#8230;<br \/>InnoDB: Restoring possible half-written data pages from the doublewrite<br \/>InnoDB: buffer&#8230;<br \/>InnoDB: Doing recovery: scanned up to log sequence number 27219928522<br \/>InnoDB: Error: tried to read 16384 bytes at offset 0 3473408.<br \/>InnoDB: Was only able to read 8192.<br \/>InnoDB: Fatal error: cannot read from file. OS error number 17.<br \/>130508 16:31:05 InnoDB: Assertion failure in thread 47198419330368 in file os0file.c line 2523<br \/>InnoDB: We intentionally generate a memory trap.<br \/>InnoDB: Submit a detailed bug report to http:\/\/bugs.mysql.com.<br \/>InnoDB: If you get repeated assertion failures or crashes, even<br \/>InnoDB: immediately after the mysqld startup, there may be<br \/>InnoDB: corruption in the InnoDB tablespace. Please refer to<br \/>InnoDB: http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/forcing-innodb-recovery.html<br \/>InnoDB: about forcing recovery.<br \/>08:31:05 UTC &#8211; mysqld got signal 6 ;<br \/>This could be because you hit a bug. It is also possible that this binary<br \/>or one of the libraries it was linked against is corrupt, improperly built,<br \/>or misconfigured. This error can also be caused by malfunctioning hardware.<br \/>We will try our best to scrape up some info that will hopefully help<br \/>diagnose the problem, but since we have already crashed,<br \/>something is definitely wrong and this may fail.<br \/>key<em>buffer<\/em>size=16777216<br \/>read<em>buffer<\/em>size=1048576<br \/>max<em>used<\/em>connections=0<br \/>max<em>threads=500<br \/>thread<\/em>count=0<br \/>connection<em>count=0<br \/>It is possible that mysqld could use up to<br \/>key<\/em>buffer<em>size + (read<\/em>buffer<em>size + sort<\/em>buffer<em>size)*max<\/em>threads = 1046083 K bytes of memory<br \/>Hope that&#8217;s ok; if not, decrease some variables in the equation.<br \/>Thread pointer: 0x0<br \/>Attempting backtrace. You can use the following information to find out<br \/>where mysqld died. If you see no messages after this, something went<br \/>terribly wrong&#8230;<br \/>stack<em>bottom = 0 thread<\/em>stack 0x40000<br \/>\/usr\/local\/mysql\/bin\/mysqld(my<em>print<\/em>stacktrace+0x2e)[0x76a3ee]<br \/>\/usr\/local\/mysql\/bin\/mysqld(handle<em>fatal<\/em>signal+0x386)[0x655046]<br \/>\/lib64\/libpthread.so.0[0x3fade0ebe0]<br \/>\/lib64\/libc.so.6(gsignal+0x35)[0x3fad630265]<br \/>\/lib64\/libc.so.6(abort+0x110)[0x3fad631d10]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x85bfc4]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x822641]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x801597]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x801a4f]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x7f4240]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x7c5c40]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x7c5fa2]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x7c7727]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x7b61b6]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x78787a]<br \/>\/usr\/local\/mysql\/bin\/mysqld(<em>Z24ha<\/em>initialize<em>handlertonP13st<\/em>plugin<em>int+0x41)[0x657231]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x56714b]<br \/>\/usr\/local\/mysql\/bin\/mysqld(<\/em>Z11plugin<em>initPiPPci+0xa42)[0x567d12]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x4f21b2]<br \/>\/usr\/local\/mysql\/bin\/mysqld(<\/em>Z11mysqld<em>mainiPPc+0x865)[0x4f4ec5]<br \/>\/lib64\/libc.so.6(<\/em><em>libc<\/em>start<em>main+0xf4)[0x3fad61d994]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x4ed769]<br \/>The manual page at http:\/\/dev.mysql.com\/doc\/mysql\/en\/crashing.html contains<br \/>information that should help you find out what is causing the crash.<br \/>130508 16:31:05 mysqld<\/em>safe mysqld from pid file \/data\/mysql\/log\/scaner.pid ended<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a<br \/>\u5220\u9664\u6389<br \/>ibdata* ,<br \/>ib_logfile* ,<br \/>\u6240\u6709\u7684\u65e5\u5fd7\u3002 \uff08\u8fd9\u4e2a\u53ef\u4ee5\u4e0d\u5220\u9664\uff09<br \/>\u91cd\u542f\u540e\u53ef\u542f\u52a8\u6570\u636e\u5e93\uff0c\u56e0\u6570\u636e\u5e93\u662f\u975e\u6b63\u5e38\u5173\u95ed\u5f15\u8d77\u7684\u3002\u6240\u6709\u4f1a\u9020\u6210\u6570\u636e\u4e22\u5931\u3002 \u8981\u505a\u597d\u5907\u4efd\u5de5\u4f5c<\/p>\n<p>\u5907\u5e93\u540c\u6b65\u65f6\u4e00\u76f4\u62a5\u9519<br \/>\u53ea\u8981\u4e3b\u5e93 \u6709\u4fee\u6539 \uff0c\u5907\u5e93\u5c31\u4f1a\u62a5 Error &#8216;Unknown collation: &#8216;2048&#8221; on query. Default database: &#8216;123flashchat4&#8217;. Query: &#8216;create table test110(test int(10))&#8217;<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5<br \/>show variables like &#8216;collat%&#8217;;<\/p>\n<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>| Variable<em>name | Value |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>| collation<\/em>connection | latin1<em>swedish<\/em>ci |<br \/>| collation<em>database | latin1<\/em>swedish<em>ci |<br \/>| collation<\/em>server | latin1<em>swedish<\/em>ci |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>\u7b2c\u4e00\u884c\u6362\u4e0b utf8<em>general<\/em>ci<br \/>set collation<em>connection = utf8<\/em>general_ci;<\/p>\n<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>| Variable<em>name | Value |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>| collation<\/em>connection | utf8<em>general<\/em>ci |<br \/>| collation<em>database | latin1<\/em>swedish<em>ci |<br \/>| collation<\/em>server | latin1<em>swedish<\/em>ci |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>\u5c31\u4e0d\u4f1a\u62a5\u5b57\u7b26\u96c6\u7684\u95ee\u9898<\/p>\n<p>\u5f00\u673a\u542f\u52a8\u8bbe\u7f6e utf8<em>general<\/em>ci<\/p>\n<p>[client]<br \/>port = 3306<br \/>socket = \/tmp\/mysql.sock<br \/>default-character-set=utf8<\/p>\n<p>\u679c\u7136\u662fclient\u7684\u95ee\u9898<\/p>\n<p>show processlist;<br \/>show variables like &#8216;%slow%&#8217;;<\/p>\n<p>sql \u4f18\u5316<br \/>http:\/\/blog.csdn.net\/ylqmf\/article\/details\/6834897<\/p>\n<p>uv pv \u6570\u636e\u5e93\u7edf\u8ba1<\/p>\n<p>echo &#8220;select COUNT( * ) from (SELECT COUNT( * ) AS hs , ip FROM rizhi.varnish<em>67<\/em>12<em>Aug<\/em>2013 GROUP BY ip) as hs;&#8221; |mysql -u root -p996633 | tail -1<br \/>echo &#8220;select ID from rizhi.varnish<em>67<\/em>12<em>Aug<\/em>2013 order by ID desc limit 1;&#8221; | mysql -u root -p996633 | tail -1<\/p>\n<p>\u6279\u91cf\u4fee\u6539\u5b57\u6bb5<\/p>\n<p>\u53c2\u8003\u6587\u6863\uff1a http:\/\/hi.baidu.com\/java513\/item\/3083e90d5de76b17acdc703b<\/p>\n<p>2011-03-03 18:31 MySQL\u6570\u636e\u5e93\u6279\u91cf\u53bb\u6389\u67d0\u4e00\u4e2a\u5b57\u6bb5\u503c\u4e2d\u524d\u51e0\u4f4d\u5b57\u7b26(\u6216\u53bb\u6389\u7279\u5b9a\u7684\u503c)<br \/>MySQL\u6570\u636e\u5e93\u6279\u91cf\u53bb\u6389\u67d0\u4e00\u4e2a\u5b57\u6bb5\u503c\u4e2d\u524d\u51e0\u4f4d\u5b57\u7b26<br \/>\u6bd4\u5982\uff0c\u5728\u88681\u4e2d\uff0c\u5b57\u6bb5 csysid \u6709\u4e9b\u503c\u4e3a OM\uff0c \u5bf9\u5e94\u7684CID \u7684\u503c\u5e94\u8be5\u4e3a\u6570\u5b57\uff0c01\uff0c02\uff0c03&#8230; \u4f46\u662f\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48 \u6240\u6709\u7684\u6570\u5b57\u524d\u9762\u90fd\u52a0\u4e860M\u8fd9\u4e24\u4e2a \u5b57\u6bcd\uff0c\u53d8\u6210om01\u3001om02\u3001om03&#8230;&#8230;\u73b0\u5728\u8981\u628a\u8fd9\u4e24\u4e2a\u5b57\u6bcd\u53bb\u6389,\u8be5\u5982\u4f55\u5199\u8bed\u53e5\u3002\u5982\u4f55\u5355\u7eaf\u9488\u5bf9\u4e0a\u8fb9\u8fd9\u4e2a\u8868\u7684\u8bdd\uff0c\u56e0\u4e3a\u524d\u4e24\u4e2a\u5b57\u6bcd\u4e00\u6837\uff0c\u6240\u4ee5\u53ef\u4ee5\u6279\u91cf\u628a\u524d\u4e24\u4e2a\u5b57\u6bcd\u53bb\u6389\u5c31\u53ef\u4ee5\u4e86\u3002<br \/>update \u88681 set CID=replace(CID,&#8217;om&#8217;,&#8221;)<\/p>\n<p>\u5982\u679c\u6709\u4e9b\u8868\u524d\u4e24\u4e2a\u5b57\u7b26\u5e76\u4e0d\u4e00\u6837\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u4f7f\u7528\u5982\u4e0b\u8bed\u53e5\u4e86\uff1a<br \/>update \u88681 set CID=substring(CID,3,len(CID))<\/p>\n<p>\u8fd9\u662f\u53bb\u6389\u524d\u4e24\u4e2a\u5b57\u7b26\u7684\uff0c\u5982\u679c\u9700\u8981\u53bb\u63893\u4f4d\u6216\u66f4\u591a\u5b57\u7b26\u90a3\u4e48\u4fee\u6539\u4e0b\u76f8\u5e94\u7684\u6570\u5b57\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u4f8b\u5982\u53bb\u6389 ip\u7684 12.1.2.3\uff0c \u4e2d\u7684\uff0c<br \/>update test set ip=replace(ip,&#8217;,&#8217;,&#8221;); \u5373\u53ef<\/p>\n<p>\u5b89\u88c5\u591a\u6570\u636e\u5e93<br \/>mysql<em>install<\/em>db &#8211;user=mysql &#8211;datadir=\/var\/lib\/mysql2<\/p>\n<p>service mysql stop<\/p>\n<p>[mysqld<em>multi]<br \/>mysqld = \/usr\/bin\/mysqld<\/em>safe<br \/>mysqladmin = \/usr\/bin\/mysqladmin<\/p>\n<p>[mysqld2]<br \/>socket = \/tmp\/mysql.sock2<br \/>port = 3307<br \/>pid-file = \/var\/lib\/mysql2\/hostname.pid2<br \/>datadir = \/var\/lib\/mysql2<br \/>user = mysql<\/p>\n<p>mysqld_multi &#8211;defaults-file=\/etc\/my.cnf start<\/p>\n<p>\/usr\/bin\/mysqladmin -u root password &#8216;ceshi160&#8217; -S \/tmp\/mysql.sock2<\/p>\n<p>mysql\u9501\u8868\u3001\u9501\u5e93\u64cd\u4f5c<br \/>\u4eca\u5929\u5728\u89e3\u51b3\u6570\u636e\u5e93\u540c\u6b65\u5f02\u5e38\u7684\u65f6\u5019\u7528\u5230\u4e86flush tables with read lock \u8fd9\u4e2a\u547d\u4ee4\uff0c\u4e8e\u662f\u987a\u4fbf\u5c31\u5b66\u4e60\u4e86\u4e0b\u9501\u8868\u7684\u76f8\u5173\u77e5\u8bc6\u3002<\/p>\n<p>1.FLUSH TABLES WITH READ LOCK<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u662f\u5168\u5c40\u8bfb\u9501\u5b9a\uff0c\u6267\u884c\u4e86\u547d\u4ee4\u4e4b\u540e\u6240\u6709\u5e93\u6240\u6709\u8868\u90fd\u88ab\u9501\u5b9a\u53ea\u8bfb\u3002\u4e00\u822c\u90fd\u662f\u7528\u5728\u6570\u636e\u5e93\u8054\u673a\u5907\u4efd\uff0c\u8fd9\u4e2a\u65f6\u5019\u6570\u636e\u5e93\u7684\u5199\u64cd\u4f5c\u5c06\u88ab\u963b\u585e\uff0c\u8bfb\u64cd\u4f5c\u987a\u5229\u8fdb\u884c\u3002<\/p>\n<p>\u89e3\u9501\u7684\u8bed\u53e5\u4e5f\u662funlock tables\u3002<\/p>\n<p>2.LOCK TABLEStbl<em>name [AS alias] {READ [LOCAL] | [LOW<\/em>PRIORITY] WRITE}<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u662f\u8868\u7ea7\u522b\u7684\u9501\u5b9a\uff0c\u53ef\u4ee5\u5b9a\u5236\u9501\u5b9a\u67d0\u4e00\u4e2a\u8868\u3002\u4f8b\u5982\uff1a lock tables test read; \u4e0d\u5f71\u54cd\u5176\u4ed6\u8868\u7684\u5199\u64cd\u4f5c\u3002<\/p>\n<p>\u89e3\u9501\u8bed\u53e5\u4e5f\u662funlock tables\u3002<\/p>\n<p>\u8fd9\u4e24\u4e2a\u8bed\u53e5\u5728\u6267\u884c\u7684\u65f6\u5019\u90fd\u9700\u8981\u6ce8\u610f\u4e2a\u7279\u70b9\uff0c\u5c31\u662f \u9690\u5f0f\u63d0\u4ea4\u7684\u8bed\u53e5\u3002\u5728\u9000\u51famysql\u7ec8\u7aef\u7684\u65f6\u5019\u90fd\u4f1a\u9690\u5f0f\u7684\u6267\u884cunlock tables\u3002\u4e5f\u5c31\u662f\u5982\u679c\u8981\u8ba9\u8868\u9501\u5b9a\u751f\u6548\u5c31\u5fc5\u987b\u4e00\u76f4\u4fdd\u6301\u5bf9\u8bdd\u3002<\/p>\n<p>P.S. MYSQL\u7684read lock\u548cwirte lock<\/p>\n<p>read-lock:\u5141\u8bb8\u5176\u4ed6\u5e76\u53d1\u7684\u8bfb\u8bf7\u6c42\uff0c\u4f46\u963b\u585e\u5199\u8bf7\u6c42\uff0c\u5373\u53ef\u4ee5\u540c\u65f6\u8bfb\uff0c\u4f46\u4e0d\u5141\u8bb8\u4efb\u4f55\u5199\u3002\u4e5f\u53eb\u5171\u4eab\u9501<\/p>\n<p>write-lock:\u4e0d\u5141\u8bb8\u5176\u4ed6\u5e76\u53d1\u7684\u8bfb\u548c\u5199\u8bf7\u6c42\uff0c\u662f\u6392\u4ed6\u7684(exclusive)\u3002\u4e5f\u53eb\u72ec\u5360\u9501<\/p>\n<p>http:\/\/www.52youpiao.com\/it\/post\/mysql-slave.html<br \/>\u4e3b\u4ece\u4e92\u5907<br \/>\u4e24\u53f0\u670d\u52a1\u5668\u4e92\u4e3a\u4e3b\u4ece\uff0c\u53cc\u5411\u540c\u6b65\u6570\u636e\u3002\u5f53\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u7684\u6570\u636e\u6709\u589e\u5220\u6539\u7b49\u64cd\u4f5c\u65f6\uff0c\u53e6\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u7684mysql\u540c\u6b65\u7684\u6570\u636e\u5e93\u4e5f\u6709\u540c\u6837\u7684\u64cd\u4f5c\u3002\u5229\u7528MySQL\u4e3b\u4ece\u540c\u6b65\u539f\u7406\uff0c\u5b9e\u73b0MySQL\u53cc\u5411\u540c\u6b65\u3002<\/p>\n<p>\u5b9e\u65bd\u73af\u5883<\/p>\n<p>\u670d\u52a1\u5668\u4e3awindows 2008 R2\uff0cmysql\u7248\u672c\u4e3a5.5.30\uff0c\u670d\u52a1\u5668server1\uff1a192.168.0.165 server2\uff1a192.168.0.166<\/p>\n<p>1\u3001\u914d\u7f6e\u6570\u636e\u5e93my.ini\u6587\u4ef6<\/p>\n<p>\u4fee\u6539server1\uff1a192.168.0.165\u7684my.ini\u6587\u4ef6\uff0c\u589e\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p>server-id=1<br \/>binlog-do-db=ctbsdb<br \/>binlog-ignore-db=mysql<br \/>log-slave-updates<br \/>replicate-do-db=ctbsdb<br \/>replicate-ignore-db=mysql<br \/>log-bin=mysql-bin<\/p>\n<p>auto<em>increment<\/em>offset=1<br \/>auto<em>increment<\/em>increment=2<\/p>\n<p>\u4fee\u6539server2\uff1a192.168.0.166\u7684my.ini\u6587\u4ef6\uff0c\u589e\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p>server-id=2<br \/>binlog-do-db=ctbsdb<br \/>binlog-ignore-db=mysql<br \/>log-slave-updates<br \/>replicate-do-db=ctbsdb<br \/>replicate-ignore-db=mysql<br \/>log-bin=mysql-bin<\/p>\n<p>auto<em>increment<\/em>offset=2<br \/>auto<em>increment<\/em>increment=2<\/p>\n<p>\u91cd\u542f\u4e24\u53f0\u673a\u5668\u7684mysql\u670d\u52a1\u3002<\/p>\n<p>\u914d\u7f6e\u9879\u91ca\u4e49<\/p>\n<p>server-id\uff1a\u6807\u8bc6\uff0c\u552f\u4e00\uff0c\u503c\u8303\u56f4\u5728\uff1a1\u81f32^23-1<\/p>\n<p>binlog-do-db\u548creplicate-to-db\uff1a\u8981\u540c\u6b65\u7684\u6570\u636e\u5e93\uff0c\u591a\u4e2a\u9700\u8981\u540c\u6b65\u7684\u6570\u636e\u53ef\u4ee5\u7ee7\u7eed\u5411\u4e0b\u5199<\/p>\n<p>binlog-ignore-db\u548creplicate-ignore-db\uff1a\u4e0d\u9700\u8981\u540c\u6b65\u7684\u6570\u636e\u5e93<\/p>\n<p>log-bin\uff1a\u914d\u7f6e\u662f\u5426\u5728\u6570\u636e\u5e93\u6709\u53d8\u52a8\u65f6\u5199\u4e8c\u8fdb\u5236\u65e5\u5fd7<\/p>\n<p>auto<em>increment<\/em>offset\u548cauto<em>increment<\/em>increment\uff1a\u5f53\u540c\u6b65\u65ad\u5f00\uff0c\u4e24\u53f0\u670d\u52a1\u5668\u5206\u522b\u6709\u65b0\u6570\u636e\u8fdb\u5165\uff0c\u90a3\u4e48\u4e3b\u952eID\u662f\u81ea\u589e\u957f\u5217\u4f1a\u51fa\u73b0\u51b2\u7a81\u7684\u60c5\u51b5\uff0c\u4f1a\u5bfc\u81f4\u540c\u6b65\u65e0\u6cd5\u7ee7\u7eed\u3002\u52a0\u4e0a\u4e0a\u9762\u4e24\u4e2a\u8bbe\u7f6e\u540eserver1\u7684auto_increment\u5b57\u6bb5\u4ea7\u751f\u7684\u6570\u503c\u662f\uff1a1, 3, 5, 7, \u2026\u7b49\u5947\u6570\uff0cserver2\u7684\u4e3a\u5076\u6570\u3002<\/p>\n<p>auto<em>increment<\/em>offset\u548cauto<em>increment<\/em>increment \u503c\u5f97\u8bbe\u7f6e\u95ee\u9898<br \/>\u7b2c\u4e8c\u4e2a\u53d8\u91cf\u540d auto<em>increment<\/em>offset \u6307 \u81ea\u589e\u5b57\u6bb5\u7684\u8d77\u59cb\u503c\u3002<br \/>\u6bd4\u5982\uff0c\u6709\u4e2a\u8868test\uff0c\u5b57\u6bb5id\u4e3a\u4e3b\u952e\uff0c\u81ea\u589e\uff1b<br \/>\u5982\u679cauto<em>increment<\/em>offset=1 \uff0c \u5e76\u4e14auto<em>increment<\/em>increment=1\uff0c\u90a3\u4e48\u5411\u8868\u4e2d\u63d2\u5165\u7b2c\u4e00\u6761\u6570\u636e\u65f6\uff0c\u5219\u8be5\u6761\u6570\u636e\u7684id=1\uff0c\u7b2c\u4e8c\u6761id=2\uff0c\u7b2c\u4e09\u6761id=3\u4ee5\u6b64\u7c7b\u63a8\u2026\u2026<br \/>\u5982\u679cauto<em>increment<\/em>offset=2 \uff0c \u5e76\u4e14auto<em>increment<\/em>increment=10\uff0c\u90a3\u4e48\u5411\u8868\u4e2d\u63d2\u5165\u7b2c\u4e00\u6761\u6570\u636e\u65f6\uff0c\u5219\u8be5\u6761\u6570\u636e\u7684id=2\uff0c\u7b2c\u4e8c\u6761id=12\uff0c\u7b2c\u4e09\u6761id=22\u4ee5\u6b64\u7c7b\u63a8\u2026\u2026<br \/>\u6ce8\u610f\uff1a\u5982\u679cauto<em>increment<\/em>offset\u7684\u503c\u5927\u4e8eauto<em>increment<\/em>increment\u7684\u503c\uff0c\u5219auto<em>increment<\/em>offset\u7684\u503c\u88ab\u5ffd\u7565\u3002<br \/>\u540c\u65f6\u4e0d\u4f1a\u5f71\u54cd\u5df2\u521b\u5efa\u8868\u7684ID\u503c<\/p>\n<p>\u4fee\u6539AUTO<em>INCREMENT\u7684\u503c<br \/>alter room<\/em>sequence AUTO_INCREMENT=10001;<\/p>\n<p>http:\/\/hi.baidu.com\/dba_hui\/item\/5773cd7f6df750266cc37c49<\/p>\n<p>SHOW VARIABLES LIKE &#8216;auto<em>inc%&#8217;;<br \/>SET @auto<\/em>increment_offset=5; (\u8bbe\u7f6e\u521d\u59cb\u503c)<\/p>\n<p>\u5bfc\u51fa\u6570\u636e \u53ea\u5bfc\u51fa\u8868\u7ed3\u6784 \u4e0d\u5bfc\u51fa\u6570\u636e<br \/>mysqldump &#8211;opt -d shanliao1 -u root -p &gt; shanliao1.sql<\/p>\n<p><!-- This document was created with MarkdownPad, the Markdown editor for Windows (http:\/\/markdownpad.com) --><\/p>\n<p>\u7edf\u8ba1\u6700\u5927\u7684\u8868\u7684\u8bed\u53e5:<\/p>\n<p><p>SELECT TABLE_NAME,&nbsp; CONCAT(ROUND((data_length+index_length)\/(1024*1024*1024), 2), &#8216; G&#8217;)&nbsp; AS &#8216;total&#8217; ,<br \/>CONCAT(ROUND(data_length\/(1024*1024*1024.), 2), &#8216; G&#8217;) AS &#8216;Data Size&#8217;,<br \/> CONCAT(ROUND(index_length\/(1024*1024*1024), 2), &#8216; G&#8217;) AS &#8216;Index Size&#8217; ,<br \/>TABLE_ROWS<br \/>FROM&nbsp; `TABLES` WHERE TABLE_SCHEMA=&#8217;db_G2S_OnlineSchool&#8217; ORDER BY TABLE_ROWS&nbsp; DESC limit 10; <\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2015\/07\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2015\/07\/image_thumb.png\" width=\"514\" height=\"178\"><\/a><\/p>\n<\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2015\/07\/image.png\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2015\/07\/image.png\"><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;<\/p>\n<\/p>\n<style type=\"text\/css\"><!--\nbody{\n    margin: 0 auto;\n    font-family: georgia, palatino, serif;\n    color: #444444;\n    line-height: 1;\n    max-width: 960px;\n    padding: 5px;\n}\nh1, h2, h3, h4 {\n    color: #111111;\n    font-weight: 400;\n}\nh1, h2, h3, h4, h5, p {\n    margin-bottom: 16px;\n    padding: 0;\n}\nh1 {\n    font-size: 28px;\n}\nh2 {\n    font-size: 22px;\n    margin: 20px 0 6px;\n}\nh3 {\n    font-size: 21px;\n}\nh4 {\n    font-size: 18px;\n}\nh5 {\n    font-size: 16px;\n}\na {\n    color: #0099ff;\n    margin: 0;\n    padding: 0;\n    vertical-align: baseline;\n}\na:hover {\n    text-decoration: none;\n    color: #ff6600;\n}\na:visited {\n    color: purple;\n}\nul, ol {\n    padding: 0;\n    margin: 0;\n}\nli {\n    line-height: 24px;\n    margin-left: 44px;\n}\nli ul, li ul {\n    margin-left: 24px;\n}\np, ul, ol {\n    font-size: 14px;\n    line-height: 20px;\n    max-width: 540px;\n}\npre {\n    padding: 0px 24px;\n    max-width: 800px;\n    white-space: pre-wrap;\n}\ncode {\n    font-family: consolas, monaco, andale mono, monospace;\n    line-height: 1.5;\n    font-size: 13px;\n}\naside {\n    display: block;\n    float: right;\n    width: 390px;\n}\nblockquote {\n    border-left:.5em solid #eee;\n    padding: 0 2em;\n    margin-left:0;\n    max-width: 476px;\n}\nblockquote  cite {\n    font-size:14px;\n    line-height:20px;\n    color:#bfbfbf;\n}\nblockquote cite:before {\n    content: '2014 \ufffd0A0';\n}\n\nblockquote p {  \n    color: #666;\n    max-width: 460px;\n}\nhr {\n    width: 540px;\n    text-align: left;\n    margin: 0 auto 0 0;\n    color: #999;\n}\n\nbutton,\ninput,\nselect,\ntextarea {\n  font-size: 100%;\n  margin: 0;\n  vertical-align: baseline;\n  *vertical-align: middle;\n}\nbutton, input {\n  line-height: normal;\n  *overflow: visible;\n}\nbutton::-moz-focus-inner, input::-moz-focus-inner {\n  border: 0;\n  padding: 0;\n}\nbutton,\ninput[type=\"button\"],\ninput[type=\"reset\"],\ninput[type=\"submit\"] {\n  cursor: pointer;\n  -webkit-appearance: button;\n}\ninput[type=checkbox], input[type=radio] {\n  cursor: pointer;\n}\n\/* override default chrome &#038; firefox settings *\/\ninput:not([type=\"image\"]), textarea {\n  -webkit-box-sizing: content-box;\n  -moz-box-sizing: content-box;\n  box-sizing: content-box;\n}\n\ninput[type=\"search\"] {\n  -webkit-appearance: textfield;\n  -webkit-box-sizing: content-box;\n  -moz-box-sizing: content-box;\n  box-sizing: content-box;\n}\ninput[type=\"search\"]::-webkit-search-decoration {\n  -webkit-appearance: none;\n}\nlabel,\ninput,\nselect,\ntextarea {\n  font-family: \"Helvetica Neue\", helvetica, arial, sans-serif;\n  font-size: 13px;\n  font-weight: normal;\n  line-height: normal;\n  margin-bottom: 18px;\n}\ninput[type=checkbox], input[type=radio] {\n  cursor: pointer;\n  margin-bottom: 0;\n}\ninput[type=text],\ninput[type=password],\ntextarea,\nselect {\n  display: inline-block;\n  width: 210px;\n  padding: 4px;\n  font-size: 13px;\n  font-weight: normal;\n  line-height: 18px;\n  height: 18px;\n  color: #808080;\n  border: 1px solid #ccc;\n  -webkit-border-radius: 3px;\n  -moz-border-radius: 3px;\n  border-radius: 3px;\n}\nselect, input[type=file] {\n  height: 27px;\n  line-height: 27px;\n}\ntextarea {\n  height: auto;\n}\n\n\/* grey out placeholders *\/\n:-moz-placeholder {\n  color: #bfbfbf;\n}\n::-webkit-input-placeholder {\n  color: #bfbfbf;\n}\n\ninput[type=text],\ninput[type=password],\nselect,\ntextarea {\n  -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;\n  -moz-transition: border linear 0.2s, box-shadow linear 0.2s;\n  transition: border linear 0.2s, box-shadow linear 0.2s;\n  -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\n  -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\n  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);\n}\ninput[type=text]:focus, input[type=password]:focus, textarea:focus {\n  outline: none;\n  border-color: rgba(82, 168, 236, 0.8);\n  -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\n  -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\n  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);\n}\n\n\/* buttons *\/\nbutton {\n  display: inline-block;\n  padding: 4px 14px;\n  font-family: \"Helvetica Neue\", helvetica, arial, sans-serif;\n  font-size: 13px;\n  line-height: 18px;\n  -webkit-border-radius: 4px;\n  -moz-border-radius: 4px;\n  border-radius: 4px;\n  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\n  -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);\n  background-color: #0064cd;\n  background-repeat: repeat-x;\n  background-image: -khtml-gradient(linear, left top, left bottom, from(#049cdb), to(#0064cd));\n  background-image: -moz-linear-gradient(top, #049cdb, #0064cd);\n  background-image: -ms-linear-gradient(top, #049cdb, #0064cd);\n  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #049cdb), color-stop(100%, #0064cd));\n  background-image: -webkit-linear-gradient(top, #049cdb, #0064cd);\n  background-image: -o-linear-gradient(top, #049cdb, #0064cd);\n  background-image: linear-gradient(top, #049cdb, #0064cd);\n  color: #fff;\n  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);\n  border: 1px solid #004b9a;\n  border-bottom-color: #003f81;\n  -webkit-transition: 0.1s linear all;\n  -moz-transition: 0.1s linear all;\n  transition: 0.1s linear all;\n  border-color: #0064cd #0064cd #003f81;\n  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);\n}\nbutton:hover {\n  color: #fff;\n  background-position: 0 -15px;\n  text-decoration: none;\n}\nbutton:active {\n  -webkit-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\n  -moz-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\n  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);\n}\nbutton::-moz-focus-inner {\n  padding: 0;\n  border: 0;\n}\n\n\/* CSS stylesheet is based on Kevin Burke's Markdown.css project (http:\/\/kevinburke.bitbucket.org\/markdowncss) *\/\n--><\/style>\n<p>&nbsp;<\/p>\n<h6>################################mysql<\/h6>\n<p>\u4e3b\u5907\u6570\u636e\u5e93<br \/>http:\/\/www.cnblogs.com\/hustcat\/archive\/2009\/12\/19\/1627525.html<\/p>\n<p>SET PASSWORD FOR &#8216;root&#8217;@&#8217;localhost&#8217; = PASSWORD(&#8216;ceshi160&#8217;);<br \/>GRANT REPLICATION SLAVE, REPLICATION CLIENT ON <em>.<\/em> TO repl@&#8217;192.168.0.%&#8217; IDENTIFIED BY &#8216;ceshi160&#8217;;<br \/>grant all privileges on cmm.* to &#8216;cmmw&#8217;@&#8217;192.168.0.%&#8217; identified by &#8216;cmmw123&#8217;;<br \/>grant select on cmm.* to &#8216;cmmr&#8217;@&#8217;192.168.0.%&#8217; identified by &#8216;cmmr123&#8217;;<br \/>flush privileges;<\/p>\n<p>grant select on <em>.<\/em> to &#8216;monitor&#8217;@&#8217;192.168.30.21&#8217; identified by &#8216;monitor&#8217;;<br \/>flush privileges;<\/p>\n<p>grant all privileges on <em>.<\/em> to &#8216;monitor&#8217;@&#8217;192.168.30.21&#8217; identified by &#8216;monitor&#8217;;<br \/>flush privileges;<\/p>\n<p>Starting MySQL (Percona Server). ERROR! The server quit without updating PID file (\/data\/mysqldata\/localhost.localdomain.pid).<br \/>google\u4e86\u4e0b \uff0c\u95ee\u9898\u53ef\u80fd\u7684\u539f\u56e0\u6709\u591a\u79cd\uff0c\u5177\u4f53\u4ec0\u4e48\u539f\u56e0\u6700\u597d\u7684\u529e\u6cd5\u662f\u5148\u67e5\u770b\u4e0b\u9519\u8bef\u65e5\u5fd7\uff1a<\/p>\n<p>1.\u53ef\u80fd\u662f\/usr\/local\/mysql\/data\/rekfan.pid\u6587\u4ef6\u6ca1\u6709\u5199\u7684\u6743\u9650<br \/>\u89e3\u51b3\u65b9\u6cd5 \uff1a\u7ed9\u4e88\u6743\u9650\uff0c\u6267\u884c \u201cchown -R mysql:mysql \/var\/data\u201d \u201cchmod -R 755 \/usr\/local\/mysql\/data\u201d \u7136\u540e\u91cd\u65b0\u542f\u52a8mysqld\uff01<\/p>\n<p>2.\u53ef\u80fd\u8fdb\u7a0b\u91cc\u5df2\u7ecf\u5b58\u5728mysql\u8fdb\u7a0b<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u7528\u547d\u4ee4\u201cps -ef|grep mysqld\u201d\u67e5\u770b\u662f\u5426\u6709mysqld\u8fdb\u7a0b\uff0c\u5982\u679c\u6709\u4f7f\u7528\u201ckill -9 \u8fdb\u7a0b\u53f7\u201d\u6740\u6b7b\uff0c\u7136\u540e\u91cd\u65b0\u542f\u52a8mysqld\uff01<\/p>\n<p>3.\u53ef\u80fd\u662f\u7b2c\u4e8c\u6b21\u5728\u673a\u5668\u4e0a\u5b89\u88c5mysql\uff0c\u6709\u6b8b\u4f59\u6570\u636e\u5f71\u54cd\u4e86\u670d\u52a1\u7684\u542f\u52a8\u3002<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u53bbmysql\u7684\u6570\u636e\u76ee\u5f55\/data\u770b\u770b\uff0c\u5982\u679c\u5b58\u5728mysql-bin.index\uff0c\u5c31\u8d76\u5feb\u628a\u5b83\u5220\u9664\u6389\u5427\uff0c\u5b83\u5c31\u662f\u7f6a\u9b41\u7978\u9996\u4e86\u3002\u672c\u4eba\u5c31\u662f\u4f7f\u7528\u7b2c\u4e09\u6761\u65b9\u6cd5\u89e3\u51b3\u7684 \uff01http:\/\/blog.rekfan.com\/?p=186<\/p>\n<p><!--more-->4.mysql\u5728\u542f\u52a8\u65f6\u6ca1\u6709\u6307\u5b9a\u914d\u7f6e\u6587\u4ef6\u65f6\u4f1a\u4f7f\u7528\/etc\/my.cnf\u914d\u7f6e\u6587\u4ef6\uff0c\u8bf7\u6253\u5f00\u8fd9\u4e2a\u6587\u4ef6\u67e5\u770b\u5728[mysqld]\u8282\u4e0b\u6709\u6ca1\u6709\u6307\u5b9a\u6570\u636e\u76ee\u5f55(datadir)\u3002<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u8bf7\u5728[mysqld]\u4e0b\u8bbe\u7f6e\u8fd9\u4e00\u884c\uff1adatadir = \/usr\/local\/mysql\/data <\/p>\n<p>5.skip-federated\u5b57\u6bb5\u95ee\u9898<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u68c0\u67e5\u4e00\u4e0b\/etc\/my.cnf\u6587\u4ef6\u4e2d\u6709\u6ca1\u6709\u6ca1\u88ab\u6ce8\u91ca\u6389\u7684skip-federated\u5b57\u6bb5\uff0c\u5982\u679c\u6709\u5c31\u7acb\u5373\u6ce8\u91ca\u6389\u5427\u3002<\/p>\n<p>6.\u9519\u8bef\u65e5\u5fd7\u76ee\u5f55\u4e0d\u5b58\u5728<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u4f7f\u7528\u201cchown\u201d \u201cchmod\u201d\u547d\u4ee4\u8d4b\u4e88mysql\u6240\u6709\u8005\u53ca\u6743\u9650<\/p>\n<p>7.selinux\u60f9\u7684\u7978\uff0c\u5982\u679c\u662fcentos\u7cfb\u7edf\uff0c\u9ed8\u8ba4\u4f1a\u5f00\u542fselinux<br \/>\u89e3\u51b3\u65b9\u6cd5\uff1a\u5173\u95ed\u5b83\uff0c\u6253\u5f00\/etc\/selinux\/config\uff0c\u628aSELINUX=enforcing\u6539\u4e3aSELINUX=disabled\u540e\u5b58\u76d8\u9000\u51fa\u91cd\u542f\u673a\u5668\u8bd5\u8bd5\u3002<\/p>\n<p>mysql MYI\u6587\u4ef6\u4e22\u5931\u5982\u4f55\u4fee\u590d [\u590d\u5236\u94fe\u63a5]<\/p>\n<p>MYI \u6587\u4ef6\u662f\u7d22\u5f15\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u5373\u4f7f\u662f\u5220\u9664\u4e86\uff0c\u8fd8\u53ef\u4ee5\u6839\u636eMYD\u4ee5\u53cafrm\u6587\u4ef6\u6765\u6062\u590d\u3002<br \/>\u6240\u4ee5\uff0c\u5f53\u4f60\u5907\u4efd\u6570\u636e\u5e93\u65f6\uff0c\u5982\u679c\u60f3\u7701\u7a7a\u95f4\uff0c\u90a3\u4e48\u5c31\u53bb\u6389*MYI\u5427\u3002<br \/>MYI\u6062\u590d\u53ef\u4ee5\u8fd9\u6837\u64cd\u4f5c\uff1a<br \/>\u9996\u5148\u8fdb\u5165mysql\u547d\u4ee4\u884c<br \/>\u6267\u884c\u547d\u4ee4<br \/>mysql&gt; repair table tablename USE_FRM;<br \/>\u590d\u5236\u4ee3\u7801<br \/>\u8fd9\u6837\u5c31\u53ef\u4ee5\u6062\u590dMYI\u6587\u4ef6\u4e86\u3002<\/p>\n<p>mysql Copying to tmp table \u6162<br \/>\u54e6\uff0c\u539f\u6765\u662f\u8fd9\u6837\u7684\uff0c\u5982\u679c\u67e5\u8be2\u8d85\u51fa\u4e86tmp<em>table<\/em>size\u7684\u9650\u5236\uff0c\u90a3\u4e48mysql\u7528\/tmp\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\uff0c\u7136\u540e\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002<br \/>set global tmp<em>table<\/em>size=509715200 (500M)<\/p>\n<p>mysql \u5361\u6b7b \u5927\u90e8\u5206\u7ebf\u7a0b\u957f\u65f6\u95f4\u5904\u4e8esending data\u7684\u72b6\u6001<br \/>\u628aquery_cache\u51cf\u5c0f\u5230\u9ed8\u8ba4\u503c 16M\uff0c\u628a\u4e00\u4e9b\u4e0d\u600e\u4e48\u53d8\u52a8\u7684\u6570\u636e\uff0c\u505a\u4e86\u9759\u6001\u5316\u3002\u60ca\u5947\u7684\u53d1\u73b0\uff0c12\u5929\u8fc7\u53bb\u4e86\uff0c\u6ca1\u518d\u51fa\u8fc7\u95ee\u9898&#8230;&#8230;<\/p>\n<p>\u4fee\u590d\u8868<br \/>mysql&gt; REPAIR TABLE mytable;<\/p>\n<p>\u547d\u4ee4\u6765\u4fee\u590d<br \/>mysqlcheck -A -r -c -p<\/p>\n<p>\u4e3b\u7ad9\u6ce8\u518c\u95ee\u9898<br \/>grant all privileges on livehelp_host.* to &#8216;flashchat&#8217;@&#8217;216.158.78.234&#8217; identified by &#8216;dj7ad62zz&#8217;;<\/p>\n<p>ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log<\/p>\n<p>\u5728\u53e6\u5916\u4e00\u53f0\u4e0a\u6267\u884c\u4e5f\u662f\u4e00\u6837\u63d0\u793a\u8fd9\u4e2a\u9519\u8bef\u3002 \u7f51\u4e0a\u67e5\u4e86\u4e00\u4e9b\u8d44\u6599\uff0c\u53d1\u73b0\u5927\u6982\u6709\u4e24\u79cd\u65b9\u6cd5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c1.\u662f\u6e05\u7406mysql\u7684\u76f8\u5173\u65e5\u5fd7\uff1b2.\u662freset slave \uff1b\u4f46\u662f\u6e05\u7406\u65e5\u5fd7\u7684\u65b9\u6cd5\u6709\u70b9\u590d\u6742\uff0c\u4f7f\u7528\u7b2c2\u79cd\u65b9\u6cd5\u6bd4\u8f83\u65b9\u4fbf\u3002<\/p>\n<p>mysql&gt; slave stop;<\/p>\n<p>mysql&gt; reset slave;<\/p>\n<p>mysql&gt; change master to master<em>host=&#8217;172.17.2.10&#8242;,master<\/em>user=&#8217;sync&#8217;,master<em>password=&#8217;123456&#8242;,master<\/em>log<em>file=&#8217;updatelog.000004&#8242;,master<\/em>log_pos=106;<\/p>\n<p>mysql&gt; slave start;<\/p>\n<p>\u53e6\u5916\u4e00\u53f0\u4e5f\u6309\u7167\u8fd9\u79cd\u65b9\u6cd5\u6267\u884c\uff0c\u8f7b\u677e\u641e\u5b9a\u3002\u914d\u7f6e\u5b8c\u6210\u67e5\u770bmysql\u4e3b\u4ece\u540c\u6b65\u72b6\u6001\u6b63\u5e38\uff01<\/p>\n<p>&#8216;Could not find first log file name in binary log index file&#8217; from master when reading data from binary log<\/p>\n<p>\u56e0\u4e3a\u540c\u6b65\u7684bin-log \u6709\u95ee\u9898<\/p>\n<p>\u5148\u505c\u6b62slave \u7684 \u540c\u6b65<\/p>\n<p>stop slave;<\/p>\n<p>\u67e5\u770b\u4e3b\u5e93\u7684\u72b6\u6001<\/p>\n<p>show master status;<br \/>flush logs;<\/p>\n<p>\u518d\u6b21 show master status;<\/p>\n<p>mysql&gt; mysql&gt; show master status;<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>| File | Position | Binlog<em>Do<\/em>DB | Binlog<em>Ignore<\/em>DB |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>| mysql-bin.000256 | 284 | 123flashchat4 | |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>1 row in set (0.00 sec)<\/p>\n<p>\u4ece\u5e93 \u6839\u636e\u8fd9\u4e2a\u4fe1\u606f\u53bb\u540c\u6b65<\/p>\n<p>CHANGE MASTER TO MASTER_HOST=&#8217;216.158.73.10&#8242;,<\/p>\n<pre><code>MASTER_USER='repl',\n\nMASTER_PASSWORD='topcmm888',\n\nMASTER_LOG_FILE='mysql-bin.000256',\n<\/code><\/pre>\n<p>MASTER<em>LOG<\/em>POS=284;<\/p>\n<p>show slave status G<br \/>\u5373\u53ef<\/p>\n<p>\u663e\u793a\u8be6\u7ec6\u4fe1\u606f<br \/>show variables;<\/p>\n<p>\u64cd\u4f5c\u65e5\u5fd7\uff1a<br \/>http:\/\/www.cnblogs.com\/cocos\/archive\/2010\/12\/22\/1913557.html<\/p>\n<p>mysql \u89e3\u51b3\u4e00\u4e2a\u5947\u602a\u7684\u95ee\u9898\uff0c\u8be6\u89c1\u6b63\u6587 2013-05-09 10:23:17<br \/>\u5206\u7c7b\uff1a Mysql\/postgreSQL<br \/>\u9519\u8bef\u65e5\u5fd7\u62a5\u9519\u5982\u4e0b\uff1a<\/p>\n<p>130508 16:30:53 mysqld<em>safe Starting mysqld daemon with databases from \/data\/mysql<br \/>130508 16:30:54 [Warning] The syntax &#8216;&#8211;log-slow-queries&#8217; is deprecated and will be removed in a future release. Please use &#8216;&#8211;slow-query-log&#8217;\/&#8217;&#8211;slow-query-log-file&#8217; instead.<br \/>130508 16:30:54 InnoDB: The InnoDB memory heap is disabled<br \/>130508 16:30:54 InnoDB: Mutexes and rw<\/em>locks use GCC atomic builtins<br \/>130508 16:30:54 InnoDB: Compressed tables use zlib 1.2.3<br \/>130508 16:30:54 InnoDB: Initializing buffer pool, size = 500.0M<br \/>130508 16:30:54 InnoDB: Completed initialization of buffer pool<br \/>130508 16:30:54 InnoDB: highest supported file format is Barracuda.<br \/>InnoDB: Log scan progressed past the checkpoint lsn 27219795678<br \/>130508 16:30:54 InnoDB: Database was not shut down normally!<br \/>InnoDB: Starting crash recovery.<br \/>InnoDB: Reading tablespace information from the .ibd files&#8230;<br \/>InnoDB: Restoring possible half-written data pages from the doublewrite<br \/>InnoDB: buffer&#8230;<br \/>InnoDB: Doing recovery: scanned up to log sequence number 27219928522<br \/>InnoDB: Error: tried to read 16384 bytes at offset 0 3473408.<br \/>InnoDB: Was only able to read 8192.<br \/>InnoDB: Fatal error: cannot read from file. OS error number 17.<br \/>130508 16:31:05 InnoDB: Assertion failure in thread 47198419330368 in file os0file.c line 2523<br \/>InnoDB: We intentionally generate a memory trap.<br \/>InnoDB: Submit a detailed bug report to http:\/\/bugs.mysql.com.<br \/>InnoDB: If you get repeated assertion failures or crashes, even<br \/>InnoDB: immediately after the mysqld startup, there may be<br \/>InnoDB: corruption in the InnoDB tablespace. Please refer to<br \/>InnoDB: http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/forcing-innodb-recovery.html<br \/>InnoDB: about forcing recovery.<br \/>08:31:05 UTC &#8211; mysqld got signal 6 ;<br \/>This could be because you hit a bug. It is also possible that this binary<br \/>or one of the libraries it was linked against is corrupt, improperly built,<br \/>or misconfigured. This error can also be caused by malfunctioning hardware.<br \/>We will try our best to scrape up some info that will hopefully help<br \/>diagnose the problem, but since we have already crashed,<br \/>something is definitely wrong and this may fail.<br \/>key<em>buffer<\/em>size=16777216<br \/>read<em>buffer<\/em>size=1048576<br \/>max<em>used<\/em>connections=0<br \/>max<em>threads=500<br \/>thread<\/em>count=0<br \/>connection<em>count=0<br \/>It is possible that mysqld could use up to<br \/>key<\/em>buffer<em>size + (read<\/em>buffer<em>size + sort<\/em>buffer<em>size)*max<\/em>threads = 1046083 K bytes of memory<br \/>Hope that&#8217;s ok; if not, decrease some variables in the equation.<br \/>Thread pointer: 0x0<br \/>Attempting backtrace. You can use the following information to find out<br \/>where mysqld died. If you see no messages after this, something went<br \/>terribly wrong&#8230;<br \/>stack<em>bottom = 0 thread<\/em>stack 0x40000<br \/>\/usr\/local\/mysql\/bin\/mysqld(my<em>print<\/em>stacktrace+0x2e)[0x76a3ee]<br \/>\/usr\/local\/mysql\/bin\/mysqld(handle<em>fatal<\/em>signal+0x386)[0x655046]<br \/>\/lib64\/libpthread.so.0[0x3fade0ebe0]<br \/>\/lib64\/libc.so.6(gsignal+0x35)[0x3fad630265]<br \/>\/lib64\/libc.so.6(abort+0x110)[0x3fad631d10]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x85bfc4]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x822641]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x801597]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x801a4f]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x7f4240]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x7c5c40]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x7c5fa2]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x7c7727]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x7b61b6]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x78787a]<br \/>\/usr\/local\/mysql\/bin\/mysqld(<em>Z24ha<\/em>initialize<em>handlertonP13st<\/em>plugin<em>int+0x41)[0x657231]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x56714b]<br \/>\/usr\/local\/mysql\/bin\/mysqld(<\/em>Z11plugin<em>initPiPPci+0xa42)[0x567d12]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x4f21b2]<br \/>\/usr\/local\/mysql\/bin\/mysqld(<\/em>Z11mysqld<em>mainiPPc+0x865)[0x4f4ec5]<br \/>\/lib64\/libc.so.6(<\/em><em>libc<\/em>start<em>main+0xf4)[0x3fad61d994]<br \/>\/usr\/local\/mysql\/bin\/mysqld[0x4ed769]<br \/>The manual page at http:\/\/dev.mysql.com\/doc\/mysql\/en\/crashing.html contains<br \/>information that should help you find out what is causing the crash.<br \/>130508 16:31:05 mysqld<\/em>safe mysqld from pid file \/data\/mysql\/log\/scaner.pid ended<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a<br \/>\u5220\u9664\u6389<br \/>ibdata* ,<br \/>ib_logfile* ,<br \/>\u6240\u6709\u7684\u65e5\u5fd7\u3002 \uff08\u8fd9\u4e2a\u53ef\u4ee5\u4e0d\u5220\u9664\uff09<br \/>\u91cd\u542f\u540e\u53ef\u542f\u52a8\u6570\u636e\u5e93\uff0c\u56e0\u6570\u636e\u5e93\u662f\u975e\u6b63\u5e38\u5173\u95ed\u5f15\u8d77\u7684\u3002\u6240\u6709\u4f1a\u9020\u6210\u6570\u636e\u4e22\u5931\u3002 \u8981\u505a\u597d\u5907\u4efd\u5de5\u4f5c<\/p>\n<p>\u5907\u5e93\u540c\u6b65\u65f6\u4e00\u76f4\u62a5\u9519<br \/>\u53ea\u8981\u4e3b\u5e93 \u6709\u4fee\u6539 \uff0c\u5907\u5e93\u5c31\u4f1a\u62a5 Error &#8216;Unknown collation: &#8216;2048&#8221; on query. Default database: &#8216;123flashchat4&#8217;. Query: &#8216;create table test110(test int(10))&#8217;<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5<br \/>show variables like &#8216;collat%&#8217;;<\/p>\n<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>| Variable<em>name | Value |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>| collation<\/em>connection | latin1<em>swedish<\/em>ci |<br \/>| collation<em>database | latin1<\/em>swedish<em>ci |<br \/>| collation<\/em>server | latin1<em>swedish<\/em>ci |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>\u7b2c\u4e00\u884c\u6362\u4e0b utf8<em>general<\/em>ci<br \/>set collation<em>connection = utf8<\/em>general_ci;<\/p>\n<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>| Variable<em>name | Value |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>| collation<\/em>connection | utf8<em>general<\/em>ci |<br \/>| collation<em>database | latin1<\/em>swedish<em>ci |<br \/>| collation<\/em>server | latin1<em>swedish<\/em>ci |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>\u5c31\u4e0d\u4f1a\u62a5\u5b57\u7b26\u96c6\u7684\u95ee\u9898<\/p>\n<p>\u5f00\u673a\u542f\u52a8\u8bbe\u7f6e utf8<em>general<\/em>ci<\/p>\n<p>[client]<br \/>port = 3306<br \/>socket = \/tmp\/mysql.sock<br \/>default-character-set=utf8<\/p>\n<p>\u679c\u7136\u662fclient\u7684\u95ee\u9898<\/p>\n<p>show processlist;<br \/>show variables like &#8216;%slow%&#8217;;<\/p>\n<p>sql \u4f18\u5316<br \/>http:\/\/blog.csdn.net\/ylqmf\/article\/details\/6834897<\/p>\n<p>uv pv \u6570\u636e\u5e93\u7edf\u8ba1<\/p>\n<p>echo &#8220;select COUNT( * ) from (SELECT COUNT( * ) AS hs , ip FROM rizhi.varnish<em>67<\/em>12<em>Aug<\/em>2013 GROUP BY ip) as hs;&#8221; |mysql -u root -p996633 | tail -1<br \/>echo &#8220;select ID from rizhi.varnish<em>67<\/em>12<em>Aug<\/em>2013 order by ID desc limit 1;&#8221; | mysql -u root -p996633 | tail -1<\/p>\n<p>\u6279\u91cf\u4fee\u6539\u5b57\u6bb5<\/p>\n<p>\u53c2\u8003\u6587\u6863\uff1a http:\/\/hi.baidu.com\/java513\/item\/3083e90d5de76b17acdc703b<\/p>\n<p>2011-03-03 18:31 MySQL\u6570\u636e\u5e93\u6279\u91cf\u53bb\u6389\u67d0\u4e00\u4e2a\u5b57\u6bb5\u503c\u4e2d\u524d\u51e0\u4f4d\u5b57\u7b26(\u6216\u53bb\u6389\u7279\u5b9a\u7684\u503c)<br \/>MySQL\u6570\u636e\u5e93\u6279\u91cf\u53bb\u6389\u67d0\u4e00\u4e2a\u5b57\u6bb5\u503c\u4e2d\u524d\u51e0\u4f4d\u5b57\u7b26<br \/>\u6bd4\u5982\uff0c\u5728\u88681\u4e2d\uff0c\u5b57\u6bb5 csysid \u6709\u4e9b\u503c\u4e3a OM\uff0c \u5bf9\u5e94\u7684CID \u7684\u503c\u5e94\u8be5\u4e3a\u6570\u5b57\uff0c01\uff0c02\uff0c03&#8230; \u4f46\u662f\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48 \u6240\u6709\u7684\u6570\u5b57\u524d\u9762\u90fd\u52a0\u4e860M\u8fd9\u4e24\u4e2a \u5b57\u6bcd\uff0c\u53d8\u6210om01\u3001om02\u3001om03&#8230;&#8230;\u73b0\u5728\u8981\u628a\u8fd9\u4e24\u4e2a\u5b57\u6bcd\u53bb\u6389,\u8be5\u5982\u4f55\u5199\u8bed\u53e5\u3002\u5982\u4f55\u5355\u7eaf\u9488\u5bf9\u4e0a\u8fb9\u8fd9\u4e2a\u8868\u7684\u8bdd\uff0c\u56e0\u4e3a\u524d\u4e24\u4e2a\u5b57\u6bcd\u4e00\u6837\uff0c\u6240\u4ee5\u53ef\u4ee5\u6279\u91cf\u628a\u524d\u4e24\u4e2a\u5b57\u6bcd\u53bb\u6389\u5c31\u53ef\u4ee5\u4e86\u3002<br \/>update \u88681 set CID=replace(CID,&#8217;om&#8217;,&#8221;)<\/p>\n<p>\u5982\u679c\u6709\u4e9b\u8868\u524d\u4e24\u4e2a\u5b57\u7b26\u5e76\u4e0d\u4e00\u6837\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u4f7f\u7528\u5982\u4e0b\u8bed\u53e5\u4e86\uff1a<br \/>update \u88681 set CID=substring(CID,3,len(CID))<\/p>\n<p>\u8fd9\u662f\u53bb\u6389\u524d\u4e24\u4e2a\u5b57\u7b26\u7684\uff0c\u5982\u679c\u9700\u8981\u53bb\u63893\u4f4d\u6216\u66f4\u591a\u5b57\u7b26\u90a3\u4e48\u4fee\u6539\u4e0b\u76f8\u5e94\u7684\u6570\u5b57\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u4f8b\u5982\u53bb\u6389 ip\u7684 12.1.2.3\uff0c \u4e2d\u7684\uff0c<br \/>update test set ip=replace(ip,&#8217;,&#8217;,&#8221;); \u5373\u53ef<\/p>\n<p>\u5b89\u88c5\u591a\u6570\u636e\u5e93<br \/>mysql<em>install<\/em>db &#8211;user=mysql &#8211;datadir=\/var\/lib\/mysql2<\/p>\n<p>service mysql stop<\/p>\n<p>[mysqld<em>multi]<br \/>mysqld = \/usr\/bin\/mysqld<\/em>safe<br \/>mysqladmin = \/usr\/bin\/mysqladmin<\/p>\n<p>[mysqld2]<br \/>socket = \/tmp\/mysql.sock2<br \/>port = 3307<br \/>pid-file = \/var\/lib\/mysql2\/hostname.pid2<br \/>datadir = \/var\/lib\/mysql2<br \/>user = mysql<\/p>\n<p>mysqld_multi &#8211;defaults-file=\/etc\/my.cnf start<\/p>\n<p>\/usr\/bin\/mysqladmin -u root password &#8216;ceshi160&#8217; -S \/tmp\/mysql.sock2<\/p>\n<p>mysql\u9501\u8868\u3001\u9501\u5e93\u64cd\u4f5c<br \/>\u4eca\u5929\u5728\u89e3\u51b3\u6570\u636e\u5e93\u540c\u6b65\u5f02\u5e38\u7684\u65f6\u5019\u7528\u5230\u4e86flush tables with read lock \u8fd9\u4e2a\u547d\u4ee4\uff0c\u4e8e\u662f\u987a\u4fbf\u5c31\u5b66\u4e60\u4e86\u4e0b\u9501\u8868\u7684\u76f8\u5173\u77e5\u8bc6\u3002<\/p>\n<p>1.FLUSH TABLES WITH READ LOCK<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u662f\u5168\u5c40\u8bfb\u9501\u5b9a\uff0c\u6267\u884c\u4e86\u547d\u4ee4\u4e4b\u540e\u6240\u6709\u5e93\u6240\u6709\u8868\u90fd\u88ab\u9501\u5b9a\u53ea\u8bfb\u3002\u4e00\u822c\u90fd\u662f\u7528\u5728\u6570\u636e\u5e93\u8054\u673a\u5907\u4efd\uff0c\u8fd9\u4e2a\u65f6\u5019\u6570\u636e\u5e93\u7684\u5199\u64cd\u4f5c\u5c06\u88ab\u963b\u585e\uff0c\u8bfb\u64cd\u4f5c\u987a\u5229\u8fdb\u884c\u3002<\/p>\n<p>\u89e3\u9501\u7684\u8bed\u53e5\u4e5f\u662funlock tables\u3002<\/p>\n<p>2.LOCK TABLEStbl<em>name [AS alias] {READ [LOCAL] | [LOW<\/em>PRIORITY] WRITE}<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u662f\u8868\u7ea7\u522b\u7684\u9501\u5b9a\uff0c\u53ef\u4ee5\u5b9a\u5236\u9501\u5b9a\u67d0\u4e00\u4e2a\u8868\u3002\u4f8b\u5982\uff1a lock tables test read; \u4e0d\u5f71\u54cd\u5176\u4ed6\u8868\u7684\u5199\u64cd\u4f5c\u3002<\/p>\n<p>\u89e3\u9501\u8bed\u53e5\u4e5f\u662funlock tables\u3002<\/p>\n<p>\u8fd9\u4e24\u4e2a\u8bed\u53e5\u5728\u6267\u884c\u7684\u65f6\u5019\u90fd\u9700\u8981\u6ce8\u610f\u4e2a\u7279\u70b9\uff0c\u5c31\u662f \u9690\u5f0f\u63d0\u4ea4\u7684\u8bed\u53e5\u3002\u5728\u9000\u51famysql\u7ec8\u7aef\u7684\u65f6\u5019\u90fd\u4f1a\u9690\u5f0f\u7684\u6267\u884cunlock tables\u3002\u4e5f\u5c31\u662f\u5982\u679c\u8981\u8ba9\u8868\u9501\u5b9a\u751f\u6548\u5c31\u5fc5\u987b\u4e00\u76f4\u4fdd\u6301\u5bf9\u8bdd\u3002<\/p>\n<p>P.S. MYSQL\u7684read lock\u548cwirte lock<\/p>\n<p>read-lock:\u5141\u8bb8\u5176\u4ed6\u5e76\u53d1\u7684\u8bfb\u8bf7\u6c42\uff0c\u4f46\u963b\u585e\u5199\u8bf7\u6c42\uff0c\u5373\u53ef\u4ee5\u540c\u65f6\u8bfb\uff0c\u4f46\u4e0d\u5141\u8bb8\u4efb\u4f55\u5199\u3002\u4e5f\u53eb\u5171\u4eab\u9501<\/p>\n<p>write-lock:\u4e0d\u5141\u8bb8\u5176\u4ed6\u5e76\u53d1\u7684\u8bfb\u548c\u5199\u8bf7\u6c42\uff0c\u662f\u6392\u4ed6\u7684(exclusive)\u3002\u4e5f\u53eb\u72ec\u5360\u9501<\/p>\n<p>http:\/\/www.52youpiao.com\/it\/post\/mysql-slave.html<br \/>\u4e3b\u4ece\u4e92\u5907<br \/>\u4e24\u53f0\u670d\u52a1\u5668\u4e92\u4e3a\u4e3b\u4ece\uff0c\u53cc\u5411\u540c\u6b65\u6570\u636e\u3002\u5f53\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u7684\u6570\u636e\u6709\u589e\u5220\u6539\u7b49\u64cd\u4f5c\u65f6\uff0c\u53e6\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u7684mysql\u540c\u6b65\u7684\u6570\u636e\u5e93\u4e5f\u6709\u540c\u6837\u7684\u64cd\u4f5c\u3002\u5229\u7528MySQL\u4e3b\u4ece\u540c\u6b65\u539f\u7406\uff0c\u5b9e\u73b0MySQL\u53cc\u5411\u540c\u6b65\u3002<\/p>\n<p>\u5b9e\u65bd\u73af\u5883<\/p>\n<p>\u670d\u52a1\u5668\u4e3awindows 2008 R2\uff0cmysql\u7248\u672c\u4e3a5.5.30\uff0c\u670d\u52a1\u5668server1\uff1a192.168.0.165 server2\uff1a192.168.0.166<\/p>\n<p>1\u3001\u914d\u7f6e\u6570\u636e\u5e93my.ini\u6587\u4ef6<\/p>\n<p>\u4fee\u6539server1\uff1a192.168.0.165\u7684my.ini\u6587\u4ef6\uff0c\u589e\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p>server-id=1<br \/>binlog-do-db=ctbsdb<br \/>binlog-ignore-db=mysql<br \/>log-slave-updates<br \/>replicate-do-db=ctbsdb<br \/>replicate-ignore-db=mysql<br \/>log-bin=mysql-bin<\/p>\n<p>auto<em>increment<\/em>offset=1<br \/>auto<em>increment<\/em>increment=2<\/p>\n<p>\u4fee\u6539server2\uff1a192.168.0.166\u7684my.ini\u6587\u4ef6\uff0c\u589e\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p>server-id=2<br \/>binlog-do-db=ctbsdb<br \/>binlog-ignore-db=mysql<br \/>log-slave-updates<br \/>replicate-do-db=ctbsdb<br \/>replicate-ignore-db=mysql<br \/>log-bin=mysql-bin<\/p>\n<p>auto<em>increment<\/em>offset=2<br \/>auto<em>increment<\/em>increment=2<\/p>\n<p>\u91cd\u542f\u4e24\u53f0\u673a\u5668\u7684mysql\u670d\u52a1\u3002<\/p>\n<p>\u914d\u7f6e\u9879\u91ca\u4e49<\/p>\n<p>server-id\uff1a\u6807\u8bc6\uff0c\u552f\u4e00\uff0c\u503c\u8303\u56f4\u5728\uff1a1\u81f32^23-1<\/p>\n<p>binlog-do-db\u548creplicate-to-db\uff1a\u8981\u540c\u6b65\u7684\u6570\u636e\u5e93\uff0c\u591a\u4e2a\u9700\u8981\u540c\u6b65\u7684\u6570\u636e\u53ef\u4ee5\u7ee7\u7eed\u5411\u4e0b\u5199<\/p>\n<p>binlog-ignore-db\u548creplicate-ignore-db\uff1a\u4e0d\u9700\u8981\u540c\u6b65\u7684\u6570\u636e\u5e93<\/p>\n<p>log-bin\uff1a\u914d\u7f6e\u662f\u5426\u5728\u6570\u636e\u5e93\u6709\u53d8\u52a8\u65f6\u5199\u4e8c\u8fdb\u5236\u65e5\u5fd7<\/p>\n<p>auto<em>increment<\/em>offset\u548cauto<em>increment<\/em>increment\uff1a\u5f53\u540c\u6b65\u65ad\u5f00\uff0c\u4e24\u53f0\u670d\u52a1\u5668\u5206\u522b\u6709\u65b0\u6570\u636e\u8fdb\u5165\uff0c\u90a3\u4e48\u4e3b\u952eID\u662f\u81ea\u589e\u957f\u5217\u4f1a\u51fa\u73b0\u51b2\u7a81\u7684\u60c5\u51b5\uff0c\u4f1a\u5bfc\u81f4\u540c\u6b65\u65e0\u6cd5\u7ee7\u7eed\u3002\u52a0\u4e0a\u4e0a\u9762\u4e24\u4e2a\u8bbe\u7f6e\u540eserver1\u7684auto_increment\u5b57\u6bb5\u4ea7\u751f\u7684\u6570\u503c\u662f\uff1a1, 3, 5, 7, \u2026\u7b49\u5947\u6570\uff0cserver2\u7684\u4e3a\u5076\u6570\u3002<\/p>\n<p>auto<em>increment<\/em>offset\u548cauto<em>increment<\/em>increment \u503c\u5f97\u8bbe\u7f6e\u95ee\u9898<br \/>\u7b2c\u4e8c\u4e2a\u53d8\u91cf\u540d auto<em>increment<\/em>offset \u6307 \u81ea\u589e\u5b57\u6bb5\u7684\u8d77\u59cb\u503c\u3002<br \/>\u6bd4\u5982\uff0c\u6709\u4e2a\u8868test\uff0c\u5b57\u6bb5id\u4e3a\u4e3b\u952e\uff0c\u81ea\u589e\uff1b<br \/>\u5982\u679cauto<em>increment<\/em>offset=1 \uff0c \u5e76\u4e14auto<em>increment<\/em>increment=1\uff0c\u90a3\u4e48\u5411\u8868\u4e2d\u63d2\u5165\u7b2c\u4e00\u6761\u6570\u636e\u65f6\uff0c\u5219\u8be5\u6761\u6570\u636e\u7684id=1\uff0c\u7b2c\u4e8c\u6761id=2\uff0c\u7b2c\u4e09\u6761id=3\u4ee5\u6b64\u7c7b\u63a8\u2026\u2026<br \/>\u5982\u679cauto<em>increment<\/em>offset=2 \uff0c \u5e76\u4e14auto<em>increment<\/em>increment=10\uff0c\u90a3\u4e48\u5411\u8868\u4e2d\u63d2\u5165\u7b2c\u4e00\u6761\u6570\u636e\u65f6\uff0c\u5219\u8be5\u6761\u6570\u636e\u7684id=2\uff0c\u7b2c\u4e8c\u6761id=12\uff0c\u7b2c\u4e09\u6761id=22\u4ee5\u6b64\u7c7b\u63a8\u2026\u2026<br \/>\u6ce8\u610f\uff1a\u5982\u679cauto<em>increment<\/em>offset\u7684\u503c\u5927\u4e8eauto<em>increment<\/em>increment\u7684\u503c\uff0c\u5219auto<em>increment<\/em>offset\u7684\u503c\u88ab\u5ffd\u7565\u3002<br \/>\u540c\u65f6\u4e0d\u4f1a\u5f71\u54cd\u5df2\u521b\u5efa\u8868\u7684ID\u503c<\/p>\n<p>\u4fee\u6539AUTO<em>INCREMENT\u7684\u503c<br \/>alter room<\/em>sequence AUTO_INCREMENT=10001;<\/p>\n<p>http:\/\/hi.baidu.com\/dba_hui\/item\/5773cd7f6df750266cc37c49<\/p>\n<p>SHOW VARIABLES LIKE &#8216;auto<em>inc%&#8217;;<br \/>SET @auto<\/em>increment_offset=5; (\u8bbe\u7f6e\u521d\u59cb\u503c)<\/p>\n<p>\u5bfc\u51fa\u6570\u636e \u53ea\u5bfc\u51fa\u8868\u7ed3\u6784 \u4e0d\u5bfc\u51fa\u6570\u636e<br \/>mysqldump &#8211;opt -d shanliao1 -u root -p &gt; shanliao1.sql<\/p>\n<p><!-- This document was created with MarkdownPad, the Markdown editor for Windows (http:\/\/markdownpad.com) --><\/p>\n<p>\u7edf\u8ba1\u6700\u5927\u7684\u8868\u7684\u8bed\u53e5:<\/p>\n<p><p>SELECT TABLE_NAME,&nbsp; CONCAT(ROUND((data_length+index_length)\/(1024*1024*1024), 2), &#8216; G&#8217;)&nbsp; AS &#8216;total&#8217; ,<br \/>CONCAT(ROUND(data_length\/(1024*1024*1024.), 2), &#8216; G&#8217;) AS &#8216;Data Size&#8217;,<br \/> CONCAT(ROUND(index_length\/(1024*1024*1024), 2), &#8216; G&#8217;) AS &#8216;Index Size&#8217; ,<br \/>TABLE_ROWS<br \/>FROM&nbsp; `TABLES` WHERE TABLE_SCHEMA=&#8217;db_G2S_OnlineSchool&#8217; ORDER BY TABLE_ROWS&nbsp; DESC limit 10; <\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2015\/07\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2015\/07\/image_thumb.png\" width=\"514\" height=\"178\"><\/a><\/p>\n<\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2015\/07\/image.png\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2015\/07\/image.png\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[95,170],"class_list":{"0":"post-2994","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-5","7":"tag-mysql","9":"category-5-id","10":"post-seq-1","11":"post-parity-odd","12":"meta-position-corners","13":"fix"},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/2994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2994"}],"version-history":[{"count":3,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/2994\/revisions"}],"predecessor-version":[{"id":4451,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/2994\/revisions\/4451"}],"wp:attachment":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}