一 解压安装包
这里提供了网盘资源
链接: https://pan.baidu.com/s/1QkFqVnlvuOJ_aB2bjn-OKg?pwd=ucsy 提取码: ucsy
这里有两个压缩包,sqoop-1.4.7.tar.gz是 sqoop 的安装包,另一个是我们需要里面的一些 jar 包
解压 安装包
tar -zxf ./sqoop-1.4.7.tar.gz -C /opt/soft
改个简单的名字方便后面操作
mv sqoop-1.4.7/ sqoop147
二 修改配置文件
到sqoop/conf 目录下,拷贝sqoop-env-template.sh文件到此目录命名sqoop-env.sh
cp sqoop-env-template.sh sqoop-env.sh
vim sqoop-env.sh
#Set path to where bin/hadoop is available
export HADOOP_COMMON_HOME=/opt/soft/hadoop313
#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/opt/soft/hadoop313
#set the path to where bin/hbase is available
export HBASE_HOME=/opt/soft/hbase235
#Set the path to where bin/hive is available
export HIVE_HOME=/opt/soft/hive312
export HIVE_CONF_DIR=/opt/soft/hive312/conf
#Set the path for where zookeper config dir is
export ZOOCFGDIR=/opt/soft/zk345/conf
三 拷贝 jar 包
(1)sqoop147目录下补全 jar 包
需要sqoop-1.4.7.bin__hadoop-2.6.0目录下的sqoop-1.4.7.jar,拷贝一份到 sqoop147 目录下
cp /opt/install/sqoop-1.4.7.bin__hadoop-2.6.0/sqoop-1.4.7.jar /opt/soft/sqoop147/
(2)lib 目录下补全 jar 包
这里命令执行在/opt/soft/sqoop147/lib里
cd /opt/soft/sqoop147/lib
cp /opt/soft/hive312/lib/hive-common-3.1.2.jar ./
这个 mysql 驱动包在安装 hive 的时候复制过 ,所以我这里直接在这个目录就有,这个驱动包在这个目录没有的可以去hive 的bin目录里找找
cp /opt/install/mysql-connector-java-8.0.29.jar ./
cp /opt/install/sqoop-1.4.7.bin__hadoop-2.6.0/lib/avro-1.8.1.jar ./
四 修改环境变量
vim /etc/profile
#SQOOP
export SQOOP_HOME=/opt/soft/sqoop147
export PATH=$SQOOP_HOME/bin:$PATH
修改完source一下
source /etc/profile
五 查看 sqoop 版本以及测试连接
查看 sqoop 版本
sqoop version
[root@kb46 conf]# sqoop version
Warning: /opt/soft/sqoop147/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /opt/soft/sqoop147/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
2023-09-15 11:21:14,751 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
Sqoop 1.4.7
git commit id 2328971411f57f0cb683dfb79d19d4d19d185dd8
Compiled by maugli on Thu Dec 21 15:59:58 STD 2017
查看 sqoop 的命令
sqoop help
连接 mysql 查看 MySQL 所有数据库
这里的 ip 还有mysql密码 换成自己的
这里还有一个小技巧,在命令行敲sqoop命令时\代表连接符,\后回车接着写,是一句命令
sqoop list-databases --connect jdbc:mysql://172.25.**.**:3306/ --username root --password password
结果实例:
[root@kb46 conf]# sqoop list-databases --connect jdbc:mysql://172.25.38.169:3306/ --username root --password 100860
Warning: /opt/soft/sqoop147/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /opt/soft/sqoop147/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
2023-09-15 11:25:35,880 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
2023-09-15 11:25:35,910 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
2023-09-15 11:25:35,996 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
mysql
information_schema
performance_schema
sys
kb46