【已解决】Flink连接JDBC报错 org.apache.flink.runtime.client.JobExecutionException: Job execution failed.

2024-07-25 15:51:28 浏览数 (2)

代码语言:javascript复制
Caused by: org.apache.flink.runtime.JobException: Recovery is suppressed by NoRestartBackoffTimeStrategy
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 1,102 milliseconds ago.  The last packet sent successfully to the server was 1,095 milliseconds ago.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

环境:

Flink1.13.6 MySQL5.7.27 JDK8 Hadoop3.1.4 集成环境Idea2020

linux环境linux环境
Maven依赖
代码语言:javascript复制
<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>flink-test</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <flink.version>1.13.6</flink.version>
    </properties>

    <dependencies>
        <!--        JDBC            -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.21</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.38</version>
        </dependency>

        <!--        Flink           -->
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-java</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-streaming-java_2.12</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-shaded-hadoop-2-uber</artifactId>
            <version>2.7.5-10.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-connector-jdbc_2.12</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-clients_2.12</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <!--            Kafka           -->
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-connector-kafka_2.12</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <version>0.11.0.0</version>
        </dependency>
        <!--            Log4j         -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>


    </dependencies>

</project>
报错内容
代码语言:javascript复制
/*
* 提示:该行代码过长,系统自动注释不进行高亮。一键复制会移除系统注释 
* C:UsersLenovoDocumentsjdkbinjava.exe "-javaagent:D:Program FilesJetBrainsIntelliJ IDEA 2020.1.4libidea_rt.jar=10816:D:Program FilesJetBrainsIntelliJ IDEA 2020.1.4bin" -Dfile.encoding=UTF-8 -classpath C:UsersLenovoDocumentsjdkjrelibcharsets.jar;C:UsersLenovoDocumentsjdkjrelibdeploy.jar;C:UsersLenovoDocumentsjdkjrelibextaccess-bridge-64.jar;C:UsersLenovoDocumentsjdkjrelibextcldrdata.jar;C:UsersLenovoDocumentsjdkjrelibextdnsns.jar;C:UsersLenovoDocumentsjdkjrelibextjaccess.jar;C:UsersLenovoDocumentsjdkjrelibextjfxrt.jar;C:UsersLenovoDocumentsjdkjrelibextlocaledata.jar;C:UsersLenovoDocumentsjdkjrelibextnashorn.jar;C:UsersLenovoDocumentsjdkjrelibextsunec.jar;C:UsersLenovoDocumentsjdkjrelibextsunjce_provider.jar;C:UsersLenovoDocumentsjdkjrelibextsunmscapi.jar;C:UsersLenovoDocumentsjdkjrelibextsunpkcs11.jar;C:UsersLenovoDocumentsjdkjrelibextzipfs.jar;C:UsersLenovoDocumentsjdkjrelibjavaws.jar;C:UsersLenovoDocumentsjdkjrelibjce.jar;C:UsersLenovoDocumentsjdkjrelibjfr.jar;C:UsersLenovoDocumentsjdkjrelibjfxswt.jar;C:UsersLenovoDocumentsjdkjrelibjsse.jar;C:UsersLenovoDocumentsjdkjrelibmanagement-agent.jar;C:UsersLenovoDocumentsjdkjrelibplugin.jar;C:UsersLenovoDocumentsjdkjrelibresources.jar;C:UsersLenovoDocumentsjdkjrelibrt.jar;D:BD2302BD_codeflink-testtargetclasses;E:Mavenrepositoryorgapacheflinkflink-streaming-java_2.121.13.6flink-streaming-java_2.12-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-core1.13.6flink-core-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-annotations1.13.6flink-annotations-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-metrics-core1.13.6flink-metrics-core-1.13.6.jar;E:Mavenrepositoryorgapachecommonscommons-lang33.3.2commons-lang3-3.3.2.jar;E:Mavenrepositorycomesotericsoftwarekryokryo2.24.0kryo-2.24.0.jar;E:Mavenrepositorycomesotericsoftwareminlogminlog1.2minlog-1.2.jar;E:Mavenrepositoryorgobjenesisobjenesis2.1objenesis-2.1.jar;E:Mavenrepositorycommons-collectionscommons-collections3.2.2commons-collections-3.2.2.jar;E:Mavenrepositoryorgapachecommonscommons-compress1.21commons-compress-1.21.jar;E:Mavenrepositoryorgapacheflinkflink-file-sink-common1.13.6flink-file-sink-common-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-runtime_2.121.13.6flink-runtime_2.12-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-queryable-state-client-java1.13.6flink-queryable-state-client-java-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-hadoop-fs1.13.6flink-hadoop-fs-1.13.6.jar;E:Mavenrepositorycommons-iocommons-io2.8.0commons-io-2.8.0.jar;E:Mavenrepositoryorgapacheflinkflink-shaded-netty4.1.49.Final-13.0flink-shaded-netty-4.1.49.Final-13.0.jar;E:Mavenrepositoryorgapacheflinkflink-shaded-jackson2.12.1-13.0flink-shaded-jackson-2.12.1-13.0.jar;E:Mavenrepositoryorgapacheflinkflink-shaded-zookeeper-33.4.14-13.0flink-shaded-zookeeper-3-3.4.14-13.0.jar;E:Mavenrepositoryorgjavassistjavassist3.24.0-GAjavassist-3.24.0-GA.jar;E:Mavenrepositoryorgscala-langscala-library2.12.7scala-library-2.12.7.jar;E:Mavenrepositorycomtypesafeakkaakka-actor_2.122.5.21akka-actor_2.12-2.5.21.jar;E:Mavenrepositorycomtypesafeconfig1.3.3config-1.3.3.jar;E:Mavenrepositoryorgscala-langmodulesscala-java8-compat_2.12.8.0scala-java8-compat_2.12-0.8.0.jar;E:Mavenrepositorycomtypesafeakkaakka-stream_2.122.5.21akka-stream_2.12-2.5.21.jar;E:Mavenrepositoryorgreactivestreamsreactive-streams1.0.2reactive-streams-1.0.2.jar;E:Mavenrepositorycomtypesafessl-config-core_2.12.3.7ssl-config-core_2.12-0.3.7.jar;E:Mavenrepositoryorgscala-langmodulesscala-parser-combinators_2.121.1.1scala-parser-combinators_2.12-1.1.1.jar;E:Mavenrepositorycomtypesafeakkaakka-protobuf_2.122.5.21akka-protobuf_2.12-2.5.21.jar;E:Mavenrepositorycomtypesafeakkaakka-slf4j_2.122.5.21akka-slf4j_2.12-2.5.21.jar;E:Mavenrepositoryorgclappergrizzled-slf4j_2.121.3.2grizzled-slf4j_2.12-1.3.2.jar;E:Mavenrepositorycomgithubscoptscopt_2.123.5.0scopt_2.12-3.5.0.jar;E:Mavenrepositorycomtwitterchill_2.12.7.6chill_2.12-0.7.6.jar;E:Mavenrepositorycomtwitterchill-java.7.6chill-java-0.7.6.jar;E:Mavenrepositoryorglz4lz4-java1.6.0lz4-java-1.6.0.jar;E:Mavenrepositoryorgapacheflinkflink-java1.13.6flink-java-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-shaded-guava18.0-13.0flink-shaded-guava-18.0-13.0.jar;E:Mavenrepositoryorgapachecommonscommons-math33.5commons-math3-3.5.jar;E:Mavenrepositoryorgslf4jslf4j-api1.7.15slf4j-api-1.7.15.jar;E:Mavenrepositorycomgooglecodefindbugsjsr3051.3.9jsr305-1.3.9.jar;E:Mavenrepositoryorgapacheflinkforce-shading1.13.6force-shading-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-clients_2.121.13.6flink-clients_2.12-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-optimizer_2.121.13.6flink-optimizer_2.12-1.13.6.jar;E:Mavenrepositorycommons-clicommons-cli1.3.1commons-cli-1.3.1.jar;E:Mavenrepositoryorgapacheflinkflink-table-api-java-bridge_2.121.13.6flink-table-api-java-bridge_2.12-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-table-api-java1.13.6flink-table-api-java-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-table-planner-blink_2.121.13.6flink-table-planner-blink_2.12-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-table-api-scala_2.121.13.6flink-table-api-scala_2.12-1.13.6.jar;E:Mavenrepositoryorgscala-langscala-reflect2.12.7scala-reflect-2.12.7.jar;E:Mavenrepositoryorgscala-langscala-compiler2.12.7scala-compiler-2.12.7.jar;E:Mavenrepositoryorgscala-langmodulesscala-xml_2.121.0.6scala-xml_2.12-1.0.6.jar;E:Mavenrepositoryorgapacheflinkflink-table-api-scala-bridge_2.121.13.6flink-table-api-scala-bridge_2.12-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-scala_2.121.13.6flink-scala_2.12-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-streaming-scala_2.121.13.6flink-streaming-scala_2.12-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-table-runtime-blink_2.121.13.6flink-table-runtime-blink_2.12-1.13.6.jar;E:Mavenrepositoryorgcodehausjaninojanino3.0.11janino-3.0.11.jar;E:Mavenrepositoryorgcodehausjaninocommons-compiler3.0.11commons-compiler-3.0.11.jar;E:Mavenrepositoryorgapachecalciteavaticaavatica-core1.17.0avatica-core-1.17.0.jar;E:Mavenrepositorymysqlmysql-connector-java5.1.38mysql-connector-java-5.1.38.jar;E:Mavenrepositorycomververicaflink-connector-mysql-cdc2.1.0flink-connector-mysql-cdc-2.1.0.jar;E:Mavenrepositorycomververicaflink-connector-debezium2.1.0flink-connector-debezium-2.1.0.jar;E:Mavenrepositoryiodebeziumdebezium-api1.5.4.Finaldebezium-api-1.5.4.Final.jar;E:Mavenrepositoryiodebeziumdebezium-embedded1.5.4.Finaldebezium-embedded-1.5.4.Final.jar;E:Mavenrepositoryorgapachekafkaconnect-api2.7.0connect-api-2.7.0.jar;E:Mavenrepositoryjavaxwsrsjavax.ws.rs-api2.1.1javax.ws.rs-api-2.1.1.jar;E:Mavenrepositoryorgapachekafkaconnect-runtime2.7.0connect-runtime-2.7.0.jar;E:Mavenrepositoryorgapachekafkakafka-tools2.7.0kafka-tools-2.7.0.jar;E:Mavenrepositorynetsourceforgeargparse4jargparse4j.7.0argparse4j-0.7.0.jar;E:Mavenrepositoryorgapachekafkaconnect-transforms2.7.0connect-transforms-2.7.0.jar;E:Mavenrepositorycomfasterxmljacksonjaxrsjackson-jaxrs-json-provider2.10.5jackson-jaxrs-json-provider-2.10.5.jar;E:Mavenrepositorycomfasterxmljacksonjaxrsjackson-jaxrs-base2.10.5jackson-jaxrs-base-2.10.5.jar;E:Mavenrepositorycomfasterxmljacksonmodulejackson-module-jaxb-annotations2.10.5jackson-module-jaxb-annotations-2.10.5.jar;E:Mavenrepositoryjakartaxmlbindjakarta.xml.bind-api2.3.2jakarta.xml.bind-api-2.3.2.jar;E:Mavenrepositoryjakartaactivationjakarta.activation-api1.2.1jakarta.activation-api-1.2.1.jar;E:Mavenrepositoryorgglassfishjerseycontainersjersey-container-servlet2.31jersey-container-servlet-2.31.jar;E:Mavenrepositoryorgglassfishjerseycontainersjersey-container-servlet-core2.31jersey-container-servlet-core-2.31.jar;E:Mavenrepositoryorgglassfishhk2externaljakarta.inject2.6.1jakarta.inject-2.6.1.jar;E:Mavenrepositoryjakartawsrsjakarta.ws.rs-api2.1.6jakarta.ws.rs-api-2.1.6.jar;E:Mavenrepositoryorgglassfishjerseyinjectjersey-hk22.31jersey-hk2-2.31.jar;E:Mavenrepositoryorgglassfishhk2hk2-locator2.6.1hk2-locator-2.6.1.jar;E:Mavenrepositoryorgglassfishhk2externalaopalliance-repackaged2.6.1aopalliance-repackaged-2.6.1.jar;E:Mavenrepositoryorgglassfishhk2hk2-api2.6.1hk2-api-2.6.1.jar;E:Mavenrepositoryorgglassfishhk2hk2-utils2.6.1hk2-utils-2.6.1.jar;E:Mavenrepositoryjavaxxmlbindjaxb-api2.3.0jaxb-api-2.3.0.jar;E:Mavenrepositoryjavaxactivationactivation1.1.1activation-1.1.1.jar;E:Mavenrepositoryorgeclipsejettyjetty-server9.4.33.v20201020jetty-server-9.4.33.v20201020.jar;E:Mavenrepositoryjavaxservletjavax.servlet-api3.1.0javax.servlet-api-3.1.0.jar;E:Mavenrepositoryorgeclipsejettyjetty-http9.4.33.v20201020jetty-http-9.4.33.v20201020.jar;E:Mavenrepositoryorgeclipsejettyjetty-io9.4.33.v20201020jetty-io-9.4.33.v20201020.jar;E:Mavenrepositoryorgeclipsejettyjetty-servlet9.4.33.v20201020jetty-servlet-9.4.33.v20201020.jar;E:Mavenrepositoryorgeclipsejettyjetty-security9.4.33.v20201020jetty-security-9.4.33.v20201020.jar;E:Mavenrepositoryorgeclipsejettyjetty-servlets9.4.33.v20201020jetty-servlets-9.4.33.v20201020.jar;E:Mavenrepositoryorgeclipsejettyjetty-continuation9.4.33.v20201020jetty-continuation-9.4.33.v20201020.jar;E:Mavenrepositoryorgeclipsejettyjetty-util9.4.33.v20201020jetty-util-9.4.33.v20201020.jar;E:Mavenrepositoryorgeclipsejettyjetty-client9.4.33.v20201020jetty-client-9.4.33.v20201020.jar;E:Mavenrepositoryorgreflectionsreflections.9.12reflections-0.9.12.jar;E:Mavenrepositoryorgapachemavenmaven-artifact3.6.3maven-artifact-3.6.3.jar;E:Mavenrepositoryorgcodehausplexusplexus-utils3.2.1plexus-utils-3.2.1.jar;E:Mavenrepositoryorgapachekafkaconnect-json2.7.0connect-json-2.7.0.jar;E:Mavenrepositorycomfasterxmljacksondatatypejackson-datatype-jdk82.10.5jackson-datatype-jdk8-2.10.5.jar;E:Mavenrepositoryorgapachekafkaconnect-file2.7.0connect-file-2.7.0.jar;E:Mavenrepositoryiodebeziumdebezium-connector-mysql1.5.4.Finaldebezium-connector-mysql-1.5.4.Final.jar;E:Mavenrepositoryiodebeziumdebezium-core1.5.4.Finaldebezium-core-1.5.4.Final.jar;E:Mavenrepositorycomfasterxmljacksoncorejackson-core2.10.5jackson-core-2.10.5.jar;E:Mavenrepositorycomfasterxmljacksoncorejackson-databind2.10.5jackson-databind-2.10.5.jar;E:Mavenrepositorycomfasterxmljacksoncorejackson-annotations2.10.5jackson-annotations-2.10.5.jar;E:Mavenrepositorycomfasterxmljacksondatatypejackson-datatype-jsr3102.10.5jackson-datatype-jsr310-2.10.5.jar;E:Mavenrepositorycomgoogleguavaguava30.0-jreguava-30.0-jre.jar;E:Mavenrepositorycomgoogleguavafailureaccess1.0.1failureaccess-1.0.1.jar;E:Mavenrepositorycomgoogleguavalistenablefuture9999.0-empty-to-avoid-conflict-with-guavalistenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;E:Mavenrepositoryiodebeziumdebezium-ddl-parser1.5.4.Finaldebezium-ddl-parser-1.5.4.Final.jar;E:Mavenrepositoryorgantlrantlr4-runtime4.7.2antlr4-runtime-4.7.2.jar;E:Mavenrepositorycomzendeskmysql-binlog-connector-java.25.1mysql-binlog-connector-java-0.25.1.jar;E:Mavenrepositorycomesrigeometryesri-geometry-api2.2.0esri-geometry-api-2.2.0.jar;E:MavenrepositorycomzaxxerHikariCP4.0.3HikariCP-4.0.3.jar;E:Mavenrepositoryorgapacheflinkflink-table-common1.13.6flink-table-common-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-connector-files1.13.6flink-connector-files-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-shaded-asm-77.1-13.0flink-shaded-asm-7-7.1-13.0.jar;E:Mavenrepositoryorgapacheflinkflink-json1.13.6flink-json-1.13.6.jar;E:Mavenrepositoryorgprojectlomboklombok1.18.24lombok-1.18.24.jar;E:Mavenrepositorycomalibabafastjson1.2.78fastjson-1.2.78.jar;E:Mavenrepositoryredisclientsjedis3.2.0jedis-3.2.0.jar;E:Mavenrepositoryorgapachecommonscommons-pool22.6.2commons-pool2-2.6.2.jar;E:Mavenrepositoryorgapacheflinkflink-shaded-hadoop-2-uber2.6.5-10.0flink-shaded-hadoop-2-uber-2.6.5-10.0.jar;E:Mavenrepositoryorgslf4jslf4j-log4j121.7.15slf4j-log4j12-1.7.15.jar;E:Mavenrepositorylog4jlog4j1.2.17log4j-1.2.17.jar;E:Mavenrepositoryorgapacheflinkflink-connector-jdbc_2.121.13.6flink-connector-jdbc_2.12-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-connector-kafka_2.121.13.6flink-connector-kafka_2.12-1.13.6.jar;E:Mavenrepositoryorgapacheflinkflink-connector-base1.13.6flink-connector-base-1.13.6.jar;E:Mavenrepositoryorgapachebahirflink-connector-redis_2.121.1.0flink-connector-redis_2.12-1.1.0.jar;E:Mavenrepositorycnhutoolhutool-json5.8.5hutool-json-5.8.5.jar;E:Mavenrepositorycnhutoolhutool-core5.8.5hutool-core-5.8.5.jar;E:Mavenrepositoryorgapachekafkakafka-clients.11.0.0kafka-clients-0.11.0.0.jar;E:Mavenrepositorynetjpountzlz4lz41.3.0lz4-1.3.0.jar;E:Mavenrepositoryorgxerialsnappysnappy-java1.1.2.6snappy-java-1.1.2.6.jar day10610.FlinkJDBC
*/
log4j:WARN No appenders could be found for logger (org.apache.flink.api.java.ClosureCleaner).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.apache.flink.runtime.client.JobExecutionException: Job execution failed.
	at org.apache.flink.runtime.jobmaster.JobResult.toJobExecutionResult(JobResult.java:144)
	at org.apache.flink.runtime.minicluster.MiniClusterJobClient.lambda$getJobExecutionResult$3(MiniClusterJobClient.java:137)
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616)
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:591)
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
	at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975)
	at org.apache.flink.runtime.rpc.akka.AkkaInvocationHandler.lambda$invokeRpc$0(AkkaInvocationHandler.java:237)
	at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
	at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750)
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
	at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975)
	at org.apache.flink.runtime.concurrent.FutureUtils$1.onComplete(FutureUtils.java:1081)
	at akka.dispatch.OnComplete.internal(Future.scala:264)
	at akka.dispatch.OnComplete.internal(Future.scala:261)
	at akka.dispatch.japi$CallbackBridge.apply(Future.scala:191)
	at akka.dispatch.japi$CallbackBridge.apply(Future.scala:188)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
	at org.apache.flink.runtime.concurrent.Executors$DirectExecutionContext.execute(Executors.java:73)
	at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:68)
	at scala.concurrent.impl.Promise$DefaultPromise.$anonfun$tryComplete$1(Promise.scala:284)
	at scala.concurrent.impl.Promise$DefaultPromise.$anonfun$tryComplete$1$adapted(Promise.scala:284)
	at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:284)
	at akka.pattern.PromiseActorRef.$bang(AskSupport.scala:573)
	at akka.pattern.PipeToSupport$PipeableFuture$$anonfun$pipeTo$1.applyOrElse(PipeToSupport.scala:22)
	at akka.pattern.PipeToSupport$PipeableFuture$$anonfun$pipeTo$1.applyOrElse(PipeToSupport.scala:21)
	at scala.concurrent.Future.$anonfun$andThen$1(Future.scala:532)
	at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:29)
	at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:29)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
	at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
	at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:81)
	at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)
	at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
	at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:44)
	at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
	at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
	at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
	at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: org.apache.flink.runtime.JobException: Recovery is suppressed by NoRestartBackoffTimeStrategy
	at org.apache.flink.runtime.executiongraph.failover.flip1.ExecutionFailureHandler.handleFailure(ExecutionFailureHandler.java:138)
	at org.apache.flink.runtime.executiongraph.failover.flip1.ExecutionFailureHandler.getFailureHandlingResult(ExecutionFailureHandler.java:82)
	at org.apache.flink.runtime.scheduler.DefaultScheduler.handleTaskFailure(DefaultScheduler.java:216)
	at org.apache.flink.runtime.scheduler.DefaultScheduler.maybeHandleTaskFailure(DefaultScheduler.java:206)
	at org.apache.flink.runtime.scheduler.DefaultScheduler.updateTaskExecutionStateInternal(DefaultScheduler.java:197)
	at org.apache.flink.runtime.scheduler.SchedulerBase.updateTaskExecutionState(SchedulerBase.java:682)
	at org.apache.flink.runtime.scheduler.SchedulerNG.updateTaskExecutionState(SchedulerNG.java:79)
	at org.apache.flink.runtime.jobmaster.JobMaster.updateTaskExecutionState(JobMaster.java:435)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleRpcInvocation(AkkaRpcActor.java:305)
	at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleRpcMessage(AkkaRpcActor.java:212)
	at org.apache.flink.runtime.rpc.akka.FencedAkkaRpcActor.handleRpcMessage(FencedAkkaRpcActor.java:77)
	at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleMessage(AkkaRpcActor.java:158)
	at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:26)
	at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:21)
	at scala.PartialFunction.applyOrElse(PartialFunction.scala:123)
	at scala.PartialFunction.applyOrElse$(PartialFunction.scala:122)
	at akka.japi.pf.UnitCaseStatement.applyOrElse(CaseStatements.scala:21)
	at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:171)
	at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:172)
	at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:172)
	at akka.actor.Actor.aroundReceive(Actor.scala:517)
	at akka.actor.Actor.aroundReceive$(Actor.scala:515)
	at akka.actor.AbstractActor.aroundReceive(AbstractActor.scala:225)
	at akka.actor.ActorCell.receiveMessage(ActorCell.scala:592)
	at akka.actor.ActorCell.invoke(ActorCell.scala:561)
	at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:258)
	at akka.dispatch.Mailbox.run(Mailbox.scala:225)
	at akka.dispatch.Mailbox.exec(Mailbox.scala:235)
	... 4 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 1,102 milliseconds ago.  The last packet sent successfully to the server was 1,095 milliseconds ago.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981)
	at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:164)
	at com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4801)
	at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1643)
	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1215)
	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2255)
	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2286)
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2085)
	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:795)
	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:247)
	at day10610.FlinkJDBC$MySQLSink.open(FlinkJDBC.java:35)
	at org.apache.flink.api.common.functions.util.FunctionUtils.openFunction(FunctionUtils.java:34)
	at org.apache.flink.streaming.api.operators.AbstractUdfStreamOperator.open(AbstractUdfStreamOperator.java:102)
	at org.apache.flink.streaming.api.operators.StreamSink.open(StreamSink.java:46)
	at org.apache.flink.streaming.runtime.tasks.OperatorChain.initializeStateAndOpenOperators(OperatorChain.java:442)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreGates(StreamTask.java:585)
	at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.call(StreamTaskActionExecutor.java:55)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.executeRestore(StreamTask.java:565)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.runWithCleanUpOnFail(StreamTask.java:650)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restore(StreamTask.java:540)
	at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:759)
	at org.apache.flink.runtime.taskmanager.Task.run(Task.java:566)
	at java.lang.Thread.run(Thread.java:750)
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
	at sun.security.ssl.HandshakeContext.<init>(HandshakeContext.java:171)
	at sun.security.ssl.ClientHandshakeContext.<init>(ClientHandshakeContext.java:106)
	at sun.security.ssl.TransportContext.kickstart(TransportContext.java:238)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:410)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:389)
	at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:149)
	... 30 more

Process finished with exit code 1
运行代码
代码语言:javascript复制
package day10610;

import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class FlinkJDBC {

    public static void main(String[] args) throws Exception {
        //TODO 1.env-准备环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setRuntimeMode(RuntimeExecutionMode.AUTOMATIC);
        //TODO 2.source-加载数据
        DataStream<Student> studentDS = env.fromElements(new Student(0, "lucy", 19));
        //TODO 3.transformation-数据转换处理
        //TODO 4.sink-数据输出
        studentDS.addSink(new MySQLSink());
        //TODO 5.execute-执行
        env.execute();
    }

    private static class MySQLSink extends RichSinkFunction<Student> {
        Connection conn = null;
        PreparedStatement ps = null;

        //连接JDBC一次
        @Override
        public void open(Configuration parameters) throws Exception {
            conn = DriverManager.getConnection("jdbc:mysql://hadoop10:3306/yangyulin?useSSL=true", "root", "0000");
            ps = conn.prepareStatement("INSERT INTO `t_student` (`id`, `name`, `age`) VALUES (999, ?, ?)");
        }

        @Override
        public void invoke(Student value, Context context) throws Exception {
            //设置?占位符参数
            ps.setString(1, value.getName());
            ps.setInt(2, value.getAge());
            //执行SQL将数据插入到MySQL
            ps.executeUpdate();
        }

        //关闭JDBC一次
        @Override
        public void close() throws Exception {
            if (conn != null) conn.close();
            if (ps != null) ps.close();

        }
    }
}

###修改代码

代码语言:javascript复制
 conn = DriverManager.getConnection("jdbc:mysql://hadoop10:3306/yangyulin?useSSL=true", "root", "0000");

修改为

代码语言:javascript复制
conn = DriverManager.getConnection("jdbc:mysql://hadoop10:3306/yangyulin?useSSL=false", "root", "0000");

true修改为false即可


2023-6-28更新: Job execution failed.这个报错是Flink给出job中的运行时异常,需要做的是查看log,检查业务代码中的逻辑。

0 人点赞