{"id":6021,"date":"2021-06-16T13:57:27","date_gmt":"2021-06-16T05:57:27","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=6021"},"modified":"2025-10-21T14:39:52","modified_gmt":"2025-10-21T06:39:52","slug":"txsql-%e7%81%be%e9%9a%be%e6%81%a2%e5%a4%8d","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=6021","title":{"rendered":"TXSQL \u4e09\u8282\u70b9\u6545\u969c\uff0c\u707e\u96be\u60c5\u51b5\u4e0b\uff0c\u6570\u636e\u6062\u590d\u65b9\u6848"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<p>\u5f53\u51fa\u73b0 txsql \u670d\u52a1\u4e0d\u53ef\u7528\uff0c\u6240\u6709 txsql pod \u7684\u72b6\u6001\u5747\u4e3a 0\/1 running \u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u672c\u6848\u4f8b\u7684\u65b9\u6cd5\u6062\u590d txsql \u7684\u6570\u636e\uff1b<\/p>\n<hr \/>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<p>\u4e3b\u8981\u7684\u64cd\u4f5c\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u4ee5 read-only \u6a21\u5f0f\u542f\u52a8\u6240\u6709 txsql pod \u4e2d\u7684 mysql \u670d\u52a1\uff1b<\/li>\n<li>\u5907\u4efd\u6240\u6709 txsql server \u8282\u70b9\u7684\u6570\u636e\uff1b<\/li>\n<li>\u5220\u9664 txsql \u6bcf\u4e2a\u8282\u70b9\u4e0a\u7684\u6570\u636e\u76ee\u5f55\uff0c\u5f3a\u5236 txsql \u5728\u4e0b\u6b21\u91cd\u542f\u65f6\u91cd\u65b0\u521d\u59cb\u5316\u670d\u52a1\uff1b<\/li>\n<li>\u5c06\u5907\u4efd\u7684\u6570\u636e\u5bfc\u5165 txsql\uff1b<\/li>\n<\/ol>\n<p><strong>PS\uff1a\u5efa\u8bae\u76f4\u63a5\u5bf9\u4e09\u4e2a txsql server \u90fd\u6267\u884c\u5168\u5e93\u5907\u4efd\u3002<\/strong><\/p>\n<hr \/>\n<h4>1\u3001\u4ee5 read_only \u6a21\u5f0f\u542f\u52a8 txsql \u4e2d\u7684 mysql \u670d\u52a1<\/h4>\n<p><strong>1.1. \u627e\u5230 mysqld \u7684\u542f\u52a8\u547d\u4ee4\uff1a<\/strong><\/p>\n<p>\u542f\u52a8 txsql \u670d\u52a1\uff0c\u7b49\u5f85\u6240\u6709\u7684 txsql pod \u72b6\u6001\u4e3a 0\/1 running\uff1b\u7136\u540e<strong>\u4f9d\u6b21\u8fdb\u5165\u6240\u6709 txsql \u7684 pod<\/strong>\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<strong><code>kubectl exec -it txsql-server-txsql1-xxxxxxxxxx-xxxxx bash<\/code><\/strong>\uff0c<br \/>\n\u7136\u540e\u4f7f\u7528 <code>ps -ef |grep mysqld<\/code> \u627e\u5230 mysqld \u7684\u542f\u52a8\u547d\u4ee4\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/06\/image-1623378521766.png\" alt=\"file\" \/><br \/>\n<img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/06\/image-1623378720824.png\" alt=\"file\" \/><\/p>\n<p>\u6ce8\u610f\uff1a\u9009\u62e9\u7684\u90e8\u5206\u5373\u4e3a mysqld \u7684\u542f\u52a8\u547d\u4ee4\uff0c\u9700\u8981\u7c98\u8d34\u5230\u6587\u672c\u4e2d\u5907\u7528<\/p>\n<pre><code class=\"language-shell\">\/usr\/bin\/txsql\/sbin\/mysqld --defaults-file=\/usr\/bin\/txsql\/etc\/my.cnf --basedir=\/usr\/bin\/txsql\/percona.src --datadir=\/vdir\/hadoop\/txsql\/percona.workspace\/data --plugin-dir=\/usr\/bin\/txsql\/percona.src\/lib\/mysql\/plugin --user=mysql --super-read-only --log-error=\/vdir\/hadoop\/txsql\/log\/my.err --pid-file=\/vdir\/hadoop\/txsql\/percona.workspace\/data\/percona.pid --socket=\/vdir\/hadoop\/txsql\/percona.workspace\/tmp\/percona.sock --port=13306 --rpl_phx_sync_master=OFF &<\/code><\/pre>\n<p><strong>1.2. \u4fee\u6539\u811a\u672c <code>\/usr\/bin\/txsql\/tools\/txsql.sh<\/code> \u9632\u6b62 txsql \u7684 pod \u81ea\u52a8\u91cd\u542f\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/strong><\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/06\/image-1623379128074.png\" alt=\"file\" \/><\/p>\n<p>\u7136\u540e\u6267\u884c <strong><code>\/usr\/bin\/txsql\/tools\/txsql.sh kill<\/code><\/strong> \uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/06\/image-1623379412511.png\" alt=\"file\" \/><\/p>\n<p><strong>1.3. \u4ee5 read-only \u6a21\u5f0f\u542f\u52a8 txsql pod \u4e2d\u7684 mysql \u670d\u52a1<\/strong><\/p>\n<p>\u5728 1.1 \u6b65\u4fdd\u5b58\u7684 mysqld \u542f\u52a8\u547d\u4ee4\u540e\u9762\u6dfb\u52a0\u4e00\u4e2a\u53c2\u6570\uff1a<strong><code>--rpl_phx_sync_master=OFF<\/code><\/strong>\uff0c\u5e76\u5728\u672b\u5c3e\u589e\u52a0\u4e00\u4e2a &amp; \u540e\u53f0\u8fd0\u884c mysqld\uff1b\u7136\u540e\u5728 pod \u5185\u6267\u884c\uff1b\u5207\u8bb0\u8981\u4f7f\u7528\u73b0\u573a\u4fdd\u7559\u7684\u542f\u52a8\u547d\u4ee4\u6765\u6267\u884c\uff1b\u7136\u540e<strong><code>ps -ef|grep mysqld<\/code><\/strong>\u9a8c\u8bc1 mysqld \u542f\u52a8\u72b6\u6001 \uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/06\/image-1623379702062.png\" alt=\"file\" \/><\/p>\n<h4>2\u3001\u5bf9\u4e09\u4e2a txsql server \u90fd\u6267\u884c\u5168\u5e93\u5907\u4efd\uff1b<\/h4>\n<p><strong>2.1. \u4f7f\u7528socket\u65b9\u5f0f\u767b\u5f55 mysql\u6570\u636e\u5e93\uff0c\u4e09\u4e2a txsql server pod \u90fd\u64cd\u4f5c<\/strong><br \/>\n-p \u540e\u9762\u7684\u5bc6\u7801\u662f \/etc\/txsql1\/conf\/db.properties \u4e2d\u7684\u5bc6\u7801\uff0c\u4f8b\u5982\uff1a<\/p>\n<p><strong>2.2. \u7136\u540e\u6267\u884c\u5168\u5e93\u5907\u4efd\uff1a<\/strong><\/p>\n<pre><code class=\"language-shell\">\/usr\/bin\/txsql\/percona.src\/bin\/mysqldump -h 172.22.22.2 -P 13306 -u[user_name] -p[user_password] --set-gtid-purged=off --triggers --routines --events  --all-databases > alldata.sql<\/code><\/pre>\n<p>\u786e\u5b9a\u5907\u4efd\u6570\u636e\u662f\u6b63\u786e\u7684\uff0c\u53ef\u4ee5\u7528 head \u548c tail \u67e5\u770b\u5907\u4efd\u6587\u4ef6\u7684\u5f00\u5934\u548c\u7ed3\u5c3e\u662f\u662f\u5426\u6b63\u786e\uff1b<\/p>\n<p>\u5c06\u5907\u4efd\u6570\u636e\u4fdd\u5b58\u5230\u5bbf\u4e3b\u673a\u8def\u5f84\uff0c\u6bd4\u5982\u5907\u4efd\u5230\u8282\u70b9\u7684 \/etc\/txsql1\/conf\/ \u8def\u5f84\u4e0b\uff0c\u7136\u540e\u518d cp \u4e00\u4efd\u5230 \/root\/ \u76ee\u5f55\u4e0b<\/p>\n<p>\u6bd4\u5bf9\u4e09\u4e2a\u5907\u4efd\u6587\u4ef6\u7684\u5927\u5c0f\uff0c\u9009\u62e9\u6587\u4ef6\u6700\u5927\u7684\u4e3a\u4e3b\u5e93\u6587\u4ef6\u3002<\/p>\n<h4>3\u3001\u5220\u9664 txsql \u6bcf\u4e2a\u8282\u70b9\u4e0a\u7684\u6570\u636e\u76ee\u5f55\uff0c\u5f3a\u5236 txsql \u5728\u4e0b\u6b21\u91cd\u542f\u65f6\u91cd\u65b0\u521d\u59cb\u5316\u670d\u52a1\uff1b<\/h4>\n<p><strong><font color = red>\u5371\u9669\u52a8\u4f5c\uff0c\u8bf7\u52a1\u5fc5\u5c0f\u5fc3\u8c28\u614e\u64cd\u4f5c<\/font><\/strong><br \/>\n\u505c\u6b62 txsql pod \u5185\u6240\u6709\u670d\u52a1\uff0c\u5220\u9664\u6240\u6709 txsql pod \u7684\u6570\u636e\u76ee\u5f55\u5185\u7684\u5168\u90e8\u5185\u5bb9\uff081.1 \u7684 mysqld \u542f\u52a8\u547d\u4ee4\u53c2\u6570 &#8211;datadir\uff0c\u8fd9\u91cc\u4e00\u5b9a\u8981\u770b\u6e05\u695a\uff0c\u662f datadir \uff0c\u8981\u628a\u6570\u636e\u76ee\u5f55\u4fdd\u7559\uff0c\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u5168\u5220\u6389\u3002\uff09<\/p>\n<pre><code class=\"language-shell\">\/usr\/bin\/txsql\/tools\/txsql.sh kill\n# \u9996\u5148\u505c\u6b62pod\u5185\u6240\u6709\u670d\u52a1\nrm -rf \/vdir\/hadoop\/txsql\/*\n\n# \u6b64\u5904\u5207\u8bb0\uff0c\u5982\u679c\u662f aquila-txsql \u6216\u8005 guardian-txsql \uff0cdata \u76ee\u5f55\u4e00\u5b9a\u8981\u4fdd\u7559\u3002\n# \u6b64\u5904\u5207\u8bb0\uff0c\u5982\u679c\u662f aquila-txsql \u6216\u8005 guardian-txsql \uff0cdata \u76ee\u5f55\u4e00\u5b9a\u8981\u4fdd\u7559\u3002\n# \u6b64\u5904\u5207\u8bb0\uff0c\u5982\u679c\u662f aquila-txsql \u6216\u8005 guardian-txsql \uff0cdata \u76ee\u5f55\u4e00\u5b9a\u8981\u4fdd\u7559\u3002\nrm -rf \/vdir\/guardian\/txsql\/data\/*\n\n# \u518d\u6b21\u63d0\u9192\uff0c\u5371\u9669\u64cd\u4f5c\uff0c\u8bf7\u786e\u4fdd\u5907\u4efd\u7684\u6570\u636e\u5df2\u7ecf\u5b58\u50a8\u5728pod\u4e4b\u5916\u7684\u5b89\u5168\u7684\u76ee\u5f55\u4e0b\uff01<\/code><\/pre>\n<p>\u5220\u9664\u4e4b\u540e\u5728 manager web \u754c\u9762\u91cd\u542f txsql \u670d\u52a1\u3002\u5927\u7ea6 10 \u5206\u949f\u540e\uff0ctxsql \u670d\u52a1\u88ab\u91cd\u65b0\u90e8\u7f72\uff0c\u6b64\u65f6TxSQL\u5e94\u8be5\u5904\u4e8e\u5065\u5eb7\u7684\u72b6\u6001\u3002<\/p>\n<h4>4\u3001\u5c06\u5907\u4efd\u7684\u6570\u636e\u5bfc\u5165 txsql\uff1b<\/h4>\n<p>\u91cd\u65b0\u90e8\u7f72\u6210\u529f\u540e\uff0c\u8fdb\u5165\u67d0\u4e2a txsql \u7684 pod\uff0ccd \/usr\/bin\/txsql\/tools\uff0c\u5c06\u6b65\u9aa4 2.2 \u5907\u4efd\u7684\u6570\u636e\u6587\u4ef6 alldata.sql \u4e0a\u4f20\u5230 \/usr\/bin\/txsql\/tools \u76ee\u5f55\u4e0b\uff1b<br \/>\n\u6267\u884c .\/txsql.sh shell \u767b\u5f55 txsql\uff0c \u7136\u540e source alldata.sql \u6062\u590d\u6570\u636e\uff1b<br \/>\n\u7136\u540e\u6267\u884c flush privileges \u5f3a\u5236 mysql \u5237\u65b0\u7528\u6237\u6743\u9650\uff0c\u5237\u65b0\u7528\u6237\u6743\u9650\u540e\u518d source \u4e00\u6b21\uff1b<\/p>\n<pre><code class=\"language-sql\">cd \/usr\/bin\/txsql\/tools\n.\/txsql.sh shell\n# \u6ce8\u610f\u8981source\u4e24\u6b21\uff0c\u7b2c\u4e00\u6b21 source \u4e4b\u540e\u6267\u884c flush privileges; \n# flush privileges \u524d\u5fc5\u987b\u8981\u5148 set sql_log_bin=0\uff0c\u5426\u5219\u4f1a\u5f15\u8d77\u4e25\u91cd\u7684\u9519\u8bef\uff0c\u7136\u540e\u518d source \u4e00\u6b21\nmysql> use mysql;\nmysql> set global super_read_only=off;\nmysql> set global read_only=off;\nmysql> source alldata.sql\nmysql> use mysql;\nmysql> set sql_log_bin=0;\nmysql> update user set password=password('password') where user = 'inceptoruser';\nmysql> GRANT ALL PRIVILEGES ON *.* TO inceptoruser@'%' IDENTIFIED BY 'password';\nmysql> flush privileges;\nmysql> source alldata.sql<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u5f53\u51fa\u73b0 txsql \u670d\u52a1\u4e0d\u53ef\u7528\uff0c\u6240\u6709 txsql pod \u7684\u72b6\u6001\u5747\u4e3a 0\/1 running \u65f6\uff0c\u53ef ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=6021\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6021","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/6021","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6021"}],"version-history":[{"count":5,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/6021\/revisions"}],"predecessor-version":[{"id":17509,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/6021\/revisions\/17509"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}