zoukankan      html  css  js  c++  java
  • mysql数据库参数innodb_buffer_pool_size和max_connections

    接到报故,查看mysql数据库以下参数

    1、innodb_buffer_pool_size

    2、max_connections

    该参数定义了数据缓冲区buffer pool大小,类似于oracle的db_cache_size

    mysql> show global variables like 'innodb_buffer_pool_size';
    +-------------------------+-----------+
    | Variable_name           | Value     |
    +-------------------------+-----------+
    | innodb_buffer_pool_size | 134217728 |
    +-------------------------+-----------+
    1 row in set (0.00 sec)

    那么如何设置该参数大小呢?首先查看运行时buffer pool相关数据指标:

    mysql> show global status like 'Innodb_buffer_pool_pages_data';
    +-------------------------------+-------+
    | Variable_name                 | Value |
    +-------------------------------+-------+
    | Innodb_buffer_pool_pages_data | 314   |
    +-------------------------------+-------+
    1 row in set (0.00 sec)

    mysql> show global status like 'Innodb_buffer_pool_pages_total';
    +--------------------------------+-------+
    | Variable_name                  | Value |
    +--------------------------------+-------+
    | Innodb_buffer_pool_pages_total | 8191  |
    +--------------------------------+-------+
    1 row in set (0.00 sec)

    mysql> show global status like 'Innodb_page_size';
    +------------------+-------+
    | Variable_name    | Value |
    +------------------+-------+
    | Innodb_page_size | 16384 |
    +------------------+-------+
    1 row in set (0.00 sec)

    上述三项指标的含义如下:

    Innodb_buffer_pool_pages_data
    The number of pages in the InnoDB buffer pool containing data. The number includes both dirty and
    clean pages.

    Innodb_buffer_pool_pages_total
    The total size of the InnoDB buffer pool, in pages.

    Innodb_page_size
    InnoDB page size (default 16KB). Many values are counted in pages; the page size enables them to be
    easily converted to bytes

    计算Innodb_buffer_pool_pages_data/Innodb_buffer_pool_pages_total*100%
    当结果 > 95% 则增加 innodb_buffer_pool_size, 建议使用物理内存的 75%
    当结果 < 95% 则减少 innodb_buffer_pool_size, 
    建议设置大小为: Innodb_buffer_pool_pages_data* Innodb_page_size * 1.05 / (1024*1024*1024)

    --------------------------------------------------------------------------------------------------------------------------------------------------------

    MySQL服务器的连接数并不是要达到最大的100%为好,还是要具体问题具体分析,下面就对MySQL服务器最大连接数的合理设置进行了详尽的分析,供您参考。

    我们经常会遇见“MySQL: ERROR 1040: Too many connections”的情况,一种是访问量确实很高,MySQL服务器抗不住,这个时候就要考虑增加从服务器分散读压力,另外一种情况是MySQL配置文件中max_connections值过小:

    mysql> show variables like 'max_connections';
    +-----------------+-------+
    | Variable_name | Value |
    +-----------------+-------+
    | max_connections | 256 |
    +-----------------+-------+

    这台MySQL服务器最大连接数是256,然后查询一下服务器响应的最大连接数:

    mysql> show global status like 'Max_used_connections';

    MySQL服务器过去的最大连接数是245,没有达到服务器连接数上限256,应该没有出现1040错误,比较理想的设置是:

    Max_used_connections / max_connections * 100% ≈ 85%

    最大连接数占上限连接数的85%左右,如果发现比例在10%以下,MySQL服务器连接上线就设置得过高了。

  • 相关阅读:
    Document
    Document
    Document
    css3 无缝轮播效果小demo(轮播效果/渐隐渐现效果)
    4.Redux (这篇文章需要修改)
    3.React-router/BrowserRouter/withRouter/Switch/history/exact/strict/Link/Redirect/PropTypes
    2.React数据传递 之☞ 父子之间数据传递 / React生命周期
    1.React (基础篇)
    13. Vuex ,一个专为 Vue.js 应用程序开发的状态管理模式
    12. vue 路由(vue-router)
  • 原文地址:https://www.cnblogs.com/paul8339/p/5935923.html
Copyright © 2011-2022 走看看