jenkins中启动java的jar包起不来, 最终原因是没有swap空间。

1. 报错:

> OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000795380000, 591396864, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 591396864 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/hs_err_pid23.log

2. 查看服务器内存:

[root@me opt]# free -m
              total        used        free      shared  buff/cache   available
Mem:          31490       28715        2018           9         756        2380
Swap:             0           0           0
[root@me opt]# free -g
              total        used        free      shared  buff/cache   available
Mem:             30          28           1           0           0           2
Swap:             0           0           0

3. 操作:

[root@me opt]# dd if=/dev/zero of=swapfile bs=1024 count=500000
500000+0 records in
500000+0 records out
512000000 bytes (512 MB) copied, 1.41014 s, 363 MB/s
[root@me opt]# mkswap swapfile
Setting up swapspace version 1, size = 499996 KiB
no label, UUID=6f2e755d-d294-4f4c-8671-d965ae9d15e5
[root@soin opt]# swapon swapfile
swapon: /opt/swapfile: insecure permissions 0644, 0600 suggested.
[root@me opt]# free -h
              total        used        free      shared  buff/cache   available
Mem:            30G         28G        1.4G        9.1M        1.3G        2.3G
Swap:          488M          0B        488M

4. 解释说明:

4.1 root权限下,创建swapfile

第一步:创建一个大小为500M的文件
dd if=/dev/zero of=swapfile bs=1024 count=500000

4.2 将swapfile设置为swap空间

(第二步:把这个文件变成swap文件)
mkswap swapfile

4.3 启用交换空间,感同mount操作

swapon swapfile (删除交换空间 swapoff swapfile)

5. over


丰木
322 声望19 粉丝

遇见超乎想象的自己!