大数据技术-StreamX学习笔记

部署StreamX

官网地址http://www.streamxhub.com/docs/intro

image-20220425212425551

解压streamx安装包

tar -zxvf streamx-console-service-1.2.2-bin.tar.gz -C /opt/module

部署streamx平台

在mysql中创建数据库

mysql> create database streamx charset utf8 collate utf8_general_ci;

初始化表

use streamx; 
source /opt/module/streamx-console-service-1.2.2/script/final.sql

配置连接信息vim streamx-console-service-1.2.2/conf/application.yml

image-20220425212906212

image-20220425213037947

启动server

/opt/module/streamx-console-service-1.2.2/bin/startup.sh

image-20220425213123893

访问页面http://服务器:10000/,默认用户名admin,密码streamx

img

系统配置

配置Flink Home

image-20220425213348281

image-20220425213410781

集成Flink Stream

编写flink项目,并将代码推送到远程仓库

pom依赖和打包方式

    <properties>
        <flink.version>1.13.6</flink.version>
        <scala.binary.version>2.11</scala.binary.version>
        <slf4j.version>1.7.30</slf4j.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-java</artifactId>
            <version>${flink.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-clients_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-runtime-web_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-to-slf4j</artifactId>
            <version>2.14.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <excludes>
                                    <exclude>com.google.code.findbugs:jsr305</exclude>
                                    <exclude>org.slf4j:*</exclude>
                                    <exclude>log4j:*</exclude>
                                </excludes>
                            </artifactSet>
                            <filters>
                                <filter>
                                    <!-- Do not copy the signatures in the META-INF folder.
                                    Otherwise, this might cause SecurityExceptions when using the JAR. -->
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <transformers combine.children="append">
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer">
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

编写一个最简单的测试,并流推送到远程代码仓库

image-20220425213655149

配置项目

image-20220425213907621

image-20220425214039258

编译项目

image-20220425214109211

第一次编译需要的时间比较久, 因为需要下载许多的依赖,编译成功会呈现上图的SUCCESSFUL绿色标签

提交应用

image-20220425214216281

image-20220425214526187

image-20220425214740738

image-20220425214932451

确认执行结果

image-20220425215200208

image-20220425215219427

集成Flink Sql

编写Flink Sql

create table s1 (
  id string,
  ts bigint,
  vc int
) with(
  'connector' = 'kafka',
  'topic' = 's1',
  'properties.bootstrap.servers' = 'hadoop102:9092,hadoop103:9092,hadoop104:9092',
  'properties.group.id' = 'czs',
  'scan.startup.mode' = 'latest-offset',
  'format' = 'csv'
);

create table s2 (
  id string,
  ts bigint,
  vc int
) with(
  'connector' = 'print'
);

insert into s2 select * from s1;

准备依赖

<dependency> 
    <groupId>org.apache.flink</groupId> 
    <artifactId>flink-connector-kafka_2.11</artifactId> 
    <version>1.13.6</version> 
</dependency>

image-20220425222248745

image-20220425222224080

image-20220425220514373

image-20220425222423987

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值