Derby的另一个实例可能已经引导了数据库/ home / cloudera / metastore_db [英] Another instance of Derby may have already booted the database /home/cloudera/metastore_db

查看:1089
本文介绍了Derby的另一个实例可能已经引导了数据库/ home / cloudera / metastore_db的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Spark将正常的文本文件加载到配置单元表中。我正在使用Spark版本2.0.2。我已经在Spark版本1.6.0中成功完成了它,我试图在版本2x
中做同样的事情。我执行了以下步骤:

  import org.apache.spark.sql.SparkSession 
val spark = SparkSession.builder()。appName(SparkHiveLoad)。master(local)。enableHiveSupport()。getOrCreate() )
进口spark.implicits._

到现在为止没有问题。
但是当我尝试将文件加载到Spark时:

  val partfile = spark.read.textFile(hdfs ://quickstart.cloudera:8020 / user / cloudera / partfile)



 引起:org.apache.derby.iapi.error.StandardException:另一个Derby实例可能已经启动了数据库/家庭/ Cloudera公司/ metastore_db。 

core-site.xml中的默认属性:

 <属性> 
<名称> fs.defaultFS< / name>
< value> hdfs://quickstart.cloudera:8020< / value>
< / property>

没有其他配置单元或spark会话在后台运行。
我看到了不同的问题,但有同样的例外。所以请阅读一次,如果您仍然认为它是重复的,您可以将其标记。



有谁能告诉我如何修复它。

解决方案

Spark 2.0.2 spark.sparkContext.textFile 通常用于
读取文本文件。


Spark SQL的Scala接口支持自动将包含大小写类的RDD转换为DataFrame。 case类定义表的模式。使用反射读取case类的参数名称,并成为列的名称。案例类也可以嵌套或包含复杂类型,例如Seq或Arrays。此RDD可以隐式转换为DataFrame,然后将其注册为表格。表格可用于后续的SQL语句。



示例代码:

  mport org.apache.spark.sql.catalyst.encoders.ExpressionEncoder 
import org.apache.spark.sql.Encoder

//用于从RDD到DataFrames的隐式转换
import spark.implicits._

//从文本文件创建Person对象的RDD,将其转换为Dataframe
val peopleDF = spark.sparkContext
.textFile(例子/ src / main / resources / people.txt)
.map(_。split(,))
.map(attributes => Person(attributes(0),attributes(1 ).trim.toInt))
.toDF()
//将DataFrame注册为临时视图
peopleDF.createOrReplaceTempView(people)

请参阅 Spark Documentation 了解更多关于它的信息,并检查其他opton。


I am trying to load a normal text file into a hive table using Spark. I am using Spark version 2.0.2. I have done it successfully in Spark version: 1.6.0 and I am trying to do the same in version 2x I executed the below steps:

    import org.apache.spark.sql.SparkSession
    val spark = SparkSession.builder().appName("SparkHiveLoad").master("local").enableHiveSupport().getOrCreate()
    import spark.implicits._

There is no problem until now. But when I try to load the file into Spark:

val partfile = spark.read.textFile("hdfs://quickstart.cloudera:8020/user/cloudera/partfile")

I am getting an exception:

Caused by: org.apache.derby.iapi.error.StandardException: Another instance of Derby may have already booted the database /home/cloudera/metastore_db.

The default property in core-site.xml:

 <property>
    <name>fs.defaultFS</name>
    <value>hdfs://quickstart.cloudera:8020</value>
  </property>

There were no other hive or spark sessions running on the background. I saw different questions with same exception. So read it once and if you still think it is a duplicate, you can mark it.

Could anyone tell me how can I fix it.

解决方案

In Spark 2.0.2 spark.sparkContext.textFile is generally being used to read a textfile.

The Scala interface for Spark SQL supports automatically converting an RDD containing case classes to a DataFrame. The case class defines the schema of the table. The names of the arguments to the case class are read using reflection and become the names of the columns. Case classes can also be nested or contain complex types such as Seqs or Arrays. This RDD can be implicitly converted to a DataFrame and then be registered as a table. Tables can be used in subsequent SQL statements.

Sample code:

mport org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.Encoder

// For implicit conversions from RDDs to DataFrames
import spark.implicits._

// Create an RDD of Person objects from a text file, convert it to a Dataframe
val peopleDF = spark.sparkContext
  .textFile("examples/src/main/resources/people.txt")
  .map(_.split(","))
  .map(attributes => Person(attributes(0), attributes(1).trim.toInt))
  .toDF()
// Register the DataFrame as a temporary view
peopleDF.createOrReplaceTempView("people")

Please refer Spark Documentation for more information about it and to check other optons as well.

这篇关于Derby的另一个实例可能已经引导了数据库/ home / cloudera / metastore_db的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆