Skip to content

Commit 673725f

Browse files
AUTO: Docs repo sync - ScalarDB (#993)
* AUTO: Sync ScalarDB docs in English to docs site repo * AUTO: Sync ScalarDB docs in English to docs site repo * Remove old comment * Change folder name * Add ScalarDB Analytics design doc * Add ScalarDB Analytics develop and deploy docs * Remove ScalarDB Analytics version compatibility doc The contents of the version compatibility doc have been moved to the "Run Analytical Queries Through ScalarDB Analytics" doc. * Add redirect for ScalarDB Analytics version compatibility doc --------- Co-authored-by: josh-wong <[email protected]> Co-authored-by: Josh Wong <[email protected]>
1 parent 46b39af commit 673725f

File tree

10 files changed

+1075
-44
lines changed

10 files changed

+1075
-44
lines changed

docs/scalardb-analytics-spark/version-compatibility.mdx

Lines changed: 0 additions & 18 deletions
This file was deleted.
File renamed without changes.
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
---
2+
tags:
3+
- Enterprise Option
4+
- Public Preview
5+
displayed_sidebar: docsEnglish
6+
---
7+
8+
import Tabs from '@theme/Tabs';
9+
import TabItem from '@theme/TabItem';
10+
11+
# Deploy ScalarDB Analytics in Public Cloud Environments
12+
13+
This guide explains how to deploy ScalarDB Analytics in a public cloud environment. ScalarDB Analytics currently uses Apache Spark as an execution engine and supports managed Spark services provided by public cloud providers, such as Amazon EMR and Databricks.
14+
15+
## Supported managed Spark services and their application types
16+
17+
ScalarDB Analytics supports the following managed Spark services and application types.
18+
19+
| Public Cloud Service | Spark Driver | Spark Connect | JDBC |
20+
| -------------------------- | ------------ | ------------- | ---- |
21+
| Amazon EMR (EMR on EC2) ||||
22+
| Databricks ||||
23+
24+
## Configure and deploy
25+
26+
Select your public cloud environment, and follow the instructions to set up and deploy ScalarDB Analytics.
27+
28+
<Tabs groupId="cloud-service" queryString>
29+
<TabItem value="emr" label="Amazon EMR">
30+
31+
<h3>Use Amazon EMR</h3>
32+
33+
You can use Amazon EMR (EMR on EC2) to run analytical queries through ScalarDB Analytics. For the basics to launch an EMR cluster, please refer to the [AWS EMR on EC2 documentation](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-plan.html).
34+
35+
<h4>ScalarDB Analytics configuration</h4>
36+
37+
To enable ScalarDB Analytics, you need to add the following configuration to the Software setting when you launch an EMR cluster. Be sure to replace the content in the angle brackets:
38+
39+
```json
40+
[
41+
{
42+
"Classification": "spark-defaults",
43+
"Properties": {
44+
"spark.jars.packages": "com.scalar-labs:scalardb-analytics-spark-all-<SPARK_VERSION>_<SCALA_VERSION>:<SCALARDB_ANALYTICS_VERSION>",
45+
"spark.sql.catalog.<CATALOG_NAME>": "com.scalar.db.analytics.spark.ScalarDbAnalyticsCatalog",
46+
"spark.sql.extensions": "com.scalar.db.analytics.spark.extension.ScalarDbAnalyticsExtensions",
47+
"spark.sql.catalog.<CATALOG_NAME>.license.cert_pem": "<YOUR_LICENSE_CERT_PEM>",
48+
"spark.sql.catalog.<CATALOG_NAME>.license.key": "<YOUR_LICENSE_KEY>",
49+
50+
// Add your data source configuration below
51+
}
52+
}
53+
]
54+
```
55+
56+
The following describes what you should change the content in the angle brackets to:
57+
58+
- `<SPARK_VERSION>`: The version of Spark.
59+
- `<SCALA_VERSION>`: The version of Scala used to build Spark.
60+
- `<SCALARDB_ANALYTICS_VERSION>`: The version of ScalarDB Analytics.
61+
- `<CATALOG_NAME>`: The name of the catalog.
62+
- `<YOUR_LICENSE_CERT_PEM>`: The PEM encoded license certificate.
63+
- `<YOUR_LICENSE_KEY>`: The license key.
64+
65+
For more details, refer to [Set up ScalarDB Analytics in the Spark configuration](development.mdx#set-up-scalardb-analytics-in-the-spark-configuration).
66+
67+
<h4>Run analytical queries via the Spark driver</h4>
68+
69+
After the EMR Spark cluster has launched, you can use ssh to connect to the primary node of the EMR cluster and run your Spark application. For details on how to create a Spark Driver application, refer to [Spark Driver application](development.mdx?spark-application-type=spark-driver#spark-driver-application).
70+
71+
<h4>Run analytical queries via Spark Connect</h4>
72+
73+
You can use Spark Connect to run your Spark application remotely by using the EMR cluster that you launched.
74+
75+
You first need to configure the Software setting in the same way as the [Spark Driver application](development.mdx?spark-application-type=spark-driver#spark-driver-application). You also need to set the following configuration to enable Spark Connect.
76+
77+
<h5>Allow inbound traffic for a Spark Connect server</h5>
78+
79+
1. Create a security group to allow inbound traffic for a Spark Connect server. (Port 15001 is the default).
80+
2. Allow the role of "Amazon EMR service role" to attach the security group to the primary node of the EMR cluster.
81+
3. Add the security group to the primary node of the EMR cluster as "Additional security groups" when you launch the EMR cluster.
82+
83+
<h5>Launch the Spark Connect server via a bootstrap action</h5>
84+
85+
1. Create a script file to launch the Spark Connect server as follows:
86+
87+
```bash
88+
#!/usr/bin/env bash
89+
90+
set -eu -o pipefail
91+
92+
cd /var/lib/spark
93+
94+
sudo -u spark /usr/lib/spark/sbin/start-connect-server.sh --packages org.apache.spark:spark-connect_<SCALA_VERSION>:<SPARK_FULL_VERSION>,com.scalar-labs:scalardb-analytics-spark-all-<SPARK_VERSION>_<SCALA_VERSION>:<SCALARDB_ANALYTICS_VERSION>
95+
```
96+
97+
The following describes what you should change the content in the angle brackets to:
98+
99+
- `<SCALA_VERSION>`: The major and minor version of Scala that matches your Spark installation (such as 2.12 or 2.13)
100+
- `<SPARK_FULL_VERSION>`: The full version of Spark you are using (such as 3.5.3)
101+
- `<SPARK_VERSION>`: The major and minor version of Spark you are using (such as 3.5)
102+
- `<SCALARDB_ANALYTICS_VERSION>`: The version of ScalarDB Analytics
103+
104+
2. Upload the script file to S3.
105+
3. Allow the role of "EC2 instance profile for Amazon EMR" to access the uploaded script file in S3.
106+
4. Add the uploaded script file to "Bootstrap actions" when you launch the EMR cluster.
107+
108+
<h5>Run analytical queries</h5>
109+
110+
You can run your Spark application via Spark Connect from anywhere by using the remote URL of the Spark Connect server, which is `sc://<PRIMARY_NODE_PUBLIC_HOSTNAME>:15001`.
111+
112+
For details on how to create a Spark application by using Spark Connect, refer to [Spark Connect application](development.mdx?spark-application-type=spark-connect#spark-connect-application).
113+
114+
</TabItem>
115+
<TabItem value="databricks" label="Databricks">
116+
<h3>Use Databricks</h3>
117+
118+
You can use Databricks to run analytical queries through ScalarDB Analytics.
119+
120+
:::note
121+
122+
Note that Databricks provides a modified version of Apache Spark, which works differently from the original Apache Spark.
123+
124+
:::
125+
126+
<h4>Launch Databricks cluster</h4>
127+
128+
ScalarDB Analytics works with all-purpose and jobs-compute clusters on Databricks. When you launch the cluster, you need to configure the cluster to enable ScalarDB Analytics as follows:
129+
130+
1. Store the license certificate and license key in the cluster by using the Databricks CLI.
131+
132+
```console
133+
databricks secrets create-scope scalardb-analytics-secret # you can use any secret scope name
134+
cat license_key.json | databricks secrets put-secret scalardb-analytics-secret license-key
135+
cat license_cert.pem | databricks secrets put-secret scalardb-analytics-secret license-cert
136+
```
137+
138+
:::note
139+
140+
For details on how to install and use the Databricks CLI, refer to the [Databricks CLI documentation](https://docs.databricks.com/en/dev-tools/cli/index.html).
141+
142+
:::
143+
144+
2. Select "No isolation shared" for the cluster mode. (This is required. ScalarDB Analytics works only with this cluster mode.)
145+
3. Select an appropriate Databricks runtime version that supports Spark 3.4 or later.
146+
4. Configure "Advanced Options" > "Spark config" as follows, replacing `<CATALOG_NAME>` with the name of the catalog that you want to use:
147+
148+
```
149+
spark.sql.catalog.<CATALOG_NAME> com.scalar.db.analytics.spark.ScalarDbAnalyticsCatalog
150+
spark.sql.extensions com.scalar.db.analytics.spark.extension.ScalarDbAnalyticsExtensions
151+
spark.sql.catalog.<CATALOG_NAME>.license.key {{secrets/scalardb-analytics-secret/license-key}}
152+
spark.sql.catalog.<CATALOG_NAME>.license.cert_pem {{secrets/scalardb-analytics-secret/license-pem}}
153+
```
154+
155+
:::note
156+
157+
You also need to configure the data source. For details, refer to [Set up ScalarDB Analytics in the Spark configuration](development.mdx#set-up-scalardb-analytics-in-the-spark-configuration).
158+
159+
:::
160+
161+
:::note
162+
163+
If you specified different secret names in the previous step, be sure to replace the secret names in the configuration above.
164+
165+
:::
166+
167+
5. Add the library of ScalarDB Analytics to the launched cluster as a Maven dependency. For details on how to add the library, refer to the [Databricks cluster libraries documentation](https://docs.databricks.com/en/libraries/cluster-libraries.html).
168+
169+
<h4>Run analytical queries via the Spark Driver</h4>
170+
171+
You can run your Spark application on the properly configured Databricks cluster with Databricks Notebook or Databricks Jobs to access the tables in ScalarDB Analytics. To run the Spark application, you can migrate your Pyspark, Scala, or Spark SQL application to Databricks Notebook, or use Databricks Jobs to run your Spark application. ScalarDB Analytics works with task types for Notebook, Python, JAR, and SQL.
172+
173+
For more details on how to use Databricks Jobs, refer to the [Databricks Jobs documentation](https://docs.databricks.com/en/jobs/index.html)
174+
175+
<h4>Run analytical queries via the JDBC driver</h4>
176+
177+
Databricks supports JDBC to run SQL jobs on the cluster. You can use this feature to run your Spark application in SQL with ScalarDB Analytics by configuring extra settings as follows:
178+
179+
1. Download the ScalarDB Analytics library JAR file from the Maven repository.
180+
2. Upload the JAR file to the Databricks workspace.
181+
3. Add the JAR file to the cluster as a library, instead of the Maven dependency.
182+
4. Create an init script as follows, replacing `<PATH_TO_YOUR_JAR_FILE_IN_WORKSPACE>` with the path to your JAR file in the Databricks workspace:
183+
184+
```bash
185+
#!/bin/bash
186+
187+
# Target directories
188+
TARGET_DIRECTORIES=("/databricks/jars" "/databricks/hive_metastore_jars")
189+
JAR_PATH="<PATH_TO_YOUR_JAR_FILE_IN_WORKSPACE>
190+
191+
# Copy the JAR file to the target directories
192+
for TARGET_DIR in "${TARGET_DIRECTORIES[@]}"; do
193+
mkdir -p "$TARGET_DIR"
194+
cp "$JAR_PATH" "$TARGET_DIR/"
195+
done
196+
```
197+
198+
5. Upload the init script to the Databricks workspace.
199+
6. Add the init script to the cluster to "Advanced Options" > "Init scripts" when you launch the cluster.
200+
201+
After the cluster is launched, you can get the JDBC URL of the cluster in the "Advanced Options" > "JDBC/ODBC" tab on the cluster details page.
202+
203+
To connect to the Databricks cluster by using JDBC, you need to add the Databricks JDBC driver to your application dependencies. For example, if you are using Gradle, you can add the following dependency to your `build.gradle` file:
204+
205+
```groovy
206+
implementation("com.databricks:databricks-jdbc:0.9.6-oss")
207+
```
208+
209+
Then, you can connect to the Databricks cluster by using JDBC with the JDBC URL (`<YOUR_CLUSTERS_JDBC_URL>`), as is common with JDBC applications.
210+
211+
```java
212+
Class.forName("com.databricks.client.jdbc.Driver");
213+
String url = "<YOUR_CLUSTERS_JDBC_URL>";
214+
Connection conn = DriverManager.getConnection(url)
215+
```
216+
217+
For more details on how to use JDBC with Databricks, refer to the [Databricks JDBC Driver documentation](https://docs.databricks.com/en/integrations/jdbc/index.html).
218+
219+
</TabItem>
220+
</Tabs>

0 commit comments

Comments
 (0)