欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

阿里云ECS镜象默认未创建交换分区SWAP导致应用内存不够出现异常

程序员文章站 2022-06-02 16:41:33
...

阿里云环境数据宕机了。

SQL> connect / as sysdba
Connected to an idle instance.
SQL> show parameter sga
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0


SQL> shutdown immediate
ORA-01034: ORACLE not available
ORA-27102: out of memory
Linux-x86_64 Error: 12: Cannot allocate memory
Additional information: 26
Additional information: 23
Additional information: 1660944384

看内存发现swap没了


[[email protected] ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           7820        2654         142        3245        5023        1637
Swap:             0           0           0
[[email protected]]# dd if=/dev/zero of=/swapfile bs=1024 count=4194304
4194304+0 records in
4194304+0 records out
4294967296 bytes (4.3 GB) copied, 25.8686 s, 166 MB/s
[[email protected]]# mkswap /swapfile 
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=f0d30855-a3a0-4b09-85ff-f5a393059382
[[email protected]]# swapon /swapfile 
swapon: /swapfile: insecure permissions 0644, 0600 suggested.
[[email protected] ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           7.6G        1.9G        465M        3.2G        5.2G        2.2G
Swap:          4.0G          0B        4.0G

为什么交换分区没有?经分析是采用的阿里镜像快速安装的操作系统,没有交换分区。
按8G以上,按8G设交换分区,8G以下按实际物理内存设置交换分区。
对其他所有阿里云机器批量修改

[[email protected] ~]#  free -h
              total        used        free      shared  buff/cache   available
Mem:            15G        960M        5.3G        692K        9.3G         14G
Swap:            0B          0B          0B
[[email protected] ~]#  dd if=/dev/zero of=/swapfile bs=1024 count=8388608
8388608+0 records in
8388608+0 records out
8589934592 bytes (8.6 GB) copied, 38.701 s, 222 MB/s
[[email protected] ~]#  mkswap /swapfile 
Setting up swapspace version 1, size = 8388604 KiB
no label, UUID=65fd6266-3f89-4ada-931e-45d51c95e3e1
[[email protected] ~]#  swapon /swapfile
swapon: /swapfile: insecure permissions 0644, 0600 suggested.
[[email protected] ~]#  free -h
              total        used        free      shared  buff/cache   available
Mem:            15G        967M        174M        692K         14G         14G
Swap:          8.0G          0B        8.0G

为了确认下次开机自动打开SWAP

[[email protected] ~]# vi /etc/fstab
/swapfile	swap	swap	default	0	0
[[email protected] ~]# 
相关标签: ORACEL ECOLOGY