Sqoop 安装部署

Sqoop 安装部署

一、安装 sqoop

sqoop 下载地址:https://archive.apache.org/dist/sqoop/1.4.7/
我们的hadoop3.13 版本的,对应的sqoop是1.4.7,我们下1.4.7版本的就行了。
在这里插入图片描述
上传到 linux 的 /opt/software 目录下
在这里插入图片描述
接下来解压到,/opt 目录下
输入命令: tar -zxvf sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz -C /opt/
在这里插入图片描述
输入命令: mv sqoop-1.4.7.bin__hadoop-2.6.0/ sqoop 把名字改为sqoop
在这里插入图片描述

二、修改配置文件

Sqoop的配置文件与大多数大数据框架类似,在sqoop根目录下的conf目录中

1、重命名配置文件

输入命令: mv sqoop-env-template.sh sqoop-env.sh
在这里插入图片描述

2、修改配置文件

输入命令:vim sqoop-env.sh 添加如下配置

export ZOOKEEPER_HOME=/opt/zookeeper
export HADOOP_COMMON_HOME=/opt/hadoop-3.1.3
export HADOOP_MAPRED_HOME=/opt/hadoop-3.1.3
export HIVE_HOME=/opt/hive
export ZOOKEEPER_HOME=/opt/zookeeper
export ZOOCFGDIR=/opt/zookeeper

然后把 mysql 的驱动,拷贝到 sqoop 的 lib 目录下就可以了

三、测试验证

1、测试

输入命令:bin/sqoop help 可以看到命令提示
在这里插入图片描述

2、测试Sqoop是否能够成功连接数据库

输入命令:bin/sqoop list-databases --connect jdbc:mysql://hadoop102:3306/ --username root --password p@ssw0rd 可以看到已经连接成功了
在这里插入图片描述

四、mysql 数据导入到 hdfs

输入代码: 下面是语法格式,前面四行都是与mysql相关的,下面是哪行就是与 hdfs 相关的

bin/sqoop import \   --导入
--connect jdbc:mysql://hadoop102:3306/shtd_store \  --mysql数据库连接
--username root \			-- 用户
--password p@ssw0rd \       --密码
--table user_info \         --表名
--target-dir /user/dates \	--hdfs 文件地址
--delete-target-dir \   --如果有这个文件就删除,在公司里就不要用了,测试的时候还可以
--num-mappers 1 \			--mappers 数量 
--fields-terminated-by "\t"  --数据的分割符
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure! Here's a step-by-step guide to deploying Sqoop on Ubuntu: 1. Install Java Development Kit (JDK): - Open Terminal and run the command: `sudo apt update` - Install OpenJDK by running: `sudo apt install openjdk-8-jdk` 2. Verify Java installation: - Run the command: `java -version` - You should see java version information printed on the console. 3. Download and install Sqoop: - Visit the Apache Sqoop website (https://sqoop.apache.org/) and navigate to the "Downloads" section. - Choose the latest stable release and copy the download link for the binary package (e.g., sqoop-x.x.x.bin__hadoop-x.x.x.tar.gz). - In Terminal, navigate to the directory where you want to install Sqoop. - Download the package using the command: `wget [download_link]` (replace [download_link] with the actual download link). - Extract the downloaded package using: `tar -xvf sqoop-x.x.x.bin__hadoop-x.x.x.tar.gz` (replace x.x.x with the version number). 4. Configure Sqoop: - Open the Sqoop configuration file using a text editor: `sudo nano sqoop-x.x.x.bin__hadoop-x.x.x/conf/sqoop-env.sh` - Set the JAVA_HOME variable to your JDK installation path. For example: `export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64` - Save and close the file. 5. Set up environment variables: - Open the ~/.bashrc file in a text editor: `nano ~/.bashrc` - Add the following lines at the end of the file: ``` export SQOOP_HOME=/path/to/sqoop export PATH=$PATH:$SQOOP_HOME/bin ``` - Save and close the file. - Run `source ~/.bashrc` to apply the changes. 6. Test Sqoop installation: - Run the command: `sqoop version` - You should see the Sqoop version information printed on the console without any errors. Congratulations! You have successfully deployed Sqoop on Ubuntu. You can now use Sqoop for data transfer between Hadoop and relational databases.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值