首页 > 其他分享 >EMR SQOOP 测试过程纪录

EMR SQOOP 测试过程纪录

时间:2023-02-04 22:31:14浏览次数:37  
标签:master1 sqoop -- 纪录 SQOOP hadoop EMR test MySQL

1、sqoop定义

Sqoop 是一款开源的工具,主要用于在 Hadoop 和传统数据库(MySQL、PostgreSQL 等)之间进行数据传递,可以将一个关系型数据库(例如 MySQL、Oracle、Postgres 等)中的数据导入到 Hadoop 的 HDFS 中,也可以将 HDFS 的数据导入到关系型数据库中。Sqoop 中一大亮点就是可以通过 Hadoop 的 MapReduce 把数据从关系型数据库中导入数据到 HDFS。

2、sqoop测试过程记录 

测试时的全纪录可以供以后使用参考,出于安全省略了一些关键的引用版本输出,不影响看全过程的实录内容。

MySQL [mysql]> use test;
Database changed
MySQL [test]> show tables;
Empty set (0.00 sec)

MySQL [test]> create table sqoop_test(id int not null primary key auto_increment, title varchar(64), time timestamp, content varchar(255));
Query OK, 0 rows affected (0.01 sec)

MySQL [test]> insert into sqoop_test values(null, 'first', now(), 'hdfs');
Query OK, 1 row affected (0.00 sec)

MySQL [test]> insert into sqoop_test values(null, 'second', now(), 'mr');
Query OK, 1 row affected (0.00 sec)

MySQL [test]> insert into sqoop_test values(null, 'third', now(), 'yarn');
Query OK, 1 row affected (0.00 sec)

MySQL [test]> select * from sqoop_test;
+----+--------+---------------------+---------+
| id | title | time | content |
+----+--------+---------------------+---------+
| 1 | first | 2022-08-29 11:56:19 | hdfs |
| 2 | second | 2022-08-29 11:56:27 | mr |
| 3 | third | 2022-08-29 11:56:34 | yarn |
+----+--------+---------------------+---------+
3 rows in set (0.00 sec)

MySQL [test]> exit
Bye
[root@emr-master1 ~]# su hadoop
[hadoop@emr-master1 root]$ cd
[hadoop@emr-master1 ~]$ sqoop-import --connect jdbc:mysql://x.x.x.x/test --username root -P --table sqoop_test --target-dir /sqoop
Warning: /usr/local/service/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
省略输出.........
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Enter password: [hadoop@^Cr-master1 ~]$ sqoop-import --connect jdbc:mysql://x.x.x.x/test --username root -P --table sqoop_test --target-dir /sqoop
[hadoop@emr-master1 ~]$ /bin/sqoop-import --connect jdbc:mysql://x.x.x.x/test --username root -P --table sqoop_test --target-dir /sqoop
bash: /bin/sqoop-import: No such file or directory
[hadoop@emr-master1 ~]$ which sqoop-import
/usr/local/service/sqoop/bin/sqoop-import
[hadoop@emr-master1 ~]$ /usr/local/service/sqoop/bin/sqoop-import --connect jdbc:mysql://x.x.x.x/test --username root -P --table sqoop_test --target-dir /sqoop
Warning: /usr/local/service/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
省略输出.........
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Enter password:
Note: /xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Note: Recompile with -Xlint:deprecation for details.
[hadoop@emr-master1 ~]$ hadoop fs -cat /sqoop/*
1,first,2022-08-29 11:56:19.0,hdfs
2,second,2022-08-29 11:56:27.0,mr
3,third,2022-08-29 11:56:34.0,yarn
[hadoop@emr-master1 ~]$ mysql -h x.x.x.x -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 191754
Server version: 5.6.28-cdb2016-log 20220302

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MySQL [test]> show tables;
+----------------+
| Tables_in_test |
+----------------+
| sqoop_test |
+----------------+
1 row in set (0.00 sec)

MySQL [test]> create table sqoop_test_back(id int not null primary key auto_increment, title varchar(64), time timestamp, content varchar(255));
Query OK, 0 rows affected (0.00 sec)

MySQL [test]> show tables;
+-----------------+
| Tables_in_test |
+-----------------+
| sqoop_test |
| sqoop_test_back |
+-----------------+
2 rows in set (0.00 sec)

MySQL [test]> exit
Bye
[hadoop@emr-master1 ~]$ which sqoop-export
/usr/local/service/sqoop/bin/sqoop-export
[hadoop@emr-master1 ~]$ /usr/local/service/sqoop/bin/sqoop-export --connect jdbc:mysql://x.x.x.x/test --username root -P --table sqoop_test_back --export-dir /sqoop
Warning: /usr/local/service/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.

Enter password:
Note: /tmp/sqoop-hadoop/compile/4256a084d8c542ff03767ae114553d13/sqoop_test_back.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
0 [main] INFO com.hadoop.compression.lzo.GPLNativeCodeLoader - Loaded native gpl library from the embedded binaries
25 [main] INFO com.hadoop.compression.lzo.LzoCodec -
[hadoop@emr-master1 ~]$ mysql -h x.x.x.x -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 191880
Server version: 5.6.28-cdb2016-log 20220302

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MySQL [test]> select * from sqoop_test_back;
+----+--------+---------------------+---------+
| id | title | time | content |
+----+--------+---------------------+---------+
| 1 | first | 2022-08-29 11:56:19 | hdfs |
| 2 | second | 2022-08-29 11:56:27 | mr |
| 3 | third | 2022-08-29 11:56:34 | yarn |
+----+--------+---------------------+---------+
3 rows in set (0.00 sec)

MySQL [test]>

标签:master1,sqoop,--,纪录,SQOOP,hadoop,EMR,test,MySQL
From: https://blog.51cto.com/keep11/6037303

相关文章

  • EMR修改Core节点EBS卷大小
    本文用于修改已创建好的EMR集群Core节点EBS磁盘容量,由于业务场景、成本等多方面考虑,需要周期性的调整Core节点的磁盘容量,但是通过人工调整EBS卷大小非常耗时,本文通过Bootstr......
  • 宝塔邮局-并解决A纪录解析失败问题
    为什么一定要用这个邮局呢,只要是方便,在宝塔面板直接安装就行了。使用教程如下:https://www.bt.cn/bbs/thread-87496-1-1.html有一个BUG本来已经设置好了,但是总显示A记录......
  • 大数据生产环境 sqoop datax
    在日常大数据生产环境中,经常会有集群数据集和关系型数据库互相转换的需求,在需求选择的初期解决问题的方法————数据同步工具就应运而生了。此次我们选择两款生产环境常......
  • 一次典型的Memroy Leak的跟踪学习过程
    背景周四时某项目在QQ群里说自己的系统出现了CPU占用较高的情况.TOP查看发现大部分占用CPU的都是JAVA核心进城后附近的进程.所以初步怀疑是出现了FullGC的问题.然......
  • 腾讯云 EMR(Elastic Map Reduce) 数仓 实时 离线
    弹性MapReduce__弹性伸缩Hadoop服务_云原生开源大数据平台-腾讯云https://cloud.tencent.com/product/emr1.腾讯云EMR-实时数仓-课程介绍-腾讯云开发者社区-腾讯云h......
  • vulnhub靶场之BUFFEMR: 1.0.1
    准备:攻击机:虚拟机kali、本机win10。靶机:BUFFEMR:1.0.1,下载地址:https://download.vulnhub.com/buffemr/BuffEMR-v1.0.1.ova,下载后直接vbox打开即可。知识点:openemr框架......
  • Ubuntu 2022.04版本安装libsdl2-dev出现E: Error, pkgProblemResolver::Resolve gener
    $sudoapt-getinstalllibsdl2-devReadingpackagelists...DoneBuildingdependencytree...DoneReadingstateinformation...DoneSomepackagescouldnotbe......
  • oracle ,mysql,sqlserver 挑选特定行号的纪录
    oracle:SELECT*FROMtableWHEREROWNUM<101;minusSELECT*FROMtableWHEREROWNUM<91;mysql:select*fromtablelimit5,5第一个5是开始的行号,第二个5是选择纪录......
  • Forexclub:特斯拉四季度交付车辆创纪录,你认为2023年特斯拉销量如何
    周一特斯拉宣布其2022年第四季度交付了创纪录的405278辆汽车。这一数字创下了该公司的纪录,但低于华尔街的估计。据报道,报告中对交付量的普遍估计为420760。特斯拉称:“2022年......
  • 【Sqoop篇】----Sqoop从搭建到应用案例
    =========================================================声明:由于不同平台阅读格式不一致(尤其源码部分),所以获取更多阅读体验!!个人网站地址:​​http://www.lhworldblog.......