暂无图片
PostgreSQL记录一次备库所在主机swap占用问题处理
最近更新:2023-12-19 19:11:28
问题概述

近期遇到一个问题,数据库主机swap占用超50G,其中一个作为备节点的数据库进程占用36G

问题分析过程

内存使用情况,swap使用率80%

[postgres]$ free -g
              total        used        free      shared  buff/cache   available
Mem:            254          12          21          63         220         177
Swap:            63          50          13

查看占用swap较多的PID为数据库进程

[postgres]$ for i in $( cd /proc;ls |grep "^[0-9]"|awk ' $0 >100') ;do awk '/Swap:/{a=a+$2}END{print '"$i"',a/1024"M"}' /proc/$i/smaps 2>/dev/null ; done | sort -k2nr | head -10
2349619 38367.6M
2349618 38359.8M
2349620 38354.9M
2349616 38354.6M
2349622 38354.6M
1850974 38354.5M
3195297 38354.5M
3195791 38354.5M
1406798 9308.69M
1407289 9308.19M
[postgres]$ ps -ef|grep 2349616
postgres 1850974 2349616  0 Dec06 ?        00:00:00 postgres: user postgres ip(59370) idle
postgres 2349616       1  0 May26 ?        00:10:32 /app/pg_108_18801/postgresql/bin/postgres -D /data1/data_108_18801/data
postgres 2349617 2349616  0 May26 ?        00:01:11 postgres: logger   
......