轻量服务器编译安装docker trojan时报错   72%时

通过以下操作解决,和编译其他软件类似,是内存不足引起的

编译安装swoole的时候报错 fatal error: Killed signal terminated program cc1plus compilation

 
 
在Linux上安装swoole时,服务器内存较小的情况下(0.5G或者1G内存时),会出
 
现“ fatal error: Killed signal terminated program cc1plus compilation “错误,可
 
以通过增大服务器SWAP大小来解决,本文是解决办法。
 
对于make编译,如果是阿里云centos主机内存小于2G的,可能会在make编译到45%、
 
63%时报错;如果是腾讯云centos主机内存为1G时,可能会在make编译到64%时报错。
 
 
===============阿里云测试结果(引用)==================
 
c++: Internal error: Killed (program cc1plus) Please submit a full bug report. See <http://bugzilla.redhat.com/bugzilla> for instructions. make[2]: *** [sql/CMakeFiles/sql.dir/item_geofunc.cc.o] Error 1 make[1]: *** [sql/CMakeFiles/sql.dir/all] Error 2 make: *** [all] Error 2
 
================腾讯云测试结果(实测)=================
 
g++: fatal error: Killed signal terminated program cc1plus compilation terminated. make[2]: *** [sql/CMakeFiles/sql_gis.dir/gis/crosses.cc.o] Error 1 make[1]: *** [sql/CMakeFiles/sql_gis.dir/all] Error 2 make: *** [all] Error 2
 
以上均为内存不足所致,可通过设置2G交换分区来解决该问题。
 
解决方案:
 
#获取要增加的2G的SWAP文件块
dd if=/dev/zero of=/swapfile bs=1k count=2048000
#创建SWAP文件
mkswap /swapfile
#激活SWAP文件
swapon /swapfile
#查看SWAP信息是否正确
swapon -s
#添加到fstab文件中让系统引导时自动启动
echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab
swapfile文件的路径在/var/下,
编译完后, 如果不想要交换分区了,
可以删除。
删除交换分区:
swapoff /swapfile
rm -rf /swapfile
至此,问题解决。