{"id":192804,"date":"2020-07-07T09:18:12","date_gmt":"2020-07-07T01:18:12","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=192804"},"modified":"2020-06-27T11:20:07","modified_gmt":"2020-06-27T03:20:07","slug":"real-time-data-architecture","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/real-time-data-architecture.html","title":{"rendered":"\u5b9e\u65f6\u6570\u636e\u67b6\u6784\u4f53\u7cfb\u5efa\u8bbe\u6307\u5357"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u968f\u7740\u4e92\u8054\u7f51\u7684\u53d1\u5c55\u8fdb\u5165\u4e0b\u534a\u573a\uff0c\u6570\u636e\u7684\u65f6\u6548\u6027\u5bf9\u4f01\u4e1a\u7684\u7cbe\u7ec6\u5316\u8fd0\u8425\u8d8a\u6765\u8d8a\u91cd\u8981\uff0c \u5546\u573a\u5982\u6218\u573a\uff0c\u5728\u6bcf\u5929\u4ea7\u751f\u7684\u6d77\u91cf\u6570\u636e\u4e2d\uff0c\u5982\u4f55\u80fd\u5b9e\u65f6\u6709\u6548\u7684\u6316\u6398\u51fa\u6709\u4ef7\u503c\u7684\u4fe1\u606f\uff0c \u5bf9\u4f01\u4e1a\u7684\u51b3\u7b56\u8fd0\u8425\u7b56\u7565\u8c03\u6574\u6709\u5f88\u5927\u5e2e\u52a9\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u968f\u7740\u4e92\u8054\u7f51\u7684\u53d1\u5c55\u8fdb\u5165\u4e0b\u534a\u573a\uff0c\u6570\u636e\u7684\u65f6\u6548\u6027\u5bf9\u4f01\u4e1a\u7684\u7cbe\u7ec6\u5316\u8fd0\u8425\u8d8a\u6765\u8d8a\u91cd\u8981\uff0c \u5546\u573a\u5982\u6218\u573a\uff0c\u5728\u6bcf\u5929\u4ea7\u751f\u7684\u6d77\u91cf\u6570\u636e\u4e2d\uff0c\u5982\u4f55\u80fd\u5b9e\u65f6\u6709\u6548\u7684\u6316\u6398\u51fa\u6709\u4ef7\u503c\u7684\u4fe1\u606f\uff0c \u5bf9\u4f01\u4e1a\u7684\u51b3\u7b56\u8fd0\u8425\u7b56\u7565\u8c03\u6574\u6709\u5f88\u5927\u5e2e\u52a9\u3002<\/p>\n

\u6b64\u5916\uff0c\u968f\u7740 5G \u6280\u672f\u7684\u6210\u719f\u3001\u5e7f\u6cdb\u5e94\u7528\uff0c \u5bf9\u4e8e\u5de5\u4e1a\u4e92\u8054\u7f51\u3001\u7269\u8054\u7f51\u7b49\u6570\u636e\u65f6\u6548\u6027\u8981\u6c42\u975e\u5e38\u9ad8\u7684\u884c\u4e1a\uff0c\u4f01\u4e1a\u5c31\u66f4\u9700\u8981\u4e00\u5957\u5b8c\u6574\u6210\u719f\u7684\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u6765\u63d0\u9ad8\u81ea\u8eab\u7684\u884c\u4e1a\u7ade\u4e89\u529b\u3002<\/p>\n

\u672c\u6587\u4ece\u4e0a\u8ff0\u73b0\u72b6\u53ca\u5b9e\u65f6\u6570\u636e\u9700\u6c42\u51fa\u53d1\uff0c\u7ed3\u5408\u5de5\u4e1a\u754c\u6848\u4f8b\u3001\u7b14\u8005\u7684\u5b9e\u65f6\u6570\u636e\u5f00\u53d1\u7ecf\u9a8c\uff0c \u68b3\u7406\u603b\u7ed3\u4e86\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u5efa\u8bbe\u7684\u603b\u4f53\u65b9\u6848\uff0c\u672c\u6587\u4e3b\u8981\u5206\u4e3a\u4e09\u4e2a\u90e8\u5206\uff1a<\/p>\n

\u7b2c\u4e00\u90e8\u5206\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5f53\u4e0b\u5728\u5de5\u4e1a\u754c\u6bd4\u8f83\u706b\u70ed\u7684\u5b9e\u65f6\u8ba1\u7b97\u5f15\u64ce Flink \u5728\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u5efa\u8bbe\u8fc7\u7a0b\u4e2d\u4e3b\u8981\u7684\u5e94\u7528\u573a\u666f\u53ca\u5bf9\u5e94\u89e3\u51b3\u65b9\u6848;
\n\u7b2c\u4e8c\u90e8\u5206\u4ece\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u67b6\u6784\u3001\u5b9e\u65f6\u6570\u636e\u6a21\u578b\u5206\u5c42\u3001\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u5efa\u8bbe\u65b9\u5f0f\u3001\u6d41\u6279\u4e00\u4f53\u5b9e\u65f6\u6570\u636e\u67b6\u6784\u53d1\u5c55\u7b49\u56db\u4e2a\u65b9\u9762\u601d\u8003\u4e86\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u7684\u5efa\u8bbe\u65b9\u6848;
\n\u7b2c\u4e09\u90e8\u5206\u5219\u4ee5\u4e00\u4e2a\u5177\u4f53\u6848\u4f8b\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Flink SQL \u5b8c\u6210\u5b9e\u65f6\u6570\u636e\u7edf\u8ba1\u7c7b\u9700\u6c42\u3002<\/p>\n

\u4e00\u3001Flink \u5b9e\u65f6\u5e94\u7528\u573a\u666f<\/strong><\/div>\n

\u76ee\u524d\u770b\u6765\uff0cFlink \u5728\u5b9e\u65f6\u8ba1\u7b97\u9886\u57df\u5185\u7684\u4e3b\u8981\u5e94\u7528\u573a\u666f\u4e3b\u8981\u53ef\u5206\u4e3a\u56db\u7c7b\u573a\u666f\uff0c \u5206\u522b\u662f\u5b9e\u65f6\u6570\u636e\u540c\u6b65\u3001\u6d41\u5f0f ETL\u3001\u5b9e\u65f6\u6570\u636e\u5206\u6790\u548c\u590d\u6742\u4e8b\u4ef6\u5904\u7406\uff0c\u5177\u4f53\u7684\u4e1a\u52a1\u573a\u666f\u548c\u5bf9\u5e94\u7684\u89e3\u51b3\u65b9\u6848\u53ef\u8be6\u7ec6\u7814\u7a76\u4e0b\u56fe\uff0c \u6587\u5b57\u5c42\u9762\u4e0d\u518d\u8be6\u8ff0\u3002<\/p>\n

\"\"<\/p>\n

\u5b9e\u65f6\u6570\u636e\u67b6\u6784\u4f53\u7cfb\u5efa\u8bbe\u601d\u8def<\/p>\n

\u4e8c\u3001\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u67b6\u6784<\/strong><\/div>\n

\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u5927\u81f4\u5206\u4e3a\u4e09\u7c7b\u573a\u666f\uff1a\u6d41\u91cf\u7c7b\u3001\u4e1a\u52a1\u7c7b\u548c\u7279\u5f81\u7c7b\uff0c\u8fd9\u4e09\u79cd\u573a\u666f\u5404\u6709\u4e0d\u540c\u3002<\/p>\n

\u5728\u6570\u636e\u6a21\u578b\u4e0a\uff0c\u6d41\u91cf\u7c7b\u662f\u6241\u5e73\u5316\u7684\u5bbd\u8868\uff0c\u4e1a\u52a1\u6570\u4ed3\u66f4\u591a\u662f\u57fa\u4e8e\u8303\u5f0f\u7684\u5efa\u6a21\uff0c\u7279\u5f81\u6570\u636e\u662f KV \u5b58\u50a8;
\n\u4ece\u6570\u636e\u6765\u6e90\u533a\u5206\uff0c\u6d41\u91cf\u6570\u4ed3\u7684\u6570\u636e\u6765\u6e90\u4e00\u822c\u662f\u65e5\u5fd7\u6570\u636e\uff0c\u4e1a\u52a1\u6570\u4ed3\u7684\u6570\u636e\u6765\u6e90\u662f\u4e1a\u52a1 binlog \u6570\u636e\uff0c\u7279\u5f81\u6570\u4ed3\u7684\u6570\u636e\u6765\u6e90\u5219\u591a\u79cd\u591a\u6837;
\n\u4ece\u6570\u636e\u91cf\u800c\u8a00\uff0c\u6d41\u91cf\u548c\u7279\u5f81\u6570\u4ed3\u90fd\u662f\u6d77\u91cf\u6570\u636e\uff0c\u6bcf\u5929\u5341\u4ebf\u7ea7\u4ee5\u4e0a\uff0c\u800c\u4e1a\u52a1\u6570\u4ed3\u7684\u6570\u636e\u91cf\u4e00\u822c\u6bcf\u5929\u767e\u4e07\u5230\u5343\u4e07\u7ea7;
\n\u4ece\u6570\u636e\u66f4\u65b0\u9891\u7387\u800c\u8a00\uff0c\u6d41\u91cf\u6570\u636e\u6781\u5c11\u66f4\u65b0\uff0c\u5219\u4e1a\u52a1\u548c\u7279\u5f81\u6570\u636e\u66f4\u65b0\u8f83\u591a\uff0c\u6d41\u91cf\u6570\u636e\u4e00\u822c\u5173\u6ce8\u65f6\u5e8f\u548c\u8d8b\u52bf\uff0c\u4e1a\u52a1\u6570\u636e\u548c\u7279\u5f81\u6570\u636e\u5173\u6ce8\u72b6\u6001\u53d8\u66f4;
\n\u5728\u6570\u636e\u51c6\u786e\u6027\u4e0a\uff0c\u6d41\u91cf\u6570\u636e\u8981\u6c42\u8f83\u4f4e\uff0c\u800c\u4e1a\u52a1\u6570\u636e\u548c\u7279\u5f81\u6570\u636e\u8981\u6c42\u8f83\u9ad8\u3002<\/p>\n

1\u3001\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u6574\u4f53\u67b6\u6784<\/strong><\/span><\/div>\n

\"\"<\/p>\n

\u5b9e\u65f6\u6570\u636e\u67b6\u6784\u4f53\u7cfb\u5efa\u8bbe\u601d\u8def
\n\u6574\u4e2a\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u67b6\u6784\u5206\u4e3a\u4e94\u5c42\uff0c\u5206\u522b\u662f\u63a5\u5165\u5c42\uff0c\u5b58\u50a8\u5c42\uff0c\u8ba1\u7b97\u5c42\u3001\u5e73\u53f0\u5c42\u548c\u5e94\u7528\u5c42\uff0c\u4e0a\u56fe\u53ea\u662f\u6574\u4f53\u67b6\u6784\u7684\u6982\u8981\u56fe\uff0c\u6bcf\u4e00\u5c42\u5177\u4f53\u8981\u505a\u7684\u4e8b\u60c5\uff0c\u63a5\u4e0b\u6765\u901a\u8fc7\u6587\u5b57\u6765\u8be6\u8ff0\u3002<\/p>\n

1)\u63a5\u5165\u5c42\uff1a<\/strong>\u8be5\u5c42\u5229\u7528\u5404\u79cd\u6570\u636e\u63a5\u5165\u5de5\u5177\u6536\u96c6\u5404\u4e2a\u7cfb\u7edf\u7684\u6570\u636e\uff0c\u5305\u62ec binlog \u65e5\u5fd7\u3001\u57cb\u70b9\u65e5\u5fd7\u3001\u4ee5\u53ca\u540e\u7aef\u670d\u52a1\u65e5\u5fd7\uff0c\u6570\u636e\u4f1a\u88ab\u6536\u96c6\u5230 Kafka \u4e2d;\u8fd9\u4e9b\u6570\u636e\u4e0d\u53ea\u662f\u53c2\u4e0e\u5b9e\u65f6\u8ba1\u7b97\uff0c\u4e5f\u4f1a\u53c2\u4e0e\u79bb\u7ebf\u8ba1\u7b97\uff0c\u4fdd\u8bc1\u5b9e\u65f6\u548c\u79bb\u7ebf\u7684\u539f\u59cb\u6570\u636e\u662f\u7edf\u4e00\u7684;<\/p>\n

2)\u5b58\u50a8\u5c42\uff1a<\/strong>\u8be5\u5c42\u5bf9\u539f\u59cb\u6570\u636e\u3001\u6e05\u6d17\u5173\u8054\u540e\u7684\u660e\u7ec6\u6570\u636e\u8fdb\u884c\u5b58\u50a8\uff0c\u57fa\u4e8e\u7edf\u4e00\u7684\u5b9e\u65f6\u6570\u636e\u6a21\u578b\u5206\u5c42\u7406\u5ff5\uff0c\u5c06\u4e0d\u540c\u5e94\u7528\u573a\u666f\u7684\u6570\u636e\u5206\u522b\u5b58\u50a8\u5728 Kafka\u3001HDFS\u3001Kudu\u3001 Clickhouse\u3001Hbase\u3001Redis\u3001Mysql \u7b49\u5b58\u50a8\u5f15\u64ce\u4e2d\uff0c\u5404\u79cd\u5b58\u50a8\u5f15\u64ce\u5b58\u653e\u7684\u5177\u4f53\u7684\u6570\u636e\u7c7b\u578b\u5728\u5b9e\u65f6\u6570\u636e\u6a21\u578b\u5206\u5c42\u90e8\u5206\u4f1a\u8be6\u7ec6\u4ecb\u7ecd;<\/p>\n

3)\u8ba1\u7b97\u5c42\uff1a<\/strong>\u8ba1\u7b97\u5c42\u4e3b\u8981\u4f7f\u7528 Flink\u3001Spark\u3001Presto \u4ee5\u53ca ClickHouse \u81ea\u5e26\u7684\u8ba1\u7b97\u80fd\u529b\u7b49\u56db\u79cd\u8ba1\u7b97\u5f15\u64ce\uff0cFlink \u8ba1\u7b97\u5f15\u64ce\u4e3b\u8981\u7528\u4e8e\u5b9e\u65f6\u6570\u636e\u540c\u6b65\u3001 \u6d41\u5f0f ETL\u3001\u5173\u952e\u7cfb\u7edf\u79d2\u7ea7\u5b9e\u65f6\u6307\u6807\u8ba1\u7b97\u573a\u666f\uff0cSpark SQL \u4e3b\u8981\u7528\u4e8e\u590d\u6742\u591a\u7ef4\u5206\u6790\u7684\u51c6\u5b9e\u65f6\u6307\u6807\u8ba1\u7b97\u9700\u6c42\u573a\u666f\uff0cPresto \u548c ClickHouse \u4e3b\u8981\u6ee1\u8db3\u591a\u7ef4\u81ea\u52a9\u5206\u6790\u3001\u5bf9\u67e5\u8be2\u54cd\u5e94\u65f6\u95f4\u8981\u6c42\u4e0d\u592a\u9ad8\u7684\u573a\u666f;<\/p>\n

4)\u5e73\u53f0\u5c42\uff1a<\/strong>\u5728\u5e73\u53f0\u5c42\u4e3b\u8981\u505a\u4e09\u4e2a\u65b9\u9762\u7684\u5de5\u4f5c\uff0c\u5206\u522b\u662f\u5bf9\u5916\u63d0\u4f9b\u7edf\u4e00\u67e5\u8be2\u670d\u52a1\u3001\u5143\u6570\u636e\u53ca\u6307\u6807\u7ba1\u7406\u3001\u6570\u636e\u8d28\u91cf\u53ca\u8840\u7f18;<\/p>\n

5)\u5e94\u7528\u5c42\uff1a<\/strong>\u4ee5\u7edf\u4e00\u67e5\u8be2\u670d\u52a1\u5bf9\u5404\u4e2a\u4e1a\u52a1\u7ebf\u6570\u636e\u573a\u666f\u8fdb\u884c\u652f\u6301\uff0c\u4e1a\u52a1\u4e3b\u8981\u5305\u62ec\u5b9e\u65f6\u5927\u5c4f\u3001\u5b9e\u65f6\u6570\u636e\u4ea7\u54c1\u3001\u5b9e\u65f6 OLAP\u3001\u5b9e\u65f6\u7279\u5f81\u7b49\u3002<\/p>\n

\u5176\u4e2d\uff0c\u5e73\u53f0\u5c42\u8be6\u7ec6\u5de5\u4f5c\u5982\u4e0b\uff1a<\/p>\n

\u7edf\u4e00\u67e5\u8be2\u670d\u52a1\u652f\u6301\u4ece\u5e95\u5c42\u660e\u7ec6\u6570\u636e\u5230\u805a\u5408\u5c42\u6570\u636e\u7684\u67e5\u8be2\uff0c\u652f\u6301\u4ee5SQL\u5316\u65b9\u5f0f\u67e5\u8be2Redis\u3001Hbase\u7b49KV\u5b58\u50a8\u4e2d\u7684\u6570\u636e;
\n\u5143\u6570\u636e\u53ca\u6307\u6807\u7ba1\u7406\uff1a\u4e3b\u8981\u5bf9\u5b9e\u65f6\u7684Kafka\u8868\u3001Kudu\u8868\u3001Clickhouse\u8868\u3001Hive\u8868\u7b49\u8fdb\u884c\u7edf\u4e00\u7ba1\u7406\uff0c\u4ee5\u6570\u4ed3\u6a21\u578b\u4e2d\u8868\u7684\u547d\u540d\u65b9\u5f0f\u89c4\u8303\u8868\u7684\u547d\u540d\uff0c\u660e\u786e\u6bcf\u5f20\u8868\u7684\u5b57\u6bb5\u542b\u4e49\u3001\u4f7f\u7528\u65b9\uff0c\u6307\u6807\u7ba1\u7406\u5219\u662f\u5c3d\u91cf\u901a\u8fc7\u6307\u6807\u7ba1\u7406\u7cfb\u7edf\u5c06\u6240\u6709\u7684\u5b9e\u65f6\u6307\u6807\u7edf\u4e00\u7ba1\u7406\u8d77\u6765\uff0c\u660e\u786e\u8ba1\u7b97\u53e3\u5f84\uff0c\u63d0\u4f9b\u7ed9\u4e0d\u540c\u7684\u4e1a\u52a1\u65b9\u4f7f\u7528;
\n\u6570\u636e\u8d28\u91cf\u53ca\u8840\u7f18\u5206\u6790\uff1a\u6570\u636e\u8d28\u91cf\u5206\u4e3a\u5e73\u53f0\u76d1\u63a7\u548c\u6570\u636e\u76d1\u63a7\u4e24\u4e2a\u90e8\u5206\uff0c\u8840\u7f18\u5206\u6790\u5219\u4e3b\u8981\u662f\u5bf9\u5b9e\u65f6\u6570\u636e\u4f9d\u8d56\u5173\u7cfb\u3001\u5b9e\u65f6\u4efb\u52a1\u7684\u4f9d\u8d56\u5173\u7cfb\u8fdb\u884c\u5206\u6790\u3002
\n\u5e73\u53f0\u76d1\u63a7\u90e8\u5206\u4e00\u662f\u5bf9\u4efb\u52a1\u8fd0\u884c\u72b6\u6001\u8fdb\u884c\u76d1\u63a7\uff0c\u5bf9\u5f02\u5e38\u7684\u4efb\u52a1\u8fdb\u884c\u62a5\u8b66\u5e76\u6839\u636e\u8bbe\u5b9a\u7684\u53c2\u6570\u5bf9\u4efb\u52a1\u8fdb\u884c\u81ea\u52a8\u62c9\u8d77\u4e0e\u6062\u590d\uff0c\u4e8c\u662f\u9488\u5bf9 Flink \u4efb\u52a1\u8981\u5bf9 Kafka \u6d88\u8d39\u5904\u7406\u5ef6\u8fdf\u8fdb\u884c\u76d1\u63a7\u5e76\u5b9e\u65f6\u62a5\u8b66\u3002
\n\u6570\u636e\u636e\u76d1\u63a7\u5219\u5206\u4e3a\u4e24\u4e2a\u90e8\u5206\uff1a<\/p>\n

\u9996\u5148\u6d41\u5f0f ETL \u662f\u6574\u4e2a\u5b9e\u65f6\u6570\u636e\u6d41\u8f6c\u8fc7\u7a0b\u4e2d\u91cd\u8981\u7684\u4e00\u73af\uff0cETL \u7684\u8fc7\u7a0b\u4e2d\u4f1a\u5173\u8054\u5404\u79cd\u7ef4\u8868\uff0c\u5b9e\u65f6\u5173\u8054\u65f6\uff0c\u5b9a\u65f6\u5bf9\u6ca1\u6709\u5173\u8054\u4e0a\u7684\u8bb0\u5f55\u4e0a\u62a5\u5f02\u5e38\u65e5\u5fd7\u5230\u76d1\u63a7\u5e73\u53f0\uff0c\u5f53\u6570\u91cf\u8fbe\u5230\u4e00\u5b9a\u9608\u503c\u65f6\u89e6\u53d1\u62a5\u8b66;
\n\u5176\u6b21\uff0c\u90e8\u5206\u5173\u952e\u5b9e\u65f6\u6307\u6807\u91c7\u7528\u4e86 lambda \u67b6\u6784\uff0c\u56e0\u6b64\u9700\u8981\u5bf9\u5386\u53f2\u7684\u5b9e\u65f6\u6307\u6807\u4e0e\u79bb\u7ebf hive \u8ba1\u7b97\u7684\u6570\u636e\u5b9a\u65f6\u505a\u5bf9\u6bd4\uff0c\u63d0\u4f9b\u5b9e\u65f6\u6570\u636e\u7684\u6570\u636e\u8d28\u91cf\u76d1\u63a7\uff0c\u5bf9\u8d85\u8fc7\u9608\u503c\u7684\u6307\u6807\u6570\u636e\u8fdb\u884c\u62a5\u8b66\u3002
\n\u4e3a\u4e86\u914d\u5408\u6570\u636e\u76d1\u63a7\uff0c\u9700\u8981\u505a\u5b9e\u65f6\u6570\u636e\u8840\u7f18\uff0c\u4e3b\u8981\u662f\u68b3\u7406\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u4e2d\u6570\u636e\u4f9d\u8d56\u5173\u7cfb\uff0c\u4ee5\u53ca\u5b9e\u65f6\u4efb\u52a1\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u4ece\u5e95\u5c42ODS \u5230 DW \u518d\u5230 DM\uff0c\u4ee5\u53ca DM \u5c42\u88ab\u54ea\u4e9b\u6a21\u578b\u7528\u5230\uff0c \u5c06\u6574\u4e2a\u94fe\u6761\u4e32\u8054\u8d77\u6765\uff0c\u8fd9\u6837\u505a\u5728\u6570\u636e\/\u4efb\u52a1\u4e3b\u52a8\u8c03\u6574\u65f6\u53ef\u4ee5\u901a\u77e5\u5173\u8054\u7684\u4e0b\u6e38\uff0c\u6307\u6807\u5f02\u5e38\u65f6\u501f\u52a9\u8840\u7f18\u5b9a\u4f4d\u95ee\u9898\uff0c\u540c\u65f6\u57fa\u4e8e\u8840\u7f18\u5173\u7cfb\u7684\u5206\u6790\uff0c\u6211\u4eec\u4e5f\u80fd\u8bc4\u4f30\u6570\u636e\u7684\u5e94\u7528\u4ef7\u503c\uff0c\u6838\u7b97\u6570\u636e\u7684\u8ba1\u7b97\u6210\u672c\u3002<\/p>\n

2\u3001\u5b9e\u65f6\u6570\u636e\u6a21\u578b\u5206\u5c42<\/strong><\/span><\/div>\n

\"\"<\/p>\n

\u5b9e\u65f6\u6570\u636e\u67b6\u6784\u4f53\u7cfb\u5efa\u8bbe\u601d\u8def
\n\u79bb\u7ebf\u6570\u4ed3\u8003\u8651\u5230\u6548\u7387\u95ee\u9898\uff0c\u4e00\u822c\u4f1a\u91c7\u53d6\u7a7a\u95f4\u6362\u65f6\u95f4\u7684\u65b9\u5f0f\uff0c\u5c42\u7ea7\u5212\u5206\u4f1a\u6bd4\u8f83\u591a;\u5b9e\u65f6\u6570\u4ed3\u8003\u8651\u5230\u5b9e\u65f6\u6027\u95ee\u9898\uff0c\u5206\u5c42\u5219\u8d8a\u5c11\u8d8a\u597d\uff0c\u53e6\u5916\u4e5f\u51cf\u5c11\u4e86\u4e2d\u95f4\u6d41\u7a0b\u51fa\u9519\u7684\u53ef\u80fd\u6027\uff0c\u56e0\u6b64\u5c06\u5176\u5206\u4e3a\u56db\u5c42\u3002<\/p>\n

1)ODS \u5c42<\/strong><\/p>\n

\u64cd\u4f5c\u6570\u636e\u5c42\uff0c\u4fdd\u5b58\u539f\u59cb\u6570\u636e\uff0c\u5bf9\u975e\u7ed3\u6784\u5316\u7684\u6570\u636e\u8fdb\u884c\u7ed3\u6784\u5316\u5904\u7406\uff0c\u8f7b\u5ea6\u6e05\u6d17\uff0c\u51e0\u4e4e\u4e0d\u5220\u9664\u539f\u59cb\u6570\u636e\u3002<\/p>\n

\u8be5\u5c42\u7684\u6570\u636e\u4e3b\u8981\u6765\u81ea\u4e1a\u52a1\u6570\u636e\u5e93\u7684 binlog \u65e5\u5fd7\u3001\u57cb\u70b9\u65e5\u5fd7\u548c\u5e94\u7528\u7a0b\u5e8f\u65e5\u5fd7\u3002<\/p>\n

\u5bf9\u4e8e binlog \u65e5\u5fd7\u901a\u8fc7 canal \u76d1\u542c\uff0c\u5199\u5230\u6d88\u606f\u961f\u5217 Kafka \u4e2d\uff0c\u5bf9\u5e94\u4e8e\u57cb\u70b9\u548c\u5e94\u7528\u7a0b\u5e8f\u65e5\u5fd7\uff0c\u5219\u901a\u8fc7 Filebeat \u91c7\u96c6 nginx \u548c tomcat \u65e5\u5fd7\uff0c\u4e0a\u62a5\u5230Kafka \u4e2d\u3002<\/p>\n

\u9664\u4e86\u5b58\u50a8\u5728 Kafka \u4e2d\uff0c\u540c\u65f6\u4e5f\u4f1a\u5bf9\u4e1a\u52a1\u6570\u636e\u5e93\u7684 binlog \u65e5\u5fd7\u901a\u8fc7 Flink \u5199\u5165 HDFS\u3001Kudu \u7b49\u5b58\u50a8\u5f15\u64ce\uff0c\u843d\u5730\u5230 5min Hive \u8868\uff0c\u4f9b\u67e5\u8be2\u660e\u7ec6\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u63d0\u4f9b\u7ed9\u79bb\u7ebf\u6570\u4ed3\uff0c\u505a\u4e3a\u5176\u539f\u59cb\u6570\u636e;\u53e6\u5916\uff0c\u5bf9\u4e8e\u57cb\u70b9\u65e5\u5fd7\u6570\u636e\uff0c\u7531\u4e8e ODS \u5c42\u662f\u975e\u7ed3\u6784\u5316\u7684\uff0c\u5219\u6ca1\u6709\u5fc5\u8981\u843d\u5730\u3002<\/p>\n

2)DWD \u5c42<\/strong><\/p>\n

\u5b9e\u65f6\u660e\u7ec6\u6570\u636e\u5c42\uff0c\u4ee5\u4e1a\u52a1\u8fc7\u7a0b\u4f5c\u4e3a\u5efa\u6a21\u9a71\u52a8\uff0c\u57fa\u4e8e\u6bcf\u4e2a\u5177\u4f53\u7684\u4e1a\u52a1\u8fc7\u7a0b\u7279\u70b9\uff0c\u6784\u5efa\u6700\u7ec6\u7c92\u5ea6\u7684\u660e\u7ec6\u5c42\u4e8b\u5b9e\u8868;\u53ef\u4ee5\u7ed3\u5408\u4f01\u4e1a\u7684\u6570\u636e\u4f7f\u7528\u7279\u70b9\uff0c\u5c06\u660e\u7ec6\u4e8b\u5b9e\u8868\u7684\u67d0\u4e9b\u91cd\u8981\u7ef4\u5ea6\u5c5e\u6027\u5b57\u6bb5\u505a\u9002\u5f53\u5197\u4f59\uff0c\u4e5f\u5373\u5bbd\u8868\u5316\u5904\u7406\u3002<\/p>\n

\u8be5\u5c42\u7684\u6570\u636e\u6765\u6e90\u4e8e ODS \u5c42\uff0c\u901a\u8fc7\u7b80\u5355\u7684 Streaming ETL \u540e\u5f97\u5230\uff0c\u5bf9\u4e8e binlog \u65e5\u5fd7\u7684\u5904\u7406\u4e3b\u8981\u8fdb\u884c\u7b80\u5355\u7684\u6570\u636e\u6e05\u6d17\u3001\u5904\u7406\u6570\u636e\u6f02\u79fb\uff0c\u4ee5\u53ca\u53ef\u80fd\u5bf9\u591a\u4e2a ODS \u5c42\u7684\u8868\u8fdb\u884c Streaming Join\uff0c\u5bf9\u6d41\u91cf\u65e5\u5fd7\u4e3b\u8981\u662f\u505a\u4e00\u4e9b\u901a\u7528ETL \u5904\u7406\uff0c\u5c06\u975e\u7ed3\u6784\u5316\u7684\u6570\u636e\u7ed3\u6784\u5316\uff0c\u5173\u8054\u901a\u7528\u7684\u7ef4\u5ea6\u5b57\u6bb5\u3002<\/p>\n

\u8be5\u5c42\u7684\u6570\u636e\u5b58\u50a8\u5728\u6d88\u606f\u961f\u5217 Kafka \u4e2d\uff0c\u540c\u65f6\u4e5f\u4f1a\u7528 Flink \u5b9e\u65f6\u5199\u5165 Hive 5min \u8868\uff0c\u4f9b\u67e5\u8be2\u660e\u7ec6\u6570\u636e\uff0c\u540c\u65f6\u8981\u63d0\u4f9b\u7ed9\u79bb\u7ebf\u6570\u4ed3\uff0c\u505a\u4e3a\u5176\u539f\u59cb\u6570\u636e\u3002<\/p>\n

3)DIM \u5c42<\/strong><\/p>\n

\u516c\u5171\u7ef4\u5ea6\u5c42\uff0c\u57fa\u4e8e\u7ef4\u5ea6\u5efa\u6a21\u7406\u5ff5\u601d\u60f3\uff0c\u5efa\u7acb\u6574\u4e2a\u4e1a\u52a1\u8fc7\u7a0b\u7684\u4e00\u81f4\u6027\u7ef4\u5ea6\uff0c\u964d\u4f4e\u6570\u636e\u8ba1\u7b97\u53e3\u5f84\u548c\u7b97\u6cd5\u4e0d\u7edf\u4e00\u98ce\u9669\u3002<\/p>\n

DIM \u5c42\u6570\u636e\u6765\u6e90\u4e8e\u4e24\u90e8\u5206\uff1a\u4e00\u90e8\u5206\u662fFlink\u7a0b\u5e8f\u5b9e\u65f6\u5904\u7406ODS\u5c42\u6570\u636e\u5f97\u5230\uff0c\u53e6\u5916\u4e00\u90e8\u5206\u662f\u901a\u8fc7\u79bb\u7ebf\u4efb\u52a1\u51fa\u4ed3\u5f97\u5230\u3002<\/p>\n

DIM \u5c42\u7ef4\u5ea6\u6570\u636e\u4e3b\u8981\u4f7f\u7528 MySQL\u3001Hbase\u3001Redis \u4e09\u79cd\u5b58\u50a8\u5f15\u64ce\uff0c\u5bf9\u4e8e\u7ef4\u8868\u6570\u636e\u6bd4\u8f83\u5c11\u7684\u60c5\u51b5\u53ef\u4ee5\u4f7f\u7528 MySQL\uff0c\u5bf9\u4e8e\u5355\u6761\u6570\u636e\u5927\u5c0f\u6bd4\u8f83\u5c0f\uff0c\u67e5\u8be2 QPS \u6bd4\u8f83\u9ad8\u7684\u60c5\u51b5\uff0c\u53ef\u4ee5\u4f7f\u7528 Redis \u5b58\u50a8\uff0c\u964d\u4f4e\u673a\u5668\u5185\u5b58\u8d44\u6e90\u5360\u7528\uff0c\u5bf9\u4e8e\u6570\u636e\u91cf\u6bd4\u8f83\u5927\uff0c\u5bf9\u7ef4\u8868\u6570\u636e\u53d8\u5316\u4e0d\u662f\u7279\u522b\u654f\u611f\u7684\u573a\u666f\uff0c\u53ef\u4ee5\u4f7f\u7528HBase \u5b58\u50a8\u3002<\/p>\n

4)DM \u5c42<\/strong><\/p>\n

\u2460\u6570\u636e\u96c6\u5e02\u5c42<\/strong><\/p>\n

\u4ee5\u6570\u636e\u57df+\u4e1a\u52a1\u57df\u7684\u7406\u5ff5\u5efa\u8bbe\u516c\u5171\u6c47\u603b\u5c42\uff0c\u5bf9\u4e8eDM\u5c42\u6bd4\u8f83\u590d\u6742\uff0c\u9700\u8981\u7efc\u5408\u8003\u8651\u5bf9\u4e8e\u6570\u636e\u843d\u5730\u7684\u8981\u6c42\u4ee5\u53ca\u5177\u4f53\u7684\u67e5\u8be2\u5f15\u64ce\u6765\u9009\u62e9\u4e0d\u540c\u7684\u5b58\u50a8\u65b9\u5f0f\uff0c\u5206\u4e3a\u8f7b\u5ea6\u6c47\u603b\u5c42\u548c\u9ad8\u5ea6\u6c47\u603b\u5c42\uff0c\u540c\u65f6\u4ea7\u51fa\uff0c\u9ad8\u5ea6\u6c47\u603b\u5c42\u6570\u636e\u7528\u4e8e\u524d\u7aef\u6bd4\u8f83\u7b80\u5355\u7684KV\u67e5\u8be2\uff0c \u63d0\u5347\u67e5\u8be2\u6027\u80fd\uff0c\u6bd4\u5982\u5b9e\u65f6\u5927\u5c4f\uff0c\u5b9e\u65f6\u62a5\u8868\u7b49\uff0c\u6570\u636e\u7684\u65f6\u6548\u6027\u8981\u6c42\u4e3a\u79d2\u7ea7\uff0c\u8f7b\u5ea6\u6c47\u603b\u5c42Kafka\u4e2d\u5bbd\u8868\u5b9e\u65f6\u5199\u5165OLAP\u5b58\u50a8\u5f15\u64ce\uff0c\u7528\u4e8e\u524d\u7aef\u4ea7\u54c1\u590d\u6742\u7684OLAP\u67e5\u8be2\u573a\u666f\uff0c\u6ee1\u8db3\u81ea\u52a9\u5206\u6790\u548c\u4ea7\u51fa\u590d\u6742\u62a5\u8868\u7684\u9700\u6c42\uff0c\u5bf9\u6570\u636e\u7684\u65f6\u6548\u6027\u8981\u6c42\u53ef\u5bb9\u5fcd\u5230\u5206\u949f\u7ea7;<\/p>\n

\u2461\u8f7b\u5ea6\u6c47\u603b\u5c42<\/strong><\/p>\n

\u8f7b\u5ea6\u6c47\u603b\u5c42\u7531\u660e\u7ec6\u5c42\u901a\u8fc7Streaming ETL\u5f97\u5230\uff0c\u4e3b\u8981\u4ee5\u5bbd\u8868\u7684\u5f62\u5f0f\u5b58\u5728\uff0c\u4e1a\u52a1\u660e\u7ec6\u6c47\u603b\u662f\u7531\u4e1a\u52a1\u4e8b\u5b9e\u660e\u7ec6\u8868\u548c\u7ef4\u5ea6\u8868join\u5f97\u5230\uff0c\u6d41\u91cf\u660e\u7ec6\u6c47\u603b\u662f\u7531\u6d41\u91cf\u65e5\u5fd7\u6309\u4e1a\u52a1\u7ebf\u62c6\u5206\u548c\u7ef4\u5ea6\u8868join\u5f97\u5230\u3002<\/p>\n

\u8f7b\u5ea6\u6c47\u603b\u5c42\u6570\u636e\u5b58\u50a8\u6bd4\u8f83\u591a\u6837\u5316\uff0c\u9996\u5148\u5229\u7528Flink\u5b9e\u65f6\u6d88\u8d39DWD\u5c42Kafka\u4e2d\u660e\u7ec6\u6570\u636ejoin\u4e1a\u52a1\u8fc7\u7a0b\u9700\u8981\u7684\u7ef4\u8868\uff0c\u5b9e\u65f6\u6253\u5bbd\u540e\u5199\u5165\u8be5\u5c42\u7684Kafka\u4e2d\uff0c\u4ee5Json\u6216PB\u683c\u5f0f\u5b58\u50a8\u3002<\/p>\n

\u540c\u65f6\u5bf9\u591a\u7ef4\u4e1a\u52a1\u660e\u7ec6\u6c47\u603b\u6570\u636e\u901a\u8fc7Flink\u5b9e\u65f6\u5199\u5165Kudu\uff0c\u7528\u4e8e\u67e5\u8be2\u660e\u7ec6\u6570\u636e\u548c\u66f4\u590d\u6742\u7684\u591a\u7ef4\u6570\u636e\u5206\u6790\u9700\u6c42\uff0c\u5bf9\u4e8e\u6d41\u91cf\u6570\u636e\u901a\u8fc7Flink\u5206\u522b\u5199\u5165HDFS\u548cClickHouse\u7528\u4e8e\u590d\u6742\u7684\u591a\u7ef4\u6570\u636e\u5206\u6790\uff0c \u5b9e\u65f6\u7279\u5f81\u6570\u636e\u5219\u901a\u8fc7Flink join\u7ef4\u8868\u540e\u5b9e\u65f6\u5199\u5165HDFS\uff0c\u7528\u4e8e\u4e0b\u6e38\u7684\u79bb\u7ebfETL\u6d88\u8d39\u3002<\/p>\n

\u5bf9\u4e8e\u843d\u5730Kudu\u548cHDFS\u7684\u5bbd\u8868\u6570\u636e\uff0c\u53ef\u7528Spark SQL\u505a\u5206\u949f\u7ea7\u7684\u9884\u8ba1\u7b97\uff0c\u6ee1\u8db3\u4e1a\u52a1\u65b9\u590d\u6742\u6570\u636e\u5206\u6790\u9700\u6c42\uff0c\u63d0\u4f9b\u5206\u949f\u7ea7\u5ef6\u8fdf\u7684\u6570\u636e\uff0c\u4ece\u800c\u52a0\u901f\u79bb\u7ebfETL\u8fc7\u7a0b\u7684\u5ef6\u8fdf\uff0c \u53e6\u5916\u968f\u7740Flink SQL\u4e0eHive\u751f\u6001\u96c6\u6210\u7684\u4e0d\u65ad\u5b8c\u5584\uff0c\u53ef\u5c1d\u8bd5\u7528Flink SQL\u505a\u79bb\u7ebfETL\u548cOLAP\u8ba1\u7b97\u4efb\u52a1(Flink\u6d41\u8ba1\u7b97\u57fa\u4e8e\u5185\u5b58\u8ba1\u7b97\u7684\u7279\u6027\uff0c\u548cpresto\u975e\u5e38\u7c7b\u4f3c\uff0c\u8fd9\u4f7f\u5176\u4e5f\u53ef\u4ee5\u6210\u4e3a\u4e00\u4e2aOLAP\u8ba1\u7b97\u5f15\u64ce)\uff0c\u7528\u4e00\u5957\u8ba1\u7b97\u5f15\u64ce\u89e3\u51b3\u5b9e\u65f6\u79bb\u7ebf\u9700\u6c42\uff0c\u4ece\u800c\u5b9e\u73b0\u6279\u6d41\u7edf\u4e00\u3002<\/p>\n

\u5bf9\u4e8eKudu\u4e2d\u7684\u4e1a\u52a1\u660e\u7ec6\u6570\u636e\u3001ClickHouse\u4e2d\u7684\u6d41\u91cf\u660e\u7ec6\u6570\u636e\uff0c\u4e5f\u53ef\u4ee5\u6ee1\u8db3\u4e1a\u52a1\u65b9\u7684\u4e2a\u6027\u5316\u6570\u636e\u5206\u6790\u9700\u6c42\uff0c\u5229\u7528\u5f3a\u5927\u7684OLAP\u8ba1\u7b97\u5f15\u64ce\uff0c\u5b9e\u65f6\u67e5\u8be2\u660e\u7ec6\u6570\u636e\uff0c\u572810s\u91cf\u7ea7\u7684\u54cd\u5e94\u65f6\u95f4\u5185\u7ed9\u51fa\u7ed3\u679c\uff0c\u8fd9\u7c7b\u9700\u6c42\u4e5f\u5373\u662f\u5b9e\u65f6OLAP\u9700\u6c42\uff0c\u7075\u6d3b\u6027\u6bd4\u8f83\u9ad8\u3002<\/p>\n

\u2462\u9ad8\u5ea6\u6c47\u603b\u5c42<\/strong><\/p>\n

\u9ad8\u5ea6\u6c47\u603b\u5c42\u7531\u660e\u7ec6\u6570\u636e\u5c42\u6216\u8f7b\u5ea6\u6c47\u603b\u5c42\u901a\u8fc7\u805a\u5408\u8ba1\u7b97\u540e\u5199\u5165\u5230\u5b58\u50a8\u5f15\u64ce\u4e2d\uff0c\u4ea7\u51fa\u4e00\u90e8\u5206\u5b9e\u65f6\u6570\u636e\u6307\u6807\u9700\u6c42\uff0c\u7075\u6d3b\u6027\u6bd4\u8f83\u5dee\u3002<\/p>\n

\u8ba1\u7b97\u5f15\u64ce\u4f7f\u7528Flink Datastream API\u548cFlink SQL\uff0c\u6307\u6807\u5b58\u50a8\u5f15\u64ce\u6839\u636e\u4e0d\u540c\u7684\u9700\u6c42\uff0c\u5bf9\u4e8e\u5e38\u89c1\u7684\u7b80\u5355\u6307\u6807\u6c47\u603b\u6a21\u578b\u53ef\u76f4\u63a5\u653e\u5728MySQL\u91cc\u9762\uff0c\u7ef4\u5ea6\u6bd4\u8f83\u591a\u7684\u3001\u5199\u5165\u66f4\u65b0\u6bd4\u8f83\u5927\u7684\u6a21\u578b\u4f1a\u653e\u5728HBase\u91cc\u9762\uff0c \u8fd8\u6709\u4e00\u79cd\u662f\u9700\u8981\u505a\u6392\u5e8f\u3001\u5bf9\u67e5\u8be2QPS\u3001\u54cd\u5e94\u65f6\u95f4\u8981\u6c42\u975e\u5e38\u9ad8\u3001\u4e14\u4e0d\u9700\u8981\u6301\u4e45\u5316\u5b58\u50a8\u5982\u5927\u4fc3\u6d3b\u52a8\u671f\u95f4\u5728\u7ebfTopN\u5546\u54c1\u7b49\u76f4\u63a5\u5b58\u50a8\u5728Redis\u91cc\u9762\u3002<\/p>\n

\u5728\u79d2\u7ea7\u6307\u6807\u9700\u6c42\u4e2d\uff0c\u9700\u8981\u6df7\u7528Lambda\u548cKappa\u67b6\u6784\uff0c\u5927\u90e8\u5206\u5b9e\u65f6\u6307\u6807\u4f7f\u7528Kappa\u67b6\u6784\u5b8c\u6210\u8ba1\u7b97\uff0c\u5c11\u91cf\u5173\u952e\u6307\u6807(\u5982\u91d1\u989d\u76f8\u5173)\u4f7f\u7528Lambda\u67b6\u6784\u7528\u6279\u5904\u7406\u91cd\u65b0\u5904\u7406\u8ba1\u7b97\uff0c\u589e\u52a0\u4e00\u6b21\u6821\u5bf9\u8fc7\u7a0b\u3002<\/p>\n

\u603b\u4f53\u6765\u8bf4 DM \u5c42\u5bf9\u5916\u63d0\u4f9b\u4e09\u79cd\u65f6\u6548\u6027\u7684\u6570\u636e\uff1a<\/p>\n

\u9996\u5148\u662f Flink \u7b49\u5b9e\u65f6\u8ba1\u7b97\u5f15\u64ce\u9884\u8ba1\u7b97\u597d\u7684\u79d2\u7ea7\u5b9e\u65f6\u6307\u6807\uff0c\u8fd9\u79cd\u9700\u6c42\u5bf9\u6570\u636e\u7684\u65f6\u6548\u6027\u8981\u6c42\u975e\u5e38\u9ad8\uff0c\u7528\u4e8e\u5b9e\u65f6\u5927\u5c4f\u3001\u8ba1\u7b97\u7ef4\u5ea6\u4e0d\u590d\u6742\u7684\u5b9e\u65f6\u62a5\u8868\u9700\u6c42\u3002
\n\u5176\u6b21\u662f Spark SQL \u9884\u8ba1\u7b97\u7684\u5ef6\u8fdf\u5728\u5206\u949f\u7ea7\u7684\u51c6\u5b9e\u65f6\u6307\u6807\uff0c \u8be5\u7c7b\u6307\u6807\u6ee1\u8db3\u4e00\u4e9b\u6bd4\u8f83\u590d\u6742\u4f46\u5bf9\u6570\u636e\u65f6\u6548\u6027\u8981\u6c42\u4e0d\u592a\u9ad8\u7684\u6570\u636e\u5206\u6790\u573a\u666f\uff0c\u53ef\u80fd\u4f1a\u6d89\u53ca\u5230\u591a\u4e2a\u4e8b\u5b9e\u8868\u7684join\uff0c\u5982\u9500\u552e\u5f52\u56e0\u7b49\u9700\u6c42\u3002
\n\u6700\u540e\u4e00\u79cd\u5219\u662f\u4e0d\u9700\u8981\u9884\u8ba1\u7b97\uff0cad-hoc\u67e5\u8be2\u7684\u590d\u6742\u591a\u7ef4\u6570\u636e\u5206\u6790\u573a\u666f\uff0c\u6b64\u7c7b\u9700\u6c42\u6bd4\u8f83\u4e2a\u6027\u5316\uff0c\u7075\u6d3b\u6027\u6bd4\u8f83\u9ad8\uff0c\u5982\u679c OLAP \u8ba1\u7b97\u5f15\u64ce\u6027\u80fd\u8db3\u591f\u5f3a\u5927\uff0c\u4e5f\u53ef\u5b8c\u5168\u6ee1\u8db3\u79d2\u7ea7\u8ba1\u7b97\u9700\u6c42\u7684\u573a\u666f; \u5bf9\u5916\u63d0\u4f9b\u7684\u79d2\u7ea7\u5b9e\u65f6\u6570\u636e\u548c\u53e6\u5916\u4e24\u79cd\u51c6\u5b9e\u65f6\u6570\u636e\u7684\u6bd4\u4f8b\u5927\u81f4\u4e3a 3\uff1a7\uff0c\u7edd\u5927\u591a\u6570\u7684\u4e1a\u52a1\u9700\u6c42\u90fd\u4f18\u5148\u8003\u8651\u51c6\u5b9e\u65f6\u8ba1\u7b97\u6216 ad-hoc \u65b9\u5f0f\uff0c\u53ef\u4ee5\u964d\u4f4e\u8d44\u6e90\u4f7f\u7528\u3001\u63d0\u5347\u6570\u636e\u51c6\u786e\u6027\uff0c\u4ee5\u66f4\u7075\u6d3b\u7684\u65b9\u5f0f\u6ee1\u8db3\u590d\u6742\u7684\u4e1a\u52a1\u573a\u666f\u3002<\/p>\n

3\u3001\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u5efa\u8bbe\u65b9\u5f0f<\/strong><\/span><\/div>\n

\u6574\u4e2a\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\u5206\u4e3a\u4e24\u79cd\u5efa\u8bbe\u65b9\u5f0f\uff0c\u5373\u5b9e\u65f6\u548c\u51c6\u5b9e\u65f6(\u5b83\u4eec\u7684\u5b9e\u73b0\u65b9\u5f0f\u5206\u522b\u662f\u57fa\u4e8e\u6d41\u8ba1\u7b97\u5f15\u64ce\u548c ETL\u3001OLAP \u5f15\u64ce\uff0c\u6570\u636e\u65f6\u6548\u6027\u5219\u5206\u522b\u662f\u79d2\u7ea7\u548c\u5206\u949f\u7ea7\u3002<\/p>\n

1)\u5728\u8c03\u5ea6\u5f00\u9500\u65b9\u9762<\/strong>\uff0c\u51c6\u5b9e\u65f6\u6570\u636e\u662f\u6279\u5904\u7406\u8fc7\u7a0b\uff0c\u56e0\u6b64\u4ecd\u7136\u9700\u8981\u8c03\u5ea6\u7cfb\u7edf\u652f\u6301\uff0c\u8c03\u5ea6\u9891\u7387\u8f83\u9ad8\uff0c\u800c\u5b9e\u65f6\u6570\u636e\u5374\u6ca1\u6709\u8c03\u5ea6\u5f00\u9500\u3002<\/p>\n

2)\u5728\u4e1a\u52a1\u7075\u6d3b\u6027\u65b9\u9762<\/strong>\uff0c\u56e0\u4e3a\u51c6\u5b9e\u65f6\u6570\u636e\u662f\u57fa\u4e8e ETL \u6216 OLAP \u5f15\u64ce\u5b9e\u73b0\uff0c\u7075\u6d3b\u6027\u4f18\u4e8e\u57fa\u4e8e\u6d41\u8ba1\u7b97\u7684\u65b9\u5f0f\u3002<\/p>\n

3)\u5728\u5bf9\u6570\u636e\u665a\u5230\u7684\u5bb9\u5fcd\u5ea6\u65b9\u9762<\/strong>\uff0c\u56e0\u4e3a\u51c6\u5b9e\u65f6\u6570\u636e\u53ef\u4ee5\u57fa\u4e8e\u4e00\u4e2a\u5468\u671f\u5185\u7684\u6570\u636e\u8fdb\u884c\u5168\u91cf\u8ba1\u7b97\uff0c\u56e0\u6b64\u5bf9\u4e8e\u6570\u636e\u665a\u5230\u7684\u5bb9\u5fcd\u5ea6\u4e5f\u662f\u6bd4\u8f83\u9ad8\u7684\uff0c\u800c\u5b9e\u65f6\u6570\u636e\u4f7f\u7528\u7684\u662f\u589e\u91cf\u8ba1\u7b97\uff0c\u5bf9\u4e8e\u6570\u636e\u665a\u5230\u7684\u5bb9\u5fcd\u5ea6\u66f4\u4f4e\u4e00\u4e9b\u3002<\/p>\n

4)\u5728\u9002\u7528\u573a\u666f\u65b9\u9762<\/strong>\uff0c\u51c6\u5b9e\u65f6\u6570\u636e\u4e3b\u8981\u7528\u4e8e\u6709\u5b9e\u65f6\u6027\u8981\u6c42\u4f46\u4e0d\u592a\u9ad8\u3001\u6d89\u53ca\u591a\u8868\u5173\u8054\u548c\u4e1a\u52a1\u53d8\u66f4\u9891\u7e41\u7684\u573a\u666f\uff0c\u5982\u4ea4\u6613\u7c7b\u578b\u7684\u5b9e\u65f6\u5206\u6790\uff0c\u5b9e\u65f6\u6570\u636e\u5219\u66f4\u9002\u7528\u4e8e\u5b9e\u65f6\u6027\u8981\u6c42\u9ad8\u3001\u6570\u636e\u91cf\u5927\u7684\u573a\u666f\uff0c\u5982\u5b9e\u65f6\u7279\u5f81\u3001\u6d41\u91cf\u7c7b\u578b\u5b9e\u65f6\u5206\u6790\u7b49\u573a\u666f\u3002<\/p>\n

4\u3001\u6d41\u6279\u4e00\u4f53\u5b9e\u65f6\u6570\u636e\u67b6\u6784\u53d1\u5c55<\/strong><\/span><\/div>\n

\u4ece1990\u5e74 Inmon \u63d0\u51fa\u6570\u636e\u4ed3\u5e93\u6982\u5ff5\u5230\u4eca\u5929\uff0c\u5927\u6570\u636e\u67b6\u6784\u7ecf\u5386\u4e86\u4ece\u6700\u521d\u7684\u79bb\u7ebf\u5927\u6570\u636e\u67b6\u6784\u3001Lambda \u67b6\u6784\u3001Kappa \u67b6\u6784\u4ee5\u53ca Flink \u7684\u706b\u70ed\u5e26\u51fa\u7684\u6d41\u6279\u4e00\u4f53\u67b6\u6784\uff0c\u6570\u636e\u67b6\u6784\u6280\u672f\u4e0d\u65ad\u6f14\u8fdb\uff0c\u672c\u8d28\u662f\u5728\u5f80\u6d41\u6279\u4e00\u4f53\u7684\u65b9\u5411\u53d1\u5c55\uff0c\u8ba9\u7528\u6237\u80fd\u4ee5\u6700\u81ea\u7136\u3001\u6700\u5c0f\u7684\u6210\u672c\u5b8c\u6210\u5b9e\u65f6\u8ba1\u7b97\u3002<\/p>\n

1)\u79bb\u7ebf\u5927\u6570\u636e\u67b6\u6784<\/strong>\uff1a\u6570\u636e\u6e90\u901a\u8fc7\u79bb\u7ebf\u7684\u65b9\u5f0f\u5bfc\u5165\u5230\u79bb\u7ebf\u6570\u4ed3\u4e2d\uff0c\u4e0b\u6e38\u5e94\u7528\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u9009\u62e9\u76f4\u63a5\u8bfb\u53d6 DM \u6216\u52a0\u4e00\u5c42\u6570\u636e\u670d\u52a1\uff0c\u6bd4\u5982 MySQL \u6216 Redis\uff0c\u6570\u636e\u5b58\u50a8\u5f15\u64ce\u662f HDFS\/Hive\uff0cETL \u5de5\u5177\u53ef\u4ee5\u662f MapReduce \u811a\u672c\u6216 HiveSQL\u3002\u6570\u636e\u4ed3\u5e93\u4ece\u6a21\u578b\u5c42\u9762\u5206\u4e3a\u64cd\u4f5c\u6570\u636e\u5c42 ODS\u3001\u6570\u636e\u4ed3\u5e93\u660e\u7ec6\u5c42 DWD\u3001\u6570\u636e\u96c6\u5e02\u5c42 DM\u3002<\/p>\n

2)Lambda \u67b6\u6784<\/strong>\uff1a\u968f\u7740\u5927\u6570\u636e\u5e94\u7528\u7684\u53d1\u5c55\uff0c\u4eba\u4eec\u9010\u6e10\u5bf9\u7cfb\u7edf\u7684\u5b9e\u65f6\u6027\u63d0\u51fa\u4e86\u8981\u6c42\uff0c\u4e3a\u4e86\u8ba1\u7b97\u4e00\u4e9b\u5b9e\u65f6\u6307\u6807\uff0c\u5c31\u5728\u539f\u6765\u79bb\u7ebf\u6570\u4ed3\u7684\u57fa\u7840\u4e0a\u589e\u52a0\u4e86\u4e00\u4e2a\u5b9e\u65f6\u8ba1\u7b97\u7684\u94fe\u8def\uff0c\u5e76\u5bf9\u6570\u636e\u6e90\u505a\u6d41\u5f0f\u6539\u9020(\u5373\u628a\u6570\u636e\u53d1\u9001\u5230\u6d88\u606f\u961f\u5217)\uff0c\u5b9e\u65f6\u8ba1\u7b97\u53bb\u8ba2\u9605\u6d88\u606f\u961f\u5217\uff0c\u76f4\u63a5\u5b8c\u6210\u6307\u6807\u589e\u91cf\u7684\u8ba1\u7b97\uff0c\u63a8\u9001\u5230\u4e0b\u6e38\u7684\u6570\u636e\u670d\u52a1\u4e2d\u53bb\uff0c\u7531\u6570\u636e\u670d\u52a1\u5c42\u5b8c\u6210\u79bb\u7ebf&\u5b9e\u65f6\u7ed3\u679c\u7684\u5408\u5e76\u3002<\/p>\n

3)Kappa \u67b6\u6784<\/strong>\uff1aLambda \u67b6\u6784\u867d\u7136\u6ee1\u8db3\u4e86\u5b9e\u65f6\u7684\u9700\u6c42\uff0c\u4f46\u5e26\u6765\u4e86\u66f4\u591a\u7684\u5f00\u53d1\u4e0e\u8fd0\u7ef4\u5de5\u4f5c\uff0c\u5176\u67b6\u6784\u80cc\u666f\u662f\u6d41\u5904\u7406\u5f15\u64ce\u8fd8\u4e0d\u5b8c\u5584\uff0c\u6d41\u5904\u7406\u7684\u7ed3\u679c\u53ea\u4f5c\u4e3a\u4e34\u65f6\u7684\u3001\u8fd1\u4f3c\u7684\u503c\u63d0\u4f9b\u53c2\u8003\u3002\u540e\u6765\u968f\u7740 Flink \u7b49\u6d41\u5904\u7406\u5f15\u64ce\u7684\u51fa\u73b0\uff0c\u6d41\u5904\u7406\u6280\u672f\u6210\u719f\u8d77\u6765\uff0c\u8fd9\u65f6\u4e3a\u4e86\u89e3\u51b3\u4e24\u5957\u4ee3\u7801\u7684\u95ee\u9898\uff0cLickedIn \u7684 Jay Kreps \u63d0\u51fa\u4e86 Kappa \u67b6\u6784\u3002<\/p>\n

4)\u6d41\u6279\u4e00\u4f53\u67b6\u6784<\/strong>\uff1a\u6d41\u6279\u4e00\u4f53\u67b6\u6784\u6bd4\u8f83\u5b8c\u7f8e\u7684\u5b9e\u73b0\u65b9\u5f0f\u662f\u91c7\u7528\u6d41\u8ba1\u7b97 + \u4ea4\u4e92\u5f0f\u5206\u6790\u53cc\u5f15\u64ce\u67b6\u6784\uff0c\u5728\u8fd9\u4e2a\u67b6\u6784\u4e2d\uff0c\u6d41\u8ba1\u7b97\u8d1f\u8d23\u7684\u662f\u57fa\u7840\u6570\u636e\uff0c\u800c\u4ea4\u4e92\u5f0f\u5206\u6790\u5f15\u64ce\u662f\u4e2d\u5fc3\uff0c\u6d41\u8ba1\u7b97\u5f15\u64ce\u5bf9\u6570\u636e\u8fdb\u884c\u5b9e\u65f6 ETL \u5de5\u4f5c\uff0c\u4e0e\u79bb\u7ebf\u76f8\u6bd4\uff0c\u964d\u4f4e\u4e86 ETL \u8fc7\u7a0b\u7684 latency\uff0c\u4ea4\u4e92\u5f0f\u5206\u6790\u5f15\u64ce\u5219\u81ea\u5e26\u5b58\u50a8\uff0c\u901a\u8fc7\u8ba1\u7b97\u5b58\u50a8\u7684\u534f\u540c\u4f18\u5316\uff0c \u5b9e\u73b0\u9ad8\u5199\u5165 TPS\u3001\u9ad8\u67e5\u8be2 QPS \u548c\u4f4e\u67e5\u8be2 latency \uff0c\u4ece\u800c\u505a\u5230\u5168\u94fe\u8def\u7684\u5b9e\u65f6\u5316\u548c SQL \u5316\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u7528\u6279\u7684\u65b9\u5f0f\u5b9e\u73b0\u5b9e\u65f6\u5206\u6790\u548c\u6309\u9700\u5206\u6790\uff0c\u5e76\u80fd\u5feb\u901f\u7684\u54cd\u5e94\u4e1a\u52a1\u7684\u53d8\u5316\uff0c\u4e24\u8005\u914d\u5408\uff0c\u5b9e\u73b0 1 + 1 > 2 \u7684\u6548\u679c;\u8be5\u67b6\u6784\u5bf9\u4ea4\u4e92\u5f0f\u5206\u6790\u5f15\u64ce\u7684\u8981\u6c42\u975e\u5e38\u9ad8\uff0c\u4e5f\u8bb8\u662f\u672a\u6765\u5927\u6570\u636e\u5e93\u6280\u672f\u53d1\u5c55\u7684\u4e00\u4e2a\u91cd\u70b9\u548c\u65b9\u5411\u3002<\/p>\n

\u4e3a\u4e86\u5e94\u5bf9\u4e1a\u52a1\u65b9\u66f4\u590d\u6742\u7684\u591a\u7ef4\u5b9e\u65f6\u6570\u636e\u5206\u6790\u9700\u6c42\uff0c\u7b14\u8005\u76ee\u524d\u5728\u6570\u636e\u5f00\u53d1\u4e2d\u5f15\u5165 Kudu\u8fd9\u4e2a OLAP \u5b58\u50a8\u5f15\u64ce\uff0c\u5bf9\u8ba2\u5355\u7b49\u4e1a\u52a1\u6570\u636e\u4f7f\u7528 Presto + Kudu \u7684\u8ba1\u7b97\u65b9\u6848\u4e5f\u662f\u5728\u63a2\u7d22\u6d41\u6279\u4e00\u4f53\u67b6\u6784\u5728\u5b9e\u65f6\u6570\u636e\u5206\u6790\u9886\u57df\u7684\u53ef\u884c\u6027\u3002\u6b64\u5916\uff0c\u76ee\u524d\u6bd4\u8f83\u70ed\u7684\u6570\u636e\u6e56\u6280\u672f\uff0c\u5982 Delta lake\u3001Hudi \u7b49\u652f\u6301\u5728 HDFS \u4e0a\u8fdb\u884c upsert \u66f4\u65b0\uff0c\u968f\u7740\u5176\u6d41\u5f0f\u5199\u5165\u3001SQL \u5f15\u64ce\u652f\u6301\u7684\u6210\u719f\uff0c\u672a\u6765\u53ef\u4ee5\u7528\u4e00\u5957\u5b58\u50a8\u5f15\u64ce\u89e3\u51b3\u5b9e\u65f6\u3001\u79bb\u7ebf\u6570\u636e\u9700\u6c42\uff0c\u4ece\u800c\u51cf\u5c11\u591a\u5f15\u64ce\u8fd0\u7ef4\u5f00\u53d1\u6210\u672c\u3002<\/p>\n

\u4e09\u3001Flink SQL \u5b9e\u65f6\u8ba1\u7b97 UV \u6307\u6807<\/strong><\/div>\n

\u4e0a\u4e00\u90e8\u5206\u4ece\u5b8f\u89c2\u5c42\u9762\u4ecb\u7ecd\u4e86\u5982\u4f55\u5efa\u8bbe\u5b9e\u65f6\u6570\u636e\u4f53\u7cfb\uff0c\u975e\u5e38\u4e0d\u63a5\u5730\u6c14\uff0c\u53ef\u80fd\u5927\u5bb6\u9700\u8981\u7684\u53ea\u662f\u4e00\u4e2a\u5177\u4f53\u7684 case \u6765\u4e86\u89e3\u4e00\u4e0b\u8be5\u600e\u4e48\u505a\uff0c\u90a3\u4e48\u63a5\u4e0b\u6765\u7528\u4e00\u4e2a\u63a5\u5730\u6c14\u7684\u6848\u4f8b\u6765\u4ecb\u7ecd\u5982\u4f55\u5b9e\u65f6\u8ba1\u7b97 UV \u6570\u636e\u3002<\/p>\n

\u5927\u5bb6\u90fd\u77e5\u9053\uff0c\u5728 ToC \u7684\u4e92\u8054\u7f51\u516c\u53f8\uff0cUV \u662f\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u6307\u6807\uff0c\u5bf9\u4e8e\u8001\u677f\u3001\u5546\u52a1\u3001\u8fd0\u8425\u7684\u53ca\u65f6\u51b3\u7b56\u4f1a\u4ea7\u751f\u5f88\u5927\u7684\u5f71\u54cd\uff0c\u7b14\u8005\u5728\u7535\u5546\u516c\u53f8\uff0c\u76ee\u524d\u4e3b\u8981\u7684\u5de5\u4f5c\u5c31\u662f\u8ba1\u7b97 UV\u3001\u9500\u552e\u7b49\u5404\u7c7b\u5b9e\u65f6\u6570\u636e\uff0c\u4f53\u9a8c\u5c31\u7279\u522b\u6df1\u523b\uff0c \u56e0\u6b64\u5c31\u7528\u4e00\u4e2a\u7b80\u5355demo \u6f14\u793a\u5982\u4f55\u7528 Flink SQL \u6d88\u8d39 Kafka \u4e2d\u7684 PV \u6570\u636e\uff0c\u5b9e\u65f6\u8ba1\u7b97\u51fa UV \u6307\u6807\u540e\u5199\u5165 Hbase\u3002<\/p>\n

1\u3001Kafka \u6e90\u6570\u636e\u89e3\u6790<\/strong><\/span><\/div>\n

PV \u6570\u636e\u6765\u6e90\u4e8e\u57cb\u70b9\u6570\u636e\u7ecf FileBeat \u4e0a\u62a5\u6e05\u6d17\u540e\uff0c\u4ee5 ProtoBuffer \u683c\u5f0f\u5199\u5165\u4e0b\u6e38 Kafka\uff0c\u6d88\u8d39\u65f6\u7b2c\u4e00\u6b65\u8981\u5148\u53cd\u5e8f\u5217\u5316 PB \u683c\u5f0f\u7684\u6570\u636e\u4e3a Flink \u80fd\u8bc6\u522b\u7684 Row \u7c7b\u578b\uff0c\u56e0\u6b64\u4e5f\u5c31\u9700\u8981\u81ea\u5b9a\u4e49\u5b9e\u73b0 DeserializationSchema \u63a5\u53e3\uff0c\u5177\u4f53\u5982\u4e0b\u4ee3\u7801\uff0c \u8fd9\u91cc\u53ea\u62bd\u53d6\u8ba1\u7b97\u7528\u5230\u7684 PV \u7684 mid\u3001\u4e8b\u4ef6\u65f6\u95f4 time_local\uff0c\u5e76\u4ece\u5176\u89e3\u6790\u5f97\u5230 log_date \u5b57\u6bb5\uff1a<\/p>\n

public class PageViewDeserializationSchema implements DeserializationSchema {  \r\npublic static final Logger LOG = LoggerFactory.getLogger(PageViewDeserializationSchema.class);  \r\nprotected SimpleDateFormat dayFormatter;  \r\nprivate final RowTypeInfo rowTypeInfo;  \r\npublic PageViewDeserializationSchema(RowTypeInfo rowTypeInfo){  \r\ndayFormatter = new SimpleDateFormat(\"yyyyMMdd\", Locale.UK);  \r\nthis.rowTypeInfo = rowTypeInfo;  \r\n} \r\n \r\n@Override \r\n \r\npublic Row deserialize(byte[] message) throws IOException {  \r\nRow row = new Row(rowTypeInfo.getArity());  \r\nMobilePage mobilePage = null;  \r\ntry { \r\n \r\nmobilePage = MobilePage.parseFrom(message);  \r\nString mid = mobilePage.getMid();  \r\nrow.setField(0, mid);  \r\nLong timeLocal = mobilePage.getTimeLocal();  \r\nString logDate = dayFormatter.format(timeLocal);  \r\nrow.setField(1, logDate);  \r\nrow.setField(2, timeLocal);  \r\n}catch (Exception e){  \r\nString mobilePageError = (mobilePage != null) ? mobilePage.toString() : \"\";  \r\nLOG.error(\"error parse bytes payload is {}, pageview error is {}\", message.toString(), mobilePageError, e);  \r\n} \r\n return null;  \r\n} \r\n<\/pre>\n
2\u3001\u7f16\u5199 Flink Job \u4e3b\u7a0b\u5e8f<\/strong><\/span><\/div>\n

\u5c06 PV \u6570\u636e\u89e3\u6790\u4e3a Flink \u7684 Row \u7c7b\u578b\u540e\uff0c\u63a5\u4e0b\u6765\u5c31\u5f88\u7b80\u5355\u4e86\uff0c\u7f16\u5199\u4e3b\u51fd\u6570\uff0c\u5199 SQL \u5c31\u80fd\u7edf\u8ba1 UV \u6307\u6807\u4e86\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

public class RealtimeUV {  \r\npublic static void main(String[] args) throws Exception {  \r\n\/\/step1 \u4eceproperties\u914d\u7f6e\u6587\u4ef6\u4e2d\u89e3\u6790\u51fa\u9700\u8981\u7684Kakfa\u3001Hbase\u914d\u7f6e\u4fe1\u606f\u3001checkpoint\u53c2\u6570\u4fe1\u606f  \r\nMap config = PropertiesUtil.loadConfFromFile(args[0]);  \r\nString topic = config.get(\"source.kafka.topic\");  \r\nString groupId = config.get(\"source.group.id\");  \r\nString sourceBootStrapServers = config.get(\"source.bootstrap.servers\");  \r\nString hbaseTable = config.get(\"hbase.table.name\");  \r\nString hbaseZkQuorum = config.get(\"hbase.zk.quorum\");  \r\nString hbaseZkParent = config.get(\"hbase.zk.parent\");  \r\nint checkPointPeriod = Integer.parseInt(config.get(\"checkpoint.period\"));  \r\nint checkPointTimeout = Integer.parseInt(config.get(\"checkpoint.timeout\"));  \r\nStreamExecutionEnvironment sEnv = StreamExecutionEnvironment.getExecutionEnvironment(); \r\n \r\n\/\/step2 \u8bbe\u7f6eCheckpoint\u76f8\u5173\u53c2\u6570\uff0c\u7528\u4e8eFailover\u5bb9\u9519 \r\n \r\nsEnv.getConfig().registerTypeWithKryoSerializer(MobilePage.class, \r\n \r\nProtobufSerializer.class);  \r\nsEnv.getCheckpointConfig().setFailOnCheckpointingErrors(false);  \r\nsEnv.getCheckpointConfig().setMaxConcurrentCheckpoints(1);  \r\nsEnv.enableCheckpointing(checkPointPeriod,CheckpointingMode.EXACTLY_ONCE);  \r\nsEnv.getCheckpointConfig().setCheckpointTimeout(checkPointTimeout);  \r\nsEnv.getCheckpointConfig().enableExternalizedCheckpoints(  \r\nCheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION); \r\n \r\n\/\/step3 \u4f7f\u7528Blink planner\u3001\u521b\u5efaTableEnvironment,\u5e76\u4e14\u8bbe\u7f6e\u72b6\u6001\u8fc7\u671f\u65f6\u95f4\uff0c\u907f\u514dJob OOM \r\n \r\nEnvironmentSettings environmentSettings = EnvironmentSettings.newInstance()  \r\n.useBlinkPlanner()  \r\n.inStreamingMode()  \r\n.build();  \r\nStreamTableEnvironment tEnv = StreamTableEnvironment.create(sEnv, environmentSettings); \r\ntEnv.getConfig().setIdleStateRetentionTime(Time.days(1), Time.days(2));  \r\nProperties sourceProperties = new Properties(); \r\n sourceProperties.setProperty(\"bootstrap.servers\", sourceBootStrapServers);  \r\nsourceProperties.setProperty(\"auto.commit.interval.ms\", \"3000\");  \r\nsourceProperties.setProperty(\"group.id\", groupId); \r\n \r\n\/\/step4 \u521d\u59cb\u5316KafkaTableSource\u7684Schema\u4fe1\u606f\uff0c\u7b14\u8005\u8fd9\u91cc\u4f7f\u7528register TableSource\u7684\u65b9\u5f0f\u5c06\u6e90\u8868\u6ce8\u518c\u5230Flink\u4e2d\uff0c\u800c\u6ca1\u6709\u7528register DataStream\u65b9\u5f0f\uff0c\u4e5f\u662f\u56e0\u4e3a\u60f3\u719f\u6089\u4e00\u4e0b\u5982\u4f55\u6ce8\u518cKafkaTableSource\u5230Flink\u4e2d \r\n \r\nTableSchema schema = TableSchemaUtil.getAppPageViewTableSchema();  \r\nOptional proctimeAttribute = Optional.empty();  \r\nList rowtimeAttributeDescriptors = Collections.emptyList();  \r\nMap fieldMapping = new HashMap<>();  \r\nList columnNames = new ArrayList<>(); \r\n \r\nRowTypeInfo rowTypeInfo = new RowTypeInfo(schema.getFieldTypes(), schema.getFieldNames()); \r\n \r\ncolumnNames.addAll(Arrays.asList(schema.getFieldNames()));  \r\ncolumnNames.forEach(name -> fieldMapping.put(name, name));  \r\nPageViewDeserializationSchema deserializationSchema = new  \r\nPageViewDeserializationSchema(  \r\nrowTypeInfo);  \r\nMap specificOffsets = new HashMap<>();  \r\nKafka011TableSource kafkaTableSource = new Kafka011TableSource( \r\n \r\nschema, \r\n \r\nproctimeAttribute,  \r\nrowtimeAttributeDescriptors,  \r\nOptional.of(fieldMapping),  \r\ntopic, \r\n \r\nsourceProperties,  \r\ndeserializationSchema,  \r\nStartupMode.EARLIEST,  \r\nspecificOffsets);  \r\ntEnv.registerTableSource(\"pageview\", kafkaTableSource); \r\n \r\n\/\/step5 \u521d\u59cb\u5316Hbase TableSchema\u3001\u5199\u5165\u53c2\u6570\uff0c\u5e76\u5c06\u5176\u6ce8\u518c\u5230Flink\u4e2d \r\n \r\nHBaseTableSchema hBaseTableSchema = new HBaseTableSchema(); \r\nhBaseTableSchema.setRowKey(\"log_date\", String.class);  \r\nhBaseTableSchema.addColumn(\"f\", \"UV\", Long.class);  \r\nHBaseOptions hBaseOptions = HBaseOptions.builder()  \r\n.setTableName(hbaseTable)  \r\n.setZkQuorum(hbaseZkQuorum)  \r\n.setZkNodeParent(hbaseZkParent)  \r\n.build(); \r\n \r\nHBaseWriteOptions hBaseWriteOptions = HBaseWriteOptions.builder() \r\n.setBufferFlushMaxRows(1000)  \r\n.setBufferFlushIntervalMillis(1000)  \r\n.build();  \r\nHBaseUpsertTableSink hBaseSink = new HBaseUpsertTableSink(hBaseTableSchema, hBaseOptions, hBaseWriteOptions);  \r\ntEnv.registerTableSink(\"uv_index\", hBaseSink); \r\n \r\n\/\/step6 \u5b9e\u65f6\u8ba1\u7b97\u5f53\u5929UV\u6307\u6807sql, \u8fd9\u91cc\u4f7f\u7528\u6700\u7b80\u5355\u7684group by agg\uff0c\u6ca1\u6709\u4f7f\u7528minibatch\u6216\u7a97\u53e3\uff0c\u5728\u5927\u6570\u636e\u91cf\u4f18\u5316\u65f6\u6700\u597d\u4f7f\u7528\u540e\u4e24\u79cd\u65b9\u5f0f \r\n \r\nString uvQuery = \"insert into uv_index \"  \r\n+ \"select log_date,\\n\"  \r\n+ \"ROW(count(distinct mid) as UV)\\n\"  \r\n+ \"from pageview\\n\"  \r\n+ \"group by log_date\";  \r\ntEnv.sqlUpdate(uvQuery);  \r\n\/\/step7 \u6267\u884cJob  \r\nsEnv.execute(\"UV Job\");  \r\n}  \r\n} \r\n<\/pre>\n

\u4ee5\u4e0a\u5c31\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f7f\u7528 Flink SQL \u7edf\u8ba1 UV \u7684 case, \u4ee3\u7801\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u7406\u6e05\u695a\u5982\u4f55\u89e3\u6790 Kafka \u4e2d\u6570\u636e\uff0c\u5982\u4f55\u521d\u59cb\u5316 Table Schema\uff0c\u4ee5\u53ca\u5982\u4f55\u5c06\u8868\u6ce8\u518c\u5230 Flink\u4e2d\uff0c\u5373\u53ef\u4f7f\u7528 Flink SQL \u5b8c\u6210\u5404\u79cd\u590d\u6742\u7684\u5b9e\u65f6\u6570\u636e\u7edf\u8ba1\u7c7b\u7684\u4e1a\u52a1\u9700\u6c42\uff0c\u5b66\u4e60\u6210\u672c\u6bd4API \u7684\u65b9\u5f0f\u4f4e\u5f88\u591a\u3002<\/p>\n

\u8bf4\u660e\u4e00\u4e0b\uff0c\u7b14\u8005\u8fd9\u4e2a demo \u662f\u57fa\u4e8e\u76ee\u524d\u4e1a\u52a1\u573a\u666f\u800c\u5f00\u53d1\u7684\uff0c\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u53ef\u4ee5\u771f\u5b9e\u8fd0\u884c\u8d77\u6765\uff0c\u53ef\u80fd\u4e0d\u80fd\u62c6\u7bb1\u5373\u7528\uff0c\u4f60\u9700\u8981\u7ed3\u5408\u81ea\u5df1\u7684\u4e1a\u52a1\u573a\u666f\u81ea\u5b9a\u4e49\u76f8\u5e94\u7684 kafka \u6570\u636e\u89e3\u6790\u7c7b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u968f\u7740\u4e92\u8054\u7f51\u7684\u53d1\u5c55\u8fdb\u5165\u4e0b\u534a\u573a\uff0c\u6570\u636e\u7684\u65f6\u6548\u6027\u5bf9\u4f01\u4e1a\u7684\u7cbe\u7ec6\u5316\u8fd0\u8425\u8d8a\u6765\u8d8a\u91cd\u8981\uff0c \u5546\u573a\u5982\u6218\u573a\uff0c\u5728\u6bcf\u5929\u4ea7\u751f\u7684\u6d77\u91cf\u6570\u636e\u4e2d\uff0c\u5982 […]<\/p>\n","protected":false},"author":1898,"featured_media":192811,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[565],"class_list":["post-192804","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread","tag-565"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1898"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=192804"}],"version-history":[{"count":7,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192804\/revisions"}],"predecessor-version":[{"id":194922,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192804\/revisions\/194922"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/192811"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=192804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=192804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=192804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}