meta命令帮助信息

  1. $ bin/sqoop help metastore
  2. usage: sqoop metastore [GENERIC-ARGS] [TOOL-ARGS]
  3. metastore arguments:
  4. --shutdown Cleanly shut down a running metastore
  5. Generic Hadoop command-line arguments:
  6. (must preceed any tool-specific arguments)
  7. Generic options supported are
  8. -conf <configuration file> specify an application configuration file
  9. -D <property=value> use value for given property
  10. -fs <local|namenode:port> specify a namenode
  11. -jt <local|jobtracker:port> specify a job tracker
  12. -files <comma separated list of files> specify comma separated files to be copied to the map reduce cluster
  13. -libjars <comma separated list of jars> specify comma separated jar files to include in the classpath.
  14. -archives <comma separated list of archives> specify comma separated archives to be unarchived on the compute machines.
  15. The general command line syntax is
  16. bin/hadoop command [genericOptions] [commandOptions]

conf/sqoop-site-template.xml 修改内容

  • https://blog.csdn.net/PTtaoge/article/details/83902233
  • https://www.cnblogs.com/wrencai/p/3912462.html ```xml

    sqoop.metastore.client.autoconnect.url jdbc:hsqldb:hsql://master:16000/sqoop Port that this metastore should listen on. sqoop.metastore.client.record.password true If true, allow saved passwords in the metastore. sqoop.metastore.server.location /home/jack/Documents/sqoop/metastore/shared.db Path to the shared metastore database files. If this is not set, it will be placed in ~/.sqoop/. sqoop.metastore.server.port 16000 Port that this metastore should listen on.
  1. `$ mkdir -p /home/jack/Documents/sqoop/metastore` 创建元数据db文件存储路径。<br />启动metastore服务。<br />sqoop增量导入数据
  2. ```bash
  3. $ bin/sqoop metastore &
  4. $ jps
  5. 19796 Sqoop

测试,定义job(执行过程中,需要手动输入数据库密码)

  • https://blog.csdn.net/a904364908/article/details/98355032 ```bash

    初始化数据

    $ mysql -uroot -p123456 DROP TABLE IF EXISTS user; CREATE TABLE user ( id int(11) NOT NULL, name varchar(20) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO user VALUES (‘1’, ‘jack’); INSERT INTO user VALUES (‘2’, ‘tom’); INSERT INTO user VALUES (‘3’, ‘white’); INSERT INTO user VALUES (‘4’, ‘black’);

创建hive表

$ bin/sqoop create-hive-table \ —connect jdbc:mysql://master:3306/mydb \ —username root \ —password 123456 \ —table user \ —hive-table user_job \ —mysql-delimiters

定义job

$ bin/sqoop job \ —create user_import_incr \ —meta-connect jdbc:hsqldb:hsql://master:16000/sqoop \ — \ import \ —connect jdbc:mysql://master:3306/mydb \ —username root \ —password 123456 \ —table user \ —mysql-delimiters \ —incremental append \ —check-column id \ —last-value 1 \ —target-dir /user/hive/warehouse/user_job \ -m 1

执行任务

$ bin/sqoop job —exec user_import_incr

过程中(第一次执行时)需要输入,import任务里的数据库连接密码

Enter password:

查询

$ ~/Documents/hive/bin/hive hive> select * from user_job; OK 2 tom 3 white 4 black

插入数据

mysql> insert into user value (5, ‘ming’); mysql> insert into user value (6, ‘ning’);

再次执行,不需要输入密码

$ bin/sqoop job —exec user_import_incr $ ~/Documents/hive/bin/hive

查询

hive> select * from user_job; OK 2 tom 3 white 4 black 5 ming 6 ning

删除任务

$ bin/sqoop job —delete user_import_incr

  1. mysql作为metastore
  2. - [https://community.cloudera.com/t5/Community-Articles/Using-SQOOP-with-MySQL-as-metastore/ta-p/247312](https://community.cloudera.com/t5/Community-Articles/Using-SQOOP-with-MySQL-as-metastore/ta-p/247312)
  3. ```xml
  4. <configuration>
  5. <property>
  6. <name>sqoop.metastore.client.enable.autoconnect</name>
  7. <value>true</value>
  8. </property>
  9. <property>
  10. <name>sqoop.metastore.client.autoconnect.url</name>
  11. <value>jdbc:mysql://<<MYSQLHOSTNAME>>/sqoop?createDatabaseIfNotExist=true</value>
  12. </property>
  13. <property>
  14. <name>sqoop.metastore.client.autoconnect.username</name>
  15. <value>$$SQOOPUSER$$</value> </property>
  16. <property>
  17. <name>sqoop.metastore.client.autoconnect.password</name>
  18. <value>$$$SQOOPPASSWORD$$$</value>
  19. </property>
  20. <property>
  21. <name>sqoop.metastore.client.record.password</name>
  22. <value>true</value>
  23. </property>
  24. <property>
  25. <name>sqoop.metastore.server.location</name>
  26. <value>/usr/lib/sqoop/metastore/</value>
  27. </property>
  28. <property>
  29. <name>sqoop.metastore.server.port</name>
  30. <value>16000</value>
  31. </property>
  32. </configuration>