Java 拒绝在低权限用户的 Linux 中启动(作为 root 工作正常)

发布于 2024-12-03 07:23:34 字数 1351 浏览 2 评论 0原文

我被踩住了。

作为 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)

作为低权限用户时:

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.

更新:

ulimit -a 的输出(当作为低权限用户运行时):

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

血之狂魔 2024-12-10 07:23:34
virtual memory          (kbytes, -v) 200000

这就是你的罪魁祸首。具有 32M 堆的 Java Vm 不适合这样的情况:

$ 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.
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.
寄离 2024-12-10 07:23:34

将以下行添加到 /etc/security/limits.conf

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

替换为您的 Linux 用户。 -as(地址空间)将用于修改虚拟/实际内存。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文