You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+259-10
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,74 @@
1
1
# Get Started with MariaDB's NoSQL Listener
2
2
3
-
This repository contains information on how to get started using the NoSQL Listener capability of MariaDB MaxScale.
3
+
This repository contains information on how to create and use a [MariaDB MaxScale](https://mariadb.com/products/enterprise/components/#maxscale)NoSQL Listener with [MariaDB Community Server](https://mariadb.com/products/community-server/).
4
4
5
-
## Requirements
5
+
This `README` will walk you through the process of using a MongoDB driver to connect to and communicate with MariaDB, which includes storing and manage NoSQL document data within MariaDB.
6
+
7
+
# Table of Contents
8
+
1.[Requirements](#requirements)
9
+
2.[NoSQL Protocol Module](#nosql-protocol)
10
+
2.[Getting Started](#get-started)
11
+
3.[Exploring the Data](#explore)
12
+
1.[Querying MariaDB](#query-mariadb)
13
+
2.[MaxScale GUI](#maxscale-gui)
14
+
3.[MongoDB Shell](#mongodb-shell)
15
+
4.[Using the TODO Application Directly](#todo-app)
16
+
5.[Support and contribution](#support-contribution)
17
+
6.[License](#license)
18
+
19
+
## Requirements <aname="requirements"></a>
6
20
7
21
Before setting up this sample make sure you have the following installed on your machine.
The [nosqlprotocol module](https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Protocols/NoSQL.md) allows a MariaDB server or cluster to be used as the backend of an application using a [MongoDB® client library](https://docs.mongodb.com/drivers/node/current/). Internally, all documents are stored in a table containing two columns; an `id` column for the object id and a `doc` column for the document itself.
29
+
30
+
When the MongoDB® client application issues [MongoDB protocol commands](https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/), either directly or indirectly via the client library, they are transparently converted into the equivalent SQL and executed against the MariaDB backend. The MariaDB responses are then in turn converted into the format expected by the MongoDB® client library and application.
31
+
32
+
<palign="center"spacing="10">
33
+
<kbd>
34
+
<img src="media/mql_to_sql.png" />
35
+
</kbd>
36
+
</p>
37
+
38
+
For more information on the full capabilities see the documentation [here](https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Protocols/NoSQL.md).
2. Create the container instances uses [Docker Compose](https://docs.docker.com/compose/).
48
+
2. Create the container instances using [Docker Compose](https://docs.docker.com/compose/).
21
49
22
50
```bash
23
51
$ docker-compose up
24
52
```
25
53
54
+
The command above will acquire Docker images and create four container instances.
55
+
56
+
a. `mxs` - the official MariaDB MaxScale image.
57
+
58
+
b. `mdb` - the official MariaDB Community server image.
59
+
60
+
c. `todo_client` - a React.js web application that provides a user interface for managing tasks (on a todo list).
61
+
62
+
d. `todo_api` - a Node.js application programming interface (API) that exposes REST endpoints for managing data within a database using the [official MongoDB Node Driver](https://docs.mongodb.com/drivers/node/current/).
63
+
64
+
**Note**: You can confirm that the `docker-compose up`command has successfully pulled the images and created the containers by executing the following command:
65
+
66
+
```bash
67
+
$ docker ps
68
+
```
69
+
70
+
The result should show that the `mxs`, `mdb`, `todo_client` and `todo_api` are running.
71
+
26
72
3. Add a new MaxScale user to the MariaDB database.
27
73
28
74
a. Option 1 - Step into the `mdb` Docker container.
@@ -33,9 +79,9 @@ Before setting up this sample make sure you have the following installed on your
33
79
2. ```bash
34
80
$ mariadb --user root -pPassword123!
35
81
```
36
-
3. Copy, paste and execute the scripts [here](configuration/add_maxscale_user.sql).
82
+
3. Copy, paste and execute the scripts [here](configuration/add_maxscale_user.sql) using the MariaDB command line interface (CLI) client.
37
83
38
-
b. Option 2 - Execute the [add_maxscale_user.sql](configuration/add_maxscale_user.sql) on the `mdb`server using the MariaDB CLI client.
84
+
b. Option 2 - Execute the [add_maxscale_user.sql](configuration/add_maxscale_user.sql) on the MariaDB Community Server instance contained with the `mdb`containernusing the MariaDB CLI client.
@@ -57,16 +103,219 @@ Before setting up this sample make sure you have the following installed on your
57
103
$ vi etc/maxscale.cnf
58
104
```
59
105
60
-
Press `i` (to enable insert ability)
106
+
**VIM Edit Tips:**
61
107
62
-
Replace all the contents of the maxscale.cnf file with [this](configuration.maxscale.cnf).
108
+
- Press `i` (to enable insert ability)
63
109
64
-
Press `escape`. Type `:wq` and press `Enter`.
110
+
- Within insert mode replace all the contents of the maxscale.cnf file with [this](configuration.maxscale.cnf).
111
+
112
+
- To save, press `escape`, thentype`:wq` and, finally, press `Enter` to confirm.
65
113
66
114
c. Restart MaxScale
67
115
68
116
```bash
69
117
$ maxscale-restart
70
118
```
71
119
72
-
5. Open a browser window and navigate to `http://localhost:3000`.
120
+
5. Open a browser window and navigate to `http://localhost:3000`, which will load the TODO web application interface.
121
+
122
+
<p align="center" spacing="10">
123
+
<kbd>
124
+
<img src="media/demo.gif" />
125
+
</kbd>
126
+
</p>
127
+
128
+
The TODO application is made of two pieces:
129
+
130
+
1. UI - a React.js project that is hosted within the `todo_client` container and accessed at http://127.0.0.1:3000.
131
+
132
+
2. API - a Node.js (+ Express) project that exposes REST endpoints for performing CRUD (create-read-update-delete) operations on (JSON) document data stored, via the MaxScale NoSQL Listener functionality, within MariaDB. The API application is hosted within the `todo_api` container and access at http://127.0.0.1:8080/tasks.
133
+
134
+
The TODO application can be used to manage data within MariaDB
135
+
136
+
## Exploring the Data <a name="explore"></a>
137
+
138
+
After you've successfully walked through the setup instructions within [Getting Started](#get-started) you're now able to explore the NoSQL Listener capabilities within MariaDB.
139
+
140
+
### Querying MariaDB <a name="query-mariadb"></a>
141
+
142
+
If you've used the TODO application to add new `tasks` you can now explore the schema and data that have been added.
143
+
144
+
You can connect to the MariaDB Community Server instance, contained within the `mdb` container, directly by using the MariaDB client.
You can even take advantage of MariaDB's JSON querying functionality support.
202
+
203
+
```bash
204
+
MariaDB [todo]>selectjson_value(doc,'$.description') description, json_value(doc, '$.completed') completed from tasks;
205
+
+-------------+-----------+
206
+
| description | completed |
207
+
+-------------+-----------+
208
+
| Task 1 | 0 |
209
+
| Task 2 | 1 |
210
+
| Task 3 | 0 |
211
+
| Task 4 | 1 |
212
+
+-------------+-----------+
213
+
```
214
+
215
+
### MaxScale GUI <a name="maxscale-gui"></a>
216
+
217
+
The [MaxScale graphical user interface (GUI)](https://mariadb.com/resources/blog/getting-started-with-the-mariadb-maxscale-gui/) provides another way you that you can explore the data.
218
+
219
+
#### **Logging In**
220
+
221
+
Start by opening a browser window and navigating to http://localhost:8989. There you'll be prompted to login.
222
+
223
+
<p align="center" spacing="10">
224
+
<kbd>
225
+
<img src="media/maxscale_gui_login.png" />
226
+
</kbd>
227
+
</p>
228
+
229
+
**Note:** The default username is `admin` and the password is `maxscale`.
230
+
231
+
#### **Dashboard**
232
+
233
+
After you've logged in you'll be taken to a dashboard that gives you information on MaxScale, including the service and listener configuration information.
234
+
235
+
<p align="center" spacing="10">
236
+
<kbd>
237
+
<img src="media/maxscale_gui_dashboard.png" />
238
+
</kbd>
239
+
</p>
240
+
241
+
#### **Query Editor**
242
+
243
+
On the left side navigation you can select the "Query Editor" menu option.
244
+
245
+
<p align="center" spacing="10">
246
+
<kbd>
247
+
<img src="media/maxscale_gui_queryeditor.png" />
248
+
</kbd>
249
+
</p>
250
+
251
+
Then you'll be prompted for connection information. For this you can connect directly to a server and/or schema within MariaDB.
252
+
253
+
For example:
254
+
255
+
<p align="center" spacing="10">
256
+
<kbd>
257
+
<img src="media/maxscale_gui_connect.png" />
258
+
</kbd>
259
+
</p>
260
+
261
+
After you've connected you can use the Query Editor to execute SQL queries, display datasets and even visualize the data using graphs and charts.
You can also use the [Mongo Shell client](https://docs.mongodb.com/v4.4/mongo/) to connect to and communicate with MariaDB (via MaxScale). You can find more information on how to do so [here](https://github.com/mariadb-corporation/MaxScale/blob/develop/Documentation/Protocols/NoSQL.md#client-authentication).
272
+
273
+
## Using the TODO Application Directly <a name="todo-app"></a>
274
+
275
+
Optionally, if you'd prefer to run the [TODO app](app) directly on your machine, rather than through a container, can do the following:
276
+
277
+
1. Make sure that you've installed the latest version of [Node.js](https://nodejs.org/en/) and [Node Package Manager (NPM)](https://www.npmjs.com/).
278
+
279
+
2. Install the node modules for the `client` and `api` applications.
280
+
281
+
Within a terminal...
282
+
283
+
a. Navigate to [app/client](app/client) and execute:
284
+
285
+
```bash
286
+
$ npm install
287
+
```
288
+
289
+
b. Navigate to [app/api](app/api) and execute:
290
+
291
+
```bash
292
+
$ npm install
293
+
```
294
+
295
+
3. Update the MongoDB driver connection string in [app/api/db.js](app/api/db.js) to `'mongodb://127.0.0.1:17017'`.
296
+
297
+
4. Start the `client` and `api` applications.
298
+
299
+
Within separate terminals...
300
+
301
+
a. Navigate to [app/client](app/client) and execute:
302
+
303
+
```bash
304
+
$ npm start
305
+
```
306
+
307
+
b. Navigate to [app/api](app/api) and execute:
308
+
309
+
```bash
310
+
$ npm start
311
+
```
312
+
313
+
## Support and Contribution <a name="support-contribution"></a>
314
+
315
+
Thanks so much for taking a look at this repository! As the NoSQL Listener capability is in the early stages, there's plenty of potential for improvement.
316
+
317
+
If you have any questions, comments, or would like to contribute to this or future projects like this please reach out to us directly at [[email protected]](mailto:[email protected]) or on [Twitter](https://twitter.com/mariadb).
0 commit comments