Sqoop安装
也可以通过外部ui来搞 ,这样可以更方便,但是我们这里是手工安装的,为了锻炼基本功
一:下载
因为我用的是CHD 版本
所以不再官网下载
百度:cdh tar 》 ctrl+f 》查询你需要的版本 (有的时候你找的是网页 需要在下面)
https://archive.cloudera.com/cdh5/cdh/5/
二:操作
rz 长传
tar -zxvf sqoop-1.4.6-cdh5.7.0.tar.gz 解压
[hadoop@hadoop001 app]$ cd sqoop-1.4.6-cdh5.7.0/
[hadoop@hadoop001 sqoop-1.4.6-cdh5.7.0]$ vi ~/.bash_profile
export SQOOP_HOME=/home/hadoop/app/sqoop-1.4.6-cdh5.7.0
export PATH=$SQOOP_HOME/bin:$PATH
[hadoop@hadoop001 sqoop-1.4.6-cdh5.7.0]$ source ~/.bash_profile
[hadoop@hadoop001 sqoop-1.4.6-cdh5.7.0]$ cd conf
[hadoop@hadoop001 conf]$ ll
total 28
-rw-rw-r-- 1 hadoop hadoop 3895 Mar 24 2016 oraoop-site-template.xml
-rw-rw-r-- 1 hadoop hadoop 1404 Mar 24 2016 sqoop-env-template.cmd
-rwxr-xr-x 1 hadoop hadoop 1345 Mar 24 2016 sqoop-env-template.sh
-rw-rw-r-- 1 hadoop hadoop 5531 Mar 24 2016 sqoop-site-template.xml
-rw-rw-r-- 1 hadoop hadoop 5531 Mar 24 2016 sqoop-site.xml
[hadoop@hadoop001 conf]$ cp sqoop-env-template.sh sqoop-env.sh
另起一个窗口查询
[hadoop@hadoop001 app]$ echo $HADOOP_HOME
/home/hadoop/app/hadoop-2.6.0-cdh5.7.0
[hadoop@hadoop001 app]$ echo $HIVE_HOME
/home/hadoop/app/hive-1.1.0-cdh5.7.0
[hadoop@hadoop001 conf]$ vi sqoop-env.sh
export HADOOP_COMMON_HOME=/home/hadoop/app/hadoop-2.6.0-cdh5.7.0
export HADOOP_MAPRED_HOME=/home/hadoop/app/hadoop-2.6.0-cdh5.7.0
export HIVE_HOME=/home/hadoop/app/hive-1.1.0-cdh5.7.0
三 :拷贝mysql的jar包
[hadoop@hadoop001 software]$ ll
total 852
-rw-r--r-- 1 hadoop hadoop 872300 Nov 19 2018 mysql-connector-java-5.1.27.jar
[hadoop@hadoop001 software]$ pwd
/home/hadoop/software
[hadoop@hadoop001 sqoop-1.4.6-cdh5.7.0]$ cd lib
[hadoop@hadoop001 lib]$ cp /home/hadoop/software/mysql-connector-java-5.1.27.jar .
[hadoop@hadoop001 lib]$ ll
....
-rw-r--r-- 1 hadoop hadoop 872300 Jun 27 15:03 mysql-connector-java-5.1.27.jar
.....
四:简单入门
[hadoop@hadoop001 bin]$ ./sqoop help
export Export an HDFS directory to a database table
import Import a table from a database to HDFS
list-databases List available databases on a server
list-tables List available tables in a database
[hadoop@hadoop001 bin]$ ./sqoop help list-databases
usage: sqoop list-databases [GENERIC-ARGS] [TOOL-ARGS]
Common arguments:
--connect <jdbc-uri> Specify JDBC connect
string
--connection-manager <class-name> Specify connection manager
class name
--connection-param-file <properties-file> Specify connection
parameters file
--driver <class-name> Manually specify JDBC
driver class to use
--hadoop-home <hdir> Override
$HADOOP_MAPRED_HOME_ARG
--hadoop-mapred-home <dir> Override
$HADOOP_MAPRED_HOME_ARG
--help Print usage instructions
-P Read password from console
--password <password> Set authentication
password
--password-alias <password-alias> Credential provider
password alias
--password-file <password-file> Set authentication
password file path
--relaxed-isolation Use read-uncommitted
isolation for imports
--skip-dist-cache Skip copying jars to
distributed cache
--username <username> Set authentication
username
--verbose Print more information
while working
[hadoop@hadoop001 bin]$sqoop list-databases \
--connect jdbc:mysql://localhost:3306 \
--username root \
--password root
这里就会连接到相应的数据库里面
[hadoop@hadoop001 bin]$ sqoop list-tables \
--connect jdbc:mysql://localhost:3306/ruoze_d5 \
--username root \
--password root
这里就会展示相应的表下面的信息