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: en_US/data-integration/data-bridge-sqlserver.md
+54-70Lines changed: 54 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,11 +55,11 @@ This section describes how to start Microsoft SQL Server 2019 on Linux/MacOS usi
55
55
56
56
1. Install Microsoft SQL Server via Docker, and then start the docker image with the command below. Use `mqtt_public1` as the password. For the password policy of Microsoft SQL Server, see [Password Complexity](https://learn.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-ver16#password-complexity).
57
57
58
-
Note: By starting a Docker container with the environment variable `ACCEPT_EULA=Y` you agree to the terms of Microsoft EULA, see also [MICROSOFT SOFTWARE LICENSE TERMS MICROSOFT SQL SERVER 2019 STANDARD(EN_US)](https://www.microsoft.com/en-us/Useterms/Retail/SQLServerStandard/2019/Useterms_Retail_SQLServerStandard_2019_English.htm).
58
+
Note: By starting a Docker container with the environment variable `ACCEPT_EULA=Y` you agree to the terms of Microsoft EULA, see also [End-User Licensing Agreement](https://go.microsoft.com/fwlink/?linkid=857698).
59
59
60
60
```bash
61
61
# To start the Microsoft SQL Server docker image and set the password as `mqtt_public1`
@@ -71,116 +71,100 @@ This section describes how to start Microsoft SQL Server 2019 on Linux/MacOS usi
71
71
3. Enter the preset password to connect to the server in the container. The characters are not echoed when entering the password. Click `Enter` directly after entering the password.
72
72
73
73
```bash
74
-
$ /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa
75
-
$ Password:
74
+
$ /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P mqtt_public1 -N -C
76
75
1>
77
76
```
78
77
79
78
::: tip
80
79
81
-
The `mssql-tools`have been installed in the Microsoft SQL Server container provided by Microsoft, but the executable file is not in `$PATH`. Therefore, you need to specify the executable file path for `mssql-tools` before proceeding. As for the Docker deployment in this example, the file path should be `opt`.
80
+
The `mssql-tools18` package have been installed in the Microsoft SQL Server container provided by Microsoft, but the executable file is not in `$PATH`. Therefore, you need to specify the executable file path for `sqlcmd` before proceeding. As for the Docker deployment in this example, the file path should be `/opt`.
82
81
83
-
For more information on how to use `mssql-tools`, see [sqlcmd-utility](https://learn.microsoft.com/en-us/sql/tools/sqlcmd/sqlcmd-utility?view=sql-server-ver16).
82
+
For more information on how to use `mssql-tools18`, see [sqlcmd-utility](https://learn.microsoft.com/en-us/sql/tools/sqlcmd/sqlcmd-utility?view=sql-server-ver16).
84
83
85
84
:::
86
85
87
-
So far, the Microsoft SQL Server 2019 instance has been deployed and can be connected.
86
+
So far, the Microsoft SQL Server 2022 instance has been deployed and can be connected.
88
87
89
88
### Create Database and Data Tables
90
89
91
-
This section describes how to create a database and data table in Microsoft SQL Server.
90
+
Use the connection created from the previous section and the following SQL statements to create data tables.
92
91
93
-
1. Create a database `mqtt` in Microsoft SQL Server using the connection created from the previous section.
92
+
- Create the following data table for storing the MQTT message, including the message ID, topic, QoS, payload, and publish time of each message.
94
93
95
-
```bash
96
-
...
97
-
Password:
98
-
1> USE master
99
-
2> GO
100
-
Changed database context to 'master'.
101
-
1> IF NOT EXISTS(SELECT name FROM sys.databases WHERE name = 'mqtt') BEGIN CREATE DATABASE mqtt END
102
-
2> GO
103
-
```
104
-
105
-
2. Use the following SQL statements to create a data table.
106
-
107
-
- Create the following data table for storing the MQTT message, including the message ID, topic, QoS, payload, and publish time of each message.
94
+
```sql
95
+
CREATETABLEdbo.t_mqtt_msg (id intPRIMARY KEY IDENTITY(1000000001,1) NOT NULL,
96
+
msgid VARCHAR(64) NULL,
97
+
topic VARCHAR(100) NULL,
98
+
qos tinyint NOT NULL DEFAULT 0,
99
+
payload VARCHAR(100) NULL,
100
+
arrived DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP);
101
+
GO
102
+
```
108
103
109
-
```sql
110
-
CREATETABLEmqtt.dbo.t_mqtt_msg (id intPRIMARY KEY IDENTITY(1000000001,1) NOT NULL,
111
-
msgid VARCHAR(64) NULL,
112
-
topic VARCHAR(100) NULL,
113
-
qos tinyint NOT NULL DEFAULT 0,
114
-
payload VARCHAR(100) NULL,
115
-
arrived DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP);
116
-
GO
117
-
```
104
+
- Create the following data table for recording the online/offline status of clients.
118
105
119
-
- Create the following data table for recording the online/offline status of clients.
120
-
121
-
```sql
122
-
CREATE TABLE mqtt.dbo.t_mqtt_events (id int PRIMARY KEY IDENTITY(1000000001,1) NOT NULL,
123
-
clientid VARCHAR(255) NULL,
124
-
event_type VARCHAR(255) NULL,
125
-
event_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP);
126
-
GO
127
-
```
106
+
```sql
107
+
CREATETABLEdbo.t_mqtt_events (id intPRIMARY KEY IDENTITY(1000000001,1) NOT NULL,
108
+
clientid VARCHAR(255) NULL,
109
+
event_type VARCHAR(255) NULL,
110
+
event_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP);
111
+
GO
112
+
```
128
113
129
114
### Install and Configure ODBC Driver
130
115
131
-
You need to configure the ODBC driver to be able to access the Microsoft SQL Server database. You can use either FreeTDS or the msodbcsql17 driver provided by Microsoft as the ODBC driver (The connection properties for msodbcsql18 have not been adapted yet).
116
+
You need to configure the ODBC driver to be able to access the Microsoft SQL Server database. You can use either FreeTDS or the msodbcsql18 driver provided by Microsoft as the ODBC driver.
132
117
133
118
EMQX uses the DSN Name specified in the `odbcinst.ini` configuration to determine the path to the driver dynamic library. In the examples below, the DSN Name is `ms-sql`. For more information, refer to [Connection Properties](https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/connection-string-keywords-and-data-source-names-dsns?view=sql-server-ver16#connection-properties).
134
119
135
-
::: tip Note:
120
+
::: tip Note
136
121
137
122
You can choose your own DSN name according to your preference, but it is recommended to use only English letters. Additionally, the DSN Name is case-sensitive.
138
123
139
124
:::
140
125
141
-
#### Install and Configure msodbcsql17 Driver as ODBC Driver
126
+
#### Install and Configure msodbcsql18 Driver as ODBC Driver
142
127
143
128
<!-- TODO: update tag version in command and dockerfile -->
144
129
145
-
If you need to use msodbcsql17 driver as the ODBC driver, refer to the Microsoft instructions:
130
+
If you need to use msodbcsql18 driver as the ODBC driver, refer to the Microsoft instructions:
146
131
147
132
-[Install the Microsoft ODBC driver for SQL Server (Linux)](https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16&tabs=alpine18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline)
148
133
-[Install the Microsoft ODBC driver for SQL Server (macOS)](https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver16)
149
134
150
-
Restricted by [Microsoft EULA terms](https://www.microsoft.com/en-us/Useterms/Retail/SQLServerStandard/2019/Useterms_Retail_SQLServerStandard_2019_English.htm), the Docker image provided by EMQX does not include the msodbcsql17 driver. To use it in Docker or Kubernetes, you need to create a new image installed with ODBC driver based on the image provided by [EMQX-Enterprise](https://hub.docker.com/r/emqx/emqx-enterprise) to access the Microsoft SQL Server database. Using the new image means that you agree to the [Microsoft SQL Server EULA](https://www.microsoft.com/en-us/Useterms/Retail/SQLServerStandard/2019/Useterms_Retail_SQLServerStandard_2019_English.htm).
135
+
Restricted by [Microsoft EULA terms](https://go.microsoft.com/fwlink/?linkid=857698), the Docker image provided by EMQX does not include the msodbcsql18 driver. To use it in Docker or Kubernetes, you need to create a new image installed with ODBC driver based on the image provided by [EMQXEnterprise](https://hub.docker.com/r/emqx/emqx-enterprise) to access the Microsoft SQL Server database. Using the new image means that you agree to the [Microsoft SQL Server EULA](https://go.microsoft.com/fwlink/?linkid=857698).
151
136
152
137
Follow the instructions below to build a new image:
153
138
154
-
1. Get the corresponding EMQX [Dockerfile](https://github.com/emqx/emqx/blob/master/deploy/docker/Dockerfile.msodbc). You can save the file locally.
139
+
1.Use the following Dockerfile to build a new image.
155
140
156
-
The image version in this example is `emqx/emqx-enterprise:5.0.3-alpha.2`. You can build the image based on the EMQX-Enterprise version you need, or use the latest version image `emqx/emqx-enterprise:latest`.
141
+
The base image version in this example is `emqx/emqx-enterprise:5.8.1`. You can build the image based on the EMQXEnterprise version you need, or use the latest version image `emqx/emqx-enterprise:latest`.
sed -i 's/ODBC Driver 18 for SQL Server/ms-sql/g' /etc/odbcinst.ini && \
155
+
apt-get clean && \
156
+
rm -rf /var/lib/apt/lists/*
173
157
174
-
USER emqx
175
-
```
158
+
USER emqx
159
+
```
176
160
177
-
2. Build a new image using the command `docker build -f=Dockerfile.msodbc -t emqx-enterprise-with-msodbc:5.0.3-alpha.2 .`
161
+
2. Build a new image using the command `docker build -t emqx/emqx-enterprise:5.8.1-msodbc`.
178
162
179
163
3. After building, you can use `docker image ls` to obtain a list of local images. You can also upload or save the image for later use.
180
164
181
-
::: tip
165
+
::: tip Note
182
166
183
-
Check that the DSN Name in`odbcinst.ini` should be `ms-sql` if you install the msodbcsql17 driver using this example. You can change the DSN Name according to your needs.
167
+
Check that the DSN Name in `odbcinst.ini` should be `ms-sql` if you install the msodbcsql18 driver using this example. You can change the DSN Name according to your needs.
184
168
185
169
:::
186
170
@@ -238,7 +222,7 @@ The following steps assume that you run both EMQX and Microsoft SQL Server on th
238
222
4. In the **Configuration** step, configure the following information:
239
223
-**Connector name**: Enter a name for the connector, which should be a combination of upper and lower-case letters and numbers, for example: `my_sqlserver`.
240
224
-**Server Host**: Enter `127.0.0.1:1433`, or the URL if the Microsoft SQL Server is running remotely.
241
-
-**Database Name**: Enter `mqtt`.
225
+
-**Database Name**: Enter `master`.
242
226
-**Username**: Enter `sa`.
243
227
-**Password**: Enter the preset password `mqtt_public1`, or use the actual password.
244
228
-**SQL Server Driver Name**: Enter `ms-sql`, as the DSN Name configured in `odbcinst.ini`
Check the running statistics of the Microsoft SQL Server Sink.
334
318
335
-
- For the Sink used to store messages, there should be 1 new matching and 1 new outgoing message. Check whether the data is written into the `mqtt.dbo.t_mqtt_msg` data table.
319
+
- For the Sink used to store messages, there should be 1 new matching and 1 new outgoing message. Check whether the data is written into the `t_mqtt_msg` data table.
- For the Sink used to record online/offline status, there should be 2 new events recorded: client connected and client disconnected. Check whether the status recording is written into the `mqtt.dbo.t_mqtt_events` data table.
332
+
- For the Sink used to record online/offline status, there should be 2 new events recorded: client connected and client disconnected. Check whether the status recording is written into the `t_mqtt_events` data table.
0 commit comments