最近有一批数据,需要从mysql库导入到大数据平台。

业务侧给的是mysql导出的csv文件。一共31个文件 每个接近30g。

大概步骤

1 把文件上传到大数据平台hdfs目录

hdfs dfs -put /xxx/xxx/xxx/xxx.csv hdfs://hbcluster/user/xxxx/hive/xxxx.db/file

2 查看目录是否有文件

hdfs://hbcluster/user/xxxx/hive/xxxx.db/file

3 连接上hive 

beeline -u "jdbc:hive2://ip:11001,ip:11001/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" -n username -p password

4 插入表 (一定要在hive命令下,在库的用户下才能执行)use 库名;

load data inpath 'hdfs://hbcluster/user/xxxx/hive/xxxx.db/filename/file.csv' into table tablename partition(shard =1);

更多推荐