cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to disable jdbc/odbc connection to (azure) databrick cluster

OvZ
New Contributor III

Hi,

I wanna know if it is possible to disable jdbc/odbc connection to (azure) databrick cluster.

So know (download) tools could connect this way ?

Thz in adv,

Oscar

1 ACCEPTED SOLUTION

Accepted Solutions

LandanG
Databricks Employee
Databricks Employee

@Oscar van Zelst​ apart from using configuration settings to restrict access, you can also use an init script to disable connections on a cluster. The script is:

%scala
val initScriptContent = s"""
 |#!/bin/bash
 |cat > /databricks/common/conf/disable_jdbc_odbc.conf << EOL
 |{
 |  databricks.daemon.driver.startJDBC = false
 |}
 |EOL
""".stripMargin
dbutils.fs.put("dbfs:/databricks/init_scripts/disable_jdbc_odbc.conf",initScriptContent, true)

View solution in original post

13 REPLIES 13

LandanG
Databricks Employee
Databricks Employee

@Oscar van Zelst​ apart from using configuration settings to restrict access, you can also use an init script to disable connections on a cluster. The script is:

%scala
val initScriptContent = s"""
 |#!/bin/bash
 |cat > /databricks/common/conf/disable_jdbc_odbc.conf << EOL
 |{
 |  databricks.daemon.driver.startJDBC = false
 |}
 |EOL
""".stripMargin
dbutils.fs.put("dbfs:/databricks/init_scripts/disable_jdbc_odbc.conf",initScriptContent, true)

OvZ
New Contributor III

Thank you for you reply this sounds great but I get a error (sorry I am a newbie) or should I put this as a global init script ?

image

LandanG
Databricks Employee
Databricks Employee

Hi @Oscar van Zelst​ ,

You can use Cluster-scoped init scripts in the cluster configuration as seen in the screenshot or these docs.

Screen Shot 2023-01-30 at 10.49.10 AM 

OvZ
New Contributor III

The error I get if I put this as global inti script is that the cluster won't start

LandanG
Databricks Employee
Databricks Employee

Can you try using cluster-scoped init scripts?

OvZ
New Contributor III

I configure this now (see below)image but it give a error image

LandanG
Databricks Employee
Databricks Employee

@Oscar van Zelst​ Try using a cluster-scoped init script

OvZ
New Contributor III

Hi,

I have following you advise but no luck. This steps I have made; imageimageimageOn cluster level I have done this ; imageEven in de web terminal I see some files; root@0123-123553-quwe076y-10-215-1-4:/databricks/init_scripts# ls -ltr

total 4

-rw-r--r-- 1 root root 43 Jan 31 07:43 20230131_074358_00_disable_jdbc_odbc.sh.stdout.log

-rw-r--r-- 1 root root 0 Jan 31 07:43 20230131_074358_00_disable_jdbc_odbc.sh.stderr.log

root@0123-123553-quwe076y-10-215-1-4:/databricks/init_scripts# more 20230131_074358_00_disable_jdbc_odbc.sh.stdout.log

databricks.daemon.driver.startJDBC = false

But still I am able to connect by jdbc what I ‘am doing wrong ?

OvZ
New Contributor III

even if is set it on this way it does nothing..image way

OvZ
New Contributor III

Also in /tmp/custom-spark.conf you can see its set ;

root@0126-125139-sxrs37zl-10-215-1-5:/databricks/driver# cat /tmp/custom-spark.conf

...

spark.master local[*, 4]

spark.databricks.passthrough.enabled true

spark.databricks.cloudfetch.hasRegionSupport true

spark.databricks.daemon.driver.startJDBC false

LandanG
Databricks Employee
Databricks Employee

@Oscar van Zelst​ Are you saving the code as a .conf file, as seen in the code snippet?

dbutils.fs.put("dbfs:/databricks/init_scripts/disable_jdbc_odbc.conf",initScriptContent, true)

OvZ
New Contributor III

Hi ,

I have done this imageand this imageimage and if I look at terminal level its there;

root@0123-123553-quwe076y-10-215-1-4:/databricks/init_scripts# ls -ltr

total 4

-rw-r--r-- 1 root root 0 Jan 31 16:04 20230131_160437_00_disable_jdbc_odbc.conf.stdout.log

-rw-r--r-- 1 root root 0 Jan 31 16:04 20230131_160437_00_disable_jdbc_odbc.conf.stderr.log

-rw-r--r-- 1 root root 49 Jan 31 16:04 disable_jdbc_odbc.conf

root@0123-123553-quwe076y-10-215-1-4:/databricks/init_scripts# cat disable_jdbc_odbc.conf 

{

 databricks.daemon.driver.startJDBC = false

}

but still accesable by jdbc/odbc .connection it there other methodes to disable access also fine

wdphilli
New Contributor III

Hi @OvZ & @LandanG, as a point of clarification, the script provided is intended to be run in a notebook first. After running the below in a notebook, it creates the init script at the location "dbfs:/databricks/init_scripts/disable_jdbc_odbc.conf"

 

%scala
val initScriptContent = s"""
 |#!/bin/bash
 |cat > /databricks/common/conf/disable_jdbc_odbc.conf << EOL
 |{
 |  databricks.daemon.driver.startJDBC = false
 |}
 |EOL
""".stripMargin
dbutils.fs.put("dbfs:/databricks/init_scripts/disable_jdbc_odbc.conf",initScriptContent, true)

 From there, it can be added as a cluster-scoped init script under Advanced options:

wdphilli_0-1706713371163.png

After cluster startup, you will notice that the JDBC/ODBC tab does not appear in the Spark UI:

wdphilli_1-1706713417889.png

JDBC/ODBC connections will also fail with a 502 error:

wdphilli_2-1706713520973.png

 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group