操作系统:Ubuntu 16.04
我想从Digitalocean在我的512mb RAM VPS服务器上安装redis-server,我得到了命令,我得到了,
Extracting templates from packages: 100%
Preconfiguring packages ...
(Reading database ... 311316 files and directories currently installed.)
Preparing to unpack .../libisc-export160_1%3a9.10.3.dfsg.P4-
8ubuntu1.9_amd64.deb ...
Unpacking libisc-export160 (1:9.10.3.dfsg.P4-8ubuntu1.9) over
(1:9.10.3.dfsg.P4-8ubuntu1.7) ...
dpkg: unrecoverable fatal error, aborting:
fork failed: Cannot allocate memory
E: Sub-process /usr/bin/dpkg returned an error code (2)
我跑了sudo dpkg --configure -a和sudo apt-get -f install,我得到了
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libisc-export160
The following packages will be upgraded:
libisc-export160
1 upgraded, 0 newly installed, 0 to remove and 169 not upgraded.
1 not fully installed or removed.
Need to get 0 B/153 kB of archives.
After this operation, 1,024 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 311316 files and directories currently installed.)
Preparing to unpack .../libisc-export160_1%3a9.10.3.dfsg.P4-
8ubuntu1.9_amd64.deb ...
E: Sub-process /usr/bin/dpkg returned an error code (2)
我查了一下空间,
man@pay:$ free -t
total used free shared buff/cache available
Mem: 500060 352068 76032 5800 71960 114020
Swap: 0 0 0
Total: 500060 352068 76032
安装redis-server软件包时我缺少什么?
答案 0 :(得分:2)
dpkg: unrecoverable fatal error, aborting:
fork failed: Cannot allocate memory
这意味着您没有足够的内存来执行操作。
执行以下命令刷新文件系统缓冲区:
$ sync
现在再试一次。
如果您仍然遇到同样的问题,请按此操作。 要释放页面缓存:
$ echo 1 > /proc/sys/vm/drop_caches
释放dentries和i-nodes:
$ echo 2 > /proc/sys/vm/drop_caches
释放页面缓存,dentries和i-nodes:
$ echo 3 > /proc/sys/vm/drop_caches
现在再试一次。
使用redis-server时,使用RDB快照时可能会出现问题。对于写入,使用BGSAVE命令,该命令分叉当前进程,并在此分支中将数据写入磁盘。因此,主线程未被阻塞,并且写入异步发生。问题是在UNIX系统上调用fork()时,子进程还会复制父进程使用的内存内容。假设,如果Redis当前占用2Gb内存,并且系统中只剩下1Gb的可用内存,则执行BGSAVE命令时可能会出现以下错误:
# Can't save in background: fork: Cannot allocate memory
在现代系统中,当复制存储器用于分叉时,使用Copy on Write方法。仅在录制到相应部分时才复制存储器。 Redis只是为了异步保存数据而执行进程的分支,这个fork不会以任何方式更改它们,因此我们可以安全地将vm.overcommit_memory系统参数设置为1.此参数负责分配更多的可能性内存比可用。在/etc/sysctl.conf中添加一行:
vm.overcommit_memory = 1
重新阅读配置:
# sysctl -p
详情:
http://linuxamination.blogspot.com/2013/05/dpkg-unrecoverable-fatal-error-aborting.html