首页 \ 问答 \ Hadoop后端有数百万条记录插入(Hadoop backend with millions of records insertion)

Hadoop后端有数百万条记录插入(Hadoop backend with millions of records insertion)

我是hadoop的新手,有人可以建议我如何将数百万条记录上传到hadoop吗? 我可以用蜂巢做到这一点,我在哪里可以看到我的hadoop记录?

到目前为止,我已经使用配置单元在hadoop上创建数据库,我使用localhost 50070访问它。但是我无法将数据从csv文件加载到终端的hadoop。 因为它给了我错误:

FAILED:语义分析出错:第2行:0无效路径''/ user / local / hadoop / share / hadoop / hdfs'':没有匹配路径的文件hdfs:// localhost:54310 / usr / local / hadoop / share / Hadoop的/ HDFS

在终端的EROOR:

有谁能建议我解决它的方法?


I am new to hadoop, can someone please suggest me how to upload millions of records to hadoop? Can I do this with hive and where can I see my hadoop records?

Until now I have used hive for creation of the database on hadoop and I am accessing it with localhost 50070. But I am unable to load data from csv file to hadoop from terminal. As it is giving me error:

FAILED: Error in semantic analysis: Line 2:0 Invalid path ''/user/local/hadoop/share/hadoop/hdfs'': No files matching path hdfs://localhost:54310/usr/local/hadoop/share/hadoop/hdfs

EROOR IN THE TERMINAL:

Can anyone suggest me some way to resolve it?


原文:https://stackoverflow.com/questions/32835802
更新时间:2023-05-01 10:05

最满意答案

关于“哪些文件已加载到分区”:

  • 如果您使用了EXTERNAL TABLE并且只是将原始数据文件上传到映射到LOCATION的HDFS目录中,那么您可以

(a)从命令行在该目录上运行hdfs dfs -ls (或使用等效的Java API调用)(b)运行Hive查询,例如select distinct INPUT__FILE__NAME from (...)

  • 但在您的情况下,您将数据复制到“托管”表中,因此无法检索数据沿袭(即用于创建每个托管数据文件的日志文件)
  • ...除非你在日志文件中明确添加原始文件名,当然(在“特殊”标题记录上,或在每个记录的开头 - 可以使用旧的sed

关于“如何自动避免INSERT上的重复”:有一种方法,但它需要相当多的重新设计,并且会花费你的处理时间/(额外的Map步骤加MapJoin)/ ...

  1. 将日志文件映射到EXTERNAL TABLE以便您可以运行INSERT-SELECT查询
  2. 使用INPUT__FILE__NAME伪列作为源将原始文件名上载到托管表中
  3. 添加一个WHERE NOT EXISTS子句w /相关子查询,这样如果源文件名已经存在于目标中,那么你不再加载

    INSERT INTO TABLE Target SELECT ColA, ColB, ColC, INPUT__FILE__NAME AS SrcFileName FROM Source src WHERE NOT EXISTS (SELECT DISTINCT 1 FROM Target trg WHERE trg.SrcFileName =src.INPUT__FILE__NAME )

    注意实际需要的愚蠢的DISTINCT,以避免在Mappers中吹掉RAM; 对于像Oracle这样成熟的DBMS来说它会毫无用处,但是Hive优化器仍然相当粗糙......


About "which files have been loaded in a partition":

  • if you had used an EXTERNAL TABLE and just uploaded your raw data file in the HDFS directory mapped to LOCATION, then you could

(a) just run a hdfs dfs -ls on that directory from command line (or use the equivalent Java API call) (b) run a Hive query such as select distinct INPUT__FILE__NAME from (...)

  • but in your case, you copy the data into a "managed" table, so there is no way to retrieve the data lineage (i.e. which log file was used to create each managed datafile)
  • ...unless you add explicitly the original file name inside the log file, of course (either on "special" header record, or at the beginning of each record - which can be done with good old sed)

About "how to automagically avoid duplication on INSERT": there is a way, but it would require quite a bit of re-engineering, and would cost you in terms of processing time /(extra Map step plus MapJoin)/...

  1. map your log file to an EXTERNAL TABLE so that you can run an INSERT-SELECT query
  2. upload the original file name into your managed table using INPUT__FILE__NAME pseudo-column as source
  3. add a WHERE NOT EXISTS clause w/ correlated sub-query, so that if the source file name is already present in target then you load nothing more

    INSERT INTO TABLE Target SELECT ColA, ColB, ColC, INPUT__FILE__NAME AS SrcFileName FROM Source src WHERE NOT EXISTS (SELECT DISTINCT 1 FROM Target trg WHERE trg.SrcFileName =src.INPUT__FILE__NAME )

    Note the silly DISTINCT that is actually required to avoid blowing away the RAM in your Mappers; it would be useless with a mature DBMS like Oracle, but the Hive optimizer is still rather crude...

相关问答

更多
  • 关于“哪些文件已加载到分区”: 如果您使用了EXTERNAL TABLE并且只是将原始数据文件上传到映射到LOCATION的HDFS目录中,那么您可以 (a)从命令行在该目录上运行hdfs dfs -ls (或使用等效的Java API调用)(b)运行Hive查询,例如select distinct INPUT__FILE__NAME from (...) 但在您的情况下,您将数据复制到“托管”表中,因此无法检索数据沿袭(即用于创建每个托管数据文件的日志文件) ...除非你在日志文件中明确添加原始文件名,当 ...
  • 是的,你确实可以做到这一点......创建一个新类并使其成为SQLConnection类型的对象或者它是什么。 它的目的应该是创建和维护与数据库的连接并执行各种任务(这部分是可选的,因为您可以直接传入查询)。 从网上得到这个 class DBConnect { private MySqlConnection connection; private string server; private string database; private string uid; p ...
  • 这个问题有些主观。 创建应用程序时,我通常会尝试执行以下操作: 从不在多个地方定义相同的数据。 来源应该始终是明确的 如果我需要创建任何索引以便更快/更容易访问,我使用实用程序方法来执行此操作。 那些方法应该进行适当的单元测试,这样我就不会怀疑他们做错了什么 尽可能使用第三方库(例如已经建议的lodash或下划线)以最小化要编写/维护的代码量。 如果您的算法和实用程序经过适当的单元测试,您不必担心(太多)将数据置于不一致状态。 但是,如果这些是非常重要的系统/接口,您可以在输出上添加一些验证。 在输入上进行 ...
  • Capistrano是一个跨服务器自动执行任务的工具,它完全符合您的要求。 它是用Ruby编写的,使用SSH与其他机器通信。 Capistrano is a tool for automating tasks across servers, it does exactly what you ask. It's written in Ruby and uses SSH to communicate with the other machines.
  • 最常见的解决方案是使用乐观锁定 。 它归结为向您的实体添加version列,使用@Version注释。 每次提交之前,Hibernate都会检查version ,如果数据库中的版本比正在保存的实体的版本新,则会抛出异常。 The most common solution is to use optimistic locking. It comes down to adding a version column to your entities, annotated with @Version. versio ...
  • 您需要使用RSA对其进行加密,因为使用RSAProtectedConfigurationProvider,您可以跨服务器复制密钥。 网络农场场景 您可以在Web场中使用RSA加密, 因为您可以导出RSA密钥 。 如果在将Web.config文件中的数据部署到Web场中的其他服务器之前对其进行加密,则需要执行此操作。 在这种情况下,必须导出解密数据所需的私钥并将其部署到其他服务器。 使用RSA提供程序加密Web场中Web.config中的连接字符串 为此, 您必须创建自定义RSA加密密钥容器,并在Web场中的 ...
  • 在Amazon Web服务或Windows Azure之上构建您的应用程序,让他们担心这一点,因为它相当复杂。 Build your app on top of Amazon Web services or Windows Azure and let them worry about this since it's fairly complex.
  • 我没有用服务器完成它,但我用文件连接完成了这个。 而不是数据流,从每个循环开始,循环遍历服务器列表,并从您在此循环中填充的变量设置连接。 然后将数据流放在循环任务中。 I haven't done it with servers but I have done this with file connections. Instead of a data flow, start with a For each loop that will loop through a list of servers and s ...
  • 您可以将数据库中的复制用于您的目的。 You can use replication in database for your purpose.
  • 我可以为服务器创建一个类并运行多次 是。 只需在构造函数中提供不同的HashMap数据。 您必须以不同的名称在注册表中注册所有三个实例,或者通过其他一些RMI机制访问它们。 与@ JunedAhsan的回答相反,他们都可以共享相同的TCP端口,默认情况下,如果它们都是从同一个JVM导出的,那么就没有理由不这样做。 Could I create one class for servers and run multiple times Yes. Just supply the different HashMap ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。