虚拟机:CentOS Linux release 8.5.2111 名称:june
Hadoop环境:Hadoop 2.7.3
hive环境:hive-2.3.9
Hbase版本:hbase-1.2.6
Mysql版本:mysql Ver 14.14 Distrib 5.7.36, for Linux (x86_64)
下载sqoop:http://sqoop.apache.org/ 版本:1.4.6
上传虚拟机至:/opt/sqoop (sqoop文件夹自行创建:mkdir sqoop)
进入/opt/sqoop
执行命令:tar zxvf sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz
注:********是把hive中的驱动包复制到sqoop下*********
进入/opt/sqoop/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/lib
执行命令:cp /opt/hive/apache-hive-2.3.9-bin/lib/mysql-connector-java-5.1.24.jar /opt/sqoop/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/lib
进入/opt/sqoop/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/conf
执行命令:
修改内容如下(路径填写自己所安装软件的路径):
export HADOOP_COMMON_HOME=/opt/Hadoop/hadoop-2.7.3 #Set path to where hadoop-*-core.jar is available export HADOOP_MAPRED_HOME=/opt/Hadoop/hadoop-2.7.3 #set the path to where bin/hbase is available export HBASE_HOME=/opt/Hadoop/software/hbase-1.2.6 #Set the path to where bin/hive is available export HIVE_HOME=/opt/hive/apache-hive-2.3.9-bin #Set the path for where zookeper config dir is export ZOOCFGDIR=/opt/Hadoop/software/zookeeper-3.4.10
测试命令:
(以下命令是在/opt/sqoop/sqoop-1.4.6.bin__hadoop-2.0.4-alpha下执行的)
sqoop命令:
$ bin/sqoop help
$ bin/sqoop list-databases --help **显示某个子命令的帮助信息,list-databases是一个子命令
--显示出对应节点上的所有数据库,用来测试RDBMS[mysql]是否能够连接,'\'表示一条命令语句中的换行
$ bin/sqoop-list-databases \
--connect jdbc:mysql://june:3306 \
--username root \
--password .Xuan0613