参考文档:https://segmentfault.com/a/1190000002532293
测试环境:
完全分布式安装Hadoop
Hive安装(使用默认的derby存储元数据)
sqoop的安装
当然还是mysql已安装(使用iso文件建立本地仓库)
测试数据
MariaDB [(none)]> use testdb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [testdb]> select * from emp;
+------+---------+--------------+--------+------+
| id | name | deg | salary | dept |
+------+---------+--------------+--------+------+
| 1201 | gopal | manmager | 50000 | TP |
| 1202 | manisha | Proof reader | 50000 | TP |
| 1203 | kalil | php dev | 50000 | TP |
+------+---------+--------------+--------+------+
3 rows in set (0.00 sec)
MariaDB [testdb]>
导入数据
[root@master conf]# sqoop import --connect jdbc:mysql://localhost:3306/testdb --username root --password 000000 --table emp --fields-terminated-by '\t' --lines-terminated-by "\n" --hive-import --hive-overwrite --create-hive-table --hive-table emp --delete-target-dir