Java Refuses to Start in Linux under low privilege

2019-08-04 03:16发布

I'm stomped.

While as root:

root@web01 [~]# uname -a
Linux web01 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64 x86_64 x86_64 GNU/Linux`

root@web01 [~]# java -version
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)

While as a low-privilege user:

user@web01 [~]# java -Xmx32m -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

UPDATED:

Output of ulimit -a (when run as the low privilege user):

core file size          (blocks, -c) 200000
data seg size           (kbytes, -d) 200000
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 7875
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) 200000
open files                      (-n) 100
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 35
virtual memory          (kbytes, -v) 200000
file locks                      (-x) unlimited

标签: java linux root
2条回答
家丑人穷心不美
2楼-- · 2019-08-04 04:14

Add following lines to the /etc/security/limits.conf

<user> soft as unlimited
<user> hard as unlimited

Replace <user> with your linux user. -as(address space) will be used to modify virtual/actual memory.

查看更多
贼婆χ
3楼-- · 2019-08-04 04:20
virtual memory          (kbytes, -v) 200000

Here's your culprit. A Java Vm with 32M heap won't fit into that:

$ java -version
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.3) (fedora-59.1.10.3.fc15-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
$ ulimit -v 200000
$ java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
查看更多
登录 后发表回答