简体   繁体   English

内存为130GB的服务器上的innodb_buffer_pool_size的正确值?

[英]Correct value for innodb_buffer_pool_size on a server with 130gb of ram?

well i have a big server with 130gb of ram and i have running in this machine a big system that make alot of simultaneous connections to mysql with many queries. 好吧,我有一台具有130gb ram的大服务器,并且我在这台机器上运行了一个大型系统,该系统通过许多查询同时连接到mysql。

I need some help to set correct value to innodb_buffer_pool_size and if i need to set more some configs, my 'my.cnf' has theses configs: 我需要一些帮助来将正确的值设置为innodb_buffer_pool_size,如果需要设置更多配置,我的“ my.cnf”具有以下配置:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

max_connect_errors=100
open-files=10000

interactive_timeout=30
wait_timeout=30

max_connections=700

max_allowed_packet=5M
tmp_table_size=50M
max_heap_table_size=56M

query_cache_type = 1
query_cache_size=10M
query_cache_limit = 10M

sort_buffer_size=15M
read_buffer_size=15M
read_rnd_buffer_size=16M
join_buffer_size=60M
key_buffer_size=10M
myisam_sort_buffer_size=20M

thread_cache_size = 40

key_buffer=20M
key_buffer_size =20M
open_files_limit=10000
default-storage-engine=MyISAM

innodb_file_per_table=1
innodb_buffer_pool_size=3500M
innodb_additional_mem_pool_size=500M

back_log=100
expire_logs_days        = 1
max_binlog_size         = 10M

tmpdir = /var/mysqltmpdir

long_query_time=1
log_slow_queries=/var/log/mysql_slow_queries.log

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
bind-address   =  *
port = 3306

Here is also a sample that calculates the used memory. 这也是一个计算已用内存的示例。 if you have config your server you can see if there free memory or do you have use to mutch: 如果您已经配置了服务器,则可以查看是否有可用内存,或者您是否曾经使用过:

SHOW VARIABLES LIKE 'innodb_buffer_pool_size';
SHOW VARIABLES LIKE 'innodb_additional_mem_pool_size';
SHOW VARIABLES LIKE 'innodb_log_buffer_size';
SHOW VARIABLES LIKE 'thread_stack';
SET @kilo_bytes = 1024;
SET @mega_bytes = @kilo_bytes * 1024;
SET @giga_bytes = @mega_bytes * 1024;
SET @innodb_buffer_pool_size = 2 * @giga_bytes;
SET @innodb_additional_mem_pool_size = 16 * @mega_bytes;
SET @innodb_log_buffer_size = 8 * @mega_bytes;
SET @thread_stack = 192 * @kilo_bytes;
SELECT
( @@key_buffer_size + @@query_cache_size + @@tmp_table_size
+ @innodb_buffer_pool_size + @innodb_additional_mem_pool_size
+ @innodb_log_buffer_size
+ @@max_connections * (
@@read_buffer_size + @@read_rnd_buffer_size + @@sort_buffer_size
+ @@join_buffer_size + @@binlog_cache_size + @thread_stack
) ) / @giga_bytes AS MAX_MEMORY_GB;

sample small server 小型服务器样本

MariaDB [(none)]> SHOW VARIABLES LIKE 'innodb_buffer_pool_size';
+-------------------------+-----------+
| Variable_name           | Value     |
+-------------------------+-----------+
| innodb_buffer_pool_size | 134217728 |
+-------------------------+-----------+
1 row in set (0.00 sec)

MariaDB [(none)]> SHOW VARIABLES LIKE 'innodb_additional_mem_pool_size';
+---------------------------------+---------+
| Variable_name                   | Value   |
+---------------------------------+---------+
| innodb_additional_mem_pool_size | 8388608 |
+---------------------------------+---------+
1 row in set (0.00 sec)

MariaDB [(none)]> SHOW VARIABLES LIKE 'innodb_log_buffer_size';
+------------------------+----------+
| Variable_name          | Value    |
+------------------------+----------+
| innodb_log_buffer_size | 16777216 |
+------------------------+----------+
1 row in set (0.00 sec)

MariaDB [(none)]> SHOW VARIABLES LIKE 'thread_stack';
+---------------+--------+
| Variable_name | Value  |
+---------------+--------+
| thread_stack  | 294912 |
+---------------+--------+
1 row in set (0.00 sec)

MariaDB [(none)]> SET @kilo_bytes = 1024;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SET @mega_bytes = @kilo_bytes * 1024;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SET @giga_bytes = @mega_bytes * 1024;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SET @innodb_buffer_pool_size = 2 * @giga_bytes;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SET @innodb_additional_mem_pool_size = 16 * @mega_bytes;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SET @innodb_log_buffer_size = 8 * @mega_bytes;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SET @thread_stack = 192 * @kilo_bytes;
Query OK, 0 rows affected (0.00 sec)

and now the Query 现在是查询

MariaDB [(none)]> SELECT
    -> ( @@key_buffer_size + @@query_cache_size + @@tmp_table_size
    -> + @innodb_buffer_pool_size + @innodb_additional_mem_pool_size
    -> + @innodb_log_buffer_size
    -> + @@max_connections * (
    -> @@read_buffer_size + @@read_rnd_buffer_size + @@sort_buffer_size
    -> + @@join_buffer_size + @@binlog_cache_size + @thread_stack
    -> ) ) / @giga_bytes AS MAX_MEMORY_GB;
+---------------+
| MAX_MEMORY_GB |
+---------------+
|        2.3091 |
+---------------+
1 row in set (0.00 sec)

MariaDB [(none)]>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM