在HortonWorks HDP 2.1 和2.2 集群间进行数据迁移 包括(Hive数据表)

我之前搭建了一个基于HDP 2.1 的集群。   现在又根据需要重新搭建了一个新的HDP2.2版本的集群 准备做新的生产环境。  HDP2.1 集群 上大约有600GB的数据, 主要以Hive数据表格的形式存在。 因此需要将HDP2.1集群的数据 迁移到 新集群上来。 


实施的思路参考了这篇文章:

https://amalgjose.wordpress.com/2013/10/11/migrating-hive-from-one-hadoop-cluster-to-another-cluster-2/

1) Install hive in the new hadoop cluster 在新集群中安装Hive,及meta store等
2) Transfer the data present in the hive metastore directory (/user/hive/warehouse) to the new hadoop
cluster 通过hadoop distcp 命令将数据文件夹从老集群copy到新集群。

具体命令

hadoop distcp hdfs://[oldcluster.fqdn]:8020/user/hive hdfs://[newcluster.fqdn]:8020/user/

hadoop distcp hdfs://[oldcluster.fqdn]:8020/apps/hive/warehouse hdfs://[newcluster.fqdn]:8020/apps/hive/  

distcp 命令的说明http://hadoop.apache.org/docs/r1.2.1/distcp.html

3) take the mysql metastore dump.

在老集群的hive metastore所在的节点上 使用数据库dump工具将metastore 库的数据都dump出来。  hive  metastore存储了hive表的结构,数据库信息等元数据。 我所使用的hive metastore 是mysql 数据库因此使用下面的命令行

Database TypeBackupRestore

MySQL

mysqldump $dbname > $outputfilename.sql 
For example:mysqldump hive > /tmp/mydir/backup_hive.sql
mysql $dbname < $inputfilename.sql 
For example: mysql hive < /tmp/mydir/backup_hive.sql

Postgres

sudo -u $username pg_dump $databasename > $outputfilename.sql For example: sudo -u postgres pg_dump hive > /tmp/mydir/backup_hive.sqlsudo -u $username psql $databasename < $inputfilename.sql For example: sudo -u postgres psql hive < /tmp/mydir/backup_hive.sql
OracleConnect to the Oracle database using sqlplus export the database: exp username/password@database full=yes file=output_file.dmpImport the database: imp username/password@database ile=input_file.dmp


4) Install mysql in the new hadoop cluster  (这一步可忽略, 因为安装HDP2.2集群时 本来就已经安装了hive 及hive metastore


5) Open the hive mysql-metastore dump using text readers such as notepad, notepad++ etc and search for

hdfs://ip-address-old-namenode:port and replace with hdfs://ip-address-new-namenode:port and save it.

将刚才导出的数据库dump 文件,复制到本地,使用文本编辑器 查找替换 老集群的namenode的域名, 为新集群的namenode

Where ip-address-old-namenode is the ipaddress of namenode of old hadoop cluster and ip-address-
new-namenode
 is the ipaddress of namenode of new hadoop cluster.

6) After doing the above steps, restore the editted mysql dump into the mysql of new hadoop cluster.

将修改后的数据库dump文件 复制到新集群的hive metastore所在的节点上。 并使用mysql 命令行,将数据导入进去。 

For example: mysql hive < /tmp/mydir/backup_hive.sql


7) Configure hive as normal and do the hive schema upgradations if needed.

这时,应该已经可以使用hive shell或者hue 来查看导入的数据表是否可以访问了。 




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值