当前位置: 首页 > wzjs >正文

做网站价格表百度推广注册

做网站价格表,百度推广注册,杭州网站建设培训,网站验证码怎么做1. 背景 在日常的 MySQL 运维中,难免会出现参数设置不合理,导致 MySQL 在使用过程中出现各种各样的问题。 今天,我们就来讲解一下 MySQL 运维中一种常见的问题:最大连接数设置不合理,一旦到了业务高峰期就会出现连接…

1. 背景

在日常的 MySQL 运维中,难免会出现参数设置不合理,导致 MySQL 在使用过程中出现各种各样的问题。

今天,我们就来讲解一下 MySQL 运维中一种常见的问题:最大连接数设置不合理,一旦到了业务高峰期就会出现连接数打满的问题。

报错信息

ERROR 1040 (HY000): Too many connections

报错原因

这个问题,无非就是并发过高,导致最大连接数被用完引起的。

解决办法

重新设置最大连接数 max_connections 的值。

处理痛点

  1. 出现了 Too many connections 的报错信息,无法用 mysql 客户端连接进行动态修改。
  2. 修改配置参数后重启,确实可以让 max_connections 的值重新生效,但是生产环境有业务访问,肯定是不能随便重启的。

2. GDB 工具

基于以上种种问题和主要痛点,那么我们就来试试 gdb 工具吧,让我们在不重启的状态下,照样可以修改 MySQL 的参数 !!!

gdb 工具的介绍在这里就不做过多赘述了,其实大多数场景下,都是把它当做调试工具来用。今天我们更多的是用到 gdb 在线修改配置参数的功能。

3. 处理过程

下面,我们就通过一个实验场景,来模拟 mysql 连接数打满,出现 Too many connections 的问题,通过 gdb 工具的解决步骤。

  1. 准备一个数据库实例,数据库版本为 MySQL 5.7.40。
  2. 创建一个空库 jiangshifeng
mysql> create database jiangshifeng;
Query OK, 1 row affected (0.00 sec)mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| jiangshifeng       |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)mysql> use jiangshifeng;
Database changed
mysql> show tables;
Empty set (0.00 sec)
  1. 设置该实例的最大连接数为 10。
mysql> set global max_connections=10;
Query OK, 0 rows affected (0.01 sec)mysql> show variables like '%max_conn%';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| max_connect_errors | 100   |
| max_connections    | 10    |
+--------------------+-------+
2 rows in set (0.00 sec)
  1. 安装 gdb 工具。
yum install -y gdb

安装完成验证

[root@node1 ~]# gdb
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) 
(gdb) q
[root@node1 ~]# 
  1. 使用 sysbench 进行压测,模拟在 jiangshifeng 这个空库创建 11 张表,每个表的数据量为 20000000 条,连接线程数为 15。
sysbench /usr/share/sysbench/oltp_common.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=jiangshifeng --db-driver=mysql --tables=11 --table-size=20000000 --report-interval=15 --threads=15  prepare
  1. 此时,我们再次用客户端工具连接 mysql,就会报错(Too many connections)。
[root@node1 ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1040 (HY000): Too many connections
[root@node1 ~]#
  1. 通过 gdb 工具设置 max_connections 参数。

方法一

gdb -p $(pidof mysqld) -ex "set max_connections=50" -batch

方法二

[root@node1 ~]# ps -ef | grep mysql
root       1320      1  0 Mar17 ?        00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/DB/mysql --pid-file=/DB/mysql/node1.pid
mysql      1582   1320  9 Mar17 ?        03:33:44 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/DB/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=node1.err --pid-file=/DB/mysql/node1.pid --socket=/tmp/mysql.sock --port=3306[root@node1 ~]# gdb -p 1582
...
(gdb) p max_connections
$1 = 10
(gdb) 
(gdb) set max_connections=50
(gdb) p max_connections
$4 = 50
(gdb) 
$5 = 50
(gdb) q
A debugging session is active.Inferior 1 [process 1582] will be detached.Quit anyway? (y or n) y
Detaching from program: /usr/local/mysql/bin/mysqld, process 1582
[Inferior 1 (process 1582) detached]
[root@node1 sysbench]#
  1. 再次登录验证。
[root@node1 ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 146
Server version: 5.7.40-log MySQL Community Server (GPL)Copyright (c) 2000, 2022, Oracle and/or its affiliates.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.mysql>
mysql> show variables like '%max_conn%';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| max_connect_errors | 100   |
| max_connections    | 50    |
+--------------------+-------+
2 rows in set (0.10 sec)

此时,MySQL 最大连接数 max_connections 已经成功修改。并且,前面的 sysbench 压测数据还正常运行,可以理解为基本上不影响业务。

4. 总结

  1. 本次虽然只介绍了通过不重启的方式,用 gdb 修改 max_connections 参数。但是其他参数的修改也类似,可以使用同样的方式。
  2. 尽管在实验中看到了修改参数成功了,但是操作始终有未知风险的,不能总是觉得有了这些工具,一定能够万无一失。
  3. 一定要严格遵守开发规范,数据库的问题,往往是人在使用时的不当操作导致的。例如这个最大连接数,我们要评估好业务最大的并发的峰值,设置成比业务峰值大很多,就能尽量避免出现连接数打满的问题了。
  4. 另外,该参数也不是设置得越大越好,需要评估物理资源并配合压测情况得出一个合适的值,否则程序异常死锁导致不断申请新连接产生的连接数异常打满时,可能直接把数据库搞挂了。
http://www.dtcms.com/wzjs/141748.html

相关文章:

  • 做的比较漂亮的中国网站广州网站建设
  • 网站开发公司谁家好网站seo诊断
  • 网页制作与网站建设技术大全(珍藏版)四种营销模式
  • form manager wordpressseo优化网站教程
  • 做网站花了2万多营销外包
  • 双城网站建设哪家好seo收费标准
  • 永久免费不收费的聊天软件app优化提升
  • 做网站的必备软件论坛企业推广
  • B2C建站wordpress在线种子资源库
  • 专业做网站关键词排名下掉百度推广代理加盟
  • 做视频网站注意什么推广软文300字范文
  • 电话销售做网站犯法吗引流推广网站平台
  • 企业宽带西安seo霸屏
  • 网站的开发语言网络推广公司北京
  • 网站建设明薇通网络不错淮南网站seo
  • 网站建设前端后端免费网站可以下载
  • html网站运行时间代码深圳做seo有哪些公司
  • 可以做书的网站第三方网站流量统计
  • 东莞地产网站建设百度引擎搜索
  • 建站平台在线提交表格功能拼多多女装关键词排名
  • 网页设计与网站建设在线考试苏州网络公司
  • 全国工程建设信息网站app推广80元一单
  • 网站建设方案模板百度新闻头条
  • 婚车租赁网站怎样做优化推广网站推荐
  • 天津建设网站的公司百度推广客服电话人工服务
  • 如室设计网站郑州有没有厉害的seo
  • 美国有哪些做促销的网站公司网站搭建
  • 网站建设调查的问卷如何建立一个自己的网站
  • 网站建设制度南宁排名seo公司
  • html5商城网站模板线上线下一体化营销