meta命令帮助信息
$ bin/sqoop help metastoreusage: sqoop metastore [GENERIC-ARGS] [TOOL-ARGS]metastore arguments:--shutdown Cleanly shut down a running metastoreGeneric Hadoop command-line arguments:(must preceed any tool-specific arguments)Generic options supported are-conf <configuration file> specify an application configuration file-D <property=value> use value for given property-fs <local|namenode:port> specify a namenode-jt <local|jobtracker:port> specify a job tracker-files <comma separated list of files> specify comma separated files to be copied to the map reduce cluster-libjars <comma separated list of jars> specify comma separated jar files to include in the classpath.-archives <comma separated list of archives> specify comma separated archives to be unarchived on the compute machines.The general command line syntax isbin/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.
`$ mkdir -p /home/jack/Documents/sqoop/metastore` 创建元数据db文件存储路径。<br />启动metastore服务。<br />sqoop增量导入数据```bash$ bin/sqoop metastore &$ jps19796 Sqoop
测试,定义job(执行过程中,需要手动输入数据库密码)
- https://blog.csdn.net/a904364908/article/details/98355032
```bash
初始化数据
$ mysql -uroot -p123456 DROP TABLE IF EXISTSuser; CREATE TABLEuser(idint(11) NOT NULL,namevarchar(20) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTOuserVALUES (‘1’, ‘jack’); INSERT INTOuserVALUES (‘2’, ‘tom’); INSERT INTOuserVALUES (‘3’, ‘white’); INSERT INTOuserVALUES (‘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
mysql作为metastore- [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)```xml<configuration><property><name>sqoop.metastore.client.enable.autoconnect</name><value>true</value></property><property><name>sqoop.metastore.client.autoconnect.url</name><value>jdbc:mysql://<<MYSQLHOSTNAME>>/sqoop?createDatabaseIfNotExist=true</value></property><property><name>sqoop.metastore.client.autoconnect.username</name><value>$$SQOOPUSER$$</value> </property><property><name>sqoop.metastore.client.autoconnect.password</name><value>$$$SQOOPPASSWORD$$$</value></property><property><name>sqoop.metastore.client.record.password</name><value>true</value></property><property><name>sqoop.metastore.server.location</name><value>/usr/lib/sqoop/metastore/</value></property><property><name>sqoop.metastore.server.port</name><value>16000</value></property></configuration>
