环境准备
1.hadoop运行正常
2.mysql运行正常,能访问
方法
1.下载sqoop-1.4.1-incubating__hadoop-0.20.tar.gz安装至/sqoop-1.4.1
2.将mysql-connector-java-5.1.21-bin.jar复制至/sqoop-1.4.1/lib
3.修改bin/configure-sqoop
注释掉hbase zookeeper检查:
#if [ ! -d "${HBASE_HOME}" ]; then
# echo "Error: $HBASE_HOME does not exist!"
# echo 'Please set $HBASE_HOME to the root of your HBase installation.'
# exit 1
#fi
#if [ ! -d "${ZOOKEEPER_HOME}" ]; then
# echo "Error: $ZOOKEEPER_HOME does not exist!"
# echo 'Please set $ZOOKEEPER_HOME to the root of your ZooKeeper installation.'
# exit 1
#fi
#if [ ! -d "${HBASE_HOME}" ]; then
# echo "Error: $HBASE_HOME does not exist!"
# echo 'Please set $HBASE_HOME to the root of your HBase installation.'
# exit 1
#fi
#if [ ! -d "${ZOOKEEPER_HOME}" ]; then
# echo "Error: $ZOOKEEPER_HOME does not exist!"
# echo 'Please set $ZOOKEEPER_HOME to the root of your ZooKeeper installation.'
# exit 1
#fi
4. 保证/etc/profile 有 export HADOOP_HOME=//hadoop
5..运行:
<1.列出DB的所有表
bin/sqoop list-tables --connect jdbc:mysql://ip:port/dbname --username root --password 123
bin/sqoop list-tables --connect jdbc:mysql://ip:port/dbname --username root --password 123
<2.将一个表导入至hadoop
bin/sqoop import --connect jdbc:mysql://ip:port/dbname --username root --password 123 --table tbname -m 1
来源:https://www.cnblogs.com/bobsoft/archive/2012/10/07/2714478.html