场景:
安装软件:yum -y install gcc gcc-c++ libstdc++-devel
安装报错:
Error downloading packages:
libgcc-4.8.5-39.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
libmpc-1.0.1-3.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
libgomp-4.8.5-39.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
cpp-4.8.5-39.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
libstdc++-4.8.5-39.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
libstdc++-devel-4.8.5-39.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
mpfr-3.1.1-4.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
gcc-4.8.5-39.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
gcc-c++-4.8.5-39.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
分析:
进程数跑满了,或者内存跑完了
解决方案:
查看服务器的进程数
[root@instance-x0nj9foj redis]# ps -eLf | wc -l
690
修改最大进程数
echo "kernel.pid_max=1000000 " >> /etc/sysctl.conf
sysctl -p
查看内存情况,
[root@instance-x0nj9foj redis]# free
total used free shared buff/cache available
Mem: 1014876 666464 60664 57608 287748 130240
Swap: 0 0 0
---发现没有开启虚拟内存
创建目录
mkdir /swap
创建虚拟内存磁盘卷
dd if=/dev/zero of=/swap/swapadd bs=1024 count=2024288
3、将磁盘卷转为虚拟内存卷
mkswap /swap/swapadd
4、启用虚拟内存服务
swapon /swap/swapadd
设定后的内存情况
[root@instance-x0nj9foj redis]# free
total used free shared buff/cache available
Mem: 1014876 673732 72748 57608 268396 123088
Swap: 2024284 0 2024284
重新安装软件一切正常:
Complete!