3.1.1 下載sqoop1:
sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz
3.1.2 解壓並查看目錄:java
[hadoop@hadoop01 ~]$ tar -zxvf sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz --解壓
[hadoop@hadoop01 ~]$ cd sqoop-1.4.7.bin__hadoop-2.6.0
[hadoop@hadoop01 sqoop-1.4.7.bin__hadoop-2.6.0]$ ls -ll -查看目錄
total 2020
drwxr-xr-x. 2 hadoop hadoop 4096 Dec 19 2017 bin
-rw-rw-r--. 1 hadoop hadoop 55089 Dec 19 2017 build.xml
-rw-rw-r--. 1 hadoop hadoop 47426 Dec 19 2017 CHANGELOG.txt
-rw-rw-r--. 1 hadoop hadoop 9880 Dec 19 2017 COMPILING.txt
drwxr-xr-x. 2 hadoop hadoop 150 Dec 19 2017 conf
drwxr-xr-x. 5 hadoop hadoop 169 Dec 19 2017 docs
drwxr-xr-x. 2 hadoop hadoop 96 Dec 19 2017 ivy
-rw-rw-r--. 1 hadoop hadoop 11163 Dec 19 2017 ivy.xml
drwxr-xr-x. 2 hadoop hadoop 4096 Dec 19 2017 lib
-rw-rw-r--. 1 hadoop hadoop 15419 Dec 19 2017 LICENSE.txt
-rw-rw-r--. 1 hadoop hadoop 505 Dec 19 2017 NOTICE.txt
-rw-rw-r--. 1 hadoop hadoop 18772 Dec 19 2017 pom-old.xml
-rw-rw-r--. 1 hadoop hadoop 1096 Dec 19 2017 README.txt
-rw-rw-r--. 1 hadoop hadoop 1108073 Dec 19 2017 sqoop-1.4.7.jar
-rw-rw-r--. 1 hadoop hadoop 6554 Dec 19 2017 sqoop-patch-review.py
-rw-rw-r--. 1 hadoop hadoop 765184 Dec 19 2017 sqoop-test-1.4.7.jar
drwxr-xr-x. 7 hadoop hadoop 73 Dec 19 2017 src
drwxr-xr-x. 4 hadoop hadoop 114 Dec 19 2017 testdata
3.2 配置sqoop——mysql鏈接器:
下載mysql-connector-java-8.0.16.jar,並將其拷貝至sqoop安裝目錄下的lib文件夾裏
3.3 配置sqoop環境變量:mysql
[hadoop@hadoop01 sqoop-1.4.7.bin__hadoop-2.6.0]$ cd conf
[hadoop@hadoop01 conf]$ ls -ll
total 28
-rw-rw-r--. 1 hadoop hadoop 3895 Dec 19 2017 oraoop-site-template.xml
-rw-rw-r--. 1 hadoop hadoop 1404 Dec 19 2017 sqoop-env-template.cmd
-rwxr-xr-x. 1 hadoop hadoop 1345 Dec 19 2017 sqoop-env-template.sh
-rw-rw-r--. 1 hadoop hadoop 6044 Dec 19 2017 sqoop-site-template.xml
-rw-rw-r--. 1 hadoop hadoop 6044 Dec 19 2017 sqoop-site.xml
3.3.1 拷貝複製sqoop-env.sh樣本,並添加hadoop、hbase、hive、zookeeper的安裝目錄(注:沒有的就不添加)linux
[hadoop@hadoop01 conf]$ cp sqoop-env-template.sh sqoop-env.sh
[hadoop@hadoop01 conf]$ gedit sqoop-env.sh
修改的內容:
#Set path to where bin/hadoop is available
export HADOOP_COMMON_HOME=/home/hadoop/hadoop-3.2.0
#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/home/hadoop/hadoop-3.2.0
#set the path to where bin/hbase is available
export HBASE_HOME=/home/hadoop/hbase-2.2.1
#Set the path to where bin/hive is available
export HIVE_HOME=/home/hadoop/apache-hive-3.1.2-bin
#Set the path for where zookeper config dir is
export ZOOCFGDIR=/home/hadoop/apache-zookeeper-3.5.5
3.3.2 配置linux環境變量sql
[hadoop@hadoop01 conf]$ gedit ~/.bash_profile
[hadoop@hadoop01 conf]$ source ~/.bash_profile
新添加:
#sqoop
export SQOOP_HOME=/home/hadoop/sqoop-1.4.7.bin__hadoop-2.6.0
export PATH=$PATH:$SQOOP_HOME/bin
3.4 驗證sqoop是否安裝成功apache
[hadoop@hadoop01 sqoop-1.4.7.bin__hadoop-2.6.0]$ bin/sqoop help --執行該命令,看到以下信息就表示成功
Warning: /home/hadoop/sqoop-1.4.7.bin__hadoop-2.6.0/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /home/hadoop/sqoop-1.4.7.bin__hadoop-2.6.0/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /home/hadoop/sqoop-1.4.7.bin__hadoop-2.6.0/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
Error: Could not find or load main class org.apache.hadoop.hbase.util.GetJavaProperty
2019-09-29 23:38:28,571 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
usage: sqoop COMMAND [ARGS]
Available commands:
codegen Generate code to interact with database records
create-hive-table Import a table definition into Hive
eval Evaluate a SQL statement and display the results
export Export an HDFS directory to a database table
help List available commands
import Import a table from a database to HDFS
import-all-tables Import tables from a database to HDFS
import-mainframe Import datasets from a mainframe server to HDFS
job Work with saved jobs
list-databases List available databases on a server
list-tables List available tables in a database
merge Merge results of incremental imports
metastore Run a standalone Sqoop metastore
version Display version information
See 'sqoop help COMMAND' for information on a specific command.
[hadoop@hadoop01 sqoop-1.4.7.bin__hadoop-2.6.0]$
3.5 測試sqoop與mysql的鏈接
sqoop list-tables --username User --password 'User_123456' --connect jdbc:mysql://localhost:3306/hahive /**方式1**/
sqoop list-tables --username User -P --connect jdbc:mysql://localhost:3306/hahive /**方式2**/
Enter password:
若是能執行以上操做,能夠看見結果,說明sqoop能鏈接mysql。bash