HDFSへ
すべてインポート
sqoop import \
--connect jdbc:mysql://hadoop01:3306/test1 \
--username root \
--password 1234 \
--table students \
--target-dir /user/test1 \
--delete-target-dir \
--num-mappers 1 \
--fields-terminated-by '\t'
クエリのインポート
sqoop import \
--connect jdbc:mysql://hadoop01:3306/test1 \
--username root \
--password 1234 \
--target-dir /user/test1 \
--delete-target-dir \
--m 1 \
--fields-terminated-by '\t' \
--query 'select * from students where $CONDITIONS'
注:SQL 文の末尾を追加する必要があります$条件を
指定された列のインポート
sqoop import \
--connect jdbc:mysql://hadoop01:3306/test1 \
--username root \
--password 1234 \
--table students \
--target-dir /user/test1 \
--delete-target-dir \
--num-mappers 1 \
--fields-terminated-by '\t' \
--columns id,sex
ヒント:列が複数の列になる場合は分離する場合、カンマで区切って、スペースを追加しないでください
データをインポートするキーワードフィルタリングクエリ
sqoop import \
--connect jdbc:mysql://hadoop01:3306/test1 \
--username root \
--password 1234 \
--table students \
--target-dir /user/test1 \
--delete-target-dir \
--num-mappers 1 \
--fields-terminated-by '\t' \
--where "id=2"
ハイブにインポート
ハイブへの直接1
sqoop import \
--connect jdbc:mysql://hadoop01:3306/test1 \
--username root \
--password 1234 \
--table students \
--m 1 \
--hive-import \
--fields-terminated-by "\t" \
--hive-overwrite \
--hive-table students
ヒント:存在にテーブル内のハイブ、不在が自動的に作成されません。
2.負荷は、その後、ハイブにHDFSに導入されます。
1. HDFSに導入します
sqoop import \
--connect jdbc:mysql://hadoop01:3306/test1 \
--username root \
--password 1234 \
--table students \
--target-dir /user/test1 \
--delete-target-dir \
--num-mappers 1 \
--fields-terminated-by '\t'
ハイブへ2.load
load data inpath '/user/test1' into table hive表名字
MySQLへのエクスポート
sqoop export \
--connect jdbc:mysql://hadoop01:3306/test1 \
--username root \
--password 1234 \
--export-dir /user/test1 \
--table students \
--input-fields-terminated-by '\t'
--m 1
ヒント:データをエクスポートするとMySQLのテーブルが存在している必要があります