sqoop 测试

来源:互联网 发布:mac office365 编辑:程序博客网 时间:2024/06/05 21:03

sqoop在cdh安装时就已经集成了,和1.0版本相比,相对简单了。

--1.查看所有参数命令

[root@MASTER01 ~]# sqoop helpWarning: /opt/cloudera/parcels/CDH-5.2.0-1.cdh5.2.0.p0.36/bin/../lib/sqoop/../accumulo does not exist! Accumulo imports will fail.Please set $ACCUMULO_HOME to the root of your Accumulo installation.16/07/10 23:40:09 INFO sqoop.Sqoop: Running Sqoop version: 1.4.5-cdh5.2.0usage: sqoop COMMAND [ARGS]Available commands:  codegen            Generate code to interact with database records  create-hive-table  Import a table definition into Hive  eval               Evaluate a SQL statement and display the results  export             Export an HDFS directory to a database table  help               List available commands  import             Import a table from a database to HDFS  import-all-tables  Import tables from a database to HDFS  import-mainframe   Import datasets from a mainframe server to HDFS  job                Work with saved jobs  list-databases     List available databases on a server  list-tables        List available tables in a database  merge              Merge results of incremental imports  metastore          Run a standalone Sqoop metastore  version            Display version informationSee 'sqoop help COMMAND' for information on a specific command.[root@MASTER01 ~]# 


--2.列出mysql所有的database




--3.在mysql建立一个测试表,

mysql> use test;Database changedmysql> create table ml_1234(name varchar(30));Query OK, 0 rows affected (0.31 sec)
mysql> insert into ml_1234 select 'mengl'    -> ;Query OK, 1 row affected (0.06 sec)Records: 1  Duplicates: 0  Warnings: 0
mysql> select * from ml_1234;+-------+| name  |+-------+| mengl |+-------+1 row in set (0.00 sec)

--4.导入到hive

sqoop import --connect jdbc:mysql://localhost:3306/test --username root --password ****  --table ml_1234 --hive-table ml_1234 -m 1

后续明天续集



0 0
原创粉丝点击