下载安装包
http://archive.apache.org/dist/sqoop/1.4.6/sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz
我装在hadoop 用户下面
hadoop目录是 /home/hadoop/hadoop
hive 目录是 /home/hadoop/hive
sqoop 目录是 /home/hadoop/sqoop
当前目录是 /home/hadoop
tar-zxvfsqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz
mvsqoop-1.4.6.bin__hadoop-2.0.4-alpha sqoop
在 /etc/profile 增加 sqoop 环境变量
export SQOOP_HOME=/home/hadoop/sqoop
export PATH=$PATH:$SQOOP_HOME/bin
创建sqoop-env.conf文件
exportHADOOP_COMMON_HOME=/home/hadoop/hadoop
exportHADOOP_MAPRED_HOME=/home/hadoop/hadoop
export HIVE_HOME=/home/hadoop/hive
修改$SQOOP_HOME/bin/configure-sqoop
#if [ -z "${HCAT_HOME}" ]; then
# if [ -d "/usr/lib/hive-hcatalog" ]; then
# HCAT_HOME=/usr/lib/hive-hcatalog
# elif [ -d "/usr/lib/hcatalog" ]; then
# HCAT_HOME=/usr/lib/hcatalog
# else
# HCAT_HOME=${SQOOP_HOME}/../hive-hcatalog
# if [ ! -d ${HCAT_HOME} ]; then
# HCAT_HOME=${SQOOP_HOME}/../hcatalog
# fi
# fi
#fi
#if [ -z "${ACCUMULO_HOME}" ]; then
# if [ -d "/usr/lib/accumulo" ]; then
# ACCUMULO_HOME=/usr/lib/accumulo
# ACCUMULO_HOME=${SQOOP_HOME}/../accumulo
#fi
## Moved to be a runtime check in sqoop.
#if [ ! -d "${HCAT_HOME}" ]; then
# echo "Warning: $HCAT_HOME does not exist! HCatalog jobs will fail."
# echo 'Please set $HCAT_HOME to the root of your HCatalog installation.'
#
#if [ ! -d "${ACCUMULO_HOME}" ]; then
# echo "Warning: $ACCUMULO_HOME does not exist! Accumulo imports will fail."
# echo 'Please set $ACCUMULO_HOME to the root of your Accumulo installation.'
#fi
注释掉HCatalog,Accumulo检查(除非你准备使用HCatalog,Accumulo等HADOOP上的组件)
我的sqoop 要把oracle 数据库 导入到hive 里面
所以要用到oracle jdbc 驱动ojdbc6.jar
从oracle官网上下载此驱动 放在
/home/hadoop/sqoop/lib 目录下。
查看sqoop 版本
[hadoop@bi-hadoop01 sqoop]$ sqoop version
Warning: /home/hadoop/sqoop/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /home/hadoop/sqoop/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
16/10/13 14:33:44 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6
Sqoop 1.4.6
git commit id c0c5a81723759fa575844a0a1eae8f510fa32c25
Compiled by root on Mon Apr 27 14:38:36 CST 2015
查看 sqoop-import 帮助
执行 sqoop-import --help
测试oracle导入hive数据
sqoop import --hive-import --conect jdbc:oracle:thin:@192.168.106.35:1521:cyporcl --username CYP --password cyp --verbose -m 1 --table CYP_ETL_PROC_CONFIG
注意 用户名 和表名必须大写。
导入成功