복붙노트

[HADOOP] 의 예외 클라우 데라 VM에서 튜토리얼 CSV 파일을 읽는

HADOOP

의 예외 클라우 데라 VM에서 튜토리얼 CSV 파일을 읽는

나는 클라우 데라 가상 컴퓨터와 함께 제공되는 불꽃 자습서를 할 노력하고있어. 내가 오류의 톤을 얻을 수 있기 때문에하지만 올바른 라인 끝 인코딩을 사용하고 있더라도, 나는 스크립트를 실행할 수 없습니다. 튜토리얼은 빅 데이터 분석 과정에 코 세라 소개의 일부입니다. 할당은 여기에서 찾을 수 있습니다.

그래서 여기에 내가 무슨 짓을했는지. (아직없는 경우) IPython 쉘을 설치합니다 :

sudo easy_install ipython==1.2.1

오픈 / (중 1.2.0 또는 1.4.0 포함) 쉘을 시작합니다 :

PYSPARK_DRIVER_PYTHON=ipython pyspark --packages com.databricks:spark-csv_2.10:1.2.0

창 스타일의 라인 엔딩을 설정합니다. 파일이 윈도우 인코딩에 있고 그렇게하는 과정에서 말했다 것 때문이다. 이렇게하지 않으면, 당신은 다른 오류를 얻을 수 있습니다.

sc._jsc.hadoopConfiguration().set('textinputformat.record.delimiter','\r\n')

CSV 파일을로드하려고 :

yelp_df = sqlCtx.load(source='com.databricks.spark.csv',header = 'true',inferSchema = 'true',path = 'file:///usr/lib/hue/apps/search/examples/collections/solr_configs_yelp_demo/index_data.csv')

하지만이 같은 시작 오류의 아주 긴 목록을 얻는 :

Py4JJavaError: An error occurred while calling o23.load.: java.lang.RuntimeException: 
Unable to instantiate 
org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient at 
org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:472)

전체 오류 메시지는 여기에서 볼 수 있습니다. 그리고 이것은 /etc/hive/conf/hive-site.xml입니다

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>

  <!-- Hive Configuration can either be stored in this file or in the hadoop configuration files  -->
  <!-- that are implied by Hadoop setup variables.                                                -->
  <!-- Aside from Hadoop setup variables - this file is provided as a convenience so that Hive    -->
  <!-- users do not have to edit hadoop configuration files (that may be managed as a centralized -->
  <!-- resource).                                                                                 -->

  <!-- Hive Execution Parameters -->

  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://127.0.0.1/metastore?createDatabaseIfNotExist=true</value>
    <description>JDBC connect string for a JDBC metastore</description>
  </property>

  <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.jdbc.Driver</value>
    <description>Driver class name for a JDBC metastore</description>
  </property>

  <property>
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>hive</value>
  </property>

  <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>cloudera</value>
  </property>

  <property>
    <name>hive.hwi.war.file</name>
    <value>/usr/lib/hive/lib/hive-hwi-0.8.1-cdh4.0.0.jar</value>
    <description>This is the WAR file with the jsp content for Hive Web Interface</description>
  </property>

  <property>
    <name>datanucleus.fixedDatastore</name>
    <value>true</value>
  </property>

  <property>
    <name>datanucleus.autoCreateSchema</name>
    <value>false</value>
  </property>

  <property>
    <name>hive.metastore.uris</name>
    <value>thrift://127.0.0.1:9083</value>
    <description>IP address (or fully-qualified domain name) and port of the metastore host</description>
  </property>
</configuration>

어떤 도움이나 아이디어는 어떻게 해결 하는가? 나는 그것이 매우 일반적인 오류 같아요. 하지만 아직 어떤 해결책을 찾을 수 없습니다.

한 가지 더 : 별도의 로그 파일에 같은 긴 오류 메시지를 덤프하는 방법은 무엇입니까?

해결법

  1. ==============================

    1.토론의 요약 : 다음 명령은 문제를 해결 실행 :

    토론의 요약 : 다음 명령은 문제를 해결 실행 :

    sudo cp /etc/hive/conf.dist/hive-site.xml /usr/lib/spark/conf/
    

    추가 정보를 원하시면 https://www.coursera.org/learn/bigdata-analytics/supplement/tyH3p/setup-pyspark-for-dataframes를 참조하십시오.

  2. ==============================

    2.이 문제가있는 것 같다. 첫째, 하이브 - 메타 스토어는 어떤 경우에 오프라인이었다. 둘째, 스키마 유추 할 수 없습니다. 그러므로 나는 수동으로 스키마를 생성하고 CSV 파일을로드 할 때 인수로 추가. 어쨌든, 나는이 사실 schemaInfer =으로 어떻게 든 작동하는지 이해하는 것이 싶어요.

    이 문제가있는 것 같다. 첫째, 하이브 - 메타 스토어는 어떤 경우에 오프라인이었다. 둘째, 스키마 유추 할 수 없습니다. 그러므로 나는 수동으로 스키마를 생성하고 CSV 파일을로드 할 때 인수로 추가. 어쨌든, 나는이 사실 schemaInfer =으로 어떻게 든 작동하는지 이해하는 것이 싶어요.

    여기에 수동으로 정의 스키마 내 버전입니다. 그래서, 하이브가 시작되어 있는지 확인합니다 :

    sudo service hive-metastore restart
    

    그런 다음,이 구조의 이해하는 CSV 파일의 첫 부분으로보고있다. 나는이 명령 줄을 사용 :

    head /usr/lib/hue/apps/search/examples/collections/solr_configs_yelp_demo/index_data.csv
    

    이제, 파이썬 쉘을 엽니 다. 이 작업을 수행하는 방법에 대한 원래의 게시물을 참조하십시오. 그런 다음 스키마를 정의 :

    from pyspark.sql.types import *
    schema = StructType([
        StructField("business_id", StringType(), True),
        StructField("cool", IntegerType(), True),
        StructField("date", StringType(), True),
        StructField("funny", IntegerType(), True),
        StructField("id", StringType(), True),
        StructField("stars", IntegerType(), True),
        StructField("text", StringType(), True),
        StructField("type", StringType(), True),
        StructField("useful", IntegerType(), True),
        StructField("user_id", StringType(), True),
        StructField("name", StringType(), True),
        StructField("full_address", StringType(), True),
        StructField("latitude", DoubleType(), True),
        StructField("longitude", DoubleType(), True),
        StructField("neighborhood", StringType(), True),
        StructField("open", StringType(), True),
        StructField("review_count", IntegerType(), True),
        StructField("state", StringType(), True)])
    

    그런 다음 스키마를 지정하여 CSV 파일을로드합니다. 창문 라인 엔딩을 설정 할 필요가 없다는 것을 참고 :

    yelp_df = sqlCtx.load(source='com.databricks.spark.csv',
    header = 'true',
    schema = schema,
    path = 'file:///usr/lib/hue/apps/search/examples/collections/solr_configs_yelp_demo/index_data.csv')
    

    데이터 세트에서 실행 된 임의의 방법에 의한 결과. 나는 완벽하게 작동 수를 점점 시도.

    yelp_df.count()
    

    우리가 inferSchema으로 CSV를로드하는 방법을 알아낼 수 @yaron의 도움에 감사합니다. 첫째, 당신은 제대로 설치 하이브 - 메타 스토어를해야합니다 :

    sudo cp /etc/hive/conf.dist/hive-site.xml /usr/lib/spark/conf/
    

    그런 다음, 파이썬 쉘을 시작 및 Windows 인코딩 라인 엔딩을 변경하지 마십시오. 그 변경으로 지속 (세션 불변) 있음을 유의하십시오. 이전에 윈도우 스타일로 변경한다면, 당신은 그것을 '\ n을'을 다시 설정해야합니다. inferSchema true로 설정하여 그런 다음 CSV 파일을로드 :

    yelp_df = sqlCtx.load(source='com.databricks.spark.csv',
    header = 'true',
    inferSchema = 'true',
    path = 'file:///usr/lib/hue/apps/search/examples/collections/solr_configs_yelp_demo/index_data.csv')
    
  3. from https://stackoverflow.com/questions/36966550/exceptions-when-reading-tutorial-csv-file-in-the-cloudera-vm by cc-by-sa and MIT license