作者:vicanat_215 | 来源:互联网 | 2023-05-25 15:33
一、安装测试前准备
1:安装集群:如下
![image1.png](https://img.php1.cn/3cd4a/189d8/b64/5b34b53b79a39fdd.jpeg)
2:sqoop版本和hadoop版本
![image2.png](https://img.php1.cn/3cd4a/1e618/bdf/129913486c37ddf6.jpeg)
3:mysql 连接器 和 测试数据 如下:
![image3.png](https://img.php1.cn/3cd4a/1eebe/cd5/780a3060eeed6a4e.webp)
![image4.png](https://img.php1.cn/3cd4a/1eebe/cd5/7cccb7e4b6cb5cb8.webp)
![image5.png](https://img.php1.cn/3cd4a/1eebe/cd5/d942b7ec373849c3.webp)
二、sqoop配置2.1、sqoop环境变量
![image6.png](https://img.php1.cn/3cd4a/1eebe/cd5/e88efe5b0a13a7fa.webp)
2.1.1、修改sqoop_env.sh
![image7.png](https://img.php1.cn/3cd4a/1eebe/cd5/1e3db12dd78db092.webp)
2.1.2、修改configure-sqoop
本次测试不涉及HBase zookeeper,所以注释掉hbase ,zookeeper
三、开始将mysql中数据导入到hdfs
1: 输入如下 命令:
sqoop import –connectjdbc:mysql://lhmaster:3306/sqoop_mysql_to_hdfs –username root –password 831022–table sqooptesttable –target-dir /home/lihui/input/testsqoop/$today –m 1
![image8.png](https://img.php1.cn/3cd4a/1eebe/cd5/011ac27956d007f0.webp)
执行结果如下:
![image9.png](https://img.php1.cn/3cd4a/1eebe/cd5/8ad8f3bf8da691df.webp)
成功导入三行数据
2:查看hdfs上导入的数据是否与mysql中相同:如下图:
![image10.png](https://img.php1.cn/3cd4a/1eebe/cd5/086aec93f5e1e9b2.webp)
![image11.png](https://img.php1.cn/3cd4a/1eebe/cd5/c72d78d7317a9e8e.webp)
![image12.png](https://img.php1.cn/3cd4a/1eebe/cd5/8170a21e8dddfd22.webp)
三条数据与mysql数据库中数据一致,导入成功