记一次MySQL5初始化被kill的问题排查 | 京东云技术团队

写在前面

由于测试环境JED申请比较繁琐,所以Eone提供了单机版Mysql供用户使用,近期Eone搭建Mysql5的时候发现莫名被kill了,容器规格是4C8G,磁盘30G

这不科学,之前都是可以的,镜像没变,配置没变,咋就不行了呢,一定不是我的问题,是机器的问题

问题排查

重现

通过多次搭建mysql5进行采样,发现并不是稳定复现,有一些容器是可以正常启动提供服务的,找到被mysql服务被kill的容器日志,发现是MySQL初始化被kill了,

/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/export/data/mysql/data --user=admin --initialize-insecure

mysql配置文件:

[client]
socket=/tmp/mysql.sock[mysqld]
basedir=/usr/local/mysql
datadir=/export/data/mysql/data
port=3306
server_id=1
socket=/tmp/mysql.sock
log-error=/tmp/mysqld.err
pid-file=/tmp/mysqld.pidskip-host-cache
skip-name-resolve
skip-grant-tables

问题排查

初始化为什么被kill?

手动执行了下初始化的命令,发现直接被kill了

通过dmesg命令发现,貌似oom了

纳尼?怎么用了这么多内存?容器都没这么大内存诶

通过排查,发现MySQL有一个8G的匿名内存,这是哪来的???

将容器规格调整为32G内存,再次尝试,发现成功启动了,但是内存占用貌似不太正常

这不科学,正常的容器内存使用情况是这样的👇

MySQL配置不合理?

难道是因为mysql设置的大小不合理?默认不设置innodb_buffer_pool_size按理说应该是128M才对,抱着侥幸心理设置下试下

然而问题依旧,改了配置也没有效果,看来不是配置的问题

真是机器的问题?

对比了一下正常启动的机器,拿着ip找到运维,发现异常的机器是近期添加的云舰系统的机器,之前centos系统宿主机是正常的,新加的云舰系统宿主机都是异常的,看来真是机器的问题,这两台机器有啥差别呢,接下来运维同学开启了排查之路:

1. 首先,看看两台宿主机是不是物理CPU总数不一样

2. 再确认下CentOS是否开启了富容器功能

对比了下两台宿主机的资源配置,发现好像是资源配置的问题

正常的机器配置是这样的

或许真的有可能,修改下open files限制再试下

ulimit -n 1048576

竟然可以了!!!MySQL正常提供服务了,真的是机器的问题

问题分析

strace log分析
28139 execve("/usr/local/mysql/bin/mysqld-debug", ["/usr/local/mysql/bin/mysqld-debu"..., "--initialize-insecure", "--basedir=/usr/local/mysql", "--datadir=/export/data/mysql/dat"..., "--user=admin"], 0x7ffe74bdcbe8 /* 294 vars */) = 0
28139 brk(NULL)                         = 0x4b50000
28139 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3bf6000
28139 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
28139 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
28139 fstat(3, {st_mode=S_IFREG|0644, st_size=16580, ...}) = 0
28139 mmap(NULL, 16580, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f93d3bf1000
28139 close(3)                          = 0
28139 open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
28139 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240l\0\0\0\0\0\0"..., 832) = 832
28139 fstat(3, {st_mode=S_IFREG|0755, st_size=142304, ...}) = 0
28139 mmap(NULL, 2208864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f93d37ba000
28139 mprotect(0x7f93d37d0000, 2097152, PROT_NONE) = 0
28139 mmap(0x7f93d39d0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f93d39d0000
28139 mmap(0x7f93d39d2000, 13408, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f93d39d2000
28139 close(3)                          = 0
28139 open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
28139 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\16\0\0\0\0\0\0"..., 832) = 832
28139 fstat(3, {st_mode=S_IFREG|0755, st_size=19520, ...}) = 0
28139 mmap(NULL, 2109744, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f93d35b6000
28139 mprotect(0x7f93d35b9000, 2093056, PROT_NONE) = 0
28139 mmap(0x7f93d37b8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f93d37b8000
28139 close(3)                          = 0
28139 open("/lib64/libaio.so.1", O_RDONLY|O_CLOEXEC) = 3
28139 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\5\0\0\0\0\0\0"..., 832) = 832
28139 fstat(3, {st_mode=S_IFREG|0755, st_size=6264, ...}) = 0
28139 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3bf0000
28139 mmap(NULL, 2101328, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f93d33b4000
28139 mprotect(0x7f93d33b5000, 2093056, PROT_NONE) = 0
28139 mmap(0x7f93d35b4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0) = 0x7f93d35b4000
28139 close(3)                          = 0
28139 open("/lib64/libnuma.so.1", O_RDONLY|O_CLOEXEC) = 3
28139 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0004\0\0\0\0\0\0"..., 832) = 832
28139 fstat(3, {st_mode=S_IFREG|0755, st_size=50704, ...}) = 0
28139 mmap(NULL, 2144448, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f93d31a8000
28139 mprotect(0x7f93d31b2000, 2097152, PROT_NONE) = 0
28139 mmap(0x7f93d33b2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa000) = 0x7f93d33b2000
28139 close(3)                          = 0
28139 open("/lib64/libcrypt.so.1", O_RDONLY|O_CLOEXEC) = 3
28139 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\16\0\0\0\0\0\0"..., 832) = 832
28139 fstat(3, {st_mode=S_IFREG|0755, st_size=40816, ...}) = 0
28139 mmap(NULL, 2318912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f93d2f71000
28139 mprotect(0x7f93d2f79000, 2093056, PROT_NONE) = 0
28139 mmap(0x7f93d3178000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7000) = 0x7f93d3178000
28139 mmap(0x7f93d317a000, 184896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f93d317a000
28139 close(3)                          = 0
28139 open("/lib64/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
28139 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\"\0\0\0\0\0\0"..., 832) = 832
28139 fstat(3, {st_mode=S_IFREG|0755, st_size=44096, ...}) = 0
28139 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3bef000
28139 mmap(NULL, 2128952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f93d2d69000
28139 mprotect(0x7f93d2d70000, 2093056, PROT_NONE) = 0
28139 mmap(0x7f93d2f6f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7f93d2f6f000
28139 close(3)                          = 0
28139 open("/lib64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
28139 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\264\5\0\0\0\0\0"..., 832) = 832
28139 fstat(3, {st_mode=S_IFREG|0755, st_size=995840, ...}) = 0
28139 mmap(NULL, 3175456, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f93d2a61000
28139 mprotect(0x7f93d2b4a000, 2097152, PROT_NONE) = 0
28139 mmap(0x7f93d2d4a000, 40960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe9000) = 0x7f93d2d4a000
28139 mmap(0x7f93d2d54000, 82976, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f93d2d54000
28139 close(3)                          = 0
28139 open("/lib64/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
28139 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260T\0\0\0\0\0\0"..., 832) = 832
28139 fstat(3, {st_mode=S_IFREG|0755, st_size=1141560, ...}) = 0
28139 mmap(NULL, 3150168, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f93d275f000
28139 mprotect(0x7f93d2860000, 2093056, PROT_NONE) = 0
28139 mmap(0x7f93d2a5f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x100000) = 0x7f93d2a5f000
28139 close(3)                          = 0
28139 open("/lib64/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
28139 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320*\0\0\0\0\0\0"..., 832) = 832
28139 fstat(3, {st_mode=S_IFREG|0755, st_size=88720, ...}) = 0
28139 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3bee000
28139 mmap(NULL, 2184192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f93d2549000
28139 mprotect(0x7f93d255e000, 2093056, PROT_NONE) = 0
28139 mmap(0x7f93d275d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0x7f93d275d000
28139 close(3)                          = 0
28139 open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
28139 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 \34\2\0\0\0\0\0"..., 832) = 832
28139 fstat(3, {st_mode=S_IFREG|0755, st_size=2112384, ...}) = 0
28139 mmap(NULL, 3936832, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f93d2187000
28139 mprotect(0x7f93d233e000, 2097152, PROT_NONE) = 0
28139 mmap(0x7f93d253e000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b7000) = 0x7f93d253e000
28139 mmap(0x7f93d2544000, 16960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f93d2544000
28139 close(3)                          = 0
28139 open("/lib64/libfreebl3.so", O_RDONLY|O_CLOEXEC) = 3
28139 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\v\0\0\0\0\0\0"..., 832) = 832
28139 fstat(3, {st_mode=S_IFREG|0755, st_size=11376, ...}) = 0
28139 mmap(NULL, 2105536, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f93d1f84000
28139 mprotect(0x7f93d1f86000, 2093056, PROT_NONE) = 0
28139 mmap(0x7f93d2185000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x7f93d2185000
28139 close(3)                          = 0
28139 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3bed000
28139 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3bec000
28139 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3bea000
28139 arch_prctl(ARCH_SET_FS, 0x7f93d3bea740) = 0
28139 mprotect(0x7f93d253e000, 16384, PROT_READ) = 0
28139 mprotect(0x7f93d37b8000, 4096, PROT_READ) = 0
28139 mprotect(0x7f93d2185000, 4096, PROT_READ) = 0
28139 mprotect(0x7f93d275d000, 4096, PROT_READ) = 0
28139 mprotect(0x7f93d2a5f000, 4096, PROT_READ) = 0
28139 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3be9000
28139 mprotect(0x7f93d2d4a000, 32768, PROT_READ) = 0
28139 mprotect(0x7f93d39d0000, 4096, PROT_READ) = 0
28139 mprotect(0x7f93d2f6f000, 4096, PROT_READ) = 0
28139 mprotect(0x7f93d3178000, 4096, PROT_READ) = 0
28139 mprotect(0x7f93d33b2000, 4096, PROT_READ) = 0
28139 mprotect(0x7f93d35b4000, 4096, PROT_READ) = 0
28139 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3be7000
28139 mprotect(0x7f93d3bf7000, 4096, PROT_READ) = 0
28139 munmap(0x7f93d3bf1000, 16580)     = 0
28139 set_tid_address(0x7f93d3beaa10)   = 28139
28139 set_robust_list(0x7f93d3beaa20, 24) = 0
28139 rt_sigaction(SIGRTMIN, {sa_handler=0x7f93d37c0780, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f93d37c9100}, NULL, 8) = 0
28139 rt_sigaction(SIGRT_1, {sa_handler=0x7f93d37c0810, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f93d37c9100}, NULL, 8) = 0
28139 rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
28139 getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
28139 brk(NULL)                         = 0x4b50000
28139 brk(0x4b71000)                    = 0x4b71000
28139 open("/proc/self/status", O_RDONLY) = 3
28139 fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
28139 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3bf5000
28139 read(3, "Name:\tmysqld-debug\nUmask:\t0022\nS"..., 1024) = 1024
28139 read(3, "0,00000000,00000000,00000000,000"..., 1024) = 334
28139 close(3)                          = 0
28139 munmap(0x7f93d3bf5000, 4096)      = 0
28139 openat(AT_FDCWD, "/sys/devices/system/node", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
28139 getdents(3, /* 11 entries */, 32768) = 360
28139 open("/sys/devices/system/node/node0/meminfo", O_RDONLY) = 4
28139 fstat(4, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
28139 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3bf5000
28139 read(4, "Node 0 MemTotal:       226242196"..., 4096) = 1175
28139 stat("/etc/sysconfig/64bit_strstr_via_64bit_strstr_sse2_unaligned", 0x7ffda2f609d0) = -1 ENOENT (No such file or directory)
28139 stat("/etc/sysconfig/64bit_strstr_via_64bit_strstr_sse2_unaligned", 0x7ffda2f609d0) = -1 ENOENT (No such file or directory)
28139 read(4, "", 4096)                 = 0
28139 close(4)                          = 0
28139 munmap(0x7f93d3bf5000, 4096)      = 0
28139 getdents(3, /* 0 entries */, 32768) = 0
28139 close(3)                          = 0
28139 sched_getaffinity(0, 512, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) = 8
28139 openat(AT_FDCWD, "/sys/devices/system/cpu", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
28139 getdents(3, /* 77 entries */, 32768) = 2368
28139 getdents(3, /* 0 entries */, 32768) = 0
28139 close(3)                          = 0
28139 open("/proc/self/status", O_RDONLY) = 3
28139 fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
28139 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3bf5000
28139 read(3, "Name:\tmysqld-debug\nUmask:\t0022\nS"..., 1024) = 1024
28139 read(3, "0,00000000,00000000,00000000,000"..., 1024) = 334
28139 read(3, "", 1024)                 = 0
28139 close(3)                          = 0
28139 munmap(0x7f93d3bf5000, 4096)      = 0
28139 futex(0x7f93d2d6696c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
28139 futex(0x7f93d2d66978, FUTEX_WAKE_PRIVATE, 2147483647) = 0
28139 stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=370, ...}) = 0
28139 open("/etc/my.cnf", O_RDONLY)     = 3
28139 fstat(3, {st_mode=S_IFREG|0644, st_size=370, ...}) = 0
28139 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93d3bf5000
28139 read(3, "[client]\nsocket=/tmp/mysql.sock\n"..., 4096) = 370
28139 read(3, "", 4096)                 = 0
28139 close(3)                          = 0
28139 munmap(0x7f93d3bf5000, 4096)      = 0
28139 stat("/etc/mysql/my.cnf", 0x7ffda2f5c8d0) = -1 ENOENT (No such file or directory)
28139 stat("/usr/local/mysql/etc/my.cnf", 0x7ffda2f5c8d0) = -1 ENOENT (No such file or directory)
28139 stat("/root/.my.cnf", 0x7ffda2f5c8d0) = -1 ENOENT (No such file or directory)
28139 getrlimit(RLIMIT_NOFILE, {rlim_cur=1073741816, rlim_max=1073741816}) = 0
28139 mmap(NULL, 17179869184, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8fd1f84000
28139 +++ killed by SIGKILL +++

可以看到最后用 mmap 一次分配了 16G 内存,然后就被杀了。

mmap 前调用了 getrlimit , 猜测是 mysql 会根据系统资源限制来分配内存

MySQL源码分析

MySQL 源码中直接调用 getrlimit 的地方不多,排除了 ndb、innodb_memcached、libevent 之后,只有一处直接调用:

static uint set_max_open_files(uint max_file_limit)
{struct rlimit rlimit;uint old_cur;DBUG_ENTER("set_max_open_files");DBUG_PRINT("enter",("files: %u", max_file_limit));if (!getrlimit(RLIMIT_NOFILE,&rlimit)){old_cur= (uint) rlimit.rlim_cur;DBUG_PRINT("info", ("rlim_cur: %u  rlim_max: %u",(uint) rlimit.rlim_cur,(uint) rlimit.rlim_max));if (rlimit.rlim_cur == (rlim_t) RLIM_INFINITY)rlimit.rlim_cur = max_file_limit;if (rlimit.rlim_cur >= max_file_limit)DBUG_RETURN(rlimit.rlim_cur);                /* purecov: inspected */rlimit.rlim_cur= rlimit.rlim_max= max_file_limit;if (setrlimit(RLIMIT_NOFILE, &rlimit))max_file_limit= old_cur;                        /* Use original value */else{rlimit.rlim_cur= 0;                        /* Safety if next call fails */(void) getrlimit(RLIMIT_NOFILE,&rlimit);DBUG_PRINT("info", ("rlim_cur: %u", (uint) rlimit.rlim_cur));if (rlimit.rlim_cur)                        /* If call didn't fail */max_file_limit= (uint) rlimit.rlim_cur;}}DBUG_PRINT("exit",("max_file_limit: %u", max_file_limit));DBUG_RETURN(max_file_limit);

其中逻辑是:如果系统的文件打开限制是 RLIM_INFINITY 或者比要设置的 max_file_limit 大,都返回系统的限制。

这个函数也只被直接调用一次:

uint my_set_max_open_files(uint files)
{struct st_my_file_info *tmp;DBUG_ENTER("my_set_max_open_files");DBUG_PRINT("enter",("files: %u  my_file_limit: %u", files, my_file_limit));files+= MY_FILE_MIN;files= set_max_open_files(MY_MIN(files, OS_FILE_LIMIT)); // 获取最大打开文件数if (files <= MY_NFILE)DBUG_RETURN(files);// 分配内存if (!(tmp= (struct st_my_file_info*) my_malloc(key_memory_my_file_info,sizeof(*tmp) * files,MYF(MY_WME))))DBUG_RETURN(MY_NFILE);// 初始化/* Copy any initialized files */memcpy((char*) tmp, (char*) my_file_info,sizeof(*tmp) * MY_MIN(my_file_limit, files));memset((tmp + my_file_limit), 0,MY_MAX((int) (files - my_file_limit), 0) * sizeof(*tmp));my_free_open_file_info();                        /* Free if already allocated */my_file_info= tmp;my_file_limit= files;DBUG_PRINT("exit",("files: %u", files));DBUG_RETURN(files);
}

原来 MySQL5 会根据最大可打开文件数,提前为每个文件分配和初始化内存,在这个时候就可能分配过多内存,导致 OOM。MySQL8修复了这个问题。

解决

启动前设置ulimit
ENTRYPOINT ["ulimit -n 1048576 && /home/admin/start.sh"]

写在后面

在linux中,open files设置过大会出现很多问题,应该合理控制open files数量

参考文献

https://learnku.com/articles/34598

作者:京东零售 杨云龙

来源:京东云开发者社区 转载请注明来源

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/107930.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

k8s-16 k8s调度

调度器通过 kubernetes 的 watch 机制来发现集群中新创建且尚未被调度到 Node上的 Pod。调度器会将发现的每一个未调度的 Pod 调度到一个合适的 Node 上来运行。 kube-scheduler 是 Kubernetes 集群的默认调度器&#xff0c;并且是集群控制面的一部分如果你真的希望或者有这方面…

企业立案信息API的优势与应用场景

引言 随着科技的不断进步&#xff0c;创业者和企业家们在创办新企业时愈发依赖数字化工具。其中&#xff0c;企业立案信息API成为了一项重要的资源&#xff0c;它提供了有关企业立案的关键信息&#xff0c;为企业家们提供了许多优势和丰富的应用场景。本文将探讨企业立案信息A…

MybatisPlus多表关联分页返回结果异常

1. 按照该博客进行多表关联分页查询&#xff1a; https://blog.csdn.net/code_ang/article/details/116448694 2.在实际测试过程中&#xff0c;发现异常&#xff0c;分页返回的结果时而正确&#xff0c;时而错误。 count函数满足预期 count函数不满足预期 只是count了主表的…

竞赛 深度学习YOLOv5车辆颜色识别检测 - python opencv

文章目录 1 前言2 实现效果3 CNN卷积神经网络4 Yolov56 数据集处理及模型训练5 最后 1 前言 &#x1f525; 优质竞赛项目系列&#xff0c;今天要分享的是 &#x1f6a9; **基于深度学习YOLOv5车辆颜色识别检测 ** 该项目较为新颖&#xff0c;适合作为竞赛课题方向&#xff0…

C++之基于Winsock2封装UDPServer与UDPClient

文章目录 Socket过程UDPServer.hUDPServer.cppUDPClient.hUDPClient.cppmain.cppCMakeLists.txt测试截图 Socket过程 UDPServer UDPClient UDPServer.h #ifndef UDPSERVER_H_INCLUDED #define UDPSERVER_H_INCLUDED#include <iostream> #include <string> #inclu…

SAP-FI模块 处理自动生成会计凭证增强

2、固定资产业务过渡科目摘要增强功能-MIGO ENHANCEMENT 2 ZEHENC_SAPMF05A. "active version * FI 20221215&#xff1a;固定资产业务过渡科目摘要增强功能 WAIT UP TO 1 SECONDS.READ TABLE xbseg WITH KEY hkont 1601990001. IF sy-subrc 0.DATA: lt_bkdf TYPE …

flink教程

文章目录 来自于尚硅谷教程1. Flink概述1.1 特点1.2 与SparkStreaming对比 2. Flink部署2.1 集群角色2.2 部署模式2.3 Standalone运行模式2.3.1 本地会话模式部署2.3.2 应用模式 2.4 YARN运行模式2.4.1 会话模式部署2.4.2 应用模式部署 2.5 历史服务 3. 系统架构3.1 并行度3.2 …

【C++】缺省参数与函数重载

&#x1f440;樊梓慕&#xff1a;个人主页 &#x1f3a5;个人专栏&#xff1a;《C语言》《数据结构》《蓝桥杯试题》《LeetCode刷题笔记》《实训项目》《C》 &#x1f31d;每一个不曾起舞的日子&#xff0c;都是对生命的辜负 前言 本篇文章博主将带你学习缺省参数与函数重载&…

.Net Core 6 运行环境手动安装流程

安装.NET Core 6 概述 在开始之前&#xff0c;我们首先需要了解一下整个安装过程的流程。下面的表格将展示安装.NET Core 6的步骤以及每一步需要做的事情。 步骤 动作 说明 1 下载.NET Core 6 SDK 从官方网站下载.NET Core 6 SDK安装包 2 安装.NET Core 6 SDK …

win10如何取消文件夹分组

问题描述 最近不知道把哪里碰了&#xff0c;win10文件夹显示的文件都是按照日期分组了&#xff0c;很讨厌。如下图所示 修改方法 1、文件夹空白处-右击 2、分组依据(P)-选择(无)(N) 下面是操作好之后的效果图 结束 -----华丽的分割线&#xff0c;以下是凑字数&#xff0c;大…

超声波清洗机需要注意什么?不能错过的超声波清洗机

超声波清洗机在当今社会已经越来越受到人们的欢迎&#xff0c;它利用超声波的振动来清洁物品表面&#xff0c;能够快速、高效地清除污垢、油脂等。但是&#xff0c;在购买超声波清洗机时&#xff0c;需要注意哪些问题呢&#xff1f;本文将为您介绍购买超声波清洗机需要注意的几…

2023/10/15总结

学习总结 最近开始写项目了&#xff0c;然后写的过程中遇到了跨域问题。 为什么会出现跨域问题 由于浏览器的同源策略限制。同源策略是一种约定&#xff0c;它是浏览器最核心也是最基本的安全功能。如果缺少了同源策略&#xff0c;那么浏览器的正常功能可能都会收到影响。所谓…

hash join的基本原理是怎样的?

我们知道数据库里面两表关联主要有三种常见的关联方式&#xff0c;即 nested loop joinhash joinmerge join nested loop join在OLTP交易场景占比是最多的&#xff0c;常用于关联字段为主键或索引字段的情况&#xff0c;通过主键或索引以及loop的方式&#xff0c;A表可以快速…

【特纳斯电子】基于单片机的火灾监测报警系统-仿真设计

视频及资料链接&#xff1a;基于单片机的火灾监测报警系统-仿真设计 - 电子校园网 (mcude.com) 编号&#xff1a; T0152203M-FZ 设计简介&#xff1a; 本设计是基于单片机的火灾监测报警系统&#xff0c;主要实现以下功能&#xff1a; 1.通过OLED显示温度、烟雾、是否有火…

摩尔信使MThings的设备高级参数

摩尔信使MThings支持三级参数管理方案&#xff0c;依次为&#xff1a;数据级、设备级、通道级。 设备级参数不仅包含设备名称、设备地址等常用信息&#xff0c;同时提供了诸多高级参数&#xff0c;其同样是为了满足不同用户应用场景中所面临的差异化需求&#xff0c;以更加灵活…

JAVAEE初阶相关内容第十四弹--网络初识

写在前&#xff1a; 这一部分开启网络部分的相关知识&#xff0c;这一弹内容初始网络将主要进行网络相关知识的简单介绍&#xff0c;以及着重介绍协议、协议分层、OSI七层模型、TCP/IP五层模型、封装和分用。 需要认识协议&#xff0c;并知道协议的效果是什么&#xff1b;知道…

word如何设置页码?教你快速提升文档颜值!

在创建文档时&#xff0c;为了更好地组织内容&#xff0c;页码是一个必不可少的元素。但是很多人不知道word如何设置页码&#xff0c;其实word提供了多种设置页码的方法&#xff0c;以满足不同文档的需求。本文将详细介绍3种设置页码的方法&#xff0c;无论您是初学者还是有经验…

LMI FocalSpec 3D线共焦传感器 使用笔记1

一.硬件介绍 以上特别注意: 屏蔽线必须接地,因为在现场实际调试中,使用软件调试发现经常 弹窗 传感器丢失警告!! 以上 Position LED 的灯被钣金挡住,无法查看异常现象,能否将指示灯设置在软件界面上? 需要确认是软触发还是硬触发,理论上 硬触发比软触发速度要快.(我们目前使用…

LinkedList集合

LinkedList集合 底层数据结构是双链表,查询慢,增删快,但如果操做的是首元素,速度也是极快的 本身多了很多直接操做首尾元素的特有API 这些特有方法不常用,了解即可 LinkedList源码分析 迭代器的源码分析 iterator():生成一个迭代器对象,默认指向集合的0索引处hasNext():判…

sqlserver系统存储过程添加用户学习

sqlserver有一个系统存储过程sp_adduser&#xff1b;从名字看是添加用户的&#xff1b;操作一下&#xff0c; 从错误提示看还需要先添加一个登录名&#xff0c;再执行一个系统过程sp_addlogin看一下&#xff0c; 执行完之后看一下&#xff0c;安全性-登录名下面有了rabbit&…