gpt4 book ai didi

java - php(网络服务器)调用java不工作

转载 作者:行者123 更新时间:2023-12-01 09:51:02 28 4
gpt4 key购买 nike

问题

  • 在php(Web服务器)中调用java时,出现内存不足错误。

状态

  • 网络服务器 - centos 6、nginx、php-fpm、java
  • 在centos中调用java - 成功
  • 在 php 中调用 java - 发生内存不足错误

调用API

  • 案例:php
$string = exec('java -Xms2g -Xmx2g -jar /usr/share/nginx/html/my_test.jar /mytmp/testfile’, $output, $code);
  • 案例:centos 6(linux)
java -Xms2g -Xmx2g -jar /usr/share/nginx/html/my_test.jar /mytmp/testfile

错误消息

# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2555904 bytes for committing reserved memory.
# Possible reasons:
# The system is out of physical RAM or swap space
# In 32 bit mode, the process size limit was hit
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 bit OS
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
# Out of Memory Error (os_linux.cpp:2673), pid=2549, tid=140226036020992
#
# JRE version: (8.0_45-b14) (build )
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#

问题

  • 为什么工作不同?
  • 如何解决这个问题?

我尝试了(未解决)

  • 设置内存
java -Xms2g -Xmx2g 

最佳答案

我解决了这个问题。
setsebool -P httpd_execmem 上

关于java - php(网络服务器)调用java不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37588128/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com