sqoop安裝及配置
阿新 • • 發佈:2018-12-05
本文主要介紹sqoop安裝及配置。
版本:1.4.6
sqoop安裝
1.將sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz解壓到安裝目錄。
unzip sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz -d /home/hadoopadmin/
2.將sqoop加入環境變數
開啟環境變數檔案:
vim /etc/profile
追加下列內容:
export SQOOP_HOME=/home/hadoopadmin/sqoop-1.4.6.bin__hadoop-2.0.4-alpha
export PATH=$PATH:$SQOOP_HOME/bin
重新編譯環境變數:
source /etc/profile
3.給${SQOOP_HOME}/bin中檔案賦予可執行許可權
chmod 744 *
sqoop配置
1.sqoop-env.sh配置
配置檔案目錄:$SQOOP_HOME/conf,sh(重新命名sqoopenvtemplate.
sh)
#Set path to where bin/hadoop is available
export HADOOP_COMMON_HOME=/home/hadoopadmin/hadoop-2.7.1
#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/home/hadoopadmin/hadoop-2.7.1
#set the path to where bin/hbase is available
#export HBASE_HOME=
#Set the path to where bin/hive is available
export HIVE_HOME=/home/hadoopadmin/apache-hive-1.2.1-bin
2.修改$SQOOP_HOME/bin/sqoop
vim sqoop
修改最後一行內容
修改前:
exec ${HADOOP_COMMON_HOME}/bin/hadoop org.apache.sqoop.Sqoop "[email protected]"
修改後:
exec ${HADOOP_COMMON_HOME}/bin/hadoop jar $SQOOP_HOME/sqoop-1.4.6.jar org.apache.sqoop.Sqoop "[email protected]"
3.將mysql驅動jar拷貝至$SQOOP_HOME/lib目錄
4. 將hadoop-common-2.7.1.jar拷貝至$SQOOP_HOME/lib目錄
cp ${HADOOP_HOME}/share/hadoop/common/hadoop-common-2.7.1.jar ${SQOOP_HOME}/lib
5. 測試命令
打印出mysql資料庫中的所有DB
sqoop list-databases --connect jdbc:mysql://127.0.0.1:3306/ --username
root --password root
相關文章