abilashgt / study_bigdata

Apache License 2.0
0 stars 0 forks source link

spark kafka streaming reference #1

Open abilashgt opened 6 years ago

abilashgt commented 6 years ago

https://www.tutorialspoint.com/apache_kafka/apache_kafka_integration_spark.htm

https://spark.apache.org/docs/2.1.0/streaming-kafka-integration.html

abilashgt commented 6 years ago

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>com.abilashthomas.bigdata</groupId>
<artifactId>spark</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>basic-spark</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <scala.version>2.11.12</scala.version>
    <spark.version>2.1.0</spark.version>
</properties>

<repositories>
    <repository>
        <id>spark-kafka</id>
        <url>https://mvnrepository.com/artifact/org.apache.spark/spark-streaming-kafka_2.11</url>
    </repository>
</repositories>

<dependencies>
    <!-- scala -->
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>${scala.version}</version>
    </dependency>

    <!-- spark -->
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.11</artifactId>
      <version>${spark.version}</version>
    </dependency>
    <!-- spark sql and hive -->
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-sql_2.11</artifactId>
      <version>${spark.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-hive_2.11</artifactId>
        <version>${spark.version}</version>
    </dependency>
    <!-- spark streaming -->
    <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-streaming_2.11</artifactId>
        <version>${spark.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-streaming-kafka-0-8_2.11</artifactId>
        <version>${spark.version}</version>
    </dependency>
    <!--
    <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-streaming-kafka_2.10</artifactId>
        <version>1.6.3</version>
    </dependency> -->

    <!-- testing -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <finalName>basic-spark</finalName>

    <!-- scala compiler -->
    <plugins>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <version>2.15.2</version>
        <executions>
          <execution>
            <id>compile</id>
            <goals>
              <goal>compile</goal>
            </goals>
            <phase>compile</phase>
          </execution>
          <execution>
            <id>test-compile</id>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <phase>test-compile</phase>
          </execution>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- fatjar -->
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
      </plugin>

      <!-- exec main class
      alternative for executing: mvn exec:java -Dexec.mainClass="examples.SparkWordCount" -Dexec.args="testinputfile.txt 2"
      -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            <goals>
              <goal>java</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <mainClass>examples.WordCount</mainClass>
          <arguments>
            <argument>testinputfile.txt</argument>
            <argument>2</argument>
          </arguments>
        </configuration>
      </plugin>

    </plugins>
</build>

abilashgt commented 6 years ago

abi

proxy

proxy_user="xxx" proxy_pass="xxx" proxy_host="proxy.xxx.com" proxy_port="8080" export http_proxy="http://${proxy_user}:${proxy_pass}@${proxy_host}:${proxy_port}/" export https_proxy="http://${proxy_user}:${proxy_pass}@${proxy_host}:${proxy_port}/" export ftp_proxy="ftp://${proxy_user}:${proxy_pass}@${proxy_host}:${proxy_port}/" export no_proxy="localhost,127.0.0.0/8,127.0.1.1,10.132.211.61,.local,.tcs.com" export NO_PROXY="localhost,127.0.0.0/8,127.0.1.1,10.132.211.61,.local,.tcs.com" export all_proxy="{https_proxy}"

general

export PATH=$PATH:~/apps/bin

java maven

export _JAVA_OPTIONS="-Xms1024m -Xmx2048m" export JAVA_HOME=~/apps/java/default-jdk export MAVEN_HOME=~/apps/maven/default-maven export MVN_HOME=~/apps/maven/default-maven export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=proxy.tcs.com -Dhttps.proxyHost=proxy.tcs.com -Dhttp.proxyPort=8080 -Dhttps.proxyPort=8080 -Dhttps.proxyUser=984620 -Dhttp.proxyUser=984620 -Dhttps.proxyPassword=Gu!tar!6 -Dhttp.proxyPassword=Gu!tar!6"

git

export GIT_HOME=~/abi_store/apps/git/default-git

export PATH=$PATH:$GIT_HOME

sbt

export SBT_HOME=/apps/sbt/default-sbt

export PATH=$PATH:$SBT_HOME/bin

scala

export SCALA_HOME=/apps/scala/default-scala

export PATH=$PATH:$SCALA_HOME/bin

node

export NODE_HOME=/apps/node/default-node

export PATH=$PATH:$NODE_HOME/bin

hadoop

export HADOOP_HOME=~/apps/hadoop/default-hadoop export HADOOP_PREFIX=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib" export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop export YARN_CONF_DIR=$HADOOP_HOME/etc/hadoop export YARN_HOME=$HADOOP_HOME

export CLASSPATH=$CLASSPATH:$HADOOP_HOME/share/hadoop/hdfs:$HADOOP_HOME/share/hadoop/hdfs/lib:$HADOOP_HOME/share/hadoop/common:$HADOOP_HOME/share/hadoop/common/lib
export PATH=$PATH:$HADOOP_HOME/bin

spark

export SPARK_HOME=~/apps/spark/default-spark export PATH=$PATH:$SPARK_HOME/bin

hive

export HIVE_HOME=/apps/hive/default-hive

export PATH=$PATH:$HIVE_HOME/bin

export CLASSPATH=$CLASSPATH:$HIVE_HOME/lib

zookeeper

export ZOOKEEPER_HOME=~/apps/zookeeper/default-zookeeper export PATH=$PATH:$ZOOKEEPER_HOME/bin

kafka

export KAFKA_HOME=/apps/kafka/default-kafka

export PATH=$PATH:$KAFKA_HOME/bin

hbase

export HBASE_HOME=~/apps/hbase/default-hbase export PATH=$PATH:$HBASE_HOME/bin

mosquitto

export MOSQUITTO_HOME=~/apps/mosquitto/default-mosquitto export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${MOSQUITTO_HOME}/lib export PATH=$PATH:$MOSQUITTO_HOME/bin export PATH=$PATH:$MOSQUITTO_HOME/sbin