hadoop数据怎么迁移

发布时间:2021-08-19 09:23:17 作者:chen
来源:亿速云 阅读:360

本篇内容主要讲解“hadoop数据怎么迁移”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“hadoop数据怎么迁移”吧!

tcp工具使用说明:

在表结构/分区创建好的情况下,在hadoop2.0集群的任意一个节点上执行:

hadoop distcp -Dmapreduce.job.queue.name=queue_name  -update -skipcrccheck [source_path...] <target_path>

1、    source_path参数为hadoop1.0上需要拷贝的表/分区数据目录全路径,必须采用hftp协议访问,如test库下的test表路径为hftp://hadoop1:50070/user/hive/warehouse/test.db/test

2、    target_path参数为hadoop2.0上对应表/分区数据目录路径,如/user/hive/warehouse/test.db/test

3、    跨版本集群拷贝时-update -skipcrccheck参数必须带上。

4、    -Dmapreduce.job.queue.name参数用于指定任务在哪个资源池中运行,如:-Dmapreduce.job.queue.name=queue_0401_01。

5、Distcp任务执行时以MR任务运行,会占用指定资源池中资源。

表数据拷贝示例:

hadoop distcp -Dmapreduce.job.queue.name=queue_0401_01 -update -skipcrccheck hftp://hadoop1:50070/user/hive/warehouse/social.db/sina_wb_timelines  /user/hive/warehouse/social.db/sina_wb_timelines

分区数据拷贝示例:

hadoop distcp -Dmapreduce.job.queue.name=queue_0401_01 -update -skipcrccheck hftp://hadoop1:50070/user/hive/warehouse/social.db/sina_wb_timelines/d=21  /user/hive/warehouse/social.db/sina_wb_timelines/d=21

1、建立表结构:

CREATE  TABLE `fin_fa_wide_asset`(

  `period_name` string,

  `set_of_books_id` string,

  `book_type_code` string,

  `segment1` string,

  `segment2` string,

  `segment3` string,

  `asset_id` string,

  `description` string,

  `asset_category_id` string,

  `asset_number` string,

  `use_department` string,

  `operating_status` string,

  `use_status` string,

  `use_people` string,

  `city` string,

  `location` string,

  `units_assigned` double,

  `date_placed_in_service` string,

  `deprn_run_date` string,

  `cost` double,

  `original_cost` double,

  `salvage_value` double,

  `recoverable_cost` double,

  `current_net_value` double,

  `ytd_deprn` double,

  `deprn_reserve` double,

  `salvage_cost_rate` double,

  `deprn_method_code` string,

  `deprn_in_months` double,

  `life_in_months` double,

  `deprn_amount` double,

  `deprn_adjustment_acct` string,

  `po_number` string,

  `asset_invoice_id` string,

  `invoice_number` string)

PARTITIONED BY (

  `y` string,

  `m` string)row format delimited fields terminated by '\001' stored as rcfile;

2、导数:

hadoop distcp -Dmapreduce.job.queue.name=queue_0009_01 -update -skipcrccheck hftp://hadoop1:50070/user/hive/warehouse/jt_mas_safe.db/fin_fa_wide_asset  /user/hive/warehouse/jt_mas_safe.db/fin_fa_wide_asset

3、加载数据脚本,视不同表分区而定:

alter table jt_mas_safe.fin_fa_wide_asset add partition(y='2015',m='08');

load data inpath '/user/hive/warehouse/jt_mas_safe.db/fin_fa_wide_asset/y=2015/m=08' into table jt_mas_safe.fin_fa_wide_asset partition(y='2015',m='08’);

到此,相信大家对“hadoop数据怎么迁移”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

推荐阅读:
  1. mysql数据迁移
  2. redis数据迁移

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

hadoop

上一篇:jQuery插件开发的示例分析

下一篇:jquery对象与DOM对象转化的示例分析

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》