# 查看命令帮助
[hadoop@hadoop ~]$ sqoop help
20/06/06 18:07:14 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.16.2
usage: 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 information
See 'sqoop help COMMAND' for information on a specific command.
# 查看命令的参数
[hadoop@hadoop ~]$ sqoop help list-databases
#使用sqoop获取数据库的列表
[hadoop@hadoop ~]$ sqoop list-databases \
> --connect jdbc:mysql://192.168.228.128:3306 \
> --username root \
> --password root
20/06/06 18:51:16 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.16.2
20/06/06 18:51:16 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
20/06/06 18:51:16 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
Sat Jun 06 18:51:17 CST 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
information_schema
mysql
performance_schema
sys
# 使用sqoop导数据到hadoop
[hadoop@hadoop ~]$ sqoop import \
> --connect jdbc:mysql://192.168.228.128:3306/ruozedata \
> --username root \
> --password root \
> --table sqoop_test
出现如下错误,很明显,就是缺少jar包,参考https://community.cloudera.com/t5/Support-Questions/Sqoop-import-exception-java-lang-NoClassDefFoundError-org/td-p/50758,下载到对应的jar包放入$SQOOP_HOME/lib下即可
网友评论