MAPREDUCE服务 MRS-Spark Structured Streaming状态操作样例程序开发思路:数据规划

时间:2024-06-13 09:39:22

数据规划

  1. 在kafka中生成模拟数据(需要有Kafka权限用户)。
  2. 确保集群安装完成,包括安装HDFS、Yarn、Spark2x和Kafka服务。
  3. 将Kafka的Broker配置参数“allow.everyone.if.no.acl.found”的值修改为“true”
  4. 创建Topic。

    {zkQuorum}表示ZooKeeper集群信息,格式为IP:port。

    $KAFKA_HOME/bin/kafka-topics.sh --create --zookeeper {zkQuorum}/kafka --replication-factor 1 --partitions 1 --topic {Topic}

  5. 启动Kafka的Producer,向Kafka发送数据。

    {ClassPath}表示工程jar包的存放路径,详细路径由用户指定,可参考在Linux环境中调测Spark应用章节中导出jar包的操作步骤。

    java -cp $SPARK_HOME/conf:$SPARK_HOME/jars/*:$SPARK_HOME/jars/streamingClient010/*:{ClassPath} com.huawei.bigdata.spark.examples.KafkaProducer {brokerlist} {topic} {number of events produce every 0.02s}

    示例:

    java -cp /opt/client/Spark2x/spark/conf:/opt/StructuredStreamingState-1.0.jar:/opt/client/Spark2x/spark/jars/*:/opt/client/Spark2x/spark/jars/streamingClient010/* com.huawei.bigdata.spark.examples.KafkaProducer xxx.xxx.xxx.xxx:21005,xxx.xxx.xxx.xxx:21005,xxx.xxx.xxx.xxx:21005 mytopic 10

support.huaweicloud.com/devg-lts-mrs/mrs_07_200124.html