2

我在本地使用 hdinsight hadoop,在我尝试使用 hive 的 hdfs 上成功运行 mapreduce 作业后,不幸的是,在创建表时运行 hive 查询时出现错误。

我从另一个堆栈解决方案中获得了以下代码,因为我只在本地运行它而不使用 azure:

var db = new HiveConnection(
                    webHCatUri: new Uri("http://localhost:50111"),
                    userName: (string)"hadoop", password: (string)null);

// also tried command with no ; inside quotes
string command = "CREATE TABLE log4jLogs(t1 string, t2 string, t3 string," +
                                  "t4 string, t5 string, t6 string, t7 string)" +
                  "ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ';";
db.ExecuteHiveQuery(command).Wait();

这总是在处理一段时间后引发异常。例外是:

System.AggregateException:发生一个或多个错误。---> System.NullReferenc eException:对象引用未设置为对象的实例。在 System.Threading.Tasks.TaskAwaiter 1.GetResult() at Microsoft.Hadoop.Hive.HiveConnection.<ExecuteHiveQuery>d__2.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationTo ken cancellationToken) at System.Threading.Tasks.Task.Wait() at ConsoleApplication1.Program.CreateActorsTable() in c:\Users\Administrator\ Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\Pr ogram.cs:line 90 ---> (Inner Exception #0) System.NullReferenceException: Object reference not se t to an instance of an object. at System.Threading.Tasks.TaskAwaiter1.GetResult() 在 Microsoft.Hadoop.Hive.HiveConnection.d__2.MoveNext()<---

我检查了 hadoop 的日志,其中我得到以下信息:

java.io.IOException:在 org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java: 762) 在 org.apache.hadoop.mapred.MapTask.run(MapTask.java:364) 在 org.apache.hadoop.mapred.Child$4.run(Child.java:266) 在 java.security.AccessController.doPrivileged( Native Method) at javax.security.auth.Subject.doAs(Subject.java:396) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1136) at org.apache.hadoop.mapred.Child。 main(Child.java:260) 由:java.net.URISyntaxException:索引 6 处的权限中的非法字符:asv://{0}@{1}/6f8d3bc9-89a2-4e1d-9749-2805d31f05f0 at java.net .URI$Parser.fail(URI.java:2810) 在 java.net.URI$Parser。parseAuthority(URI.java:3148) 在 java.net.URI$Parser.parseHierarchical(URI.java:3059) 在 java.net.URI$Parser.parse(URI.java:3015) 在 java.net.URI.( URI.java:577) 在 org.apache.hcatalog.templeton.tool.TempletonUtils.addUserHomeDirectoryIfApplicable(TempletonUtils.java:227) 在 org.apache.hcatalog.templeton.tool.TempletonControllerJob$LaunchMapper.run(TempletonControllerJob.java:152) ... 7 更多

如果有人能指出我正确的方向,我会很高兴,因为我无法弄清楚为什么会失败。

4

1 回答 1

0

如果要使用 hive 连接首先必须启动 hive 服务器。Hive 服务器可执行文件位于 hdp/hive/bin 中。使用命令提示符启动hiveserver2.exe。您可以使用同样位于同一文件夹中的 hiveserver2.xml 修改 Hive 服务器配置。

于 2015-03-20T07:41:12.820 回答