max_user_connections 与 max_connections,max_connect_errors, nr_open, file-max
LINUX文件设置:
ulimit -n <num> ----> [/etc/profile,/.bashrc] ---->/etc/security/limits.conf [* soft|hard nofile <num> ] ------>/proc/sys/fs/nr_open-----> /proc/sys/fs/file-max ----->/etc/sysctl.conf
LINUX 连接设置:
ulimit -u <num> ------->[/etc/profile,/.bashrc]--------->/etc/security/limits.conf[* soft|hard nproc <num>]
mysql 应用程连接设置:my.cnf
[mysqld]
max_connections=4
max_connect_errors=
最大用户连接:
max_user_connections 3 //针对同一用户的链接
所有用户连接之和:
max_connections 4 //所有用户连接的和
实验:
会话1
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.28-debug-log Source distribution Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
会话2
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.28-debug-log Source distribution Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
会话3
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.28-debug-log Source distribution Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
会话4:
[root@localhost ~]# mysql -uroot -p //root 用户 more than 'max_user_connections'
Enter password: ERROR (): User root already has more than 'max_user_connections' active connections [root@localhost ~]# mysql -umysql -p //mysql用户可登陆
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.6.-debug-log Source distribution Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
会话5:
Last login: Thu Jul :: from 192.168.1.152
[root@localhost ~]# mysql -umysql -p
Enter password:
ERROR (): Too many connections 已超过最大连接数
[root@localhost ~]#
max_connect_errors:
mysql的这个参数指的是网络错误 密码错误并不算在内,尝试用for循环尝试密码的用户host并不会block 以下是mysql非常出名的分支percona的cto关于max_connect_errors的评论 There seems to be confusion around that variable. It does not really block hosts for repeated invalid passwords but for aborted connections due to network errors.
模拟网络错误:max_connect_errors=1
http://www.cnblogs.com/ivictor/p/5311607.html
[root@localhost ~]# telnet 192.168.1.26 3306
Trying 192.168.1.26...
Connected to 192.168.1.26 (192.168.1.26).
Escape character is '^]'.
jHost '192.168.1.26' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'Connection closed by foreign host.
[root@localhost ~]# mysql -h192.168.1.26 -p -uroot
Enter password:
ERROR 1129 (HY000): Host '192.168.1.26' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' [root@localhost ~]# mysql -h192.168.1.26 -p -uroot
Enter password:
ERROR 1129 (HY000): Host '192.168.1.26' is blocked because of many connection errors; unblock with 'mysqladmin flush-host'
一、程序运行一段时间后,tomcat启动后,连接池不能使用,拿不到数据库连接,查看catalina.out发现如下错误:
[http-80-35] ERROR sls.database.DBConn - org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create Poola
bleConnectionFactory (null, message from server: Host localhost is blocked because of many connection errors; unblock with mysqladmin flush-hosts) 二、出现的原因:
数据库的错误链接处达到最大,数据库服务器拒绝连接。
由于出现某台host连接错误次数等于max_connect_errors(默认10) ,主机'host_name'再次尝试时被屏蔽。可有效反的防止dos攻击,使用'mysqladmin flush-hosts'解除屏蔽。 【连接次数失败过多,并超过max_connect_erros的值后,服务器会直接拒绝来源机器的所有连接,只要把 mysql server默认 max_connect_errors = 10
把这个值设置大点就好了,记得一定要执行mysqladmin flush-hosts命令来解锁,原来的主机才可以恢复正常连接的.】
三、解决方案:
1.查看数据库允许的错误链接数:
show status 看那个abort_client.
2.运行:
mysqladmin flush-hosts命令,解除数据库的连接屏蔽,重新允许数据库被访问。 3.也可以重启mysql数据库,这样,也可以将错误链接数清零。 4.修改my.inf或者:my.cnf修改max_connect_errors的值,可以适当大些。
配置文件中,如果没有此键值,请在[mysqld]内增加该值。
# Maximum amount of errors allowed per host. If this limit is reached,
# the host will be blocked from connecting to the MySQL server until
# "FLUSH HOSTS" has been run or the server was restarted. Invalid
# passwords and other errors during the connect phase result in
# increasing this value. See the "Aborted_connects" status variable for
# global counter.
max_connect_errors = 8000
[mysqld]
max_connections=xx
max_connect_errors=xx
max_user_connections=xx
max_user_connections 与 max_connections,max_connect_errors, nr_open, file-max的更多相关文章
- mysql实例的连接数max_user_connections 和max_connections 配置的那些事
今天在查线上问题时,通过phpMyAdmin来进行DML操作,发现比平时慢多了,就各种进原因. 项目的场景是一个mysql实例中创建了多个数据库,猜想可能是相互影响所致. 然后,查询线上Mysql数据 ...
- MySQL二进制包安装及启动问题排查
环境部署:VMware10.0+CentOS6.9(64位)+MySQL5.7.19(64位)一.操作系统调整 # 更改时区 .先查看时区 [root@localhost ~]# date -R Tu ...
- MySQL的max_user_connections拒绝连接的一次踩雷经验
近期线上的数据遇到一个问题,最终原因为max_user_connections和max_connections的一个bug导致,具体过程如下 现象 前端页面不断的出现错误页面. 排查处理过程 按照数据 ...
- php使用file函数、fseek函数读取大文件效率分析
php读取大文件可以使用file函数和fseek函数,但是二者之间效率可能存在差异,本文章向大家介绍php file函数与fseek函数实现大文件读取效率对比分析,需要的朋友可以参考一下. 1. 直接 ...
- NR_OPEN 与 NR_FILE 的区别
NR_OPEN 与 NR_FILE 的区别 阅读0.11版的内核源码时,在linux-0.11/fs/pipe.c中,函数sys_pipe()里面出现了2个宏定义,NR_OPEN 与 NR_FILE. ...
- I/O————File对象
File文件对象 文件和文件夹都是用File代表 创建一个文件对象,(并不会有真正的文件或文件夹被创建) File f1 = new File("d:/lolfilder"); S ...
- LNMP一键安装脚本
#!/bin/bash #LNMP(Fastcgi) #CentOS + MySQL 5.5 #-- iptables -F iptables -X iptables -Z iptables -A I ...
- LNMP搭建(CentOS 6.3+Nginx 1.2.0+PHP 5.3.15(fpm)+ MySQL 5.5.35)
Nginx (“engine x”) 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器. Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 ...
- MYSQL汇总
一.1.1 MYSQL 一.1.1.1 基础特性 1)性能卓越,服务稳定,很少出现异常宕机: 2)开放源代码且无版权制约,自主性强,使用成本低: 3)历史悠久,社区及用户非常活跃,遇到问题,可快速获得 ...
随机推荐
- 西南科技大学第十届ACM程序设计竞赛题解
A.德州扑克 B. 我恨11(1089) 问题描述 11是一个孤独的数字,小明十分讨厌这个数字,因此如果哪个数字中出现了11或者该数字是11的倍数,他同样讨厌这个数字.现在问题来了,在闭区间[L,R] ...
- POJ 1149 PIGS ★(经典网络流构图)
[题意] 有M个猪圈,每个猪圈里初始时有若干头猪.一开始所有猪圈都是关闭的.依 次来了N个顾客,每个顾客分别会打开指定的几个猪圈,从中买若干头猪.每 个顾客分别都有他能够买的数量的上限.每个顾客走后, ...
- (四)学习MVC之修改个人资料和身份验证登陆
1.修改资料不用建立模型,直接在UserControl.cs添加 ChangeInfo(): #region 修改用户资料 [UserAuthorize] public ActionResult Ch ...
- guake默认快捷键
toggle guake visibility 切换guake可见 :F12 toggle fullscreen 切换全屏幕 :F11 quit 退出 :Shift+Ctrl+Q new ...
- 静态Web开发 JavaScript
三章 Javascript 1节javascript基本语法和注意事项 脚本,一条条的文字命令.执行时由系统的一个解释器,将其一条条的翻译成机器可识别的指令,然后执行.(不需要编译)常见的脚本:批处理 ...
- [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.4.4
(1). There is a natural isomorphism between the spaces $\scrH\otimes \scrH^*$ and $\scrL(\scrH,\scrK ...
- 《深入Java虚拟机学习笔记》- 第2章 平台无关
Java虚拟机学习笔记(二)平台无关
- convert nocdb to cdb using dbms_pdb
convert nocdb to cdb using dbms_pdb 本文介绍将nocdb转换为cdb 环境介绍: ORACLE_HOME: /u01/app/oracle/product/12 ...
- [LeetCode] Two Sum水过
刷LeetCode的第一题,TwoSum,基本算是水过. 题目:https://leetcode.com/problems/two-sum/ Given an array of integers, f ...
- HDU-4619 Warm up 2 二分匹配
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4619 一看就知道是二分匹配题目,对每个点拆点建立二分图,最后答案除2.因为这里是稀疏图,用邻接表处理. ...