| <div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#docusaurus_skipToContent_fallback">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/zh-CN/"><div class="navbar__logo"><img src="/zh-CN/img/logo.png" alt="Apache Linkis Logo" class="themedImage_ToTc themedImage--light_HNdA"><img src="/zh-CN/img/logo.png" alt="Apache Linkis Logo" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate">Apache Linkis</b></a><a class="navbar__item navbar__link" href="/zh-CN/download/main">下载</a><a class="navbar__item navbar__link" href="/zh-CN/community/how-to-subscribe">社区</a><a class="navbar__item navbar__link" href="/zh-CN/blog">博客</a><a class="navbar__item navbar__link" href="/zh-CN/team">团队</a><a class="navbar__item navbar__link" href="/zh-CN/user">用户</a><a href="https://docs.qq.com/doc/DUkdTTGhVSlZ0VXVt" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">FAQ</a><div class="navbar__item dropdown dropdown--hoverable"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Apache</a><ul class="dropdown__menu"><li><a href="https://www.apache.org/" target="_blank" rel="noopener noreferrer" class="dropdown__link">基金会</a></li><li><a href="https://www.apache.org/licenses/" target="_blank" rel="noopener noreferrer" class="dropdown__link">证书</a></li><li><a href="https://www.apache.org/events/current-event" target="_blank" rel="noopener noreferrer" class="dropdown__link">事件</a></li><li><a href="https://www.apache.org/security/" target="_blank" rel="noopener noreferrer" class="dropdown__link">安全</a></li><li><a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">赞助</a></li><li><a href="https://privacy.apache.org/policies/privacy-policy-public.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Privacy</a></li><li><a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">致谢</a></li></ul></div></div><div class="navbar__items navbar__items--right"><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">文档</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/zh-CN/docs/latest/about/introduction">1.6.0</a></li><li><a class="dropdown__link" href="/zh-CN/docs/1.5.0/about/introduction">1.5.0</a></li><li><a class="dropdown__link" href="/zh-CN/docs/1.4.0/about/introduction">1.4.0</a></li><li><a class="dropdown__link" href="/zh-CN/docs/1.7.0/about/introduction">Next(1.7.0)</a></li><li><a class="dropdown__link" href="/zh-CN/versions">All Version</a></li></ul></div><a href="https://github.com/apache/linkis" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-github-link" aria-label="GitHub"></a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link"><svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" class="iconLanguage_nlXk"><path fill="currentColor" d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"></path></svg>简体中文</a><ul class="dropdown__menu"><li><a href="/docs/1.5.0/engine-usage/flink" target="_self" rel="noopener noreferrer" class="dropdown__link" lang="en">English</a></li><li><a href="/zh-CN/docs/1.5.0/engine-usage/flink" target="_self" rel="noopener noreferrer" class="dropdown__link dropdown__link--active" lang="zh-CN">简体中文</a></li></ul></div><div class="searchBox_ZlJk"><button type="button" class="DocSearch DocSearch-Button" aria-label="搜索"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">搜索</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX"><button aria-label="回到顶部" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebar_njMd"><nav class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.5.0/about/introduction">关于 Linkis</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.5.0/quick/live-demo">快速体验</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.5.0/deployment/deploy-quick">部署指南</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.5.0/user-guide/how-to-use">使用指南</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" href="/zh-CN/docs/1.5.0/engine-usage/overview">引擎使用</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/overview">总览</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/spark">Spark</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/hive">Hive</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/python">Python</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/shell">Shell</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/jdbc">JDBC</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/flink">Flink</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/openlookeng">openLooKeng</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/sqoop">Sqoop</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/pipeline">Pipeline</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/elasticsearch">ElasticSearch</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/presto">Presto</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/impala">Impala</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/trino">Trino</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/seatunnel">Seatunnel</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/hbase">HBase</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/repl">Repl</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.5.0/engine-usage/nebula">Nebula</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.5.0/auth/ldap">安全认证</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.5.0/api/overview">API</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.5.0/architecture/overview">架构设计</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.5.0/development/directory-structure">开发指南</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.5.0/tuning-and-troubleshooting/overview">调优排障</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.5.0/upgrade/upgrade-from-0.X-to-1.0-guide">升级指南</a></div></li></ul></nav></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="theme-doc-version-banner alert alert--warning margin-bottom--md" role="alert"><div>This is documentation for <!-- -->Apache Linkis<!-- --> <b>1.5.0</b>, 非最新版本。</div><div class="margin-top--md">有关最新文档,请参阅最新稳定版本<b><a href="/zh-CN/docs/latest/engine-usage/flink">latest version</a></b> (<!-- -->1.6.0<!-- -->).</div></div><div class="docItemContainer_Djhp"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="页面路径"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="主页面" class="breadcrumbs__link" href="/zh-CN/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_OVgt"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">引擎使用</span><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">Flink</span><meta itemprop="position" content="2"></li></ul></nav><span class="theme-doc-version-badge badge badge--secondary">版本:1.5.0</span><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><h1>Flink 引擎使用文档</h1><p>本文主要介绍在 <code>Linkis</code> 中,<code>flink</code> 引擎插件的安装、使用和配置。</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-前置工作">1. 前置工作<a class="hash-link" href="#1-前置工作" title="Direct link to heading"></a></h2><h3 class="anchor anchorWithStickyNavbar_LWe7" id="11-引擎环境配置">1.1 引擎环境配置<a class="hash-link" href="#11-引擎环境配置" title="Direct link to heading"></a></h3><p>如果您希望在您的服务器上使用 <code>Flink</code> 引擎,您需要保证以下的环境变量已经设置正确并且引擎的启动用户是有这些环境变量的。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="12-引擎验证">1.2 引擎验证<a class="hash-link" href="#12-引擎验证" title="Direct link to heading"></a></h3><p>强烈建议您在执行 <code>Flink</code> 任务之前,检查下执行用户的这些环境变量。具体方式是</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">sudo su - ${username}</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">echo ${JAVA_HOME}</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">echo ${FLINK_HOME}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><table><thead><tr><th>环境变量名</th><th>环境变量内容</th><th>备注</th></tr></thead><tbody><tr><td>JAVA_HOME</td><td>JDK安装路径</td><td>必须</td></tr><tr><td>HADOOP_HOME</td><td>Hadoop安装路径</td><td>必须</td></tr><tr><td>HADOOP_CONF_DIR</td><td>Hadoop配置路径</td><td>Linkis启动Flink引擎采用的Flink on yarn的模式,所以需要yarn的支持。</td></tr><tr><td>FLINK_HOME</td><td>Flink安装路径</td><td>必须</td></tr><tr><td>FLINK_CONF_DIR</td><td>Flink配置路径</td><td>必须,如 ${FLINK_HOME}/conf</td></tr><tr><td>FLINK_LIB_DIR</td><td>Flink包路径</td><td>必须,${FLINK_HOME}/lib</td></tr></tbody></table><h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-引擎插件安装">2. 引擎插件安装<a class="hash-link" href="#2-引擎插件安装" title="Direct link to heading"></a></h2><h3 class="anchor anchorWithStickyNavbar_LWe7" id="21-引擎插件准备二选一非默认引擎">2.1 引擎插件准备(二选一)<a href="/zh-CN/docs/1.5.0/engine-usage/overview">非默认引擎</a><a class="hash-link" href="#21-引擎插件准备二选一非默认引擎" title="Direct link to heading"></a></h3><p>方式一:直接下载引擎插件包</p><p><a href="https://linkis.apache.org/zh-CN/blog/2022/04/15/how-to-download-engineconn-plugin" target="_blank" rel="noopener noreferrer">Linkis 引擎插件下载</a></p><p>方式二:单独编译引擎插件(需要有 <code>maven</code> 环境)</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain"># 编译</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">cd ${linkis_code_dir}/linkis-engineconn-plugins/flink/</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">mvn clean install</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"># 编译出来的引擎插件包,位于如下目录中</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">${linkis_code_dir}/linkis-engineconn-plugins/flink/target/out/</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p><a href="/zh-CN/docs/1.5.0/deployment/install-engineconn">EngineConnPlugin 引擎插件安装</a></p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="22-引擎插件的上传和加载">2.2 引擎插件的上传和加载<a class="hash-link" href="#22-引擎插件的上传和加载" title="Direct link to heading"></a></h3><p>将 2.1 中的引擎插件包上传到服务器的引擎目录下</p><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic">${LINKIS_HOME}</span><span class="token plain">/lib/linkis-engineconn-plugins</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>上传后目录结构如下所示</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">linkis-engineconn-plugins/</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">├── flink</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">│ ├── dist</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">│ │ └── 1.12.2</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">│ │ ├── conf</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">│ │ └── lib</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">│ └── plugin</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">│ └── 1.12.2</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="23-引擎刷新">2.3 引擎刷新<a class="hash-link" href="#23-引擎刷新" title="Direct link to heading"></a></h3><h4 class="anchor anchorWithStickyNavbar_LWe7" id="231-重启刷新">2.3.1 重启刷新<a class="hash-link" href="#231-重启刷新" title="Direct link to heading"></a></h4><p>通过重启 <code>linkis-cg-linkismanager</code> 服务刷新引擎</p><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token builtin class-name" style="color:rgb(189, 147, 249)">cd</span><span class="token plain"> </span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic">${LINKIS_HOME}</span><span class="token plain">/sbin</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token function" style="color:rgb(80, 250, 123)">sh</span><span class="token plain"> linkis-daemon.sh restart cg-linkismanager</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="232-检查引擎是否刷新成功">2.3.2 检查引擎是否刷新成功<a class="hash-link" href="#232-检查引擎是否刷新成功" title="Direct link to heading"></a></h3><p>可以查看数据库中的 <code>linkis_engine_conn_plugin_bml_resources</code> 这张表的 <code>last_update_time</code> 是否为触发刷新的时间。</p><div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token comment" style="color:rgb(98, 114, 164)">#登陆到linkis的数据库 </span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">select</span><span class="token plain"> </span><span class="token operator">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">from</span><span class="token plain"> linkis_cg_engine_conn_plugin_bml_resources</span><span class="token punctuation" style="color:rgb(248, 248, 242)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="3-flink引擎的使用">3. Flink引擎的使用<a class="hash-link" href="#3-flink引擎的使用" title="Direct link to heading"></a></h2><p><code>Linkis</code> 的 <code>Flink</code> 引擎是通过 <code>flink on yarn</code> 的方式进行启动的,所以需要指定用户使用的队列,如下图所示。</p><p><img loading="lazy" alt="yarn" src="/zh-CN/assets/images/yarn-conf-395feb3695fdbf71df62544d5df21ad3.png" width="1296" height="556" class="img_ev3q"> </p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="31-通过-linkis-cli-提交任务">3.1 通过 <code>Linkis-cli</code> 提交任务<a class="hash-link" href="#31-通过-linkis-cli-提交任务" title="Direct link to heading"></a></h3><div class="language-shell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-shell codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token function" style="color:rgb(80, 250, 123)">sh</span><span class="token plain"> ./bin/linkis-cli -engineType flink-1.12.2 </span><span class="token punctuation" style="color:rgb(248, 248, 242)">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">-codeType sql -code </span><span class="token string" style="color:rgb(255, 121, 198)">"show tables"</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">-submitUser hadoop -proxyUser hadoop</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>更多 <code>Linkis-Cli</code> 命令参数参考: <a href="/zh-CN/docs/1.5.0/user-guide/linkiscli-manual"><code>Linkis-Cli</code> 使用</a></p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="32-通过-computationengineconn-提交任务">3.2 通过 <code>ComputationEngineConn</code> 提交任务<a class="hash-link" href="#32-通过-computationengineconn-提交任务" title="Direct link to heading"></a></h3><p><code>FlinkSQL</code> 可以支持多种数据源,例如 <code>binlog</code> , <code>kafka</code> , <code>hive</code> 等,如果您想要在 <code>Flink</code> 代码中使用这些数据源,您需要将这些 <code>connector</code> 的插件 <code>jar</code> 包放置到 <code>Flink</code> 引擎的 <code>lib</code> 中,并重启下 <code>Linkis</code> 的 <code>EnginePlugin</code> 服务。如你想要在您的 <code>FlinkSQL</code> 中使用 <code>binlog</code> 作为数据源,那么您需要将 <code>flink-connector-mysql-cdc-1.1.1.jar</code> 放置到 <code>Flink</code> 引擎的 <code>lib</code> 中。</p><p>为了方便大家进行采样调试,我们在 <code>Scriptis</code> 新增了 <code>fql</code> 的脚本类型,专门用于执行 <code>FlinkSQL</code> 。但是需要保证您的 <code>DSS</code> 已经升级到 <code>DSS1.0.0</code> 。升级到 <code>DSS1.0.0</code> 之后,您可以直接进入 <code>Scriptis</code> ,新建 <code>fql</code> 脚本进行编辑和执行。</p><p><code>FlinkSQL</code> 的编写示例,以 <code>binlog</code> 为例</p><div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">TABLE</span><span class="token plain"> mysql_binlog </span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> id </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">INT</span><span class="token plain"> </span><span class="token operator">NOT</span><span class="token plain"> </span><span class="token boolean">NULL</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> name STRING</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> age </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">INT</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">WITH</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'connector'</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'mysql-cdc'</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'hostname'</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'ip'</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'port'</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'port'</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'username'</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'username'</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'password'</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'password'</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'database-name'</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'dbname'</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'table-name'</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'tablename'</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'debezium.snapshot.locking.mode'</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'none'</span><span class="token plain"> </span><span class="token comment" style="color:rgb(98, 114, 164)">--建议添加,不然会要求锁表</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token punctuation" style="color:rgb(248, 248, 242)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">select</span><span class="token plain"> </span><span class="token operator">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">from</span><span class="token plain"> mysql_binlog </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">where</span><span class="token plain"> id </span><span class="token operator">></span><span class="token plain"> </span><span class="token number">10</span><span class="token punctuation" style="color:rgb(248, 248, 242)">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>在 <code>Scriptis</code> 中使用 <code>select</code> 语法进行调试的时候,<code>Flink</code> 引擎会有一个自动 <code>cancel</code> 的机制,即到了指定的时间或者采样的行数到了指定的数量,<code>Flink</code> 引擎将会主动将任务 <code>cancel</code> ,并且将已经获取到的结果集持久化,然后前端会调用打开结果集的接口将结果集在前端进行展示。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="33-通过-onceengineconn-提交任务">3.3 通过 <code>OnceEngineConn</code> 提交任务<a class="hash-link" href="#33-通过-onceengineconn-提交任务" title="Direct link to heading"></a></h3><p><code>OnceEngineConn</code> 的使用方式是用于正式启动 <code>Flink</code> 的流式应用,具体的是通过 <code>LinkisManagerClient</code> 调用 <code>LinkisManager</code> <code>的createEngineConn</code> 的接口,并将代码发给创建的 <code>Flink</code> 引擎,然后 <code>Flink</code> 引擎就开始执行,此方式可以被其他系统进行调用,比如 <code>Streamis</code> 。 <code>Client</code> 的使用方式也很简单,首先新建一个 <code>maven</code> 项目,或者在您的项目中引入以下的依赖。</p><div class="language-xml codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-xml codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">org.apache.linkis</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">linkis-computation-client</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">${linkis.version}</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>然后新建 <code>scala</code> 测试文件,点击执行,就完成了从一个 <code>binlog</code> 数据进行解析并插入到另一个 <code>mysql</code> 数据库的表中。但是需要注意的是,您必须要在 <code>maven</code> 项目中新建一个 <code>resources</code> 目录,放置一个 <code>linkis.properties</code> 文件,并指定 <code>linkis</code> 的 <code>gateway</code> 地址和 <code>api</code> 版本,如</p><div class="language-properties codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-properties codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">wds.linkis.server.version=v1</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">wds.linkis.gateway.url=http://ip:9001/</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><div class="language-java codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-java codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">object OnceJobTest {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> def main(args: Array[String]): Unit = {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> val sql = """CREATE TABLE mysql_binlog (</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | id INT NOT NULL,</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | name STRING,</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | age INT</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> |) WITH (</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'connector' = 'mysql-cdc',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'hostname' = 'ip',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'port' = 'port',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'username' = '${username}',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'password' = '${password}',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'database-name' = '${database}',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'table-name' = '${tablename}',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'debezium.snapshot.locking.mode' = 'none'</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> |);</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> |CREATE TABLE sink_table (</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | id INT NOT NULL,</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | name STRING,</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | age INT,</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | primary key(id) not enforced</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> |) WITH (</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'connector' = 'jdbc',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'url' = 'jdbc:mysql://${ip}:port/${database}',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'table-name' = '${tablename}',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'driver' = 'com.mysql.jdbc.Driver',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'username' = '${username}',</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> | 'password' = '${password}'</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> |);</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> |INSERT INTO sink_table SELECT id, name, age FROM mysql_binlog;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> |""".stripMargin</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> val onceJob = SimpleOnceJob.builder().setCreateService("Flink-Test").addLabel(LabelKeyUtils.ENGINE_TYPE_LABEL_KEY, "flink-1.12.2")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> .addLabel(LabelKeyUtils.USER_CREATOR_LABEL_KEY, "hadoop-Streamis").addLabel(LabelKeyUtils.ENGINE_CONN_MODE_LABEL_KEY, "once")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> .addStartupParam(Configuration.IS_TEST_MODE.key, true)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> // .addStartupParam("label." + LabelKeyConstant.CODE_TYPE_KEY, "sql")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> .setMaxSubmitTime(300000)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> .addExecuteUser("hadoop").addJobContent("runType", "sql").addJobContent("code", sql).addSource("jobName", "OnceJobTest")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> .build()</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> onceJob.submit()</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> println(onceJob.getId)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> onceJob.waitForCompleted()</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> System.exit(0)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> }</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"><a href="https://github.com/apache/linkis-website/edit/dev/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.5.0/engine-usage/flink.md" target="_blank" rel="noreferrer noopener" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_Z9Sw" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>编辑</a></div><div class="col lastUpdated_vwxv"></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><a class="pagination-nav__link pagination-nav__link--prev" href="/zh-CN/docs/1.5.0/engine-usage/jdbc"><div class="pagination-nav__sublabel">上一篇</div><div class="pagination-nav__label">JDBC</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/zh-CN/docs/1.5.0/engine-usage/openlookeng"><div class="pagination-nav__sublabel">下一篇</div><div class="pagination-nav__label">openLooKeng</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#1-前置工作" class="table-of-contents__link toc-highlight">1. 前置工作</a><ul><li><a href="#11-引擎环境配置" class="table-of-contents__link toc-highlight">1.1 引擎环境配置</a></li><li><a href="#12-引擎验证" class="table-of-contents__link toc-highlight">1.2 引擎验证</a></li></ul></li><li><a href="#2-引擎插件安装" class="table-of-contents__link toc-highlight">2. 引擎插件安装</a><ul><li><a href="#21-引擎插件准备二选一非默认引擎" class="table-of-contents__link toc-highlight">2.1 引擎插件准备(二选一)非默认引擎</a></li><li><a href="#22-引擎插件的上传和加载" class="table-of-contents__link toc-highlight">2.2 引擎插件的上传和加载</a></li><li><a href="#23-引擎刷新" class="table-of-contents__link toc-highlight">2.3 引擎刷新</a></li><li><a href="#232-检查引擎是否刷新成功" class="table-of-contents__link toc-highlight">2.3.2 检查引擎是否刷新成功</a></li></ul></li><li><a href="#3-flink引擎的使用" class="table-of-contents__link toc-highlight">3. Flink引擎的使用</a><ul><li><a href="#31-通过-linkis-cli-提交任务" class="table-of-contents__link toc-highlight">3.1 通过 <code>Linkis-cli</code> 提交任务</a></li><li><a href="#32-通过-computationengineconn-提交任务" class="table-of-contents__link toc-highlight">3.2 通过 <code>ComputationEngineConn</code> 提交任务</a></li><li><a href="#33-通过-onceengineconn-提交任务" class="table-of-contents__link toc-highlight">3.3 通过 <code>OnceEngineConn</code> 提交任务</a></li></ul></li></ul></div></div></div></div></main></div></div><footer class="footer"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Linkis</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/zh-CN/docs/latest/about/introduction">文档</a></li><li class="footer__item"><a class="footer__link-item" href="/zh-CN/faq/main">FAQ</a></li><li class="footer__item"><a href="https://github.com/apache/linkis/releases" target="_blank" rel="noopener noreferrer" class="footer__link-item">版本</a></li></ul></div><div class="col footer__col"><div class="footer__title">社区</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://github.com/apache/linkis" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li><li class="footer__item"><a href="https://github.com/apache/linkis/issues" target="_blank" rel="noopener noreferrer" class="footer__link-item">Issue Tracker</a></li><li class="footer__item"><a href="https://github.com/apache/linkis/pulls" target="_blank" rel="noopener noreferrer" class="footer__link-item">Pull Requests</a></li></ul></div><div class="col footer__col"><div class="footer__title">订阅邮件组</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/zh-CN/community/how-to-subscribe">如何订阅</a></li><li class="footer__item"><a href="mailto:dev-subscribe@linkis.apache.org" target="_blank" rel="noopener noreferrer" class="footer__link-item">订阅邮件</a></li><li class="footer__item"><a href="https://lists.apache.org/list.html?dev@linkis.apache.org" target="_blank" rel="noopener noreferrer" class="footer__link-item">邮件归档</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright"><div style="text-align: left;"> |