【问题标题】:Unable to import data using sqoop无法使用 sqoop 导入数据
【发布时间】:2017-11-01 07:47:37
【问题描述】:

我想使用 sqoop 将数据从 MySQL 导入到远程 Hive。我在中间件机器上安装了 Sqoop。当我运行这个命令时:

sqoop import --driver com.mysql.jdbc.Driver --connect jdbc:mysql://192.168.2.146:3306/fir --username root -P -m 1 --table beard_size_list --connect jdbc:hive2://192.168.2.141:10000/efir --username oracle -P -m 1 --hive-table lnd_beard_size_list --hive-import;

这个命令是否正确,我可以将数据从远程 MySQL 导入远程 Hive 吗?

当我运行此命令时,它会继续尝试连接到资源管理器:

17/11/01 10:54:05 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.6.1.0-129
Enter password: 
17/11/01 10:54:10 INFO tool.BaseSqoopTool: Using Hive-specific delimiters 
for output. You can override
17/11/01 10:54:10 INFO tool.BaseSqoopTool: delimiters with --fields-
terminated-by, etc.
17/11/01 10:54:10 WARN sqoop.ConnFactory: Parameter --driver is set to an 
explicit driver however appropriate connection manager is not being set (via 
--connection-manager). Sqoop is going to fall back to 
org.apache.sqoop.manager.GenericJdbcManager. Please specify explicitly which 
connection manager should be used next time.
17/11/01 10:54:10 INFO manager.SqlManager: Using default fetchSize of 1000
17/11/01 10:54:10 INFO tool.CodeGenTool: Beginning code generation
17/11/01 10:54:11 INFO manager.SqlManager: Executing SQL statement: SELECT 
t.* FROM beard_size_list AS t WHERE 1=0
17/11/01 10:54:11 INFO manager.SqlManager: Executing SQL statement: SELECT 
t.* FROM beard_size_list AS t WHERE 1=0
17/11/01 10:54:11 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is 
/usr/hdp/2.6.1.0-129/hadoop-mapreduce
Note: /tmp/sqoop-
oracle/compile/d93080265a09913fbfe9e06e92d314a3/beard_size_list.java uses or 
overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
17/11/01 10:54:15 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-
oracle/compile/d93080265a09913fbfe9e06e92d314a3/beard_size_list.jar
17/11/01 10:54:15 INFO mapreduce.ImportJobBase: Beginning import of 
beard_size_list
17/11/01 10:54:15 INFO Configuration.deprecation: mapred.jar is deprecated. 
Instead, use mapreduce.job.jar
17/11/01 10:54:15 INFO manager.SqlManager: Executing SQL statement: SELECT 
t.* FROM beard_size_list AS t WHERE 1=0
17/11/01 10:54:17 INFO Configuration.deprecation: mapred.map.tasks is 
deprecated. Instead, use mapreduce.job.maps
17/11/01 10:54:17 INFO client.RMProxy: Connecting to ResourceManager at 
hortonworksn2.com/192.168.2.191:8050
17/11/01 10:54:17 INFO client.AHSProxy: Connecting to Application History 
server at hortonworksn2.com/192.168.2.191:10200
17/11/01 10:54:19 INFO ipc.Client: Retrying connect to server: 
hortonworksn2.com/192.168.2.191:8050. Already tried 0 time(s); retry policy 
is RetryUpToMaximumCountWithFixedSleep(maxRetries=50, sleepTime=1000 
MILLISECONDS)
17/11/01 10:54:20 INFO ipc.Client: Retrying connect to server: 
hortonworksn2.com/192.168.2.191:8050. Already tried 1 time(s); retry policy 
is RetryUpToMaximumCountWithFixedSleep(maxRetries=50, sleepTime=1000 
MILLISECONDS)
17/11/01 10:54:21 INFO ipc.Client: Retrying connect to server: 
hortonworksn2.com/192.168.2.191:8050. Already tried 2 time(s); retry policy 
is RetryUpToMaximumCountWithFixedSleep(maxRetries=50, sleepTime=1000 
MILLISECONDS)
17/11/01 10:54:22 INFO ipc.Client: Retrying connect to server: 
hortonworksn2.com/192.168.2.191:8050. Already tried 3 time(s); retry policy 
is RetryUpToMaximumCountWithFixedSleep(maxRetries=50, sleepTime=1000 
MILLISECONDS)
17/11/01 10:54:23 INFO ipc.Client: Retrying connect to server: 
hortonworksn2.com/192.168.2.191:8050. Already tried 4 time(s); retry policy 
is RetryUpToMaximumCountWithFixedSleep(maxRetries=50, sleepTime=1000 
MILLISECONDS)

它尝试连接的端口是 8050,但实际端口是 8033。我该如何解决这个问题?

【问题讨论】:

    标签: mysql hadoop hive sqoop resourcemanager


    【解决方案1】:

    试试下面这个命令:

    sqoop import --driver com.mysql.jdbc.Driver --connect jdbc:mysql://192.168.2.146:3306/fir --username root -P -m 1 --table beard_size_list ;

    【讨论】:

      【解决方案2】:

      请检查以下属性是否正确设置为yarn-site.xml

      <name>yarn.resourcemanager.address</name>
      <value>192.168.2.191:8033</value>
      

      【讨论】:

      • 是的,我改变了端口重启了集群但是错误还是一样
      【解决方案3】:

      为什么您在代码中添加了两次 -connect 语句?试试下面的代码:

      sqoop import --driver com.mysql.jdbc.Driver --connect jdbc:mysql://192.168.2.146:3306/fir --username root -P -m 1 --split-by beard_size_list_table_primary_key --table beard_size_list --target-dir /user/data/raw/beard_size_list --fields-terminated-by "," --hive-import --create-hive-table --hive-table dbschema.beard_size_list

      注意:

      create-hive-table – 如果 Hive 表已经存在,则确定设置作业是否会失败。在这种情况下它将起作用,否则您已经创建了配置单元外部表并设置了 target-dir 路径

      【讨论】:

      • 我的源和目标在远程机器上,我正在从我的中间件机器上运行 sqoop。这只是一次尝试,我不确定此命令是否有效。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-26
      • 1970-01-01
      • 2014-02-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多