我有一種情況,從兩個獨立的遠程配置單元的服務器比較兩個不同的表源和目的地,可我們能使用兩個SparkSessions
像我以下嘗試: -我們能否能夠使用多張sparksessions訪問兩個不同的配置單元的服務器
val spark = SparkSession.builder().master("local")
.appName("spark remote")
.config("javax.jdo.option.ConnectionURL", "jdbc:mysql://192.168.175.160:3306/metastore?useSSL=false")
.config("javax.jdo.option.ConnectionUserName", "hiveroot")
.config("javax.jdo.option.ConnectionPassword", "hivepassword")
.config("hive.exec.scratchdir", "/tmp/hive/${user.name}")
.config("hive.metastore.uris", "thrift://192.168.175.160:9083")
.enableHiveSupport()
.getOrCreate()
SparkSession.clearActiveSession()
SparkSession.clearDefaultSession()
val sparkdestination = SparkSession.builder()
.config("javax.jdo.option.ConnectionURL", "jdbc:mysql://192.168.175.42:3306/metastore?useSSL=false")
.config("javax.jdo.option.ConnectionUserName", "hiveroot")
.config("javax.jdo.option.ConnectionPassword", "hivepassword")
.config("hive.exec.scratchdir", "/tmp/hive/${user.name}")
.config("hive.metastore.uris", "thrift://192.168.175.42:9083")
.enableHiveSupport()
.getOrCreate()
我試着用SparkSession.clearActiveSession() and SparkSession.clearDefaultSession()
,但它不工作,拋出下面的錯誤:
Hive: Failed to access metastore. This class should not accessed in runtime.
org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
有沒有我們可以達到訪問使用多個SparkSessions
或代蜂巢表任何其他方式。
感謝
我無法在SparkSession中找到newSession()方法。有沒有例子請。 – Vignesh
我的代碼研究了構建火花並給出了上面的指針。你必須檢查文檔方法。事實上,我正在研究火花的<2版本。請檢查像'setActiveSession'等方法... –