./spark-shell无法正常启动(spark1.6.1-bin.hadoop2.6版本)

cod*_*din 3 apache-spark

我安装了这个火花版:spark-1.6.1-bin-hadoop2.6.tgz.

现在当我用./spark-shell命令启动spark时我得到了这个问题(它显示了很多错误行,所以我只是把一些看起来很重要)

     Cleanup action completed
        16/03/27 00:19:35 ERROR Schema: Failed initialising database.
        Failed to create database 'metastore_db', see the next exception for details.
        org.datanucleus.exceptions.NucleusDataStoreException: Failed to create database 'metastore_db', see the next exception for details.
            at org.datanucleus.store.rdbms.ConnectionFactoryImpl$ManagedConnectionImpl.getConnection(ConnectionFactoryImpl.java:516)

        Caused by: java.sql.SQLException: Directory /usr/local/spark-1.6.1-bin-hadoop2.6/bin/metastore_db cannot be created.
            org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
            ... 128 more
        Caused by: ERROR XBM0H: Directory /usr/local/spark-1.6.1-bin-hadoop2.6/bin/metastore_db cannot be created.


        Nested Throwables StackTrace:
        java.sql.SQLException: Failed to create database 'metastore_db', see the next exception for details.
  org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
            ... 128 more
        Caused by: ERROR XBM0H: Directory /usr/local/spark-1.6.1-bin-hadoop2.6/bin/metastore_db cannot be created.
            at org.apache.derby.iapi.error.StandardException.newException


        Caused by: java.sql.SQLException: Directory /usr/local/spark-1.6.1-bin-hadoop2.6/bin/metastore_db cannot be created.
            at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
            at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
            at 
            ... 128 more

        <console>:16: error: not found: value sqlContext
                 import sqlContext.implicits._
                        ^
        <console>:16: error: not found: value sqlContext
                 import sqlContext.sql
                        ^

        scala> 
Run Code Online (Sandbox Code Playgroud)

我尝试了一些配置来解决这个问题,我在其他关于sqlContext值找不到问题的问题中搜索,例如:

/ etc/hosts文件:

127.0.0.1  hadoophost localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
    10.2.0.15 hadoophost
Run Code Online (Sandbox Code Playgroud)

echo $HOSTNAME 收益:

hadoophost

.bashrc文件包含:

export SPARK_LOCAL_IP=127.0.0.1
Run Code Online (Sandbox Code Playgroud)

但是不行,你可以帮助尝试理解为什么火花没有正确启动?

蜂房default.xml.template

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
--><configuration>
  <!-- WARNING!!! This file is auto generated for documentation purposes ONLY! -->
  <!-- WARNING!!! Any changes you make to this file will be ignored by Hive.   -->
  <!-- WARNING!!! You must make your changes in hive-site.xml instead.         -->
Run Code Online (Sandbox Code Playgroud)

在主文件夹中,我遇到了同样的问题:

[hadoopadmin@hadoop home]$ pwd
/home
[hadoopadmin@hadoop home]$ 
Run Code Online (Sandbox Code Playgroud)

文件夹权限:

[hadoopdadmin@hadoop spark-1.6.1-bin-hadoop2.6]$ ls -la
total 1416
drwxr-xr-x. 12 hadoop hadoop    4096 .
drwxr-xr-x. 16 root   root      4096  ..
drwxr-xr-x.  2 hadoop hadoop    4096  bin
-rw-r--r--.  1 hadoop hadoop 1343562  CHANGES.txt
drwxr-xr-x.  2 hadoop hadoop    4096  conf
drwxr-xr-x.  3 hadoop hadoop    4096  data
drwxr-xr-x.  3 hadoop hadoop    4096  ec2
drwxr-xr-x.  3 hadoop hadoop    4096  examples
drwxr-xr-x.  2 hadoop hadoop    4096  lib
-rw-r--r--.  1 hadoop hadoop   17352  LICENSE
drwxr-xr-x.  2 hadoop hadoop    4096  licenses
-rw-r--r--.  1 hadoop hadoop   23529  NOTICE
drwxr-xr-x.  6 hadoop hadoop    4096  python
drwxr-xr-x.  3 hadoop hadoop    4096  R
-rw-r--r--.  1 hadoop hadoop    3359  README.md
-rw-r--r--.  1 hadoop hadoop     120  RELEASE
drwxr-xr-x.  2 hadoop hadoop    4096  sbin
Run Code Online (Sandbox Code Playgroud)

Alb*_*nto 10

显然您没有权限在该目录中写入,我建议您./spark-shell在您的HOME(您可能希望将该命令添加到您的PATH)中运行,或者在您的用户可访问和写入的任何其他目录中运行.

这也可能与您的笔记本和Spark一起使用