溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Linux屏蔽storm ui的kill功能的方法步驟

發(fā)布時間:2021-09-27 15:30:24 來源:億速云 閱讀:136 作者:iii 欄目:系統(tǒng)運維

本篇內(nèi)容介紹了“Linux屏蔽storm ui的kill功能的方法步驟”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!

  有兩種方法:

  1.前端增加nginx,做location

  分析ui頁面,對應(yīng)kill的button,html中的action為:

  代碼如下:

  《input enabled=“” onclick=“confirmAction(‘xxxxxxxxxx’, ‘xxxxxxxx’, ‘kill’, true, 30)” type=“button” value=“Kill”》

  調(diào)用了js的confirmAction方法,這個方法存在于storm-core/src/ui/public/js/script.js 中,方法的定義如下:

  代碼如下:

  function confirmAction(id, name, action, wait, defaultWait) {var opts = {type:‘POST’,url:‘/topology/’ + id + ‘/’ + action};

  if (wait) {

  var waitSecs = prompt(‘Do you really want to ’ + action + ‘ topology “’ + name + ‘”? ’ +‘If yes, please, specify wait time in seconds:’,defaultWait);if (waitSecs != null && waitSecs != “” && ensureInt(waitSecs)) {opts.url += ‘/’ + waitSecs;} else {return false;}

  } else if (!confirm(‘Do you really want to ’ + action + ‘ topology “’ + name + ‘”?’)) {return false;}

  $(“input[type=button]”).attr(“disabled”, “disabled”);$.ajax(opts).always(function () {window.location.reload();}).fail(function () {alert(“Error while communicating with Nimbus.”)});return false;}

  以看到方法主要分為兩步,生成post請求的url,格式為‘/topology/’ + id + ‘/’ + action + ‘/’ + waitSecs,這里action為kill,waitSecs為觸發(fā)kill時手動填入的時間,比如這里的30s,最終的url格式如下:

  代碼如下:

  /topology/xxxxx/kill/xxxx

  第二步就是根據(jù)這個設(shè)置觸發(fā)一個ajax請求,這里我們只需要關(guān)心第一步即可,設(shè)置nginx如下:

  代碼如下:

  upstream storm {

  server 127.0.0.1:8888 weight=3 max_fails=3 fail_timeout=5s;}

  server {

  server_name storm.xxx.com;

  listen 80;

  proxy_set_header Host $host;

  proxy_read_timeout 3600;

  proxy_set_header X-Forwarded-For $remote_addr;access_log /var/log/nginx/storm.access.log main;error_log /var/log/nginx/storm.error.log debug;location ~* /topology/(.*)/kill/(.*) {return 403;}

  location / {

  proxy_pass http://storm;

  }

  }

  這樣,就可以屏蔽掉前端的kill功能了。

  注意一個細節(jié),storm ui的默認端口時8080,這個端口和nm沖突(見bug https://github.com/yahoo/storm-yarn/issues/25),設(shè)置storm.yaml ui.port: 8888,并重啟ui即可。

  2.更改代碼,去掉action相關(guān)的button

  代碼如下:

  storm-core/src/ui/public/topology.html

  去除掉下面的部分:

  代碼如下:

  《div id=“topology-actions”》

  《h3 class=“js-only”》Topology actions《/h3》

  《p id=“topology-actions” class=“js-only”》

  《/p》

  《/div》

“Linux屏蔽storm ui的kill功能的方法步驟”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI