{"id":159531,"date":"2024-11-03T15:20:19","date_gmt":"2024-11-03T07:20:19","guid":{"rendered":"https:\/\/server.hk\/cnblog\/159531\/"},"modified":"2024-11-03T15:20:20","modified_gmt":"2024-11-03T07:20:20","slug":"%e7%b4%85%e8%89%b2%e9%80%a3%e6%8e%a5flink%e8%88%87redis%e7%9a%84%e6%b7%b1%e5%ba%a6%e5%b0%8d%e6%8e%a5%ef%bc%88redis%e9%80%a3%e6%8e%a5flink%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/159531\/","title":{"rendered":"\u7d05\u8272\u9023\u63a5flink\u8207redis\u7684\u6df1\u5ea6\u5c0d\u63a5\uff08redis\u9023\u63a5flink\uff09"},"content":{"rendered":"<h1 id=\"%e7%b4%85%e8%89%b2%e9%80%a3%e6%8e%a5flink%e8%88%87redis%e7%9a%84%e6%b7%b1%e5%ba%a6%e5%b0%8d%e6%8e%a5%ef%bc%88redis%e9%80%a3%e6%8e%a5flink%ef%bc%89-xcFDAJFxJQ\">\u7d05\u8272\u9023\u63a5Flink\u8207Redis\u7684\u6df1\u5ea6\u5c0d\u63a5\uff08Redis\u9023\u63a5Flink\uff09<\/h1>\n<p>\u5728\u7576\u4eca\u5927\u6578\u64da\u6642\u4ee3\uff0c\u6d41\u8655\u7406\u6280\u8853\u7684\u9700\u6c42\u65e5\u76ca\u589e\u52a0\u3002Apache Flink\u4f5c\u70ba\u4e00\u500b\u5f37\u5927\u7684\u6d41\u8655\u7406\u6846\u67b6\uff0c\u80fd\u5920\u5be6\u6642\u8655\u7406\u5927\u91cf\u6578\u64da\u3002\u800cRedis\u5247\u662f\u4e00\u500b\u9ad8\u6548\u7684\u9375\u503c\u6578\u64da\u5eab\uff0c\u5e38\u7528\u65bc\u7de9\u5b58\u548c\u6578\u64da\u5b58\u5132\u3002\u5c07Flink\u8207Redis\u9032\u884c\u6df1\u5ea6\u5c0d\u63a5\uff0c\u53ef\u4ee5\u5be6\u73fe\u9ad8\u6548\u7684\u6578\u64da\u8655\u7406\u548c\u5b58\u5132\uff0c\u5f9e\u800c\u63d0\u5347\u61c9\u7528\u7684\u6027\u80fd\u548c\u97ff\u61c9\u901f\u5ea6\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%81%b8%e6%93%87flink%e8%88%87redis%e7%9a%84%e7%b5%90%e5%90%88-xcFDAJFxJQ\">\u70ba\u4ec0\u9ebc\u9078\u64c7Flink\u8207Redis\u7684\u7d50\u5408<\/h2>\n<p>Flink\u7684\u6d41\u8655\u7406\u80fd\u529b\u4f7f\u5176\u80fd\u5920\u8655\u7406\u5be6\u6642\u6578\u64da\u6d41\uff0c\u800cRedis\u7684\u9ad8\u6027\u80fd\u6578\u64da\u5b58\u5132\u7279\u6027\u5247\u80fd\u5920\u5feb\u901f\u8b80\u53d6\u548c\u5beb\u5165\u6578\u64da\u3002\u9019\u7a2e\u7d50\u5408\u4f7f\u5f97\u958b\u767c\u8005\u80fd\u5920\u5728\u5be6\u6642\u6578\u64da\u8655\u7406\u4e2d\uff0c\u5229\u7528Redis\u7684\u5feb\u901f\u5b58\u53d6\u7279\u6027\uff0c\u5f9e\u800c\u63d0\u9ad8\u6574\u9ad4\u7cfb\u7d71\u7684\u6548\u7387\u3002<\/p>\n<h2 id=\"flink%e8%88%87redis%e7%9a%84%e5%9f%ba%e6%9c%ac%e6%9e%b6%e6%a7%8b-xcFDAJFxJQ\">Flink\u8207Redis\u7684\u57fa\u672c\u67b6\u69cb<\/h2>\n<p>\u5728\u5c07Flink\u8207Redis\u9032\u884c\u6574\u5408\u6642\uff0c\u901a\u5e38\u6703\u6d89\u53ca\u4ee5\u4e0b\u5e7e\u500b\u7d44\u4ef6\uff1a<\/p>\n<ul>\n<li><strong>Flink\u96c6\u7fa4\uff1a<\/strong>\u8ca0\u8cac\u6d41\u6578\u64da\u7684\u8655\u7406\u548c\u8a08\u7b97\u3002<\/li>\n<li><strong>Redis\u670d\u52d9\u5668\uff1a<\/strong>\u7528\u65bc\u5b58\u5132\u548c\u6aa2\u7d22\u6578\u64da\u3002<\/li>\n<li><strong>\u6578\u64da\u6e90\uff1a<\/strong>\u53ef\u4ee5\u662fKafka\u3001\u6587\u4ef6\u7cfb\u7d71\u6216\u5176\u4ed6\u6578\u64da\u6e90\u3002<\/li>\n<li><strong>\u6578\u64da\u63a5\u6536\u5668\uff1a<\/strong>\u5c07\u8655\u7406\u5f8c\u7684\u6578\u64da\u5beb\u5165Redis\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e5%af%a6%e7%8f%beflink%e8%88%87redis%e7%9a%84%e9%80%a3%e6%8e%a5-xcFDAJFxJQ\">\u5982\u4f55\u5be6\u73feFlink\u8207Redis\u7684\u9023\u63a5<\/h2>\n<p>\u8981\u5be6\u73feFlink\u8207Redis\u7684\u9023\u63a5\uff0c\u9996\u5148\u9700\u8981\u5728Flink\u9805\u76ee\u4e2d\u5f15\u5165Redis\u7684\u4f9d\u8cf4\u3002\u4ee5\u4e0b\u662fMaven\u7684\u4f9d\u8cf4\u914d\u7f6e\u793a\u4f8b\uff1a<\/p>\n<pre><code>\n&lt;dependency&gt;\n    &lt;groupId&gt;org.apache.flink&lt;\/groupId&gt;\n    &lt;artifactId&gt;flink-connector-redis_2.12&lt;\/artifactId&gt;\n    &lt;version&gt;1.14.0&lt;\/version&gt;\n&lt;\/dependency&gt;\n<\/code><\/pre>\n<h3 id=\"%e7%a4%ba%e4%be%8b%e4%bb%a3%e7%a2%bc-xcFDAJFxJQ\">\u793a\u4f8b\u4ee3\u78bc<\/h3>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5c07Flink\u6d41\u6578\u64da\u5beb\u5165Redis\uff1a<\/p>\n<pre><code>\nimport org.apache.flink.api.common.functions.MapFunction;\nimport org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;\nimport org.apache.flink.streaming.api.datastream.DataStream;\nimport org.apache.flink.streaming.connectors.redis.RedisSink;\nimport org.apache.flink.streaming.connectors.redis.util.RedisSinkFunction;\n\npublic class FlinkRedisExample {\n    public static void main(String[] args) throws Exception {\n        final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();\n\n        DataStream input = env.fromElements(\"data1\", \"data2\", \"data3\");\n\n        RedisSink redisSink = new RedisSink(new RedisSinkFunction() {\n            @Override\n            public void invoke(String value, Context context) {\n                \/\/ \u5beb\u5165Redis\u7684\u908f\u8f2f\n            }\n        });\n\n        input.addSink(redisSink);\n\n        env.execute(\"Flink Redis Example\");\n    }\n}\n<\/code><\/pre>\n<h2 id=\"%e6%80%a7%e8%83%bd%e8%80%83%e9%87%8f-xcFDAJFxJQ\">\u6027\u80fd\u8003\u91cf<\/h2>\n<p>\u5728\u9032\u884cFlink\u8207Redis\u7684\u6574\u5408\u6642\uff0c\u6027\u80fd\u662f\u9700\u8981\u91cd\u9ede\u8003\u91cf\u7684\u56e0\u7d20\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u512a\u5316\u5efa\u8b70\uff1a<\/p>\n<ul>\n<li><strong>\u6279\u91cf\u5beb\u5165\uff1a<\/strong>\u5c07\u591a\u689d\u6578\u64da\u5408\u4f75\u5f8c\u518d\u5beb\u5165Redis\uff0c\u53ef\u4ee5\u6e1b\u5c11\u7db2\u7d61\u5ef6\u9072\u3002<\/li>\n<li><strong>\u9023\u63a5\u6c60\uff1a<\/strong>\u4f7f\u7528\u9023\u63a5\u6c60\u4f86\u7ba1\u7406Redis\u9023\u63a5\uff0c\u907f\u514d\u983b\u7e41\u5efa\u7acb\u548c\u95dc\u9589\u9023\u63a5\u3002<\/li>\n<li><strong>\u6578\u64da\u5e8f\u5217\u5316\uff1a<\/strong>\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u5e8f\u5217\u5316\u65b9\u5f0f\uff0c\u4ee5\u63d0\u9ad8\u6578\u64da\u50b3\u8f38\u6548\u7387\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-xcFDAJFxJQ\">\u7d50\u8ad6<\/h2>\n<p>\u5c07Flink\u8207Redis\u9032\u884c\u6df1\u5ea6\u5c0d\u63a5\uff0c\u80fd\u5920\u5145\u5206\u767c\u63ee\u5169\u8005\u7684\u512a\u52e2\uff0c\u5be6\u73fe\u9ad8\u6548\u7684\u5be6\u6642\u6578\u64da\u8655\u7406\u548c\u5b58\u5132\u3002\u96a8\u8457\u5927\u6578\u64da\u6280\u8853\u7684\u767c\u5c55\uff0c\u9019\u7a2e\u7d50\u5408\u5c07\u5728\u5404\u7a2e\u61c9\u7528\u5834\u666f\u4e2d\u767c\u63ee\u8d8a\u4f86\u8d8a\u91cd\u8981\u7684\u4f5c\u7528\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u95dc\u65bc\u9ad8\u6548\u7684\u6578\u64da\u8655\u7406\u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\uff0c\u63a2\u7d22\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u548c <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u670d\u52d9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u7d05\u8272\u9023\u63a5\u5982\u4f55\u5be6\u73feFlink\u8207Redis\u7684\u6df1\u5ea6\u5c0d\u63a5\uff0c\u63d0\u5347\u6578\u64da\u8655\u7406\u6548\u7387\u8207\u5be6\u6642\u6027\u80fd\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-159531","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/159531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=159531"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/159531\/revisions"}],"predecessor-version":[{"id":159532,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/159531\/revisions\/159532"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=159531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=159531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=159531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}