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
These libraries will be used later on. The following section is for interaction with MS SQL databases.
32
-
33
-
Modern Linux distributions use PAM to handle the authentication tasks of applications (services) on the system (PAM stands for _Pluggable Authentication Modules_, see `man PAM`). However we do not need that here.
34
-
The above installation may have led to inserting a line into PAM configuration file `/etc/pam.d/common-auth`. The line looks like this (note the defining part `pam_krb5.so`):
This line makes every application that needs authentication on the system (like sudo, screensaver unlock, update manager, ...) first try the Kerberos connection to authenticate.
41
-
This is overkill as we don't want to use Kerberos that way, and it can significantly slow down all other system authentications.
42
-
Therefore, you should _comment out_ the above line in `/etc/pam.d/common-auth`.
43
-
44
-
### MS SQL Server tools
45
-
46
-
As most of the databases at INBO are SQL Server, an appropriate driver and the command line toolset is required to fully support database connections to SQL Server.
47
-
48
-
#### ODBC driver
49
-
50
-
Download and install the [Microsoft ODBC Driver for SQL Server](https://www.microsoft.com/en-us/download/details.aspx?id=53339). The installation instructions for different Linux flavours can be downloaded together with the ODBC driver. For `Ubuntu 16.04` (and most distributions based on it), following instructions apply:
The instructions for different platforms are explained [here](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools). In order to test the SQL connection later in this tutorial, add `/opt/mssql-tools/bin/` to your PATH environment variable.
71
30
72
-
You could also decide to go for the binaries: download [the debian package of mssql-tools](https://apt-mo.trafficmanager.net/repos/mssql-ubuntu-xenial-release/pool/main/m/mssql-tools/mssql-tools_14.0.1.246-1_amd64.deb) and install with:
31
+
During installation, you may be asked for extra configuration input.
32
+
To answer that, see next section: [Configure Kerberos client](#configure-kerberos-client).
73
33
74
-
```
75
-
sudo apt-get install libgss3
76
-
sudo dpkg -i mssql-tools_14.0.1.246-1_amd64.deb
77
-
```
78
34
79
35
### Configure Kerberos client
80
36
81
37
*(again, the commands assume root privileges)*
82
38
83
-
Start with the kerberos configuration dialogue:
39
+
Start with the Kerberos configuration dialogue:
84
40
85
-
```
41
+
```bash
86
42
dpkg-reconfigure krb5-config
87
43
```
88
44
Use `INBO.BE` as the realm (this is the realm of the kerberos servers):
@@ -118,15 +74,82 @@ Next, adapt the `krb5.conf`, probably available in the `/etc` directory. Add th
118
74
forwardable= true
119
75
```
120
76
121
-
Inbo staff can download a preconfigured krb5.conf file here:"https://drive.google.com/a/inbo.be/file/d/1q4MOWl3i-DDy1s3vwOeqPkpToa1S-3zE/view?usp=sharing".
122
-
In order to sync the timing of the domain controller server and client side, install `ntp`:
77
+
INBO staff can download a preconfigured `krb5.conf` file here:
Active: active since Mon 2020-09-07 08:27:03 CEST; 59min ago
91
+
Docs: man:systemd.special(7)
92
+
93
+
$ timedatectl status
94
+
Local time: ma 2020-09-07 09:27:00 CEST
95
+
Universal time: ma 2020-09-07 07:27:00 UTC
96
+
RTC time: ma 2020-09-07 07:27:00
97
+
Time zone: Europe/Brussels (CEST, +0200)
98
+
System clock synchronized: yes
99
+
NTP service: active
100
+
RTC inlocal TZ: no
124
101
```
102
+
103
+
Note the line `NTP service: active`.
104
+
105
+
If you do have the `systemd-timesyncd` package but the unit is _not_ active, run `systemctl enable --now time-sync.target`.
106
+
Further information can be found [here](https://wiki.archlinux.org/index.php/Systemd-timesyncd).
107
+
108
+
Only if you **don't** have the `systemd-timesyncd` package, install `ntp` instead:
109
+
110
+
```bash
125
111
sudo apt-get install ntp
126
112
```
127
-
After installation, check if the following two files do exist:
113
+
114
+
_If_ you installed `ntp`, check whether the following two files do exist:
115
+
128
116
*`/etc/ntp.conf`
129
-
*`/etc/ntp.conf.dhcp` (empty file, just amke sure there is a file)
117
+
*`/etc/ntp.conf.dhcp` (empty file, just make sure there is a file)
118
+
119
+
### MS SQL Server ODBC driver and tools
120
+
121
+
As most of the databases at INBO are SQL Server, an appropriate driver and the command line toolset is required to fully support database connections to SQL Server.
122
+
123
+
Apart from the ODBC driver, we will also install following tools:
124
+
125
+
***sqlcmd**: Command-line query utility.
126
+
***bcp**: Bulk import-export utility.
127
+
128
+
For Linux, follow [these installation instructions](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).[^installnotes]
129
+
130
+
Also follow the 'optional' instructions, as these will install the tools.
131
+
132
+
Hence, for Ubuntu 20.04 or Linux Mint 20 you would do:
On Ubuntu 20.04, if installing `msodbcsql17` and `mssql-tools` fails because of incompatible `unixodbc` version, you can first try `apt install unixodbc=2.3.6-0.1build1 unixodbc-dev=2.3.6-0.1build1`.
149
+
150
+
[^installnotes]: You can also find the debian packages of Microsoft ODBC Driver for SQL Server [here](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server).
151
+
You can find separate installation instructions for `sqlcmd`, `bcp` and `unixodbc-dev`[here](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools).
152
+
130
153
131
154
## Test installation
132
155
@@ -164,36 +187,46 @@ sqlcmd -S DBServerName -E
164
187
2> Go
165
188
```
166
189
190
+
On Ubuntu 20.04, you may get an error:
191
+
192
+
```
193
+
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2746.
194
+
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
195
+
```
196
+
197
+
If you are in that case, have a look at working solutions in [this GitHub issue](https://github.com/microsoft/azuredatastudio/issues/10337).
167
198
168
199
## SQL ODBC connections
169
200
170
201
To support database connections from other applications (e.g. GUI environments, but also R, Python,...), the configuration of database drivers and connections should be provided in the `/etc/odbc.ini` and `/etc/odbcinst.ini`.
171
202
172
203
Make sure the ODBC driver for SQL Server is available with a recognizable name in the `/etc/odbcinst.ini` file:
173
204
```
174
-
[ODBC Driver 13 for SQL Server]
175
-
Description=Microsoft ODBC Driver 13 for SQL Server
### Connecting by explicitly providing the SQL connection string to ODBC libraries/packages
181
212
182
-
Inbo staff can consult a list of connection strings [here](https://docs.google.com/spreadsheets/d/1Wu7GmWm-NyHLHYWwuu74aQuugkDKGnLF-8XFFPz_F_M/edit?usp=sharing)
213
+
INBO staff can consult a list of connection strings [here](https://docs.google.com/spreadsheets/d/1Wu7GmWm-NyHLHYWwuu74aQuugkDKGnLF-8XFFPz_F_M/edit?usp=sharing).
183
214
At this moment, you can actually connect using typical ODBC libraries/packages provided by R or Python:
184
215
185
-
```{r eval = FALSE}
216
+
```r
186
217
library(DBI)
187
218
connection<- dbConnect(
188
219
odbc::odbc(),
189
-
.connection_string = "Driver={ODBC Driver 13 for SQL Server};Server=DBServername;Database=DBName;Trusted_Connection=yes;"
220
+
.connection_string="Driver={ODBC Driver 17 for SQL Server};Server=DBServername;Database=DBName;Trusted_Connection=yes;"
190
221
)
191
222
dbListTables(connection)
192
223
```
193
224
225
+
However, most recommended for INBO staff using R is the use of the [inbodb](https://inbo.github.io/inbodb/) package, most notably the [`connect_inbo_dbase()`](https://inbo.github.io/inbodb/reference/connect_inbo_dbase.html) function.
226
+
194
227
```python
195
228
import pyodbc
196
-
conn = pyodbc.connect("Driver={ODBC Driver 13 for SQL Server};Server=DBServername;Database=DBName;Trusted_Connection=yes;")
229
+
conn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};Server=DBServername;Database=DBName;Trusted_Connection=yes;")
197
230
```
198
231
199
232
In RStudio, you can also make the connection with the GUI:
@@ -215,7 +248,7 @@ However, it is probably easier to provide the configuration to specific database
0 commit comments