使用sqoop将数据从mysql导入到hdfs

参考文档:http://www.yiibai.com/sqoop/sqoop_import.html
实验前提:

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   |
+------+---------+--------------+--------+------+
2 rows in set (0.00 sec)

导入数据:

sqoop import --connect jdbc:mysql://localhost/testdb --username root --password 000000 --table emp -m 1

验证数据:

[root@master bin]# hadoop fs -cat /user/root/emp/*
1201,gopal,manmager,50000,TP
1202,manisha,Proof reader,50000,TP

你可能感兴趣的:(使用sqoop将数据从mysql导入到hdfs)