gpt4 book ai didi

mysql - 使用 Oozie 永远运行的 Sqoop 作业

转载 作者:可可西里 更新时间:2023-11-01 16:59:25 27 4
gpt4 key购买 nike

我们有两个节点的 hadoop yarn 集群,它是 hadoop 2.2,在其上我们使用 oozie 在单个工作流中安排了两个操作,第一个操作是 python map-reduce 流操作,第二个是 sqoop export 作业,它实际上是将 map-reduce 流操作的输出传输到 mysql 数据库。

流式操作成功执行,导致 sqoop 作业启动,并一直运行。

stdout 结果如下。

Sqoop command arguments :
export
--connect
jdbc:mysql://localhost/database
--username
root
--password
root
--table
tableName
--direct
--export-dir
/user/hduser/oozieProject/workflow/output

=================================================================
Invoking Sqoop command line now >>>

2137 [main] WARN org.apache.sqoop.tool.SqoopTool - $SQOOP_CONF_DIR has not been set in the environment. Cannot check for additional configuration.
2158 [main] INFO org.apache.sqoop.Sqoop - Running Sqoop version: 1.4.4.2.0.6.1-102
2170 [main] WARN org.apache.sqoop.tool.BaseSqoopTool - Setting your password on the command-line is insecure. Consider using -P instead.
2178 [main] WARN org.apache.sqoop.ConnFactory - $SQOOP_CONF_DIR has not been set in the environment. Cannot check for additional configuration.
2197 [main] INFO org.apache.sqoop.manager.MySQLManager - Preparing to use a MySQL streaming resultset.
2197 [main] INFO org.apache.sqoop.tool.CodeGenTool - Beginning code generation
2464 [main] INFO org.apache.sqoop.manager.SqlManager - Executing SQL statement: SELECT t.* FROM `missedCalls` AS t LIMIT 1
2483 [main] INFO org.apache.sqoop.manager.SqlManager - Executing SQL statement: SELECT t.* FROM `missedCalls` AS t LIMIT 1
2485 [main] INFO org.apache.sqoop.orm.CompilationManager - HADOOP_MAPRED_HOME is /usr/local/hadoop
3838 [main] INFO org.apache.sqoop.orm.CompilationManager - Writing jar file: /tmp/sqoop-hduser/compile/21bd1d5fe13adeed4f46a09f8b3d38fe/missedCalls.jar
3847 [main] INFO org.apache.sqoop.mapreduce.ExportJobBase - Beginning export of missedCalls
Heart beat
Heart beat
Heart beat
Heart beat
Heart beat
Heart beat
Heart beat
Heart beat

作业属性如下

nameNode=hdfs://master:54310
jobTracker=master:8035
queueName=default

oozie.libpath=${nameNode}/user/hduser/share/lib
oozie.use.system.libpath=true
oozie.wf.rerun.failnodes=true

oozieProjectRoot=${nameNode}/user/hduser/oozieProject
appPath=${oozieProjectRoot}/workflow
oozie.wf.application.path=${appPath}
oozieLibPath=${oozie.libpath}

mapred.tasktracker.map.tasks.maximum=4
mapred.tasktracker.reduce.tasks.maximum=4

inputDir=${oozieProjectRoot}/data/*
outputDir=${appPath}/output

工作流xml如下

<!--Oozie workflow file: workflow.xml --> 
<workflow-app name="WorkflowStreamingMRAction-Python" xmlns="uri:oozie:workflow:0.1">
<start to="streamingaAction"/>
<action name="streamingaAction">
<map-reduce>
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<prepare>
<delete path="${outputDir}"/>
</prepare>
<streaming>
<mapper>python mapper.py</mapper>
<reducer>python reducer.py</reducer>
</streaming>
<configuration>
<property>
<name>oozie.libpath</name>
<value>${oozieLibPath}/mapreduce-streaming</value>
</property>
<property>
<name>mapred.input.dir</name>
<value>${inputDir}</value>
</property>
<property>
<name>mapred.output.dir</name>
<value>${outputDir}</value>
</property>
<property>
<name>mapred.reduce.tasks</name>
<value>4</value>
</property>
</configuration>
<file>${appPath}/mapper.py#mapper.py</file>
<file>${appPath}/reducer.py#reducer.py</file>
</map-reduce>
<ok to="sqoopAction"/>
<error to="killJobAction"/>
</action>

<action name="sqoopAction">
<sqoop xmlns="uri:oozie:sqoop-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<command>export --connect jdbc:mysql://localhost/database --username root --password myPwd --table tableName --direct --export-dir /user/hduser/oozieProject/workflow/output</command>
</sqoop>
<ok to="end"/>
<error to="killJobAction"/>
</action>
<kill name="killJobAction">
<message>"Killed job due to error: ${wf:errorMessage(wf:lastErrorNode())}"</message>
</kill>
<end name="end" />

请指教哪里出了问题?

谢谢

最佳答案

它不会永远运行。你只需要等待。

首先,您在上面看到的 Sqoop 导出作业只是一个 Oozie 计划作业。和 Heart beat意味着它现在正在运行。你只需要等待。其实你可以去 YARN 资源管理器页面(通常是 http://$namenode:8088/cluster),然后你可以找到“真正的”Sqoop 导出作业。 (我猜映射器的默认数量是 4。)

其次,Sqoop 使用 INSERT 进行“导出”语句,所以比较慢。当表很大时,我不建议使用 Sqoop 导出,例如,当它有超过 100 万个条目时。

第三,由于我注意到您尝试导出到 MySQL,您可以尝试批处理模式,它运行 INSERT这样查询:INSERT INTO <TABLE> VALUES (<ROW1>), (<ROW2>), etc.

因此您可以将命令更改为: sqoop export -D sqoop.export.records.per.statement=1000 --connect jdbc:mysql://localhost/database --username root --password myPwd --table tableName --direct --export-dir /user/hduser/oozieProject/workflow/output --batch

关于mysql - 使用 Oozie 永远运行的 Sqoop 作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26338281/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com