{"id":1178,"date":"2019-05-08T00:00:00","date_gmt":"2019-05-08T00:00:00","guid":{"rendered":"https:\/\/en.pingcap.com\/blog\/tidb-binlog-tutorial\/"},"modified":"2023-09-12T03:52:57","modified_gmt":"2023-09-12T10:52:57","slug":"tidb-binlog-tutorial","status":"publish","type":"post","link":"https:\/\/www.pingcap.com\/ko\/blog\/tidb-binlog-tutorial\/","title":{"rendered":"TiDB Binlog Tutorial"},"content":{"rendered":"<p>This tutorial will start with a very simple TiDB Binlog deployment with a single node of each component (Placement Driver, TiKV Server, TiDB Server, Pump, and Drainer), set up to push data into a MariaDB Server instance.<\/p>\n<p>This tutorial is targeted toward users who have some familiarity with the <a href=\"https:\/\/docs.pingcap.com\/tidb\/stable\/tidb-architecture\/\">TiDB Architecture<\/a>, who may have already set up a TiDB cluster (though that is not mandatory), and who wants to gain hands-on familiarity with the features and functionality of TiDB Binlog. This tutorial is a good way to &#8220;kick the tires&#8221; of TiDB Binlog and to familiarize yourself with the concepts of its architecture.<\/p>\n<blockquote><p><strong>Warning:<\/strong><\/p>\n<p>The methodology used to deploy TiDB in this tutorial should <strong>not<\/strong> be used to deploy TiDB in a production or development setting.<\/p><\/blockquote>\n<p>This tutorial assumes you&#8217;re using a modern Linux distribution on x86-64. I&#8217;ll use a minimal CentOS 7 installation running in VMware for the examples. It&#8217;ll be easiest if you start from a clean install, so that you aren&#8217;t impacted by quirks of your existing environment. If you don&#8217;t want to use local virtualization, you can easily and inexpensively start a CentOS 7 VM in your favorite cloud provider.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Overview\"><\/span>Overview<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>TiDB Binlog is a solution to collect binary log data from TiDB server and provide real-time data backup and replication. It pushes incremental data updates made to a TiDB Server cluster into any of various downstream platforms.<\/p>\n<p>You can use TiDB Binlog for incremental backups, to replicate data from one TiDB cluster to another, or to send TiDB updates through Kafka to a downstream platform of your choice.<\/p>\n<p>TiDB Binlog is particularly useful when you migrate data from MySQL or MariaDB to TiDB, in which case you may use the TiDB DM (Data Migration) platform to get data from a MySQL\/MariaDB cluster into TiDB, and then use TiDB Binlog to keep a separate, downstream MySQL\/MariaDB instance\/cluster in sync with your TiDB cluster. TiDB Binlog enables application traffic to TiDB to be pushed to a downstream MySQL or MariaDB instance\/cluster, which reduces the risk of a migration to TiDB because you can easily revert the application to MySQL or MariaDB without downtime or data loss.<\/p>\n<p>See <a href=\"https:\/\/docs.pingcap.com\/tidb\/stable\/tidb-binlog-overview\/\">TiDB Binlog Cluster Overview<\/a> for more information.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Architecture\"><\/span>Architecture<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>TiDB Binlog comprises two components: the <strong>Pump<\/strong> and the <strong>Drainer<\/strong>. Several Pump nodes make up a Pump cluster. Each Pump node connects to TiDB Server instances and receives updates made to each of the TiDB Server instances in a cluster. A Drainer connects to the Pump cluster and transforms updates into the correct format for a particular downstream destination, be it Kafka or another TiDB Cluster or a MySQL\/MariaDB server.<\/p>\n<p>The clustered architecture of the Pump component ensures that updates won&#8217;t be lost as new TiDB Server instances join or leave the TiDB Cluster or Pump nodes join or leave the Pump cluster.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Installation\"><\/span>Installation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>We&#8217;re using MariaDB Server in this case instead of MySQL Server because RHEL\/CentOS 7 includes MariaDB Server in their default package repositories. We&#8217;ll need the client as well as the server for later, so let&#8217;s install them now:<\/p>\n<pre><code class=\"language-bash\">sudo yum install -y mariadb-server\n<\/code><\/pre>\n<p>Even if you&#8217;ve already started a TiDB cluster, it will be easier to follow along with this tutorial if you set up a new, very simple cluster. We will install from a tarball, using a simplified form of the <a href=\"https:\/\/docs.pingcap.com\/tidb\/v3.0\/deploy-tidb-from-binary\">Local Deployment<\/a> guide. You may also wish to consult <a href=\"https:\/\/docs.pingcap.com\/tidb\/v3.0\/test-deployment-from-binary-tarball\">Testing Deployment from Binary Tarball<\/a> for best practices establishing a real testing deployment that goes beyond the scope of this tutorial.<\/p>\n<pre><code class=\"language-bash\">curl -L http:\/\/download.pingcap.org\/tidb-latest-linux-amd64.tar.gz | tar xzf -\ncd tidb-latest-linux-amd64\n<\/code><\/pre>\n<p>Expect this output:<\/p>\n<pre><code>[kolbe@localhost ~]$ curl -LO http:\/\/download.pingcap.org\/tidb-latest-linux-amd64.tar.gz | tar xzf -\n  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n100  368M  100  368M    0     0  8394k      0  0:00:44  0:00:44 --:--:-- 11.1M\n[kolbe@localhost ~]$ cd tidb-latest-linux-amd64\n[kolbe@localhost tidb-latest-linux-amd64]$\n<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Configuration\"><\/span>Configuration<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Now we&#8217;ll start a very simple TiDB cluster, with a single instance each of <code>pd-server<\/code>, <code>tikv-server<\/code>, and <code>tidb-server<\/code>.<\/p>\n<p>First, let&#8217;s populate the config files we&#8217;ll use:<\/p>\n<pre><code class=\"language-bash\">printf &gt; pd.toml %s\\n 'log-file=\"pd.log\"' 'data-dir=\"pd.data\"'\nprintf &gt; tikv.toml %s\\n 'log-file=\"tikv.log\"' '[storage]' 'data-dir=\"tikv.data\"' '[pd]' 'endpoints=[\"127.0.0.1:2379\"]' '[rocksdb]' max-open-files=1024 '[raftdb]' max-open-files=1024\nprintf &gt; pump.toml %s\\n 'log-file=\"pump.log\"' 'data-dir=\"pump.data\"' 'addr=\"127.0.0.1:8250\"' 'advertise-addr=\"127.0.0.1:8250\"' 'pd-urls=\"http:\/\/127.0.0.1:2379\"'\nprintf &gt; tidb.toml %s\\n 'store=\"tikv\"' 'path=\"127.0.0.1:2379\"' '[log.file]' 'filename=\"tidb.log\"' '[binlog]' 'enable=true'\nprintf &gt; drainer.toml %s\\n 'log-file=\"drainer.log\"' '[syncer]' 'db-type=\"mysql\"' '[syncer.to]' 'host=\"127.0.0.1\"' 'user=\"root\"' 'password=\"\"' 'port=3306'\n<\/code><\/pre>\n<p>This will allow you to see the contents of the config files:<\/p>\n<pre><code class=\"language-bash\">for f in *.toml; do echo \"$f:\"; cat \"$f\"; echo; done\n<\/code><\/pre>\n<p>Expect this output:<\/p>\n<pre><code>drainer.toml:\nlog-file=\"drainer.log\"\n[syncer]\ndb-type=\"mysql\"\n[syncer.to]\nhost=\"127.0.0.1\"\nuser=\"root\"\npassword=\"\"\nport=3306\n\npd.toml:\nlog-file=\"pd.log\"\ndata-dir=\"pd.data\"\n\npump.toml:\nlog-file=\"pump.log\"\ndata-dir=\"pump.data\"\naddr=\"127.0.0.1:8250\"\nadvertise-addr=\"127.0.0.1:8250\"\npd-urls=\"http:\/\/127.0.0.1:2379\"\n\ntidb.toml:\nstore=\"tikv\"\npath=\"127.0.0.1:2379\"\n[log.file]\nfilename=\"tidb.log\"\n[binlog]\nenable=true\n\ntikv.toml:\nlog-file=\"tikv.log\"\n[storage]\ndata-dir=\"tikv.data\"\n[pd]\nendpoints=[\"127.0.0.1:2379\"]\n[rocksdb]\nmax-open-files=1024\n[raftdb]\nmax-open-files=1024\n<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Bootstrapping\"><\/span>Bootstrapping<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Now we can start each component. This is best done in a specific order, first bringing up the PD (Placement Driver), then TiKV Server (the backend key\/value store used by TiDB Platform), then Pump (because TiDB must connect to the Pump service to send the binary log), and finally TiDB Server (the frontend that speaks the MySQL protocol to your applications).<\/p>\n<p>Start all the services:<\/p>\n<pre><code class=\"language-bash\">.\/bin\/pd-server --config=pd.toml &amp;&gt;pd.out &amp;\n.\/bin\/tikv-server --config=tikv.toml &amp;&gt;tikv.out &amp;\n.\/bin\/pump --config=pump.toml &amp;&gt;pump.out &amp;\nsleep 3\n.\/bin\/tidb-server --config=tidb.toml &amp;&gt;tidb.out &amp;\n<\/code><\/pre>\n<p>Expect this output:<\/p>\n<pre><code>[kolbe@localhost tidb-latest-linux-amd64]$ .\/bin\/pd-server --config=pd.toml &amp;&gt;pd.out &amp;\n[1] 20935\n[kolbe@localhost tidb-latest-linux-amd64]$ .\/bin\/tikv-server --config=tikv.toml &amp;&gt;tikv.out &amp;\n[2] 20944\n[kolbe@localhost tidb-latest-linux-amd64]$ .\/bin\/pump --config=pump.toml &amp;&gt;pump.out &amp;\n[3] 21050\n[kolbe@localhost tidb-latest-linux-amd64]$ sleep 3\n[kolbe@localhost tidb-latest-linux-amd64]$ .\/bin\/tidb-server --config=tidb.toml &amp;&gt;tidb.out &amp;\n[4] 21058\n<\/code><\/pre>\n<p>And if you execute <code>jobs<\/code>, you should see the list of running daemons:<\/p>\n<pre><code>[kolbe@localhost tidb-latest-linux-amd64]$ jobs\n[1]   Running                 .\/bin\/pd-server --config=pd.toml &amp;&gt;pd.out &amp;\n[2]   Running                 .\/bin\/tikv-server --config=tikv.toml &amp;&gt;tikv.out &amp;\n[3]-  Running                 .\/bin\/pump --config=pump.toml &amp;&gt;pump.out &amp;\n[4]+  Running                 .\/bin\/tidb-server --config=tidb.toml &amp;&gt;tidb.out &amp;\n<\/code><\/pre>\n<p>If one of the services has failed to start (if you see &#8220;<code>Exit 1<\/code>&#8221; instead of &#8220;<code>Running<\/code>&#8220;, for example), try to restart that individual service.<\/p>\n<div class=\"trackable-btns\"><a href=\"\/download\"><button>Download TiDB<\/button><\/a><br \/>\n<a href=\"https:\/\/share.hsforms.com\/1e2W03wLJQQKPd1d9rCbj_Q2npzm\"><button>Subscribe to Blog<\/button><\/a><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Connecting\"><\/span>Connecting<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You should have all 4 components of our TiDB Cluster running now, and you can now connect to the TiDB Server on port 4000 using the MariaDB\/MySQL command-line client:<\/p>\n<pre><code class=\"language-bash\">mysql -h 127.0.0.1 -P 4000 -u root -e 'select tidb_version()G'\n<\/code><\/pre>\n<p>Expect this output:<\/p>\n<pre><code>[kolbe@localhost tidb-latest-linux-amd64]$ mysql -h 127.0.0.1 -P 4000 -u root -e 'select tidb_version()G'\n*************************** 1. row ***************************\ntidb_version(): Release Version: v3.0.0-beta.1-154-gd5afff70c\nGit Commit Hash: d5afff70cdd825d5fab125c8e52e686cc5fb9a6e\nGit Branch: master\nUTC Build Time: 2019-04-24 03:10:00\nGoVersion: go version go1.12 linux\/amd64\nRace Enabled: false\nTiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e\nCheck Table Before Drop: false\n<\/code><\/pre>\n<p>At this point we have a TiDB Cluster running, and we have <code>pump<\/code> reading binary logs from the cluster and storing them as relay logs in its data directory. The next step is to start a MariaDB server that <code>drainer<\/code> can write to, and to start <code>drainer<\/code>:<\/p>\n<pre><code class=\"language-bash\">sudo systemctl start mariadb\n.\/bin\/drainer --config=drainer.toml &amp;&gt;drainer.out &amp;\n<\/code><\/pre>\n<p>If you are using an operating system that makes it easier to install MySQL server, that&#8217;s also OK \u2014 just make sure it&#8217;s listening on port 3306 and that you can either connect to it as user &#8220;root&#8221; with an empty password, or adjust rainer.toml as necessary.<\/p>\n<pre><code class=\"language-bash\">mysql -h 127.0.0.1 -P 3306 -u root\n<\/code><\/pre>\n<pre><code class=\"language-sql\">show databases;\n<\/code><\/pre>\n<p>Expect this output:<\/p>\n<pre><code>[kolbe@localhost ~]$ mysql -h 127.0.0.1 -P 3306 -u root\nWelcome to the MariaDB monitor.  Commands end with ; or g.\nYour MariaDB connection id is 20\nServer version: 5.5.60-MariaDB MariaDB Server\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType 'help;' or 'h' for help. Type 'c' to clear the current input statement.\n\nMariaDB [(none)]&gt; show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| information_schema |\n| mysql              |\n| performance_schema |\n| test               |\n| tidb_binlog        |\n+--------------------+\n5 rows in set (0.01 sec)\n<\/code><\/pre>\n<p>Here we can already see the <code>tidb_binlog<\/code> database, which contains the <code>checkpoint<\/code> table used by <code>drainer<\/code> to record up to what point binary logs from the TiDB cluster have been applied.<\/p>\n<pre><code class=\"language-sql\">MariaDB [tidb_binlog]&gt; use tidb_binlog;\nDatabase changed\nMariaDB [tidb_binlog]&gt; select * from checkpoint;\n+---------------------+---------------------------------------------+\n| clusterID           | checkPoint                                  |\n+---------------------+---------------------------------------------+\n| 6678715361817107733 | {\"commitTS\":407637466476445697,\"ts-map\":{}} |\n+---------------------+---------------------------------------------+\n1 row in set (0.00 sec)\n<\/code><\/pre>\n<p>Now, let&#8217;s open another client connection to the TiDB server, so that we can create a table and insert some rows into it. (It&#8217;s easiest to do this under GNU screen so you can keep multiple clients open at the same time.)<\/p>\n<pre><code class=\"language-bash\">mysql -h 127.0.0.1 -P 4000 --prompt='TiDB [d]&gt; ' -u root\n<\/code><\/pre>\n<pre><code class=\"language-sql\">create database tidbtest;\nuse tidbtest;\ncreate table t1 (id int unsigned not null auto_increment primary key);\ninsert into t1 () values (),(),(),(),();\nselect * from t1;\n<\/code><\/pre>\n<p>Expect this output:<\/p>\n<pre><code>TiDB [(none)]&gt; create database tidbtest;\nQuery OK, 0 rows affected (0.12 sec)\n\nTiDB [(none)]&gt; use tidbtest;\nDatabase changed\nTiDB [tidbtest]&gt; create table t1 (id int unsigned not null auto_increment primary key);\nQuery OK, 0 rows affected (0.11 sec)\n\nTiDB [tidbtest]&gt; insert into t1 () values (),(),(),(),();\nQuery OK, 5 rows affected (0.01 sec)\nRecords: 5  Duplicates: 0  Warnings: 0\n\nTiDB [tidbtest]&gt; select * from t1;\n+----+\n| id |\n+----+\n|  1 |\n|  2 |\n|  3 |\n|  4 |\n|  5 |\n+----+\n5 rows in set (0.00 sec)\n<\/code><\/pre>\n<p>Switching back to the MariaDB client, we should find the new database, new table, and the rows we&#8217;ve newly inserted:<\/p>\n<pre><code class=\"language-sql\">use tidbtest;\nshow tables;\nselect * from t1;\n<\/code><\/pre>\n<p>Expect this output:<\/p>\n<pre><code>MariaDB [(none)]&gt; use tidbtest;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nMariaDB [tidbtest]&gt; show tables;\n+--------------------+\n| Tables_in_tidbtest |\n+--------------------+\n| t1                 |\n+--------------------+\n1 row in set (0.00 sec)\n\nMariaDB [tidbtest]&gt; select * from t1;\n+----+\n| id |\n+----+\n|  1 |\n|  2 |\n|  3 |\n|  4 |\n|  5 |\n+----+\n5 rows in set (0.00 sec)\n<\/code><\/pre>\n<p>You should see the same rows when querying the MariaDB server that you inserted into TiDB. Congratulations! You&#8217;ve just set up TiDB Binlog!<\/p>\n<h2><span class=\"ez-toc-section\" id=\"binlogctl\"><\/span>binlogctl<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Information about Pumps and Drainers that have joined the cluster is stored in pd, and the binlogctl tool is used to query and manipulate information about their states. See <a href=\"https:\/\/docs.pingcap.com\/tidb\/v3.0\/maintain-tidb-binlog-cluster#binlogctl-guide\">binlogctl guide<\/a> for more information.<\/p>\n<p>You can use <code>binlogctl<\/code> to get a view of the current status of Pumps and Drainers in the cluster:<\/p>\n<pre><code class=\"language-bash\">.\/bin\/binlogctl -cmd drainers\n.\/bin\/binlogctl -cmd pumps\n<\/code><\/pre>\n<p>Expect this output:<\/p>\n<pre><code>[kolbe@localhost tidb-latest-linux-amd64]$ .\/bin\/binlogctl -cmd drainers\n[2019\/04\/11 17:44:10.861 -04:00] [INFO] [nodes.go:47] [\"query node\"] [type=drainer] [node=\"{NodeID: localhost.localdomain:8249, Addr: 192.168.236.128:8249, State: online, MaxCommitTS: 407638907719778305, UpdateTime: 2019-04-11 17:44:10 -0400 EDT}\"]\n\n[kolbe@localhost tidb-latest-linux-amd64]$ .\/bin\/binlogctl -cmd pumps\n[2019\/04\/11 17:44:13.904 -04:00] [INFO] [nodes.go:47] [\"query node\"] [type=pump] [node=\"{NodeID: localhost.localdomain:8250, Addr: 192.168.236.128:8250, State: online, MaxCommitTS: 407638914024079361, UpdateTime: 2019-04-11 17:44:13 -0400 EDT}\"]\n<\/code><\/pre>\n<p>If I kill the Drainer, the cluster puts it in the &#8220;paused&#8221; state, which means that the cluster expects it to rejoin:<\/p>\n<pre><code class=\"language-bash\">pkill drainer\n.\/bin\/binlogctl -cmd drainers\n<\/code><\/pre>\n<p>Expect this output:<\/p>\n<pre><code>[kolbe@localhost tidb-latest-linux-amd64]$ pkill drainer\n[kolbe@localhost tidb-latest-linux-amd64]$ .\/bin\/binlogctl -cmd drainers\n[2019\/04\/11 17:44:22.640 -04:00] [INFO] [nodes.go:47] [\"query node\"] [type=drainer] [node=\"{NodeID: localhost.localdomain:8249, Addr: 192.168.236.128:8249, State: paused, MaxCommitTS: 407638915597467649, UpdateTime: 2019-04-11 17:44:18 -0400 EDT}\"]\n<\/code><\/pre>\n<p>You use &#8220;NodeIDs&#8221; with <code>binlogctl<\/code> to control individual nodes. In this case, the NodeID of the Drainer is &#8220;localhost.localdomain:8249&#8221; and the NodeID of the Pump is &#8220;localhost.localdomain:8250&#8221;.<\/p>\n<p>The main use of <code>binlogctl<\/code> in this tutorial is likely to be in the event of a cluster restart. If you end all processes in the TiDB cluster and try to restart them (but not the downstream MySQL\/MariaDB server or the Drainer), <code>pump<\/code> will believe that <code>drainer<\/code> is still &#8220;online&#8221; and will refuse to start, because it cannot contact <code>drainer<\/code>.<\/p>\n<p>There are 3 solutions to that issue:<\/p>\n<ol>\n<li>Stop Drainer using <code>binlogctl<\/code> instead of killing the process:\n<pre><code>.\/bin\/binlogctl --pd-urls=http:\/\/127.0.0.1:2379 --cmd=drainers\n.\/bin\/binlogctl --pd-urls=http:\/\/127.0.0.1:2379 --cmd=offline-drainer --node-id=localhost.localdomain:8249\n<\/code><\/pre>\n<\/li>\n<li>Start Drainer <em>before<\/em> starting Pump.<\/li>\n<li>Use <code>binlogctl<\/code> after starting pd (but before starting Drainer or Pump) to update the state of the paused Drainer:\n<pre><code>.\/bin\/binlogctl --pd-urls=http:\/\/127.0.0.1:2379 --cmd=update-drainer --node-id=localhost.localdomain:8249 --state=offline\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h2><span class=\"ez-toc-section\" id=\"Cleanup\"><\/span>Cleanup<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To stop the TiDB cluster and TiDB Binlog processes, you can execute <code>pkill -P $$<\/code> in the shell where you first started the various processes that form the cluster (pd-server, tikv-server, pump, tidb-server, drainer). To give them each time to shut down cleanly, it&#8217;s helpful to stop them in a particular order:<\/p>\n<pre><code class=\"language-bash\">for p in tidb-server drainer pump tikv-server pd-server; do pkill \"$p\"; sleep 1; done\n<\/code><\/pre>\n<p>Expect this output:<\/p>\n<pre><code>kolbe@localhost tidb-latest-linux-amd64]$ for p in tidb-server drainer pump tikv-server pd-server; do pkill \"$p\"; sleep 1; done\n[4]-  Done                    .\/bin\/tidb-server --config=tidb.toml &amp;&gt;tidb.out\n[5]+  Done                    .\/bin\/drainer --config=drainer.toml &amp;&gt;drainer.out\n[3]+  Done                    .\/bin\/pump --config=pump.toml &amp;&gt;pump.out\n[2]+  Done                    .\/bin\/tikv-server --config=tikv.toml &amp;&gt;tikv.out\n[1]+  Done                    .\/bin\/pd-server --config=pd.toml &amp;&gt;pd.out\n<\/code><\/pre>\n<p>If you wish to restart the cluster after all services exit, you can do so using the same commands you used originally to start the services. As discussed in the <code>binlogctl<\/code> section above, you&#8217;ll need to start <code>drainer<\/code> before <code>pump<\/code> can start, and <code>pump<\/code> must start before <code>tidb-server<\/code> can start.<\/p>\n<pre><code class=\"language-bash\">.\/bin\/pd-server --config=pd.toml &amp;&gt;pd.out &amp;\n.\/bin\/tikv-server --config=tikv.toml &amp;&gt;tikv.out &amp;\n.\/bin\/drainer --config=drainer.toml &amp;&gt;drainer.out &amp;\nsleep 3\n.\/bin\/pump --config=pump.toml &amp;&gt;pump.out &amp;\nsleep 3\n.\/bin\/tidb-server --config=tidb.toml &amp;&gt;tidb.out &amp;\n<\/code><\/pre>\n<p>If any of the components fail to start, try again to start the unsuccessful component(s).<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In this tutorial, we&#8217;ve set up TiDB Binlog to replicate from a TiDB cluster to a downstream MariaDB server. We did that using a single <code>pump<\/code> and a single <code>drainer<\/code>. As we&#8217;ve seen, TiDB Binlog is a comprehensive platform for capturing and processing changes to a TiDB cluster.<\/p>\n<p>In a more robust development, testing, or production deployment, you&#8217;d have multiple TiDB servers for HA and scaling purposes, and you&#8217;d use multiple instances of <code>pump<\/code> to ensure that application traffic to TiDB server instances is unaffected by problems in the Pump cluster. You may also use additional <code>drainer<\/code> instances to push updates to different downstream platforms or to implement incremental backups.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn to deploy TiDB Binlog with a simple TiDB cluster.<\/p>","protected":false},"author":117,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ub_ctt_via":"","footnotes":""},"categories":[13],"tags":[36,29],"class_list":["post-1178","post","type-post","status-publish","format-standard","hentry","category-product","tag-ecosystem-tools","tag-tutorial"],"acf":[],"featured_image_src":null,"author_info":{"display_name":"Kolbe Kegel","author_link":"https:\/\/www.pingcap.com\/ko\/blog\/author\/kolbe-kegel\/"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>TiDB Binlog Tutorial | TiDB<\/title>\n<meta name=\"description\" content=\"Learn about the benefits of TiDB and the TiDB Cloud solutions from PingCAP. Read our latest post &quot;TiDB Binlog Tutorial&quot; here.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pingcap.com\/ko\/blog\/tidb-binlog-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"TiDB Binlog Tutorial | TiDB\" \/>\n<meta property=\"og:description\" content=\"Learn about the benefits of TiDB and the TiDB Cloud solutions from PingCAP. Read our latest post &quot;TiDB Binlog Tutorial&quot; here.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pingcap.com\/ko\/blog\/tidb-binlog-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"TiDB\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/pingcap2015\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-08T00:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-12T10:52:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/static.pingcap.com\/files\/2024\/09\/11005522\/Homepage-Ad.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1440\" \/>\n\t<meta property=\"og:image:height\" content=\"714\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Kolbe Kegel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@PingCAP\" \/>\n<meta name=\"twitter:site\" content=\"@PingCAP\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kolbe Kegel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/\"},\"author\":{\"name\":\"Kolbe Kegel\",\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/person\/ee08feab4f9d62e19006cc67a7fdf247\"},\"headline\":\"TiDB Binlog Tutorial\",\"datePublished\":\"2019-05-08T00:00:00+00:00\",\"dateModified\":\"2023-09-12T10:52:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/\"},\"wordCount\":1430,\"publisher\":{\"@id\":\"https:\/\/www.pingcap.com\/#organization\"},\"keywords\":[\"Ecosystem tools\",\"Tutorial\"],\"articleSection\":[\"Product\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/\",\"url\":\"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/\",\"name\":\"TiDB Binlog Tutorial | TiDB\",\"isPartOf\":{\"@id\":\"https:\/\/www.pingcap.com\/#website\"},\"datePublished\":\"2019-05-08T00:00:00+00:00\",\"dateModified\":\"2023-09-12T10:52:57+00:00\",\"description\":\"Learn about the benefits of TiDB and the TiDB Cloud solutions from PingCAP. Read our latest post \\\"TiDB Binlog Tutorial\\\" here.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pingcap.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"TiDB Binlog Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pingcap.com\/#website\",\"url\":\"https:\/\/www.pingcap.com\/\",\"name\":\"TiDB\",\"description\":\"TiDB | SQL at Scale\",\"publisher\":{\"@id\":\"https:\/\/www.pingcap.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pingcap.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pingcap.com\/#organization\",\"name\":\"PingCAP\",\"url\":\"https:\/\/www.pingcap.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png\",\"contentUrl\":\"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png\",\"width\":811,\"height\":232,\"caption\":\"PingCAP\"},\"image\":{\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/pingcap2015\",\"https:\/\/x.com\/PingCAP\",\"https:\/\/linkedin.com\/company\/pingcap\",\"https:\/\/youtube.com\/channel\/UCuq4puT32DzHKT5rU1IZpIA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/person\/ee08feab4f9d62e19006cc67a7fdf247\",\"name\":\"Kolbe Kegel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/static.pingcap.com\/files\/2022\/10\/17234942\/avatar.jpg\",\"contentUrl\":\"https:\/\/static.pingcap.com\/files\/2022\/10\/17234942\/avatar.jpg\",\"caption\":\"Kolbe Kegel\"},\"url\":\"https:\/\/www.pingcap.com\/ko\/blog\/author\/kolbe-kegel\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"TiDB Binlog Tutorial | TiDB","description":"Learn about the benefits of TiDB and the TiDB Cloud solutions from PingCAP. Read our latest post \"TiDB Binlog Tutorial\" here.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pingcap.com\/ko\/blog\/tidb-binlog-tutorial\/","og_locale":"ko_KR","og_type":"article","og_title":"TiDB Binlog Tutorial | TiDB","og_description":"Learn about the benefits of TiDB and the TiDB Cloud solutions from PingCAP. Read our latest post \"TiDB Binlog Tutorial\" here.","og_url":"https:\/\/www.pingcap.com\/ko\/blog\/tidb-binlog-tutorial\/","og_site_name":"TiDB","article_publisher":"https:\/\/facebook.com\/pingcap2015","article_published_time":"2019-05-08T00:00:00+00:00","article_modified_time":"2023-09-12T10:52:57+00:00","og_image":[{"width":1440,"height":714,"url":"https:\/\/static.pingcap.com\/files\/2024\/09\/11005522\/Homepage-Ad.png","type":"image\/png"}],"author":"Kolbe Kegel","twitter_card":"summary_large_image","twitter_creator":"@PingCAP","twitter_site":"@PingCAP","twitter_misc":{"Written by":"Kolbe Kegel","Est. reading time":"12\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/#article","isPartOf":{"@id":"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/"},"author":{"name":"Kolbe Kegel","@id":"https:\/\/www.pingcap.com\/#\/schema\/person\/ee08feab4f9d62e19006cc67a7fdf247"},"headline":"TiDB Binlog Tutorial","datePublished":"2019-05-08T00:00:00+00:00","dateModified":"2023-09-12T10:52:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/"},"wordCount":1430,"publisher":{"@id":"https:\/\/www.pingcap.com\/#organization"},"keywords":["Ecosystem tools","Tutorial"],"articleSection":["Product"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/","url":"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/","name":"TiDB Binlog Tutorial | TiDB","isPartOf":{"@id":"https:\/\/www.pingcap.com\/#website"},"datePublished":"2019-05-08T00:00:00+00:00","dateModified":"2023-09-12T10:52:57+00:00","description":"Learn about the benefits of TiDB and the TiDB Cloud solutions from PingCAP. Read our latest post \"TiDB Binlog Tutorial\" here.","breadcrumb":{"@id":"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pingcap.com\/blog\/tidb-binlog-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pingcap.com\/"},{"@type":"ListItem","position":2,"name":"TiDB Binlog Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.pingcap.com\/#website","url":"https:\/\/www.pingcap.com\/","name":"\ud2f0DB","description":"TiDB | SQL at Scale","publisher":{"@id":"https:\/\/www.pingcap.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pingcap.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/www.pingcap.com\/#organization","name":"PingCAP","url":"https:\/\/www.pingcap.com\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/","url":"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png","contentUrl":"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png","width":811,"height":232,"caption":"PingCAP"},"image":{"@id":"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/pingcap2015","https:\/\/x.com\/PingCAP","https:\/\/linkedin.com\/company\/pingcap","https:\/\/youtube.com\/channel\/UCuq4puT32DzHKT5rU1IZpIA"]},{"@type":"Person","@id":"https:\/\/www.pingcap.com\/#\/schema\/person\/ee08feab4f9d62e19006cc67a7fdf247","name":"Kolbe Kegel","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.pingcap.com\/#\/schema\/person\/image\/","url":"https:\/\/static.pingcap.com\/files\/2022\/10\/17234942\/avatar.jpg","contentUrl":"https:\/\/static.pingcap.com\/files\/2022\/10\/17234942\/avatar.jpg","caption":"Kolbe Kegel"},"url":"https:\/\/www.pingcap.com\/ko\/blog\/author\/kolbe-kegel\/"}]}},"grav_blocks":false,"card_markup":"<a class=\"card-resource bg-white\" href=\"https:\/\/www.pingcap.com\/ko\/blog\/tidb-binlog-tutorial\/\"><div class=\"card-resource__content-container\"><div class=\"card-resource__content-head\"><div class=\"card-resource__category\">Product<\/div><\/div><h5 class=\"card-resource__title\">TiDB Binlog Tutorial<\/h5><\/div><\/a>","_links":{"self":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/posts\/1178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/users\/117"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/comments?post=1178"}],"version-history":[{"count":2,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/posts\/1178\/revisions"}],"predecessor-version":[{"id":13860,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/posts\/1178\/revisions\/13860"}],"wp:attachment":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/media?parent=1178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/categories?post=1178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/tags?post=1178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}