Sqoop 全量/增量 shell脚本实战案例?

1. 全量导入:
#!/bin/bash
# 定义变量
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=123456
MYSQL_DATABASE=test
# 导入数据
sqoop import \
--connect jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE} \
--username ${MYSQL_USER} \
--password ${MYSQL_PASSWORD} \
--table user \
--target-dir /user/hive/warehouse/user \
--delete-target-dir \
--num-mappers 1
2. 增量导入:
#!/bin/bash
# 定义变量
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=123456
MYSQL_DATABASE=test
# 导入数据
sqoop import \
--connect jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE} \
--username ${MYSQL_USER} \
--password ${MYSQL_PASSWORD} \
--table user \
--target-dir /user/hive/warehouse/user \
--delete-target-dir \
--num-mappers 1 \
--check-column id \
--incremental append \
--last-value 0

你可能感兴趣的:(数据仓库,sqoop,mysql,数据库)