본문 바로가기
빅데이터/oozie

[oozie] 우지의 hive 액션 예제

by hs_seo 2017. 4. 6.

우지의 하이브 액션을 이용하는 방법은 다음과 같다.


  • 다음의 파일을 준비
    • 필수: workflow.xml, count.hql, job.properties
    • 옵션: hive-site.xml
  • 생성한 파일을 hdfs에 업로드
  • 우지 명령어 실행
    • oozie job --oozie http://localhost:11000/oozie -config ./job.properties -run


<workflow.xml>

<workflow-app xmlns="uri:oozie:workflow:0.4" name="${jobName}">

  <global>

    <job-tracker>localhost:8032</job-tracker>

    <name-node>hdfs://localhost:8020</name-node>

    <job-xml>hive-site.xml</job-xml>

    <configuration>

      <property>

        <name>oozie.use.system.libpath</name>

        <value>true</value>

      </property>

      <property>

        <name>oozie.launcher.mapreduce.job.acl-view-job</name>

        <value>*</value>

      </property>

      <property>

        <name>oozie.launcher.mapred.job.queue.name</name>

        <value>q1</value>

      </property>

      

      <property>

        <name>mapred.job.queue.name</name>

        <value>queue</value>

      </property>

      

      <property>

        <name>oozie.launcher.mapreduce.map.memory.mb</name>

        <value>768</value>

      </property>

      <property>

        <name>oozie.launcher.yarn.app.mapreduce.am.resource.mb</name>

        <value>1024</value>

      </property>

      <property>

        <name>oozie.launcher.mapreduce.map.java.opts</name>

        <value>-Xmx512m</value>

      </property>

      <property>

        <name>oozie.launcher.yarn.app.mapreduce.am.command-opts</name>

        <value>-Xmx768m</value>

      </property>

    </configuration>

  </global>

  <start to="hive_action"/>

  <action name="hive_action">

    <hive xmlns="uri:oozie:hive-action:0.4">

      <script>count.hql</script>

    </hive>

    <ok to="end"/>

    <error to="kill"/>

  </action>

  <kill name="kill">

    <message>Map/Reduce failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>

  </kill>

  <end name="end"/>

</workflow-app>


<hive-site.xml>

<?xml version="1.0"?>

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>


<property>

<name>hive.exec.scratchdir</name>

<value>/tmp/hivescratch</value>

</property>

<property>

<name>hive.exec.local.scratchdir</name>

<value>/tmp/hivescratch</value>

</property>

<property>

<name>hive.exec.stagingdir</name>

<value>/tmp/hive-staging</value>

</property>


<property>

<name>hive.querylog.location</name>

<value>/mnt/hadoop/hivelog</value>

</property>


</configuration>



<count.hql>

USE sapmle_db;


SELECT COUNT(1)

 FROM sample;


EXIT;


<job.properties>

  * workflow.xml 에 전달하는 파라미터는 . 으로 구분하면 안됨

jobName=Hive_Action_Example


appPath=hdfs://localhost:8020/user/hadoop/TEST/

oozie.wf.application.path=${appPath}

oozie.use.system.libpath=true


반응형