连接池最大连接数不够
异常表现:
- 系统运行或执行压测期间,客户端连接报错
Failed to get connection from node ***。 - 在error log中能看到
Got error 1 when reading table 'table_name'(以后会修复)。
问题确认:
连接各个sqlnode,通过下述语句检查连接池连向各个datanode的最大连接数(主要影响DML语句)。
mysql> show variables like 'greatdb_max_connections';
+-------------------------+-------+
| Variable_name | Value |
+-------------------------+-------+
| greatdb_max_connections | 1500 |
+-------------------------+-------+
若客户端连向单一sqlnode的连接超过greatdb_max_connections,则可能触发上述报错。
解决方法:
- 连接到sqlnode,执行
set persist greatdb_max_connections(永久生效)或修改配置文件,重启该sqlnode。 - 检查重启后的sqlnode状态。在其它sqlnode上执行
select * from information_schema.greatdb_sqlnodes,确认重启后的sqlnode已重新加入集群。 - 按上述步骤逐个操作剩余sqlnode。
操作系统参数nproc或nofile过小
异常表现:
- 在高并发下执行sysbench或benchmarksql时,报如下错误
Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug。如果是nofile数量过小则会报错Can't open file:...或Too many open files。 - 调小并发度后,错误消失。
问题确认:
检查nproc:
登陆greatdb用户,执行ulimit -u检查当前用户最大允许启动进程数量。执行命令ps H -u greatdb | wc -l检查greatdb用户已启动的进程数。若greatdb用户启动的线程数达或很接近最大进程数,则可能会报上述错误。
检查nofile:
登陆greatdb用户,执行ulimit -n检查当前用户最大允许打开文件数。执行lsof -u greatdb|wc -l检查当前用户已打开文件数。除此之外,还需检查sqlnode的open_files_limit配置。
mysql> show variables like '%open_files%';
+-------------------+--------+
| Variable_name | Value |
+-------------------+--------+
| innodb_open_files | 40960 |
| open_files_limit | 655350 |
+-------------------+--------+
解决方法:
以root用户编辑/etc/security/limits.conf,为greatdb用户增加如下内容并保存(具体值可根据需求变动)
greatdb hard nofile 153600
greatdb soft nofile 153600
greatdb hard nproc 51200
greatdb soft nproc 51200
重新登陆greatdb用户,执行ulimit -a,可观察到相应资源限额已发生改变。在该会话下重新启动sqlnode或datanode(不能使用旧会话,旧会话的值尚未修改)。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




