oozie Hive demo

job.properties

nameNode=hdfs://nameservice
jobTracker=yarnRM
queueName=default
examplesRoot=examples
#oozie.libpath=${nameNode}/user/${user.name}/lib

oozie.wf.application.path=${nameNode}/user/${user.name}/oozie/hive
#outputdir=output-${data.M}

workflow.xml



<workflow-app xmlns="uri:oozie:workflow:0.2" name="hive-wf">
    <start to="hive-node"/>

    <action name="hive-node">
        <hive xmlns="uri:oozie:hive-action:0.2">
            <job-tracker>${jobTracker}job-tracker>
            <name-node>${nameNode}name-node>
            <prepare>
                <delete path="${nameNode}/user/${wf:user()}/output-data/hive"/>
                <mkdir path="${nameNode}/user/${wf:user()}/output-data"/>
            prepare>
            <configuration>
                <property>  
                    <name>oozie.hive.defaultsname>  
                    <value>my-hive-default.xmlvalue>  
                property> 
                <property>
                    <name>mapred.job.queue.namename>
                    <value>${queueName}value>
                property>


                <property>  
                      <name>hive.metastore.localname>  
                      <value>falsevalue>  
                      <description>controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVMdescription>  
                    property>  

                    <property>  
                      <name>hive.metastore.urisname>  
                      <value>thrift://crxy163:9083value>  
                      <description>host and port for the thrift metastore serverdescription>  
                    property>  

                    <property>  
                      <name>hive.metastore.warehouse.dirname>  
                      <value>/user/hive/warehousevalue>  
                      <description>location of default database for the warehousedescription>  
                    property> 

            configuration>
            <script>script.qscript>
            <param>INPUT=/user/${wf:user()}/input-data/tableparam>
            <param>OUTPUT=/user/${wf:user()}/output-data/hiveparam>
        hive>
        <ok to="end"/>
        <error to="fail"/>
    action>

    <kill name="fail">
        <message>Hive failed, error message[${wf:errorMessage(wf:lastErrorNode())}]message>
    kill>
    <end name="end"/>
workflow-app>

my-hive-default.xml




<configuration>
  <property>
    <name>hive.metastore.localname>
    <value>falsevalue>
  property>
  <property>
    <name>hive.metastore.urisname>
    <value>thrift://crxy163:9083value>
  property>
  <property>
    <name>hive.metastore.warehouse.dirname>
    <value>/user/hive/warehousevalue>
  property>
  <property>
    <name>hive.warehouse.subdir.inherit.permsname>
    <value>truevalue>
  property>
  <property>
    <name>mapred.reduce.tasksname>
    <value>-1value>
  property>
  <property>
    <name>hive.exec.reducers.bytes.per.reducername>
    <value>1073741824value>
  property>
  <property>
    <name>hive.exec.reducers.maxname>
    <value>999value>
  property>
  <property>
    <name>hive.metastore.execute.setuginame>
    <value>truevalue>
  property>
configuration>

script.q

create external table IF NOT EXISTS  test(
 IDC_ID    bigint,
 IDC_NAME    string,
 HOUSE_ID  string,
 HOUSE_NAME    string,
 SRCIP    string,
 DESTIP    string,
 SRC_PORT    int,
 DEST_PORT    int,
 DOMAIN_NAME    string,
 URL    string,
 ACCESS_TIME    string
)
partitioned by (datepart string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\|' STORED AS SEQUENCEFILE
location '/user/boco/impala/test/';

你可能感兴趣的:(oozie)