Powershell遠程在Azure A7虛擬機器執行Java JVM失敗

來源:互聯網
上載者:User

標籤:lvm   flow   except   1.7   track   maps   pre   錯誤   ror   

       近期。使用Powershell指令碼在A7 (8核,56G記憶體)配置的 Azure VM(Virtual Machine。虛擬機器)上遠程運行Java JVM時 (java.exe -version)。總是失敗並返回例如以下的錯誤資訊。

相同的Powershell指令碼。在其他低於A7配置的VM上遠程運行一切正常;此外,假設使用遠端桌面登入到VM上,再進行相同的操作,一切運行正常。


Error occurred during initialization of VMUnable to allocate 458752KB bitmaps for parallel garbage collection for the requested 14680064KB heap.Error occurred during initialization of VMCould not reserve enough space for object heap

   

       以上的實驗排除了是JVM(1.7)本身的問題。 看來問題非常有可能是出在Powershell的遠程運行方式上。

Powershell Remoting依賴於WinRM (Windows Remote Management)在遠程機器上運行操作。預設情況下,WinRM為每一個Powershell遠端連線分配了最大(MaxMemoryPerShellMB=1024)1G的記憶體空間(早期的版本號碼僅僅有150M),用於運行遠程操作。

但遠程操作所需的運行記憶體空間 > 1G時,就會出現了記憶體不足的問題,不同的操作可能表現會有所不同,如:有的會拋出OutOfMemoryException等。針對這個問題。解決的辦法就是添加MaxMemoryPerShellMB,然後重新啟動WinRM服務:


$maxMemoryPerShellVM = 3072Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB $maxMemoryPerShellVMSet-Item WSMan:\localhost\Plugin\Microsoft.PowerShell\Quotas\MaxMemoryPerShellMB $maxMemoryPerShellVMWrite-Output "List MaxMemoryPerShellMB configuration"Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB Get-Item WSMan:\localhost\Plugin\Microsoft.PowerShell\Quotas\MaxMemoryPerShellMB # Restart WinRM service to make the change take effectRestart-Service winrm


詳細要添加到多大的記憶體,須要自己去實驗一下。


參考資源

http://blog.patricknielsen.net/2012/01/powershell-remote-system-call-using.html

http://stackoverflow.com/questions/4741676/powershell-problem-running-java-remotely



Powershell遠程在Azure A7虛擬機器執行Java JVM失敗

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.