zoukankan      html  css  js  c++  java
  • Mysql Innodb 性能参数设置 https://www.rathishkumar.in/2017/01/how-to-allocate-innodb-buffer-pool-size-in-mysql.html

    参考原文:

     https://www.rathishkumar.in/2017/01/how-to-allocate-innodb-buffer-pool-size-in-mysql.html

    查看系统cpu,内存,硬盘使用情况

    1、 cat /proc/cpuinfo  或者 更直观的查看cpu的型号命令:dmesg |grep -i xeon
    
    查看内存的方法
    
    2、 cat /proc/meminfo  或者 更直观的查看内存的命令:free -m
    
    查看硬盘大小
    
    3、df -h

    这里粘贴部分原文:

    What is there inside MySQL InnoDB buffer pool?
    
    MySQL InnoDB buffer pool contains the following things inside:
    
    Data caching - InnoDB data pages.
    Indices caching - index data.
    Buffering data - Dirty pages - data which are modified in memory but not yet flushed (written) to a data disk.
    Internal structures - InnoDB buffer pool additionally stores the internal structures such as Adaptive Hash Index, row level locks, etc.
    
    The unit of the above-mentioned objects are calculated as - InnoDB pages. Each InnoDB pages is 16k in size.

    如何最优设置:

    How to deal with this situation?
    
    When we cannot keep an entire database in memory, we should try to keep at least working data set in memory. In most cases, we are not going to process the data of an entire table, so the required data set should be in memory. So it is always better to allocate around 75% - 80% of the total available memory of server machine to innodb_buffer_pool_size.

    同时文中给出了其中的一个计算方式:

    How much memory should allocate to InnoDB buffer pool?
    
    Recommended InnoDB buffer pool size based on the all InnoDB data and indices with additional 50% memory:
    
    
    set @idbdataindx = (select sum(data_length+index_length) from information_schema.tables where engine = 'innodb');
    
    set @ibpsG = @idbdataindx * 1.5 / (1024*1024*1024);
    
    select @ibpsG;

    如何设置:

    SHOW VARIABLES LIKE '%innodb_buffer_pool_size%';
    Example:
    Online method:
    SET GLOBAL innodb_buffer_pool_size = 26843545600;
    
    Offline method:
    innodb_buffer_pool = 26G   (需要重启服务器)
    SHOW VARIABLES LIKE '%innodb_buffer_pool_size%';

    Example:

    Online method:
    SET GLOBAL innodb_buffer_pool_size = 26843545600;

    Offline method:
    innodb_buffer_pool = 26G 
  • 相关阅读:
    [改善Java代码]在equals中使用getClass进行类型判断
    [改善Java代码]equals应该考虑null值的情景
    [改善Java代码]覆写equals方法时不要识别不出自己
    [改善Java代码] 推荐使用序列化实现对象的拷贝
    [改善Java代码]避免对象的浅拷贝
    [改善Java代码]让工具类不可实例化
    [改善Java代码]建议40:匿名类的构造函数很特殊
    [改善Java代码]使用匿名类的构造函数
    [改善Java代码]使用静态内部类提高封装性
    [改善Java代码]构造函数尽量简化
  • 原文地址:https://www.cnblogs.com/cbugs/p/9256090.html
Copyright © 2011-2022 走看看