1.先把sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz上传解压到/usr/local/下重命名为sqoop
1 [root@hadoop1 conf]# tail -4 /etc/profile 2 ############# sqoop env ################# 3 export SQOOP_HOME=/usr/local/sqoop 4 export PATH=$SQOOP_HOME/bin:$PATH 5 将mysql-connector-java-5.1.7-bin.jar放置在/usr/local/sqoop/lib里
2.配置sqoop各配置文件
1 [root@hadoop1 conf]# cd /usr/local/sqoop/conf 2 [root@hadoop1 conf]# cp sqoop-env-template.sh sqoop-env.sh 3 [root@hadoop1 conf]# vim sqoop-env.sh 4 export HADOOP_PREFIX=/usr/local/hadoop 5 export HADOOP_HOME=${HADOOP_PREFIX} 6 export PATH=$PATH:$HADOOP_PREFIX/bin:$HADOOP_PREFIX/sbin 7 export HADOOP_COMMON_HOME=${HADOOP_PREFIX} 8 export HADOOP_HDFS_HOME=${HADOOP_PREFIX} 9 export HADOOP_MAPRED_HOME=${HADOOP_PREFIX} 10 export HADOOP_YARN_HOME=${HADOOP_PREFIX} 11 export HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_PREFIX}/lib/native 12 export HADOOP_OPTS="-Djava.library.path=$HADOOP_PREFIX/lib/native" 13 export HIVE_HOME=/usr/local/hive 14 export PATH=$HIVE_HOME/bin:$PATH 15 export HBASE_HOME=/usr/local/hbase 16 export PATH=$HBASE/bin:$PATH 17 [root@hadoop1 bin]# cd /usr/local/sqoop/bin 18 [root@hadoop1 bin]# vim configure-sqoop # 注释一些东西 19 #if [ -z "${HCAT_HOME}" ]; then 20 # if [ -d "/usr/lib/hive-hcatalog" ]; then 21 # HCAT_HOME=/usr/lib/hive-hcatalog 22 # elif [ -d "/usr/lib/hcatalog" ]; then 23 # HCAT_HOME=/usr/lib/hcatalog 24 # else 25 # HCAT_HOME=${SQOOP_HOME}/../hive-hcatalog 26 # if [ ! -d ${HCAT_HOME} ]; then 27 # HCAT_HOME=${SQOOP_HOME}/../hcatalog 28 # fi 29 # fi 30 #fi 31 #if [ -z "${ACCUMULO_HOME}" ]; then 32 # if [ -d "/usr/lib/accumulo" ]; then 33 # ACCUMULO_HOME=/usr/lib/accumulo 34 # else 35 # ACCUMULO_HOME=${SQOOP_HOME}/../accumulo 36 # fi 37 #fi 38 #if [ ! -d "${HCAT_HOME}" ]; then 39 # echo "Warning: $HCAT_HOME does not exist! HCatalog jobs will fail." 40 # echo 'Please set $HCAT_HOME to the root of your HCatalog installation.' 41 #fi 42 43 #if [ ! -d "${ACCUMULO_HOME}" ]; then 44 # echo "Warning: $ACCUMULO_HOME does not exist! Accumulo imports will fail." 45 # echo 'Please set $ACCUMULO_HOME to the root of your Accumulo installation.' 46 #fi
3验证
1 [root@hadoop1 conf]# sqoop list-databases -connect jdbc:mysql://hadoop1:3306/ --username hive --P # 输入密码会出现mysql里的库 2 Warning: /usr/local/sqoop/../hcatalog does not exist! HCatalog jobs will fail. 3 Please set $HCAT_HOME to the root of your HCatalog installation. 4 Warning: /usr/local/sqoop/../accumulo does not exist! Accumulo imports will fail. 5 Please set $ACCUMULO_HOME to the root of your Accumulo installation. 6 17/11/15 16:21:31 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6 7 Enter password: 8 17/11/15 16:21:33 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset. 9 information_schema 10 hive