<
>

Mysql运行环境优化(Linux系统)

2019-01-05 10:01:15 来源:易采站长站 作者:于丽

在新版的mysqld_safe脚本中自带如下内容,所以不需要添加,你可以看看你的mysqld_safe脚本有没有如下内容。


if true && test $numa_interleave -eq 1
then
# Locate numactl, ensure it exists.
if ! my_which numactl > /dev/null 2>&1
then
log_error “numactl command not found, required for –numa-interleave”
exit 1
# Attempt to run a command, ensure it works.
elif ! numactl –interleave=all true
then
log_error “numactl failed, check if numactl is properly installed”
fi  # Launch mysqld with numactl.
cmd=”$cmd numactl –interleave=all”
elif test $numa_interleave -eq 1
then
log_error “–numa-interleave is not supported on this platform”
exit 1
fi

四、修改swappiness设置
swappiness是linux的一个内核参数,用来控制物理内存交换出去的策略.它允许一个百分比的值,最小的为0,最大的为100,改值默认是60.可以通过下面命令观察

# sysctl -a | grep swappiness
vm.swappiness = 60

这个设置值到底有什么影响呢?
vm.swappiness设置为0表示尽量少使用swap,100表示尽量将inactive的内存页交换到swap里或者释放cache(cache类似于预读的文件)。
inactive内存的意思是程序映射着,但是”长时间”不用的内存。我们可以利用vmstat查看系统里面有多少inactive的内存。

# vmstat -a 1
procs ———–memory———- —swap– —–io—- –system– —–cpu——
r  b   swpd   free  inact active   si   so    bi    bo   in   cs us sy id wa st
0  0 16930764 192752 3673320 28601732    0    0    19    31    0    0  1  0 99  0  0
1  0 16930764 192752 3673320 28601732    0    0     0     0 1136  271  0  0 100  0  0
0  0 16930764 192748 3673320 28601732    0    0     0    56 1167  325  1  0 99  0  0
0  0 16930764 192740 3673320 28601732    0    0     0    40 1039  164  0  0 100  0  0

在Centos7之前,这个值建议设置为0,但是在新版本的内核里面,这样设置可能导致OOM(内存溢出),然后kernel会杀掉使用内存最多的mysqld进程。

所以现在这个值推荐设置为1,设置方法如下:

在/etc/sysctl.conf文件中增加一行。

暂时禁止评论

微信扫一扫

易采站长站微信账号