内存不足且没有交换空间的解决办法

技术问题 · Fecmall · 于 6年前 发布 · 3226 次阅读

转载地址:https://www.cnblogs.com/asworm/p/4886210.html

解决的问题:

1.composer安装fxp插件时候内存不足提示提示:Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar

2.npm install的时候经常自己killed

解决拌饭:

root@tyr:/var/www/html/laravel# free -m

             total       used       free     shared    buffers     cached
Mem:           488        414         74         24          1         71
-/+ buffers/cache:        340        147
Swap:            0          0          0

root@tyr:/var/www/html/laravel# /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024

1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 25.3413 s, 42.4 MB/s

root@tyr:/var/www/html/laravel# /sbin/mkswap /var/swap.1

Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=60a9b908-925a-4161-8fca-7ae2d5a76154

root@tyr:/var/www/html/laravel# /sbin/swapon /var/swap.1

root@tyr:/var/www/html/laravel# free -m

             total       used       free     shared    buffers     cached
Mem:           488        474         13         24          2        127
-/+ buffers/cache:        344        143
Swap:         1023          0       1023
共收到 2 条回复
Caisen1988#14年前 0 个赞

你好,会遇到下面这个报错 /var/swap.1 没有权限,我设置了它指定的权限好像还是不行

root@9d70ce4aede1:/www/web# free -m
             total       used       free     shared    buffers     cached
Mem:           985        725        260          1          5         78
-/+ buffers/cache:        641        343
Swap:            0          0          0
root@9d70ce4aede1:/www/web# /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 3.61912 s, 297 MB/s
root@9d70ce4aede1:/www/web# /sbin/mkswap /var/swap.1
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=0110fb0f-9d9d-4d52-b19d-a9b482030d95
root@9d70ce4aede1:/www/web# /sbin/swapon /var/swap.1
swapon: /var/swap.1: insecure permissions 0644, 0600 suggested.
swapon: /var/swap.1: swapon failed: Operation not permitted
root@9d70ce4aede1:/www/web# free -m
             total       used       free     shared    buffers     cached
Mem:           985        923         61          1          2        271
-/+ buffers/cache:        649        335
Swap:            0          0          0

```
Fecmall#24年前 0 个赞

@Caisen1988 #1楼 报错信息,google一下查查资料吧

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics