部署
安装解压并做软链接
[hadoop@10-9-15-140 soft]$ pwd
/home/hadoop/soft
[hadoop@10-9-15-140 soft]$ wget http://archive.cloudera.com/cdh5/cdh/5/sqoop-1.4.6-cdh5.7.0.tar.gz
[hadoop@10-9-15-140 soft]$ tar -zxvf sqoop-1.4.6-cdh5.7.0.tar.gz
[hadoop@10-9-15-140 soft]$ ln -s /home/hadoop/soft/sqoop-1.4.6-cdh5.7.0 /home/hadoop/app/sqoop
配置文件修改
[hadoop@10-9-15-140 conf]$ pwd
/home/hadoop/app/sqoop/conf
[hadoop@10-9-15-140 conf]$ cp sqoop-env-template.sh sqoop-env.sh
[hadoop@10-9-15-140 conf]$ vim sqoop-env.sh
#Set path to where bin/hadoop is available
export HADOOP_COMMON_HOME=/home/hadoop/app/hadoop
#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/home/hadoop/app/hadoop
#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/hadoop/app/hive
#Set the path for where zookeper config dir is
#export ZOOCFGDIR=
环境变量配置
[hadoop@10-9-15-140 conf]$ vim ~/.bash_profile
export SQOOP_HOME=/home/hadoop/app/sqoop
export PATH=$SQOOP_HOME/bin:$PATH
[hadoop@10-9-15-140 conf]$ . ~/.bash_profile
拷贝hive的mysql的jdbc驱动包到lib目录
# 之前在hive的lib目录下已经上传了mysql的jdbc驱动包
[hadoop@10-9-15-140 conf]$ cd ~/app/hive/lib/
[hadoop@10-9-15-140 lib]$ ll | grep mysql
-rw-r--r-- 1 hadoop hadoop 1004838 Jul 28 22:25 mysql-connector-java-5.1.46.jar
[hadoop@10-9-15-140 lib]$ cp mysql-connector-java-5.1.46.jar ~/app/sqoop/lib/
验证
像Linux的help一样,我们也可以用sqoop help看看有哪些命令
[hadoop@10-9-15-140 lib]$ sqoop help
Warning: /home/hadoop/app/sqoop/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /home/hadoop/app/sqoop/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /home/hadoop/app/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /home/hadoop/app/sqoop/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
19/07/30 09:24:55 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.7.0
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@10-9-15-140 lib]$
已经安装成功
[hadoop@10-9-15-140 lib]$ sqoop list-databases \
> --connect jdbc:mysql://localhost:3306 \
> --username root \
> --password 123456
Warning: /home/hadoop/app/sqoop/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /home/hadoop/app/sqoop/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /home/hadoop/app/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /home/hadoop/app/sqoop/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
19/07/30 09:27:21 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.7.0
19/07/30 09:27:21 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
19/07/30 09:27:22 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
information_schema
d1_hive
db_temp
mysql
performance_schema
ruoze_d6
ruoze_d7
ruozedata
test
[hadoop@10-9-15-140 lib]$