{"id":603,"date":"2014-04-13T15:37:47","date_gmt":"2014-04-13T07:37:47","guid":{"rendered":"http:\/\/www.gpfeng.com\/?p=603"},"modified":"2014-04-23T15:32:59","modified_gmt":"2014-04-23T07:32:59","slug":"galera-replication-for-mysql%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"http:\/\/www.gpfeng.com\/?p=603","title":{"rendered":"Galera replication for MySQL"},"content":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u603b\u7ed3\u4e86\u4e4b\u524d\u5bf9Galera replication\u7684\u8c03\u7814\uff0c\u5185\u5bb9\u5305\u62ecGalera\u7279\u6027\uff0c\u539f\u7406\uff0cGalera cluster\u914d\u7f6e\uff0c\u53c2\u6570\u53ca\u6027\u80fd\u7b49<\/p>\n<h3>Galera replication\u662f\u4ec0\u4e48<\/h3>\n<p>MySQL DBA\u53ca\u5f00\u53d1\u5e94\u8be5\u90fd\u77e5\u9053MySQL\u6e90\u751f\u590d\u5236\u53casemi-sync\u534a\u540c\u6b65\u590d\u5236\uff0c\u5b83\u4eec\u90fd\u57fa\u4e8eMySQL binlog\uff0c\u539f\u751f\u590d\u5236\u662f\u5b8c\u5168\u5f02\u6b65\u7684\uff0cmaster\u4e0d\u9700\u8981\u4fdd\u8bc1slave\u63a5\u6536\u5e76\u6267\u884c\u4e86binlog\uff0c\u80fd\u591f\u4fdd\u8bc1master\u6700\u5927\u6027\u80fd\uff0c\u4f46\u662fslave\u53ef\u80fd\u5b58\u5728\u5ef6\u8fdf\uff0c\u4e3b\u5907\u6570\u636e\u65e0\u6cd5\u4fdd\u8bc1\u4e00\u81f4\u6027\uff0c\u5728\u4e0d\u505c\u670d\u52a1\u7684\u524d\u63d0\u4e0b\u5982\u679cmaster\u5b95\u673a\u8ba9slave\u9876\u4e0a\uff0c\u5c31\u4f1a\u4e22\u5931\u6570\u636e\uff0csemi-sync\u5728\u5f02\u6b65\u590d\u5236\u57fa\u7840\u4e0a\u589e\u52a0\u4e86\u6570\u636e\u4fdd\u62a4\u7684\u8003\u8651\uff0cmaster\u5fc5\u987b\u786e\u8ba4slave\u6536\u5230binlog\u540e\uff08\u4f46\u4e0d\u4fdd\u8bc1slave\u6267\u884c\u4e86\u4e8b\u52a1\uff09\u624d\u80fd\u6700\u7ec8\u63d0\u4ea4\u4e8b\u52a1\uff0c\u5728\u6ca1\u6709\u9000\u5316\uff08\u5ef6\u8fdf\u8f83\u5927\u65f6\u53ef\u80fd\u53d1\u751f\uff09\u6210\u5f02\u6b65\u590d\u5236\u4e4b\u524d\u53ef\u4ee5\u4fdd\u8bc1\u6570\u636e\u5b89\u5168\uff0c\u6b64\u65f6master\u6302\u6389\u4e4b\u540e\uff0cslave\u53ef\u4ee5\u5728apply\u5b8c\u6240\u6709relay log\u540e\u5207\u6362\u6210master\u63d0\u4f9b\u8bfb\u5199\u670d\u52a1<\/p>\n<p>Galera replication\u662f<a href=\"http:\/\/www.codership.com\">codership<\/a>\u63d0\u4f9b\u7684MySQL\u6570\u636e\u540c\u6b65\u65b9\u6848\uff0c\u5177\u6709\u9ad8\u53ef\u7528\uff0c\u6613\u4e8e\u6269\u5c55\u7b49\u7279\u70b9\uff0c\u5b83\u5c06\u591a\u4e2aMySQL\u8282\u70b9\u7ec4\u7ec7\u6210\u4e00\u4e2acluster<br \/>\n<!--more--><\/p>\n<h4>Galera replication\u7279\u6027<\/h4>\n<p>1. \u540c\u6b65\u590d\u5236\uff0c\u4e3b\u5907\u65e0\u5ef6\u8fdf<br \/>\n2. \u652f\u6301\u591a\u4e3b\u540c\u65f6\u8bfb\u5199\uff0c\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027<br \/>\n3. \u96c6\u7fa4\u4e2d\u5404\u8282\u70b9\u4fdd\u5b58\u5168\u91cf\u6570\u636e<br \/>\n4. \u8282\u70b9\u6dfb\u52a0\/\u5220\u9664\uff0c\u81ea\u52a8\u68c0\u6d4b\u548c\u914d\u7f6e<br \/>\n5. \u884c\u7ea7\u522b\u5e76\u884c\u590d\u5236<br \/>\n6. \u4e0d\u9700\u8981\u5199binlog<\/p>\n<p>\u76f8\u5bf9\u4e8eMySQL\u6e90\u751f\u590d\u5236\u548csemi-sync\uff0cGalera replication\u6bd4\u8f83\u6709\u5438\u5f15\u529b\u7684\u7279\u6027\uff1a<br \/>\n1. \u540c\u6b65\u590d\u5236\uff0c\u4e3b\u5907\u65e0\u5ef6\u8fdf\uff0cmaster\u5b95\u673a\u540eslave\u53ef\u4ee5<strong>\u7acb\u5373\u9876\u4e0a\u5e76\u63d0\u4f9b\u670d\u52a1<\/strong>\uff08semi-sync\u9700\u8981apply\u5b8c\u6240\u6709relay log\uff09<br \/>\n2. \u4e8b\u52a1\u51b2\u7a81\u68c0\u6d4b\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027\uff0c\u591a\u4e2a\u8282\u70b9\u53ef\u4ee5\u540c\u65f6\u8bfb\u5199\u6570\u636e\uff0c\u53ef\u4ee5\u6781\u5927\u7b80\u5316\u6570\u636e\u8bbf\u95ee<br \/>\n3. \u884c\u7ea7\u522b\u5e76\u884c\u590d\u5236\uff0cMySQL 5.6\u4e4b\u524dslave sql\u7ebf\u7a0b\u53ea\u6709\u4e00\u4e2a\uff0c\u8fd9\u4e2a\u957f\u671f\u9971\u53d7\u8bdf\u75c5\uff0c\u662f\u5bfc\u81f4slave\u843d\u540emaster\u7684\u4e3b\u8981\u539f\u56e0<\/p>\n<h4>Galera replicateion\u9650\u5236<\/h4>\n<p>1. \u96c6\u7fa4\u81f3\u5c113\u4e2a\u8282\u70b9\uff082\u4e2a\u8282\u70b9\u4e5f\u53ef\u4ee5\u8fd0\u884c\uff09<br \/>\n2. \u5b58\u50a8\u5f15\u64ce\uff1aInnodb \/ XtraDB \/ Maria<br \/>\n3. \u4e0d\u652f\u6301\u7684SQL\uff1aLOCK \/ UNLOCK TABLES \/ GET_LOCK(), RELEASE_LOCK()\u2026<br \/>\n4. \u4e0d\u652f\u6301XA Transaction<\/p>\n<p>\u76ee\u524d\u53ef\u7528\u7684\u4ea7\u54c1\uff1a<a href=\"http:\/\/blog.mariadb.org\/please-test-the-mariadb-galera-cluster-release-candidate\">MariaDB Galera Cluster<\/a> \u548c <a href=\"http:\/\/www.percona.com\/software\/percona-xtradb-cluster\">Percona XtraDB Cluster<\/a><\/p>\n<h3>Galera replication\u539f\u7406<\/h3>\n<p>Galera replication\u662f\u4e00\u79cdCertification based replication\uff0c\u4fdd\u8bc1one-copy serializability\uff0c\u7406\u8bba\u57fa\u4e8e\u8fd9\u4e24\u7bc7\u8bba\u6587\uff1a<a http:\/\/www.cs.mcgill.ca\/~kemme\/papers\/vldb00.html>Don\u2019t be lazy, be consistent<\/a> \u548c <a http:\/\/library.epfl.ch\/theses\/?nr=2090>Database State Machine Approach<\/a><\/p>\n<h4>\u7b97\u6cd5\u793a\u610f\u56fe<\/h4>\n<p><a href=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_certification.jpg\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_certification.jpg?resize=585%2C226\" width=585 height=226  alt=\"Galera_certification\" data-recalc-dims=\"1\" \/><\/a><br \/>\n\u56fe\u7247\u6765\u81ea\u4e0a\u9762\u4e24\u7bc7\u8bba\u6587<\/p>\n<h4>\u7b97\u6cd5\u4f2a\u4ee3\u7801(Certification\u5305\u542b\u4e86\u540e\u7eed\u6d41\u7a0b\uff0c\u6765\u81ea\u4e0a\u9762\u4e24\u7bc7\u8bba\u6587)<\/h4>\n<p><a href=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_algorithm.jpg\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_algorithm.jpg?w=660\" alt=\"Galera_algorithm\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<h4>\u4e8b\u52a1\u6267\u884c\u534f\u8bae<\/h4>\n<p>\u9075\u5b88deferred update replication\uff0c\u4e8b\u52a1\u5728commit\u65f6\u624d\u590d\u5236\u5230\u5176\u4ed6\u8282\u70b9\uff0c\u6267\u884c\u8fc7\u7a0b\u5206\u4e3a4\u4e2a\u9636\u6bb5\uff1a<\/p>\n<pre lang=\"c\">\r\n1\uff0eLocal read phase\r\n  a) \u672c\u5730\uff08client\u8fde\u63a5\u5230\u7684\u8282\u70b9\uff09\u6267\u884c\u4e8b\u52a1Ti\uff0c\u4f46\u4e0d\u771f\u6b63\u63d0\u4ea4\uff0c\u771f\u6b63\u63d0\u4ea4\u4e4b\u524d\u8fdb\u5165Send phase\r\n2\uff0eSend phase\r\n  a) \u82e5\u4e8b\u52a1\u53ea\u8bfb\uff0c\u76f4\u63a5\u63d0\u4ea4\uff0c\u7ed3\u675f\uff08\u591a\u7248\u672c\uff0c\u53ea\u8bfb\u4e8b\u52a1\u4e0d\u52a0\u9501\uff09\r\n  b) \u5c06\u4e8b\u52a1\u7684\u5199\u64cd\u4f5c\u5c01\u88c5\u6210WS\uff08Write Set\uff0c\u57fa\u4e8e\u884c\uff09\uff0c\u5e7f\u64ad\u5230\u6240\u6709\u8282\u70b9\uff08\u5305\u62ec\u81ea\u8eab\uff09\r\n3\uff0eLock \/ Certificaion phase\r\n  a) \u5bf9\u6536\u5230\u7684WS\u4e2d\u7684\u6bcf\u4e2aWSi(X)\r\n    i. \u82e5X\u6ca1\u6709\u88ab\u52a0\u9501\uff0c\u5bf9X\u52a0\u9501\r\n    ii. \u82e5X\u5df2\u88abTj\u52a0\u9501\u4e14Tj\u5904\u4e8eLocal read phase\/Send phase\uff0c\u56de\u6edaTj\uff0c\u5bf9X\u52a0\u9501\r\n    iii. Certification based conflict detect\r\n4\uff0eWrite phase\r\n  a) \u82e5\u68c0\u6d4b\u51fa\u51b2\u7a81\uff0c\u56de\u6edaTi\r\n  b) \u5426\u5219\uff0c\u6267\u884cWS\uff0c\u63d0\u4ea4\u4e8b\u52a1\u540e\u91ca\u653e\u9501\u8d44\u6e90\r\n  c) \u5bf9\u4e8e\u6e90\u8282\u70b9\uff0c\u63d0\u4ea4\u4e8b\u52a1\u5e76\u5411client\u8fd4\u56de\u7ed3\u679c\r\n<\/pre>\n<h4>\u5ba2\u6237\u7aef\/Galera\u8282\u70b9\u4fe1\u606f\u4ea4\u4e92\u56fe<\/h4>\n<p><a href=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_Certification_1.png\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_Certification_1.png?w=660\" alt=\"Galera_Certification_1\" data-recalc-dims=\"1\" \/><\/a><br \/>\n\u56fe\u7247\u6765\u81ea<a href=\"http:\/\/www.mysqlperformanceblog.com\">mysqlperformanceblog<\/a><\/p>\n<p>Galera replication\u91c7\u53d6\u7684\u662f\u4e50\u89c2\u7b56\u7565\uff0c\u5373\u4e8b\u52a1\u5728\u4e00\u4e2a\u8282\u70b9\u63d0\u4ea4\u65f6\uff0c\u88ab\u8ba4\u4e3a\u4e0e\u5176\u4ed6\u8282\u70b9\u4e0a\u7684\u4e8b\u52a1\u6ca1\u6709\u51b2\u7a81\uff0c\u9996\u5148\u5728\u672c\u5730\u201c\u6267\u884c\u201d\uff08\u4e4b\u6240\u4ee5\u5e26\u5f15\u53f7\uff0c\u662f\u56e0\u4e3a\u4e8b\u52a1\u6ca1\u6709\u6267\u884c\u5b8c\uff09\u540e\u518d\u53d1\u9001\u5230\u6240\u6709\u8282\u70b9\u505a\u51b2\u7a81\u68c0\u6d4b\uff0c\u5b58\u5728\u4e24\u79cd\u60c5\u51b5\u4e0b\u9700\u8981\u56de\u6eda\u4e8b\u52a1\uff1a<br \/>\n1. WS\u590d\u5236\u5230\u5176\u5b83\u8282\u70b9\uff0c\u88ab\u52a0\u5230\u6bcf\u4e2a\u8282\u70b9\u7684slave trx queue\u4e2d\uff0c\u4e0equeue\u4e2d\u524d\u9762\u7684trxs\u5728\u505acertification test\u65f6\u53d1\u73b0\u51b2\u7a81<br \/>\n2. WS\u901a\u8fc7\u4e86certification test\u540e\u88ab\u4fdd\u8bc1\u4e00\u5b9a\u4f1a\u6267\u884c\uff0c\u5728\u5b83\u6267\u884c\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u8be5\u8282\u70b9\u4e0a\u6709\u4e0e\u5176\u51b2\u7a81\u7684local trxs(Local phase)\uff0c\u56de\u6edalocal trxs<\/p>\n<p>Galera\u63d0\u4f9b\u4e86\u4e24\u4e2a\u72b6\u6001\u53c2\u6570\u8bb0\u5f55\u51b2\u7a81\uff1a<br \/>\nwsrep_local_cert_failures\uff1acertification test\u4e2d\u672a\u901a\u8fc7\u7684trx\u6570\u76ee<br \/>\nwsrep_local_bf_aborts\uff1aapply trxs\uff08\u5df2\u7ecf\u901a\u8fc7certification test\uff09\u65f6\uff0c\u56de\u6eda\u7684local trxs\uff08open but not commit\uff09\u6570\u76ee<\/p>\n<p>\u56e0\u6b64\u4e8b\u52a1\u5728commit\u8282\u70b9\u5e7f\u64ad\u540e\uff0c<strong>\u8282\u70b9\u4e4b\u95f4\u4e0d\u4ea4\u6362\u201c\u662f\u5426\u51b2\u7a81\u201d\u7684\u4fe1\u606f\uff0c\u5404\u4e2a\u8282\u70b9\u72ec\u7acb\u5f02\u6b65\u7684\u5904\u7406\u8be5\u4e8b\u52a1<\/strong>\uff0ccertification based replication\u534f\u8bae\u4fdd\u8bc1\uff1a<br \/>\n1. \u4e8b\u52a1\u5728\u6240\u6709\u8282\u70b9\u4e0a\u8981\u4e48\u90fdcommit\uff0c\u8981\u4e48\u90fdrollback\/abort<br \/>\n2. \u4e8b\u52a1\u5728\u6240\u6709\u8282\u70b9\u7684\u6267\u884c\u987a\u5e8f\u4e00\u81f4<\/p>\n<p>Certification based replication\u6240\u4f9d\u8d56\u7684\u57fa\u7840\u6280\u672f\uff1a<br \/>\nGroup Communication System<br \/>\n1) Atomic delivery (\u4e8b\u52a1\u4f20\u8f93\u8981\u4e48\u6210\u529f\u4f20\u7ed9\u4e86\u6240\u6709\u8282\u70b9\uff0c\u8981\u4e48\u90fd\u5931\u8d25)<br \/>\n2) Total order (\u4e8b\u52a1\u5728\u6240\u6709\u8282\u70b9\u4e2d\u7684\u987a\u5e8f\u4e00\u81f4)<br \/>\n3) Group maintenance (\u6bcf\u4e2a\u8282\u70b9\u77e5\u9053\u6240\u6709\u8282\u70b9\u7684\u72b6\u6001)<\/p>\n<h4>\u4f20\u7edf\u76842PC\uff08\u4e24\u9636\u6bb5\u63d0\u4ea4\uff09\u505a\u6cd5<\/h4>\n<p>1. 2PC \u4e8b\u52a1\u7ed3\u675f\u65f6\uff0c\u6240\u6709\u8282\u70b9\u6570\u636e\u8fbe\u5230\u4e00\u81f4<br \/>\n2. \u534f\u8c03\u8005\u4e0e\u53c2\u4e0e\u8005\u4e4b\u95f4\u901a\u4fe1\uff0c\u53c2\u4e0e\u8005\u4e4b\u95f4\u65e0\u8fde\u63a5<br \/>\n3. \u53d7\u7f51\u7edc\u72b6\u6001\u5f71\u54cd\u8f83\u5927<br \/>\n4. \u4e24\u6b21\u901a\u4fe1\uff0c\u9700\u8981\u5f97\u5230\u6bcf\u4e2a\u53c2\u4e0e\u8005\u7684\u53cd\u9988\u540e\u624d\u80fd\u51b3\u5b9a\u662f\u5426\u63d0\u4ea4\u4e8b\u52a1<\/p>\n<p>\u56e0\u6b64Galera replicateion\u76f8\u5bf9\u4e8e2PC\u51cf\u5c11\u4e86\u7f51\u7edc\u4f20\u8f93\u6b21\u6570\uff0c\u6d88\u9664\u4e86\u7b49\u5f85\u8282\u70b9\u8fd4\u56de\u201c\u51b3\u5b9a\u662f\u5426\u51b2\u7a81\u201d\u7684\u65f6\u95f4\uff0c\u4ece\u800c\u53ef\u4ee5\u63d0\u9ad8\u4e86\u6027\u80fd<\/p>\n<h4>Galera replication\u539f\u7406\u603b\u7ed3<\/h4>\n<p>1. \u4e8b\u52a1\u5728\u672c\u5730\u8282\u70b9\u6267\u884c\u65f6\u91c7\u53d6\u4e50\u89c2\u7b56\u7565\uff0c\u6210\u529f\u5e7f\u64ad\u5230\u6240\u6709\u8282\u70b9\u540e\u518d\u505a\u51b2\u7a81\u68c0\u6d4b<br \/>\n2. \u68c0\u6d4b\u51fa\u51b2\u7a81\u65f6\uff0c\u672c\u5730\u4e8b\u52a1\u4f18\u5148\u88ab\u56de\u6eda<br \/>\n3. \u6bcf\u4e2a\u8282\u70b9\u72ec\u7acb\u3001\u5f02\u6b65\u6267\u884c\u961f\u5217\u4e2d\u7684WS<br \/>\n4. \u4e8b\u52a1T\u5728A\u8282\u70b9\u6267\u884c\u6210\u529f\u8fd4\u56de\u5ba2\u6237\u7aef\u540e\uff0c\u5176\u4ed6\u8282\u70b9\u4fdd\u8bc1T\u4e00\u5b9a\u4f1a\u88ab\u6267\u884c\uff0c\u56e0\u6b64\u6709\u53ef\u80fd\u5b58\u5728\u5ef6\u8fdf\uff0c\u5373\u865a\u62df\u540c\u6b65<br \/>\n<a href=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_latency.jpg\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_latency.jpg?w=660\" alt=\"Galera_latency\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<h4>Galera flow control<\/h4>\n<p>galera\u662f\u540c\u6b65\u590d\u5236\uff08\u865a\u62df\u540c\u6b65\uff09\u65b9\u6848\uff0c\u4e8b\u52a1\u5728\u672c\u5730\u8282\u70b9\uff08\u5ba2\u6237\u7aef\u63d0\u4ea4\u4e8b\u52a1\u7684\u8282\u70b9\uff09\u4e0a\u63d0\u4ea4\u6210\u529f\u65f6\uff0c\u5176\u5b83\u8282\u70b9\u4fdd\u8bc1\u6267\u884c\u8be5\u4e8b\u52a1\u3002\u5728\u63d0\u4ea4\u4e8b\u52a1\u65f6\uff0c\u672c\u5730\u8282\u70b9\u628a\u4e8b\u52a1\u590d\u5236\u5230\u6240\u6709\u8282\u70b9\u540e\uff0c\u4e4b\u540e\u5404\u4e2a\u8282\u70b9\u72ec\u7acb\u5f02\u6b65\u5730\u8fdb\u884ccertification test\u3001\u4e8b\u52a1\u63d2\u5165\u5f85\u6267\u884c\u961f\u5217\u3001\u6267\u884c\u4e8b\u52a1\u3002\u7136\u800c\u7531\u4e8e\u4e0d\u540c\u8282\u70b9\u4e4b\u95f4\u6267\u884c\u4e8b\u52a1\u7684\u901f\u5ea6\u4e0d\u4e00\u6837\uff0c\u957f\u65f6\u95f4\u8fd0\u884c\u540e\uff0c\u6162\u8282\u70b9\u7684\u5f85\u6267\u884c\u961f\u5217\u53ef\u80fd\u4f1a\u8d8a\u79ef\u8d8a\u957f\uff0c\u6700\u7ec8\u53ef\u80fd\u5bfc\u81f4\u4e8b\u52a1\u4e22\u5931\u3002<\/p>\n<p>galera\u5185\u90e8\u5b9e\u73b0\u4e86flow control\uff0c\u4f5c\u7528\u5c31\u662f\u534f\u8c03\u5404\u4e2a\u8282\u70b9\uff0c\u4fdd\u8bc1\u6240\u6709\u8282\u70b9\u6267\u884c\u4e8b\u52a1\u7684\u901f\u5ea6\u5927\u4e8e\u961f\u5217\u589e\u957f\u901f\u5ea6\uff0c\u4ece\u800c\u907f\u514d\u4e22\u5931\u4e8b\u52a1\u3002\u5b9e\u73b0\u539f\u7406\u548c\u7b80\u5355\uff1a\u6574\u4e2agalera cluster\u4e2d\uff0c\u540c\u65f6\u53ea\u6709\u4e00\u4e2a\u8282\u70b9\u53ef\u4ee5\u5e7f\u64ad\u6d88\u606f\uff08\u6570\u636e\uff09\uff0c\u6bcf\u4e2a\u8282\u70b9\u90fd\u4f1a\u83b7\u5f97\u5e7f\u64ad\u6d88\u606f\u7684\u673a\u4f1a\uff08\u83b7\u5f97\u673a\u4f1a\u540e\u4e5f\u53ef\u4ee5\u4e0d\u5e7f\u64ad\uff09\uff0c\u5f53\u6162\u8282\u70b9\u7684\u5f85\u6267\u884c\u961f\u5217\u8d85\u8fc7\u4e00\u5b9a\u957f\u5ea6\u540e\uff0c\u5b83\u4f1a\u5e7f\u64ad\u4e00\u4e2aFC_PAUSE\u6d88\u606f\uff0c\u6240\u4ee5\u8282\u70b9\u6536\u5230\u6d88\u606f\u540e\u90fd\u4f1a\u6682\u7f13\u5e7f\u64ad\u6d88\u606f\uff0c\u76f4\u5230\u8be5\u6162\u8282\u70b9\u7684\u5f85\u6267\u884c\u961f\u5217\u957f\u5ea6\u51cf\u5c0f\u5230\u4e00\u5b9a\u957f\u5ea6\u540e\uff0cgalera cluster\u6570\u636e\u540c\u6b65\u53c8\u5f00\u59cb\u6062\u590d<\/p>\n<h4>flow control\u76f8\u5173\u53c2\u6570\uff1a<\/h4>\n<p>gcs.fc_limit\uff1a\u5f85\u6267\u884c\u961f\u5217\u957f\u5ea6\u8d85\u8fc7\u8be5\u503c\u65f6\uff0cflow control\u88ab\u89e6\u53d1\uff0c\u5bf9\u4e8eMaster-Slave\u6a21\u5f0f(\u53ea\u5728\u4e00\u4e2a\u8282\u70b9\u5199)\u7684galera cluster\uff0c\u53ef\u4ee5\u914d\u7f6e\u4e00\u4e2a\u8f83\u5927\u7684\u503c\uff0c\u5bf9\u542f\u52a8\u591a\u5199\u7684galera cluster\uff0c\u8f83\u5c0f\u7684\u503c\u6bd4\u8f83\u5408\u9002\uff0c\u56e0\u4e3a\u8f83\u5927\u5f85\u6267\u884c\u961f\u5217\u957f\u5ea6\u610f\u5473\u7740\u66f4\u5927\u7684\u51b2\u7a81\uff0c\u9ed8\u8ba4\u503c16<br \/>\ngcs.fc_factor\uff1a\u5f53\u5f85\u6267\u884c\u961f\u5217\u957f\u5ea6\u5f00\u59cb\u5c0f\u4e8e(gcs.fc_factor*gcs.fc_limit)\u65f6\uff0c\u6570\u636e\u540c\u6b65\u6062\u590d,\u9ed8\u8ba40.5<br \/>\ngcs.fc_master_slave\uff1agalera cluster\u662f\u5426\u4e3aMaster-Slave\u6a21\u5f0f\uff0c\u9ed8\u8ba4<\/p>\n<h3>\u5b89\u88c5MariaDB Galera Cluster<\/h3>\n<h4>\u5b89\u88c5\u51c6\u5907\uff1a<\/h4>\n<p>1. MariaDB Galera Cluster 5.5.28a RC<br \/>\n1) https:\/\/downloads.mariadb.org\/mariadb-galera\/5.5.28a\/<br \/>\n2) patched MariaDB 5.5.28\uff0c\u4ee3\u7801\u4e2d\u589e\u52a0\u4e86Galera Library API\uff08wsrep API\uff09\uff0c\u5e76\u5728\u4e8b\u52a1\u3001\u9501\u3001handler\u7b49\u6a21\u5757\u6dfb\u52a0\/\u4fee\u6539\u4e86\u8c03\u7528\u903b\u8f91<\/p>\n<p>2. Galera wsrep provider<br \/>\n1) https:\/\/launchpad.net\/galera\/+download<br \/>\n2) Galera Library\u7684\u5b9e\u73b0\uff0c\u5176\u4e2d\u5b9e\u73b0\u4e86group communication system, certification<\/p>\n<h4>\u7f16\u8bd1\u5b89\u88c5<\/h4>\n<p>1. MariaDB Galera Cluster 5.5.28a RC<br \/>\n1) \u4e0eMariaDB\u57fa\u672c\u76f8\u540c\uff0ccmake\u65f6\u589e\u52a0\u4e24\u9879\uff1a-DWITH_WSREP=ON , -DWITH_INNODB_DISALLOW_WRITES=1.<br \/>\n2. Galera wsrep provider: \u6e90\u7801\u7f16\u8bd1\u540e\u5f97\u5230libgalera_smm.so(\u9700\u8981\u7528\u5230scons)<\/p>\n<h4>\u53c2\u6570\u914d\u7f6e\uff08\u6bcf\u4e2a\u8282\u70b9\uff09<\/h4>\n<p>wsrep_provider = \/path\/to\/libgalera_smm.so<br \/>\nwsrep_cluster_address = cluster connection URL(\u540e\u9762\u8be6\u7ec6\u4ecb\u7ecd)<br \/>\nbinlog_format = ROW<br \/>\ndefault_storage_engine = INNODB<br \/>\ninnodb_autoinc_lock_mode = 2<br \/>\ninnodb_locks_unsafe_for_binlog = 1<\/p>\n<p>\u9009\u914d\uff1a\uff08\u53ef\u4ee5\u63d0\u9ad8\u6027\u80fd\uff0cgalera\u4fdd\u8bc1\u4e0d\u4e22\u6570\u636e\uff09<br \/>\ninnodb_flush_log_at_trx_commit = 2<\/p>\n<h4>\u6784\u5efa\u96c6\u7fa4\uff08\u4e09\u4e2a\u8282\u70b9\uff09<\/h4>\n<div class=\"table-responsive\"><table  style=\"width:500px; \"  class=\"easy-table easy-table-default \" border=\"1\">\n<caption>3-node-cluster<\/caption>\n<thead>\r\n<tr><th  style=\"width:250px;text-align:left\" >\u8282\u70b9\u540d\u79f0<\/th>\n<th  style=\"width:250px;text-align:left\" >ip\u5730\u5740<\/th>\n<\/tr>\n<\/thead>\n<tbody>\r\n<tr><td  style=\"text-align:left\" >galera_node1<\/td>\n<td  style=\"text-align:left\" >10.0.0.11<\/td>\n<\/tr>\n\r\n<tr><td  style=\"text-align:left\" >galera_node2<\/td>\n<td  style=\"text-align:left\" >10.0.0.22<\/td>\n<\/tr>\n\r\n<tr><td  style=\"text-align:left\" >galera_node3<\/td>\n<td  style=\"text-align:left\" >10.0.0.33<\/td>\n<\/tr>\n<\/tbody><\/table><\/div>\n<h4>\u65b0\u5efaGalera Cluster<\/h4>\n<p>\u4ee5galera_node1\u4f5c\u4e3a\u7b2c\u4e00\u4e2a\u8282\u70b9\u65b0\u5efa\u96c6\u7fa4\uff0c\u5728my.cnf\u4e2d\u914d\u7f6e\u53c2\u6570\uff1a<\/p>\n<pre lang=\"shell\">\r\nwsrep_cluster_address = gcomm:\/\/\r\nwsrep_cluster_name = galera_cluster\r\nwsrep_node_address = 10.0.0.11\r\nwsrep_node_name = galera_node1\r\nwsrep_sst_method = rsync\r\n<\/pre>\n<h4>\u6dfb\u52a0galera_node2\u8282\u70b9<\/h4>\n<p>\u5728my.cnf\u4e2d\u914d\u7f6ewsrep_cluster_address\u4e3anode1\u7684ip\u6216\u8005hostname<\/p>\n<pre lang=\"shell\">\r\nwsrep_cluster_address = gcomm:\/\/10.0.0.11\r\nwsrep_cluster_name = galera_cluster\r\nwsrep_node_address = 10.0.0.22\r\nwsrep_node_name = galera_node2\r\nwsrep_sst_method = rsync\r\n<\/pre>\n<h4>\u6dfb\u52a0galera_node3\u8282\u70b9<\/h4>\n<p>\u5728my.cnf\u4e2d\u914d\u7f6ewsrep_cluster_address\u4e3anode1\u7684ip\u6216\u8005hostname<\/p>\n<pre lang=\"shell\">\r\nwsrep_cluster_address = gcomm:\/\/10.0.0.11\r\nwsrep_cluster_name = galera_cluster\r\nwsrep_node_address = 10.0.0.33\r\nwsrep_node_name = galera_node3\r\nwsrep_sst_method = rsync\r\n<\/pre>\n<h4>\u591a\u5b9e\u4f8b\u914d\u7f6e<\/h4>\n<p>\u56e0\u4e3a\u6d4b\u8bd5\u673a\u5668\u8d44\u6e90\u6709\u9650\uff0c\u9700\u8981\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u542f\u52a8\u591a\u4e2amysqld\u5b9e\u4f8b\uff0c\u4e3a\u6bcf\u4e2amysqld\u914d\u7f6e\u4e24\u4e2a\u7aef\u53e3\u53f7\uff08\u4e00\u4e2a\u662fmysql server\u7aef\u53e3\u53f7\uff0c\u9ed8\u8ba43306\uff1b\u53e6\u5916\u4e00\u4e2a\u662fwsrep\u7aef\u53e3\u53f7\uff0c\u9ed8\u8ba44567\uff09\uff0c\u5e76\u4fee\u6539\u90e8\u5206wsrep\u914d\u7f6e\u53c2\u6570\uff0c\u4f8b\u5982\uff1a<br \/>\n<div class=\"table-responsive\"><table  style=\"width:500px; \"  class=\"easy-table easy-table-default \" border=\"1\">\n<caption>galera-cluster<\/caption>\n<thead>\r\n<tr><th  style=\"width:50px;text-align:left\" >\u8282\u70b9\u540d\u79f0<\/th>\n<th  style=\"width:50px;text-align:left\" >ip\u5730\u5740<\/th>\n<th  style=\"width:50px\" >server port<\/th>\n<th  style=\"width:50px\" >wsrep port<\/th>\n<th  style=\"width:300px\" >wsrep\u914d\u7f6e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\r\n<tr><td  style=\"text-align:left\" >galera_node1<\/td>\n<td  style=\"text-align:left\" >127.0.0.1<\/td>\n<td >3306<\/td>\n<td >4405<\/td>\n<td >wsrep_cluster_address=gcomm:\/\/ wsrep_node_address=127.0.0.1:4405 port=3306<\/td>\n<\/tr>\n\r\n<tr><td  style=\"text-align:left\" >galera_node2<\/td>\n<td  style=\"text-align:left\" >127.0.0.1<\/td>\n<td >3307<\/td>\n<td >4407<\/td>\n<td >wsrep_cluster_address=gcomm:\/\/127.0.0.1:4405 wsrep_node_address=127.0.0.1:4407 port=3307<\/td>\n<\/tr>\n\r\n<tr><td  style=\"text-align:left\" >galera_node3<\/td>\n<td  style=\"text-align:left\" >127.0.0.1<\/td>\n<td >308<\/td>\n<td >4409<\/td>\n<td >wsrep_cluster_addres=gcomm:\/\/ 127.0.0.1:4405 wsrep_node_address=127.0.0.1:4409 port=3308<\/td>\n<\/tr>\n<\/tbody><\/table><\/div><\/p>\n<p>\u542f\u52a8\u540e\u5728\u6bcf\u4e2a\u8282\u70b9\u6267\u884c\uff1a<\/p>\n<pre lang=\"mysql\">\r\nmysql> show status like \u2018wsrep%\u2019;\r\n<\/pre>\n<p>\u5f53\u770b\u5230\u4e0b\u8ff0\u72b6\u6001\u65f6:<\/p>\n<pre lang=\"shell\">\r\nwsrep_connected=ON\r\nwsrep_ready=ON\r\nwsrep_cluster_status =Primary\r\nwsrep_cluster_size=3(\u8282\u70b9\u4e2a\u6570)\r\n<\/pre>\n<p>\u5219galera\u96c6\u7fa4\u5efa\u7acb\u6210\u529f\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_status.jpg\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_status.jpg?w=660\" alt=\"Galera_status\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p><strong>\u8bf4\u660e\uff1a<\/strong><br \/>\n1. MariaDB Galera Cluster 5.5.28a RC\u6e90\u7801\u5b89\u88c5\uff0c\u5728\u7f16\u8bd1\u65f6\u82e5\u6ca1\u6709\u6253\u5f00-DWITH_WSREP=ON, -DWITH_INNODB_DISALLOW_WRITES=1\uff0c\u6216\u8005\u6ca1\u6709\u914d\u7f6e\u4efb\u4f55wsrep\u76f8\u5173\u53c2\u6570\uff0c\u5b83\u8fd0\u884c\u65f6\u5c31\u662f\u4e00\u4e2a\u666e\u901a\u7684mysqld\u5b9e\u4f8b<br \/>\n2. Galera cluster\u590d\u5236\u4e0d\u4f9d\u8d56\u4e8ebinlog\u6587\u4ef6\uff0c\u56e0\u6b64mysql-binlog\u548clog-slave-updates\u90fd\u53ef\u4ee5\u4e0d\u914d\u7f6e\uff0c\u5f53\u7136\u5982\u679c\u9700\u8981\u8bb0\u5f55binlog\uff0c\u4e5f\u53ef\u4ee5\u6253\u5f00<br \/>\n3. \u9700\u8981\u4ee5wsrep_cluster_address = gcomm:\/\/\u542f\u52a8\u7b2c\u4e00\u4e2a\u8282\u70b9\u540e\uff0c\u624d\u80fd\u76f8\u7ee7\u6dfb\u52a0\u5176\u4ed6\u8282\u70b9<\/p>\n<h3>Galera\u76f8\u5173\u53c2\u6570\u914d\u7f6e<\/h3>\n<h4>InnoDB \u76f8\u5173\u53c2\u6570<\/h4>\n<p>galera\u8865\u4e01\u7248\u7684mysql\u5728cmake\u65f6\u9700\u8981\u6307\u5b9a\uff1a<br \/>\n-DWITH_WSREP=ON , -DWITH_INNODB_DISALLOW_WRITES=1<\/p>\n<p>galera \u76ee\u524d\u53ea\u652f\u6301Innodb\/xtradb\/mariad\u5b58\u50a8\u5f15\u64ce<br \/>\ndefault_storage_engine = INNODB<\/p>\n<p>\u4e3a\u4e86\u964d\u4f4e\u51b2\u7a81\uff0c\u4e0b\u5217\u4e24\u9879\u9700\u8981\u8bbe\u7f6e<br \/>\ninnodb_autoinc_lock_mode = 2<br \/>\ninnodb_locks_unsafe_for_binlog = 1\uff08gap\u4e0d\u52a0\u9501\uff09<\/p>\n<p>\u9009\u914d\uff1a\uff08\u53ef\u4ee5\u63d0\u9ad8\u6027\u80fd\uff0cgalera\u4fdd\u8bc1\u4e0d\u4e22\u6570\u636e\uff09<br \/>\ninnodb_flush_log_at_trx_commit = 2<\/p>\n<p>\u9009\u914d\uff1agalera\u53ef\u4ee5\u4e0d\u5199binlog\uff0c\u6ce8\u91cabinlog\u8def\u5f84\u7406\u8bba\u4e0a\u53ef\u4ee5\u63d0\u9ad8\u6027\u80fd<br \/>\n#log-bin<br \/>\n#log-slave-updates=1<\/p>\n<h4>wsrep \u76f8\u5173\u53c2\u6570<\/h4>\n<p>wsrep\u53c2\u6570\u90fd\u662f\u4ee5wsrep_\u5f00\u5934\u7684(30+\u4e2a)\uff0c\u5176\u4e2d\u6709\u4e00\u4e2a\u5b57\u7b26\u4e32\u53c2\u6570\uff08wsrep_provider_options\uff09\u53ef\u4ee5\u914d\u7f6e50+\u4e2a\u66f4\u5e95\u5c42\u7684\u53c2\u6570\u3002<br \/>\n\u53ef\u4ee5\u901a\u8fc7\u201cshow variables like wsrep%\u201d\u67e5\u770b\uff0cwsrep_\u5f00\u5934\u53c2\u6570\uff0c\u70b9\u51fb\u67e5\u770b<a href=\"http:\/\/www.codership.com\/wiki\/doku.php?id=mysql_options_0.8\">\u8be6\u60c5<\/a><\/p>\n<p>\u5217\u4e3e\u51e0\u4e2a\u91cd\u8981\u7684\u53c2\u6570\uff1a<\/p>\n<pre lang=\"shell\">\r\nwsrep_auto_increment_control\uff1a\u63a7\u5236auto_increment_increment=#nodes\u548cauto_increment_offset=#node_id\uff0c\u9ed8\u8ba4ON\r\nwsrep_causal_reads\uff1a\u9ed8\u8ba4\u662f\u5728\u672c\u5730\u8282\u70b9\u8bfb\uff0c\u8bfb\u5230\u7684\u53ef\u80fd\u4e0d\u662f\u6700\u65b0\u6570\u636e\uff0c\u5f00\u542f\u540e\u5c06\u8bfb\u5230\u6700\u65b0\u6570\u636e\uff0c\u4f46\u4f1a\u589e\u52a0\u54cd\u5e94\u65f6\u95f4\uff0c\u9ed8\u8ba4OFF\r\nwsrep_certify_nonPK\uff1a\u4e3a\u6ca1\u6709\u663e\u793a\u7533\u660e\u4e3b\u952e\u7684\u8868\u751f\u6210\u4e00\u4e2a\u7528\u4e8ecertification test\u7684\u4e3b\u952e\uff0c\u9ed8\u8ba4ON\r\nwsrep_cluster_address: \u542f\u52a8\u8282\u70b9\u65f6\u9700\u8981\u6307\u5b9agalera cluster\u7684\u5730\u5740,\u4f5c\u4e3acluster\u4e2d\u7b2c\u4e00\u4e2a\u542f\u52a8\u7684\u8282\u70b9\uff0cwsrep_cluster_address=gcomm:\/\/,\u5bf9\u4e8e\u540e\u7eed\u542f\u52a8\u7684\u8282\u70b9\uff0cwsrep_cluster_address=gcomm:\/\/node1,node2,node3\t\r\nwsrep_cluster_name: \u6240\u6709node\u5fc5\u987b\u4e00\u6837, \u9ed8\u8ba4my_test_cluster\r\nwsrep_convert_LOCK_to_trx\uff1a\u5c06LOCK\/UNLOCK TABLES\u8f6c\u6362\u6210BEGIN\/COMMIT\uff0c\u9ed8\u8ba4OFF\r\nwsrep_data_home_dir\uff1agalera\u4f1a\u751f\u6210\u4e00\u4e9b\u6587\u4ef6\uff0c\u9ed8\u8ba4\u4f7f\u7528mysql_data_dir\uff0c\u9ed8\u8ba4mysql_data_dir\r\nwsrep_node_name\uff1a\u8282\u70b9\u540d\u79f0\r\nwsrep_on\uff1asession\/global,\u8bbe\u7f6e\u4e3aOFF\u65f6\uff0c\u4e8b\u52a1\u5c06\u4e0d\u4f1a\u590d\u5236\u5230\u5176\u4ed6\u8282\u70b9\uff0c\u9ed8\u8ba4ON\r\nwsrep_OSU_method\uff1aOnline Schema Update\u8bbe\u7f6e\uff0cTOI\/RSU(MySQL >= 5.5.17)\uff0c\u9ed8\u8ba4TOI\r\nwsrep_provider\uff1alibgalera_smm.so\u7684\u8def\u5f84\uff0c\u82e5\u6ca1\u6709\u914d\u7f6e\uff0cgalera\u590d\u5236\u4e0d\u4f1a\u542f\u52a8\uff0c\u9ed8\u8ba4none\r\nwsrep_provider_options\uff1a\u5f88\u957f\u7684\u5b57\u7b26\u4e32\u53d8\u91cf\uff0c\u53ef\u4ee5\u914d\u7f6e\u5f88\u591agroup communication system\u76f8\u5173\u53c2\u6570\uff0c\u5f88\u957f\u5f88\u957f...\r\nwsrep_retry_autocommit\uff1a\u4e8b\u52a1\u5728\u51b2\u7a81\u65f6\u91cd\u65b0\u5c1d\u8bd5\u7684\u6b21\u6570\uff0c\u9ed8\u8ba41\r\nwsrep_slave_threads\uff1a\u5e76\u884c\u590d\u5236\u7684slave\u7ebf\u7a0b\u6570\uff0c\u9ed8\u8ba44\r\nwsrep_sst_method\uff1aSnapshot State Transter\u65b9\u6cd5\uff1amysqldump\/rsync\/xt\uff0c\u9ed8\u8ba4mysqldump\r\n<\/pre>\n<p><strong>wsrep_provider_options<\/strong><br \/>\n\u8be5\u53c2\u6570\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5305\u542b\u4e86group communication system\u4e2d\u5f88\u591a\u53c2\u6570\u8bbe\u7f6e\uff0c\u914d\u7f6e\u65f6\u4f7f\u7528\u5206\u53f7\u9694\u5f00\uff1a<br \/>\nwsrep_provider_options=&#8221;key_a=value_a;key_b=value_b;key_c=value_c&#8221;\uff0c\u70b9\u51fb\u67e5\u770b<a href=\"http:\/\/www.codership.com\/wiki\/doku.php?id=galera_parameters\">\u8be6\u60c5<\/a><\/p>\n<p>\u5217\u4e3e\u5176\u4e2d\u90e8\u5206\u91cd\u8981\u53c2\u6570\uff1a<\/p>\n<pre lang=\"shell\">\r\nevs.send_window\uff1a\u8282\u70b9\u4e00\u6b21\u53ef\u4ee5\u53d1\u9001\u7684\u6d88\u606f\u6570\u76ee\uff0c\u9ed8\u8ba44\r\nevs.user_send_window\uff1a\u5176\u4e0eevs.send_window\u4e4b\u95f4\u7684\u5dee\u522b\u7c7b\u4f3c\u4e8emax_connections\u4e0emax_user_connection\uff0c\u9ed8\u8ba42\r\ngcs.fc_factor\uff1aflow control\u53c2\u6570\uff0c\u9ed8\u8ba40.5\r\ngcs.fc_limit\uff1aflow control\u53c2\u6570\uff0c\u9ed8\u8ba416\r\ngcs.fc_master_slave\uff1aflow control\u53c2\u6570\uff0c\u9ed8\u8ba4NO\r\ngcs.recv_q_hard_limit\uff1a\u63a5\u6536\u961f\u5217\u7684\u5360\u7528\u7684\u6700\u5927\u5185\u5b58\uff0c\u9ed8\u8ba4LLONG_MAX\r\ngcs.recv_q_soft_limit\uff1a\u5f53\u63a5\u6536\u961f\u5217\u5360\u7528\u5185\u5b58\u8d85\u8fc7(gcs.recv_q_hard_limit*gcs.recv_q_soft_limit),\u590d\u5236\u88ab\u5ef6\u8fdf\uff0c\u9ed8\u8ba40.25\r\ngmcast.listen_addr\uff1a\u8282\u70b9\u7528\u4e8e\u63a5\u6536\u5176\u5b83\u8282\u70b9\u6d88\u606f\u7684\u5730\u5740\uff0c\u9ed8\u8ba4tcp:\/\/0.0.0.0:4567\r\npc.checksum\uff1a\u662f\u5426\u5bf9\u53d1\u9001\u7684\u6d88\u606f\u505achecksum\uff0c\u9ed8\u8ba4true\r\npc.ignore_sb\uff1a\u662f\u5426\u5ffd\u7565split brain\uff0c\u9ed8\u8ba4false\r\n<\/pre>\n<h4>\u4e00\u4e2a\u4f8b\u5b50<\/h4>\n<pre lang=\"shell\">\r\nbinlog_format=row \r\ndefault-storage-engine = INNODB \r\ninnodb_autoinc_lock_mode = 2 \r\ninnodb_locks_unsafe_for_binlog = 1\r\nwsrep_provider = \/u01\/mariadb-galera\/lib\/libgalera_smm.so \r\nwsrep_cluster_address = \"gcomm:\/\/192.168.xxx.01\" \r\nwsrep_cluster_name = galera \r\nwsrep_node_address = 192.168.xxx.xxx \r\nwsrep_node_name = slave \r\nwsrep_sst_method = rsync \r\nwsrep_slave_threads = 16 \r\nwsrep_provider_options=\"gcache.page_size=128M;gcache.size=2G;gcs.fc_limit=512;gcs.fc_factor=0.9;evs.send_window=256;evs.user_send_window=128\"\r\n<\/pre>\n<h3>Galera status variables<\/h3>\n<p>Galera\u63d0\u4f9b\u4e86\u5f88\u591a\u4ee5wsrep_\u5f00\u5934\u72b6\u6001\u53c2\u6570\u76d1\u63a7mysql\u72b6\u6001\uff0c\u901a\u8fc7show status like &#8216;wsrep%&#8217;\u53ef\u4ee5\u67e5\u770b\uff1a<\/p>\n<pre lang=\"shell\">\r\nwsrep_local_state_uuid\uff1a\u5e94\u8be5\u4e0ewsrep_cluster_state_uuid\u4e00\u81f4\uff0c\u5982363acc29-9160-11e2-0800-4316271a76e4\r\nwsrep_last_committed\uff1a\u5df2\u7ecf\u63d0\u4ea4\u4e8b\u52a1\u6570\u76ee\uff0c\u6240\u6709\u8282\u70b9\u4e4b\u95f4\u76f8\u5dee\u4e0d\u5927\uff0c\u53ef\u4ee5\u7528\u6765\u8ba1\u7b97\u5ef6\u8fdf\r\nwsrep_replicated\uff1a\u4ece\u672c\u5730\u8282\u70b9\u590d\u5236\u51fa\u53bb\u7684write set\u6570\u76ee\r\nwsrep_replicated_bytes\uff1a\u4ece\u672c\u5730\u8282\u70b9\u590d\u5236\u51fa\u53bb\u7684write set\u7684\u603b\u5171\u5b57\u8282\u6570\r\nwsrep_received\uff1a\u672c\u5730\u8282\u70b9\u63a5\u6536\u6765\u81ea\u5176\u4ed6\u8282\u70b9\u7684write set\u6570\u76ee\r\nwsrep_received_bytes\uff1a\u672c\u5730\u8282\u70b9\u63a5\u6536\u6765\u81ea\u5176\u4ed6\u8282\u70b9\u7684write set\u7684\u603b\u5171\u5b57\u8282\u6570\r\nwsrep_local_commits\uff1a\u4ece\u672c\u5730\u8282\u70b9\u53d1\u51fa\u7684write set\u88ab\u63d0\u4ea4\u7684\u6570\u76ee\uff0c\u4e0d\u8d85\u8fc7wsrep_replicated\r\nwsrep_local_cert_failures\uff1acertification test\u5931\u8d25\u7684\u6570\u76ee\r\nwsrep_local_bf_aborts\uff1acertification test\u901a\u8fc7\u7684write set\u6267\u884c\u8fc7\u7a0b\u4e2d\u56de\u6eda\u7684\u4e0e\u5176\u51b2\u7a81\u7684\u672c\u5730\u4e8b\u52a1\r\nwsrep_local_replays\uff1a\u4e8b\u52a1\u88ab\u56de\u6eda\uff08bf abort\uff09\u91cd\u505a\u7684\u6570\u76ee\r\nwsrep_local_send_queue\uff1a\u53d1\u9001\u961f\u5217\u7684\u957f\u5ea6\r\nwsrep_local_send_queue_avg\uff1a\u4ece\u4e0a\u6b21\u67e5\u8be2\u72b6\u6001\u5230\u76ee\u524d\u53d1\u9001\u961f\u5217\u7684\u5e73\u5747\u957f\u5ea6\uff0c>0.0\u610f\u5473\u7740\u590d\u5236\u8fc7\u7a0b\u88ab\u8282\u6d41\u4e86\r\nwsrep_local_recv_queue\uff1a\u63a5\u6536\u961f\u5217\u7684\u957f\u5ea6\r\nwsrep_local_recv_queue_avg\uff1a\u4ece\u4e0a\u6b21\u67e5\u8be2\u72b6\u6001\u5230\u76ee\u524d\u63a5\u6536\u961f\u5217\u7684\u5e73\u5747\u957f\u5ea6\uff0c>0.0\u610f\u5473\u7740\u6267\u884c\u901f\u5ea6\u5c0f\u4e8e\u63a5\u6536\u901f\u5ea6\r\nwsrep_flow_control_paused\uff1a\u4ece\u4e0a\u6b21\u67e5\u8be2\u72b6\u6001\u5230\u76ee\u524d\u5904\u4e8eflow control\u7684\u65f6\u95f4\u5360\u6bd4\uff0c\u59820.388129\r\nwsrep_flow_control_sent\uff1a\u4ece\u4e0a\u6b21\u67e5\u8be2\u72b6\u6001\u5230\u76ee\u524d\u8282\u70b9\u53d1\u9001\u51fa\u7684FC_PAUSE\u6d88\u606f\u6570\u76ee\uff0c\u59821\r\nwsrep_flow_control_recv\uff1a\u4ece\u4e0a\u6b21\u67e5\u8be2\u72b6\u6001\u5230\u76ee\u524d\u53ca\u8282\u70b9\u63a5\u6536\u7684FC_PAUSE\u6d88\u606f\u6570\u76ee\uff0c\u59821\r\nwsrep_cert_deps_distance\uff1a\u53ef\u4ee5\u5e76\u884c\u6267\u884c\u7684write set\u7684\u6700\u5927seqno\u4e0e\u6700\u5c0fseqno\u4e4b\u95f4\u7684\u5e73\u5747\u5dee\u503c\uff0c\u59821851.825751\r\nwsrep_apply_oooe\uff1a\u961f\u5217\u4e2d\u4e8b\u52a1\u5e76\u53d1\u6267\u884c\u5360\u6bd4\uff0c\u503c\u8d8a\u9ad8\u610f\u5473\u7740\u6548\u7387\u8d8a\u9ad8\r\nwsrep_commit_window\uff1a\u5e73\u5747\u5e76\u53d1\u63d0\u4ea4\u7a97\u53e3\u5927\u5c0f\r\nwsrep_local_state\uff1a\u8282\u70b9\u7684\u72b6\u6001,\u53d6\u503c1-6\r\nwsrep_local_state_comment\uff1a\u8282\u70b9\u7684\u72b6\u6001\u63cf\u8ff0\uff0c\u6bd4\u5982Synced\r\nwsrep_incoming_addresses\uff1a\u96c6\u7fa4\u4e2d\u5176\u5b83\u8282\u70b9\u7684\u5730\u5740\uff0c\u591a\u4e2a\u5730\u5740\u4e4b\u95f4\u7528\u9017\u53f7\u5206\u9694\r\nwsrep_cluster_conf_id\uff1a\u96c6\u7fa4\u8282\u70b9\u5173\u7cfb\u6539\u53d8\u7684\u6b21\u6570\uff08\u6bcf\u6b21\u589e\u52a0\/\u5220\u9664\u90fd\u4f1a+1\uff09\r\nwsrep_cluster_size\uff1a\u96c6\u7fa4\u8282\u70b9\u4e2a\u6570\r\nwsrep_cluster_state_uuid\uff1a\u96c6\u7fa4uuid\uff0c\u6240\u6709\u8282\u70b9\u5e94\u8be5\u4e00\u6837\uff0c\u5982\uff1a363acc29-9160-11e2-0800-4316271a76e4\r\nwsrep_cluster_status\uff1a\u96c6\u7fa4\u7684\u76ee\u524d\u72b6\u6001\uff0c\u53d6\u503c\uff1aPRIMARY\uff08\u6b63\u5e38\uff09\/NON_PRIMARY\uff08\u4e0d\u4e00\u81f4\uff09\r\nwsrep_connected\uff1a\u8282\u70b9\u662f\u5426\u8fde\u63a5\u5230\u96c6\u7fa4\uff0c\u53d6\u503c\uff1aON\/OFF\r\nwsrep_local_index\uff1a\u8282\u70b9id\r\nwsrep_provider_name\uff1a\u9ed8\u8ba4Galera\r\nwsrep_provider_vendor\uff1a\u9ed8\u8ba4Codership Oy <info@codership.com>\r\nwsrep_provider_version\uff1awsrep\u7248\u672c\uff0c\u5982\uff1a2.2(rXXXX)\r\nwsrep_ready\uff1a\u8282\u70b9\u662f\u5426\u53ef\u4ee5\u63a5\u53d7\u67e5\u8be2\u4e86\uff0c\u53d6\u503c\uff1aON\/OFF\r\n<\/pre>\n<h4>\u4e00\u4e2a\u622a\u56fe\uff1a<\/h4>\n<p><a href=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_status_1.jpg\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_status_1.jpg?w=660\" alt=\"Galera_status_1\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<h4>\u5982\u4f55\u68c0\u67e5\u8282\u70b9\u662f\u5426\u52a0\u5165\u5230\u96c6\u7fa4<\/h4>\n<p>1. wsrep_cluster_state_uuid\u5e94\u8be5\u4e0e\u5176\u5b83\u6240\u6709\u8282\u70b9\u76f8\u540c<br \/>\n2. wsrep_cluster_conf_id\u5e94\u8be5\u4e0e\u5176\u5b83\u6240\u6709\u8282\u70b9\u76f8\u540c<br \/>\n3. wsrep_cluster_size\u5e94\u8be5\u662f\u6240\u6709\u8282\u70b9\u7684\u6570\u76ee<br \/>\n4. wsrep_cluster_status\u53d6\u503c\u5e94\u8be5\u662f\uff1aPrimary<br \/>\n5. wsrep_ready\u53d6\u503c\u5e94\u8be5\u662fON<br \/>\n6. wsrep_connected\u53d6\u503c\u5e94\u8be5\u662fON<\/p>\n<h4>\u5224\u65ad\u590d\u5236\u8fc7\u7a0b\u662f\u5426\u51fa\u73b0\u95ee\u9898<\/h4>\n<p>wsrep_flow_control_paused\uff0c\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u5176\u53d6\u503c\u5e94\u8be5\u63a5\u8fd1\u4e8e0.0\uff0c\u5927\u4e8e0.0\u610f\u5473\u7740\u6709\u2018\u6162\u8282\u70b9\u2019\u5f71\u54cd\u4e86\u96c6\u7fa4\u7684\u901f\u5ea6\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u901a\u8fc7\u589e\u5927wsrep_slave_threads\u6765\u89e3\u51b3<\/p>\n<h4>\u627e\u51fa\u6700\u6162\u7684\u8282\u70b9<\/h4>\n<p>wsrep_flow_control_sent,wsrep_local_recv_queue_avg\u4e24\u4e2a\u503c\u6700\u5927\u7684\u8282\u70b9<\/p>\n<p>\u53c2\u8003\uff1a<a href=\"http:\/\/www.codership.com\/wiki\/doku.php?id=galera_status_0.8\">galera status<\/a>\uff0c<a href=\"http:\/\/www.codership.com\/wiki\/doku.php?id=monitoring\">galera monitoring<\/a><\/p>\n<h3>\u6027\u80fd\u6d4b\u8bd5<\/h3>\n<p>\u7531\u4e8egalera\u540c\u6b65\u590d\u5236\u5728\u6bcf\u4e2a\u5199\u4e8b\u52a1\u63d0\u4ea4\u65f6\u90fd\u589e\u52a0\u4e86replicate trx\u548ccertification test\u7684\u5f00\u9500\uff0c\u56e0\u6b64\u6027\u80fd\u8fdc\u8fdc\u4f4e\u4e8e\u5f02\u6b65MySQL\u5b9e\u4f8b<\/p>\n<h4>\u6d4b\u8bd5\u573a\u666f<\/h4>\n<p>\u4f7f\u7528TPCC\u8fdb\u884c\u6d4b\u8bd5\uff0c\u5305\u542b3\u7ec4\u6570\u636e\uff1a<br \/>\n1\u3001normal mysql: baseline\uff0c\u5355\u4e2amysql server<br \/>\n2\u3001galera (RTT: 0.5ms): 2-nodes galera cluster\uff0c\u5355\u8282\u70b9\u8bfb\u5199<br \/>\n3\u3001galera (RTT: 15.2ms): 2-nodes galera cluster\uff0c\u5355\u8282\u70b9\u8bfb\u5199<\/p>\n<p>tpmC\u7ed3\u679c:<br \/>\n<a href=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_performance.jpg\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_performance.jpg?w=660\" alt=\"Galera_performance\" data-recalc-dims=\"1\" \/><\/a><br \/>\nTPS\u7ed3\u679c\uff1a<br \/>\n<a href=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_performance_tps.jpg\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gpfeng.com\/wp-content\/uploads\/2014\/04\/Galera_performance_tps.jpg?w=660\" alt=\"Galera_performance_tps\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<h4>\u6d4b\u8bd5\u7ed3\u8bba\uff1a<\/h4>\n<p>1. \u76f8\u5bf9\u4e8e\u5f02\u6b65MySQL\u5b9e\u4f8b\uff0cGalera replication\u6027\u80fd\u4e0b\u964d\u7ea650% ~ 60%\u5de6\u53f3<br \/>\n2. Galera\u6700\u5927\u6027\u80fd\u4e0d\u53d7RTT\u5f71\u54cd\uff0cRTT \u8f83\u5c0f\u65f6\uff080.5ms\uff09\uff0c\u5728\u8fbe\u5230\u6700\u5927\u6027\u80fd\u4e4b\u524d\uff0832\u5e76\u53d1\uff09\uff0c\u6027\u80fd\u4e0b\u964d\u5e76\u4e0d\u660e\u663e \uff0832\u5e76\u53d1\u4e0b\u964d25%\uff0c16\u5e76\u53d1\u6027\u80fd\u4e0b\u964d\u66f4\u4f4e\uff09\uff0cRTT\u8f83\u5927\u65f6\uff0815.2ms\uff09\uff0c\u5728\u8fbe\u5230\u6700\u5927\u6027\u80fd\u4e4b\u524d\uff0864\u5e76\u53d1\uff09\uff0c\u76f8\u5bf9\u4e8enorml  mysq\u6027\u80fd\u4e0b\u964d\u4e00\u76f4\u5230\u5f88\u660e\u663e\uff0c\u5f53\u538b\u529b\u9010\u6e10\u589e\u5927\uff0c\u7531\u4e8egroup io\u7684\u539f\u56e0\uff0cgalera\u6027\u80fd\u5728\u8fbe\u5230\u6700\u5927\u65f6\u8fd8\u4f1a\u63d0\u9ad8<\/p>\n<h3>Galera replication for MySQL\u5b66\u4e60\u8d44\u6599<\/h3>\n<p>1. <a href=\"http:\/\/www.codership.com\">codership\u5b98\u7f51<\/a><br \/>\n2. <a href=\"http:\/\/www.mysqlperformanceblog.com\">mysqlperformanceblog<\/a>\u641c\u7d22\u4e2dPXC(Percona XtraDB Cluster)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u603b\u7ed3\u4e86\u4e4b\u524d\u5bf9Galera replication\u7684\u8c03\u7814\uff0c\u5185\u5bb9\u5305\u62ecGalera\u7279\u6027\uff0c\u539f\u7406\uff0cGalera  &hellip; <a href=\"http:\/\/www.gpfeng.com\/?p=603\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Galera replication for MySQL<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3tPZp-9J","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/603"}],"collection":[{"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=603"}],"version-history":[{"count":15,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/603\/revisions"}],"predecessor-version":[{"id":632,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/603\/revisions\/632"}],"wp:attachment":[{"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=603"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}