@@ -24,6 +24,8 @@ The tutorial requires that ``systemd`` and MySQL are installed.
24
24
Setting up MySQL
25
25
----------------
26
26
27
+ In this section, you configure MySQL and create a database.
28
+
27
29
#. First, install the necessary packages in CentOS:
28
30
29
31
.. code-block :: console
@@ -72,7 +74,7 @@ Setting up MySQL
72
74
$ cp replicatord /usr/local/sbin/replicatord
73
75
$ cp replicatord.service /etc/systemd/system
74
76
75
- #. After that, enter the MySQL console and create a sample database (depending on
77
+ #. Enter MySQL console and create a sample database (depending on
76
78
your existing installation, you may be a user other than root):
77
79
78
80
.. code-block :: sql
@@ -95,12 +97,12 @@ Setting up MySQL
95
97
mysql menagerie -u root -p < ins_puff_rec.sql
96
98
mysql menagerie -u root -p < cr_event_tbl.sql
97
99
98
- #. Enter the MySQL console and massage the data for use with the
100
+ #. Enter MySQL console and massage the data for use with the
99
101
Tarantool replicator. On this step, you:
100
102
101
- * add an ID,
103
+ * add an ID
102
104
* change a field name to avoid conflict
103
- * cut down the number of fields.
105
+ * cut down the number of fields
104
106
105
107
With real data, this is the step that involves the most tweaking.
106
108
@@ -113,7 +115,7 @@ Setting up MySQL
113
115
ALTER TABLE pet DROP sex, DROP birth, DROP death;
114
116
QUIT
115
117
116
- #. The sample data is set up. Edit MySQL’s
118
+ #. The sample data is set up. Edit MySQL
117
119
configuration file to use it with the replicator:
118
120
119
121
.. code-block :: console
@@ -139,7 +141,7 @@ Setting up MySQL
139
141
[client]
140
142
socket = /var/lib/mysql/mysql.sock
141
143
142
- #. After exiting nano, restart mysqld:
144
+ #. After exiting `` nano `` , restart `` mysqld `` :
143
145
144
146
.. code-block :: console
145
147
@@ -150,67 +152,57 @@ Setting up MySQL
150
152
Installing and configuring Tarantool
151
153
------------------------------------
152
154
153
- Let’s install Tarantool and set up spaces for replication.
155
+ In this section, you install Tarantool and set up spaces for replication.
154
156
155
157
#. Go to the `Download page <https://www.tarantool.io/en/download/os-installation/rhel-centos/ >`_ and
156
158
follow the installation instructions.
157
159
158
160
#. Install the :ref: `tt CLI <tt-installation >` utility.
159
161
160
- #. Create a tt environment in the current directory using the :ref: `tt init <tt-init >` command.
161
-
162
- #. Edit the Lua example, which comes with Tarantool:
162
+ #. Create a new tt environment in the current directory using the :ref: `tt init <tt-init >` command.
163
163
164
- .. code-block :: console
165
-
166
- $ cd
167
- $ nano /etc/tarantool/instances.available/example.lua
164
+ #. In the ``/etc/tarantool/instances.available/mysql `` directory, create the ``tt `` instance configuration files:
168
165
169
- #. Replace the entire contents of the file with the following:
166
+ * `` config.yaml `` -- specifies the following configuration
170
167
171
- .. literalinclude :: /code_snippets/snippets/config/instances.enabled/mysql/example.lua
172
- :language: lua
173
- :lines: 3-17
174
- :dedent:
168
+ .. literalinclude :: /code_snippets/snippets/config/instances.enabled/mysql/config.yaml
169
+ :language: yaml
170
+ :dedent:
175
171
176
- To understand more of what’s happening here, have a look at the earlier
177
- `articles <https://dzone.com/articles/tarantool-101-10-steps-for-absolute-beginners-the >`_
178
- in the Tarantool 101 series or see the :ref: `getting-started <getting_started_db >` guide.
172
+ * ``instances.yml `` -- specifies instances to run in the current environment
179
173
180
- #. In ``/etc/tarantool ``, create a symlink from ``instances.available `` to a directory named
181
- ``instances.enabled `` (similar to NGINX):
174
+ .. literalinclude :: /code_snippets/snippets/config/instances.enabled/mysql/instances.yml
175
+ :language: yaml
176
+ :dedent:
182
177
183
- .. code-block :: console
178
+ * `` myapp.lua `` -- contains a Lua script with an application to load
184
179
185
- $ mkdir instances.enabled
186
- $ ln -s /instances.available/example.lua instances.enabled
180
+ .. literalinclude :: /code_snippets/snippets/config/instances.enabled/mysql/myapp.lua
181
+ :language: lua
182
+ :lines: 3-17
183
+ :dedent:
187
184
188
- #. After that, specify the following configuration in the ``config.yaml `` file and place the file into
189
- the ``instances.enabled `` directory:
185
+ For details, see the :ref: `Configuration <configuration >` section.
190
186
191
- .. literalinclude :: /code_snippets/snippets/config/instances.enabled/mysql/config.yaml
192
- :language: yaml
193
- :dedent:
187
+ #. Inside the ``instances.enabled `` directory of the created tt environment, create a symlink (``mysql ``)
188
+ to the directory from the previous step:
194
189
195
- #. Specify instances to run in the current environment in the ``instances.yml `` file and place the file into
196
- the same directory:
190
+ .. code-block :: console
197
191
198
- .. literalinclude :: /code_snippets/snippets/config/instances.enabled/mysql/instances.yml
199
- :language: yaml
200
- :dedent:
192
+ $ ln -s /etc/tarantool/instances.available/mysql mysql
201
193
202
194
#. Next, start up the Lua program with ``tt ``, the Tarantool command-line
203
195
utility:
204
196
205
197
.. code-block :: console
206
198
207
- $ tt start example
199
+ $ tt start mysql
208
200
209
- #. Enter Tarantool instance:
201
+ #. Enter the Tarantool instance:
210
202
211
203
.. code-block :: console
212
204
213
- $ tt connect example
205
+ $ tt connect mysql:instance001
214
206
215
207
#. Check that the target spaces were successfully created:
216
208
@@ -276,34 +268,35 @@ MySQL and Tarantool are now set up. You can proceed to configure the replicator.
276
268
277
269
#. Enter the Tarantool instance:
278
270
279
- .. code-block :: bash
271
+ .. code-block :: console
280
272
281
- $ tt connect example
273
+ $ tt connect mysql:instance001
282
274
283
275
#. Do a select on the ``mysqldata `` space. The replicated content from MySQL looks the following way:
284
276
285
277
.. code-block :: tarantoolsession
286
278
287
- tarantool > box.space.mysqldata:select()
279
+ mysql > box.space.mysqldata:select()
288
280
---
289
281
- - [1, 'Fluffy', 'Harold', 'cat']
290
- - [2, 'Claws', 'Gwen', 'cat']
291
- - [3, 'Buffy', 'Harold', 'dog']
292
- - [4, 'Fang', 'Benny', 'dog']
293
- - [5, 'Bowser', 'Diane', 'dog']
294
- - [6, 'Chirpy', 'Gwen', 'bird']
295
- - [7, 'Whistler', 'Gwen', 'bird']
296
- - [8, 'Slim', 'Benny', 'snake']
297
- - [9, 'Puffball', 'Diane', 'hamster']
282
+ - [2, 'Claws', 'Gwen', 'cat']
283
+ - [3, 'Buffy', 'Harold', 'dog']
284
+ - [4, 'Fang', 'Benny', 'dog']
285
+ - [5, 'Bowser', 'Diane', 'dog']
286
+ - [6, 'Chirpy', 'Gwen', 'bird']
287
+ - [7, 'Whistler', 'Gwen', 'bird']
288
+ - [8, 'Slim', 'Benny', 'snake']
289
+ - [9, 'Puffball', 'Diane', 'hamster']
298
290
299
291
.. _improving_mysql-replicator :
300
292
301
293
Testing the replication
302
294
-----------------------
303
295
304
- Finally, let’s enter a record into MySQL and then go back to Tarantool to make sure it’s replicated.
296
+ In this section, you enter a record into MySQL and check that the record is replicated to Tarantool.
297
+ To do this:
305
298
306
- #. Exit the Tarantool instance with ``CTRL-C ``.
299
+ #. Exit the Tarantool instance with ``CTRL-D ``.
307
300
308
301
#. Insert a record into MySQL:
309
302
@@ -318,10 +311,10 @@ Finally, let’s enter a record into MySQL and then go back to Tarantool to make
318
311
319
312
.. code-block :: bash
320
313
321
- $ tt connect example
314
+ $ tt connect mysql
322
315
323
- # To see the replicated data in Tarantool, run the following command:
316
+ #. To see the replicated data in Tarantool, run the following command:
324
317
325
318
.. code-block :: tarantoolsession
326
319
327
- tarantool > box.space.mysqldata:select()
320
+ mysql > box.space.mysqldata:select()
0 commit comments