Sqoop操作mysql,数据导入到HDFS
sqoop import \
--connect jdbc:mysql://192.168.30.143:3306/mydemo \
--driver com.mysql.jdbc.Driver \
--table users \
--username root \
--password ok \
--target-dir /exp03/users \
--split-by ',' \
-m 1
多表关联数据到hdfs(推荐用)
sqoop import \
--connect jdbc:mysql://192.168.30.143:3306/mydemo \
--driver com.mysql.jdbc.Driver \
--query "select s.*,r.score from users s inner join score r on s.id=r.id where r.score>=90 and \$CONDITIONS" \
--username root \
--password ok \
--delete-target-dir \
--target-dir /exp03/users \
--split-by ',' \
-m 1
把mysql的数据导入到hive
sqoop import \
--connect jdbc:mysql://192.168.30.143:3306/mydemo \
--driver com.mysql.jdbc.Driver \
--table reviews \
--username root \
--password ok \
--hive-import \
--create-hive-table \
--hive-database mytest \
--hive-table reviews \
-m 1
ads层的数据导出到Mysql
sqoop export \
--connect jdbc:mysql://192.168.30.143:3306/mydemo \
--driver com.mysql.jdbc.Driver \
--table reviews3 \
--username root \
--password ok \
--input-fields-terminated-by "\001" \
--export-dir /hive/warehouse/mytest.db/reviews \
-m 1