mysqld_multi多实例及numactl资源绑定

很多时候,我们测试mysql性能,开启mysqld_multi功能,开多个mysql实例,同时使用numa工具绑定cpu,内存资源,防止多个mysql实例间资源竞争,影响性能,或者测试数据

mysqld_multi功能的开启在其他文章中已经介绍,这里主要讲的是numa绑定系统资源,

在新版本的linux内核中,已经很好的支持了numa功能,

命令行输入numactl可以看到一些numa信息

#numactl

 

usage: numactl [--interleave=nodes] [--preferred=node]

               [--physcpubind=cpus] [--cpunodebind=nodes]

               [--membind=nodes] [--localalloc] command args ...

       numactl [--show]

       numactl [--hardware]

       numactl [--length length] [--offset offset] [--shmmode shmmode]

               [--strict]

               [--shmid id] --shm shmkeyfile | --file tmpfsfile

               [--huge] [--touch] 

               memory policy | --dump | --dump-nodes

 

memory policy is --interleave, --preferred, --membind, --localalloc

nodes is a comma delimited list of node numbers or A-B ranges or all.

cpus is a comma delimited list of cpu numbers or A-B ranges or all

all ranges can be inverted with !

all numbers and ranges can be made cpuset-relative with +

the old --cpubind argument is deprecated.

use --cpunodebind or --physcpubind instead

length can have g (GB), m (MB) or k (KB) suffixes

 

介绍几个重要参数
–interleave=all 这是使用交叉分配模式启动一个程序,也就是说程序可以随意跨节点用其他节点的内存,传说中这是效率最高的关闭NUMA特性的方法,只是传说。
–cpunodebind=node 这是把程序绑定在指定的node节点上运行,即使另一个物理节点是idle的,也不会去使用。
–localalloc 严格控制只在节点内分配内存,禁止分配其他节点下的内存到当前节点运行的程序。

从上面的信息可以看到numa主要的功能模块,系统本身会划分numa节点

命令行输入numactl --hardware查看当前系统节点信息

 

node 0 cpus: 0 2 4 6

node 0 size: 65490 MB

node 0 free: 24447 MB

node 1 cpus: 1 3 5 7

node 1 size: 65536 MB

node 1 free: 16050 MB

node distances:

node   0   1 

  0:  10  20 

  1:  20  10 

 

可以看到numa节点是2个,cpu物理节点是8个

现在我们绑定资源,两颗cpu,每颗4个物理节点,那么我们开4个mysql实例,每个实例绑定2个cpu物理节点

numactl --physcpubind=0,3 --localalloc  mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf start 1

我们看下这个语句,--physcpubind 指定绑定的cpu节点,--localalloc表示使用内存方式,不交叉,以免降低性能,mysqld_multi是mysql实例启动命令

同样我们还可以做其他划分,绑定内存节点,划分I/O等等,

numa是个很好很强大的工具,使用非常简单。

 

 

你可能感兴趣的:(numa,numactl,physcpubidn)