Linux内存不足,添加swap分区
swap分区属于交换分区,起虚拟内存的作用。由于内存资源的宝贵,于是将硬盘的一部分作为内存来使用。所以在内存不足的时候,就可以通过适当的增加交换分区大小来达到增加内存的作用。
在编译mysql5.7.23的时候,购买的服务器内存只有1G,没有分配swap分区。最后在make的时候报错。网上查阅是内存不足的原因。
c++: internal compiler error: Killed (program cc1plus) Please submit a
bug report, with preprocessed source if appropriate. See
<http://bugzilla.redhat.com/bugzilla> for instructions. make[2]: ***
[sql/CMakeFiles/sql.dir/item_geofunc.cc.o] Error 4 ma
解决方案
临时添加交换分区。
#创建1000M的分区文件
dd dd if=/dev/zero of=/swapfile bs=1024K count=1000
#创建swap分区文件
mkswap /swapfile
#挂载为swap分区
swapon /swapfile
#卸载之前挂载的swap分区
swapoff /swapfile
#查看内存状态
free -m