一、环境与软件
操作系统:Red Hat 4.8.3-9
Apache hadoop: 2.7.2
Apache Zookeeper:3.4.9
Apache Sqoop: 1.4.6
mysql JDBC:5.1.4
2、cd /opt
3、下载sqoop 的包
wget
4、tar -zxvf sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz
5、配置环境变量
vi /etc/profile
export SQOOP_HOME=/opt/sqoop-1.4.6.bin__hadoop-2.0.4-alpha
export PATH=$PATH:$SQOOP_HOME/bin
source /etc/profile
6、在
Sqoop根目录下,进入conf目录,找到其中的sqoop-env-template.sh,复制成sqoop-env.sh:
修改其中的环境变量,此处使用的主要是四个:
- #Set path to where bin/hadoop is available
- export HADOOP_COMMON_HOME=${HADOOP_HOME}
- #Set path to where hadoop-*-core.jar is available
- export HADOOP_MAPRED_HOME=${HADOOP_HOME}
- #set the path to where bin/hbase is available
- export HBASE_HOME=${HBASE_HOME}
- #Set the path for where zookeper config dir is
- export ZOOCFGDIR=${ZOOKEEPER_HOME}/conf
注:若未安装zookeeper,需先安装zookeeper
7、
检测使用:
bin/sqoop help
注意,这里可能会报警告:
Warning: /home/hadoop/deploy/sqoop-1.4.6.bin__hadoop-2.0.4-alpha//../hcatalog does not exist! HCatal ;
Warning: /home/hadoop/deploy/sqoop-1.4.6.bin__hadoop-2.0.4-alpha//../accumulo does not exist! Accumulo imports will fail.
这主要是因为集群中没有安装HCatal和accumulo环境变量,但sqoop默认会检测这两个组件。若非要去掉这两个检测,可以修改bin/config-sqoop文件,很容易找到这两个组件的检测位置。