一,環境信息
CDH集羣,Cloudera Manager5安裝部署CDH5.X詳細請見:http://blog.csdn.net/freedomboy319/article/details/44804721java
二,在CDH5.3.2中配置運行Spark SQL的Thrift Server
1,root用戶登陸CDH5.3.2集羣中的某一個節點node
2,cd /opt/cloudera/parcels/CDH/lib/spark/sbin 執行./start-thriftserver.sh –help
web
3,執行./start-thriftserver.shsql
4,進入/opt/cloudera/parcels/CDH-5.3.2-1.cdh5.3.2.p0.10/lib/spark/logs目 錄,查看日誌文件spark-root- org.apache.spark.sql.hive.thriftserver.HiveThriftServer2-1-cdh- node3.grc.out,發現報以下錯:數據庫
Spark Command: /usr/java/jdk1.7.0_67-cloudera/bin/java -cp ::/opt/cloudera/parcels/CDH-5.3.2-1.cdh5.3.2.p0.10/lib/spark/conf :/opt/cloudera/parcels/CDH-5.3.2-1.cdh5.3.2.p0.10/lib/spark/lib/spark-assembly.jar :/etc/hadoop/conf:/opt/cloudera/parcels/CDH-5.3.2-1.cdh5.3.2.p0.10/lib/hadoop/client/* ...... :/opt/cloudera/parcels/CDH-5.3.2-1.cdh5.3.2.p0.10/lib/spark/lib/jline.jar -XX:MaxPermSize=128m -Xms512m -Xmx512m org.apache.spark.deploy.SparkSubmit --class org.apache.spark.sql.hive.thriftserver.HiveThriftServer2 spark-internal ======================================== Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hive/service/server/HiveServer2 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
5,緣由是缺失jar包。解決方法:
1)cd /opt/cloudera/parcels/CDH/lib/spark/bin 目錄。
2)vi compute-classpath.sh 文件,在此文件中最後添加以下hive的jar包。apache
CLASSPATH="$CLASSPATH:/opt/cloudera/parcels/CDH/lib/hive/lib/*"
6,執行./start-thriftserver.sh瀏覽器
7,進入/opt/cloudera/parcels/CDH-5.3.2-1.cdh5.3.2.p0.10/lib/spark/logs目 錄,查看日誌文件spark-root- org.apache.spark.sql.hive.thriftserver.HiveThriftServer2-1-cdh- node3.grc.out,發現報以下錯:app
15/06/02 16:32:13 INFO HiveThriftServer2: HiveThriftServer2 started 15/06/02 16:32:13 ERROR ThriftCLIService: Error: org.apache.thrift.transport.TTransportException: Could not create ServerSocket on address 0.0.0.0/0.0.0.0:10000. at org.apache.thrift.transport.TServerSocket.<init>(TServerSocket.java:93) at org.apache.thrift.transport.TServerSocket.<init>(TServerSocket.java:79) at org.apache.hive.service.auth.HiveAuthFactory.getServerSocket(HiveAuthFactory.java:229) at org.apache.hive.service.cli.thrift.ThriftBinaryCLIService.run(ThriftBinaryCLIService.java:89) at java.lang.Thread.run(Thread.java:745) 15/06/02 16:32:13 INFO SparkUI: Stopped Spark web UI at http://cdh-node3.grc:4040 15/06/02 16:32:13 INFO DAGScheduler: Stopping DAGScheduler 15/06/02 16:32:14 INFO MapOutputTrackerMasterActor: MapOutputTrackerActor stopped! 15/06/02 16:32:14 INFO MemoryStore: MemoryStore cleared 15/06/02 16:32:14 INFO BlockManager: BlockManager stopped 15/06/02 16:32:14 INFO BlockManagerMaster: BlockManagerMaster stopped
8,緣由是與Hive中的HiveServer2 進程端口衝突。
dom
9,解決方法,在/opt/cloudera/parcels/CDH/lib/spark/conf目錄下,添加hive-site.xml文件,此文件的內容以下:oop
<?xml version="1.0" encoding="UTF-8"?> <configuration> <property> <name>hive.metastore.uris</name> <value>thrift://cdh-node3.grc:9083</value> <description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description> </property> <property> <name>hive.server2.thrift.port</name> <value>10001</value> <description>Port number of HiveServer2 Thrift interface. Can be overridden by setting $HIVE_SERVER2_THRIFT_PORT</description> </property> <property> <name>hive.server2.thrift.bind.host</name> <value>cdh-node3.grc</value> <description>Bind host on which to run the HiveServer2 Thrift interface. Can be overridden by setting $HIVE_SERVER2_THRIFT_BIND_HOST</description> </property> </configuration>
其中hive.metastore.uris的配置,是Spark SQL能夠使用Hive的matestore元數據,既在Spark SQL能夠訪問Hive的數據庫以及表信息。
10,執行jps能夠看到SparkSubmit和SparkSubmitDriverBootstrapper進程。
並查看日誌文件,能夠看到以下信息:
11,到此爲止local方式的Spark SQL 的ThrifServer啓動成功。
12,中止掉Spark SQL 的ThrifServer。
執行kill -9 SparkSubmit的進程號。這裏是:kill -9 1735
13,已yarn的cluster模式啓動thriftserver。進入/opt/cloudera/parcels/CDH/lib/spark/sbin目錄
執行:./start-thriftserver.sh –master yarn-cluster
14,在/opt/cloudera/parcels/CDH-5.3.2-1.cdh5.3.2.p0.10/lib/spark/logs中的 spark-root-org.apache.spark.sql.hive.thriftserver.HiveThriftServer2-1- cdh-node3.grc.out文件報以下錯:
在YARN Resource Manager控制檯中有以下錯誤:
注意,這裏是cdh-node10.grc主機(由YARN隨機調度ResourceManager節點啓動Spark SQL Driver)
15,解決方法,
在全部的ResourceManager節點的/opt/cloudera/parcels/CDH/lib/spark/bin目錄下的compute-classpath.sh文件添加以下配置:
CLASSPATH="$CLASSPATH:/opt/cloudera/parcels/CDH/lib/hive/lib/*"
問題還在,不知道爲啥?
16,執行
./start-thriftserver.sh –master yarn-client
日誌文件以下所示,說明啓動成功。
17,經過JDBC方式,在Spark SQL中執行job,則在日誌文件有以下錯誤:
(TID 4, cdh-node8.grc): java.lang.NoClassDefFoundError: Lorg/apache/hadoop/hive/ql/plan/TableDesc;
18,在Cloudera Manager中安裝Spark Standalone組件。
19,執行以下命令:
./start-thriftserver.sh --master spark://cdh-node3.grc:7077
在全部的Work節點都存在以下「CoarseGrainedExecutorBackend」進程:
在日誌中有「HiveThriftServer2 started」提示:
在瀏覽器中輸入「http://cdh-node3.grc:4040/executors/」 能夠查到全部的Executors。
20,經過JDBC方式,在Spark SQL中執行job,則在日誌文件有以下錯誤:
(TID 4, cdh-node8.grc): java.lang.NoClassDefFoundError: Lorg/apache/hadoop/hive/ql/plan/TableDesc; 21,在全部的Work節點的/opt/cloudera/parcels/CDH/lib/spark/bin目錄下的compute-classpath.sh文件添加以下配置:
CLASSPATH=」$CLASSPATH:/opt/cloudera/parcels/CDH/lib/hive/lib/*」
「`
而後從新啓動ThriftServer,在經過JDBC方式,在Spark SQL中執行Job成功。