web-dev-qa-db-ja.com

innodbバッファープールサイズを増やすと、mysqlのクラッシュを防ぐことができますか?

サーバーでmysqlのメモリが不足し続けます。続けます。 150708 3:39:09 [エラー]/usr/sbin/mysqld:メモリ不足(258064バイトが必要)

My.cnfを見ると、innodb_buffer_pool_sizeが134217728であることがわかりました

私はそれが134MBに変換されるバイト単位であることを想定しています。 innodb_buffer_pool_size = 134217728を変更する必要があります

to innodb_buffer_pool_size = 500MB

私が実行したとき Rolandoのクエリ は、Recommended_InnoDB_Buffer_Pool_Sizeとして481Mを取得しました。

SELECT CONCAT(CEILING(RIBPS/POWER(1024,pw)),SUBSTR(' KMGT',pw+1,1))
Recommended_InnoDB_Buffer_Pool_Size FROM
(
SELECT RIBPS,FLOOR(LOG(RIBPS)/LOG(1024)) pw
FROM
(
    SELECT SUM(data_length+index_length)*1.1*growth RIBPS
    FROM information_schema.tables AAA,
    (SELECT 1.25 growth) BBB
    WHERE ENGINE='InnoDB'
) AA
) A;

Recommended_InnoDB_Buffer_Pool_Size 481M

以下はmy.cnfの完全なコピーです

[mysqld]
thread_cache_size=6
query_cache_type=2
key_buffer_size=256M
open_files_limit=10000
query_cache_size=256M
# safe-show-database
table_cache=1024
query_cache_limit=1M
default-storage-engine=MyISAM
innodb_file_per_table=1
innodb_read_io_threads=8
innodb_write_io_threads=8
# Try number of cpus*2 for thread_concurrency
thread_concurrency=12
max_allowed_packet=268435456

max_connections=200
query_cache_size=64M
thread_cache_size=16
join_buffer_size=256K
read_buffer_size=256K
sort_buffer_size=256K
tmp_table_size=512M
max_heap_table_size=512M
max_delayed_threads=0
innodb_buffer_pool_size=134217728

これは前回のクラッシュ時のバックトレースで、thecityo_production_wp/wp_wfVulnScannersエラーを既に修正しています。

10 GBのRAMと180 GBのディスクスペースと6つの共有コアがあります。

key_buffer_size=268435456
read_buffer_size=262144
max_used_connections=0
max_threads=200
thread_count=0
connection_count=0
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 366904 K  bytes of memory
Hope thats ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x40000
/usr/sbin/mysqld(my_print_stacktrace+0x35)[0x7aabf5]
/usr/sbin/mysqld(handle_fatal_signal+0x4a4)[0x686324]
/lib64/libpthread.so.0(+0xf710)[0x7fdd49402710]
/lib64/libc.so.6(gsignal+0x35)[0x7fdd485c9625]
/lib64/libc.so.6(abort+0x175)[0x7fdd485cae05]
/usr/sbin/mysqld[0x8fbd91]
/usr/sbin/mysqld[0x8b9638]
/usr/sbin/mysqld[0x926aa5]
/usr/sbin/mysqld[0x91b362]
/usr/sbin/mysqld[0x857c7a]
/usr/sbin/mysqld[0x84cbc2]
/lib64/libpthread.so.0(+0x79d1)[0x7fdd493fa9d1]
/lib64/libc.so.6(clone+0x6d)[0x7fdd4867f8fd]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
150708 03:31:13 mysqld_safe mysqld from pid file /var/lib/mysql/mo.serveroflight.com.pid ended
150708 03:36:35 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150708  3:36:35 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
150708  3:36:35 [Note] Plugin 'FEDERATED' is disabled.
150708  3:36:35 InnoDB: The InnoDB memory heap is disabled
150708  3:36:35 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150708  3:36:35 InnoDB: Compressed tables use zlib 1.2.3
150708  3:36:35 InnoDB: Using Linux native AIO
150708  3:36:35 InnoDB: Initializing buffer pool, size = 128.0M
150708  3:36:35 InnoDB: Completed initialization of buffer pool
150708  3:36:35 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 48687241371
150708  3:36:35  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 48687308434
150708  3:36:36  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
InnoDB: Apply batch completed
150708  3:36:36  InnoDB: Error: table 'thecityo_production_wp/wp_wfNet404s'
InnoDB: in InnoDB data dictionary has tablespace id 20744,
InnoDB: but tablespace with that id or name does not exist. Have
InnoDB: you deleted or moved .ibd files?
InnoDB: This may also be a table created with CREATE TEMPORARY TABLE
InnoDB: whose .ibd and .frm files MySQL automatically removed, but the
InnoDB: table still exists in the InnoDB internal data dictionary.
InnoDB: Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting-datadict.html
InnoDB: for how to resolve the issue.
150708  3:36:36  InnoDB: Error: table 'thecityo_production_wp/wp_wfVulnScanners'
InnoDB: in InnoDB data dictionary has tablespace id 20745,
InnoDB: but tablespace with that id or name does not exist. Have
InnoDB: you deleted or moved .ibd files?
InnoDB: This may also be a table created with CREATE TEMPORARY TABLE
InnoDB: whose .ibd and .frm files MySQL automatically removed, but the
InnoDB: table still exists in the InnoDB internal data dictionary.
InnoDB: Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting-datadict.html
InnoDB: for how to resolve the issue.
150708  3:36:36  InnoDB: Waiting for the background threads to start
150708  3:36:37 InnoDB: 5.5.42 started; log sequence number 48687308434
150708  3:36:37 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
150708  3:36:37 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
150708  3:36:37 [Note] Server socket created on IP: '0.0.0.0'.
150708  3:36:37 [Note] Event Scheduler: Loaded 0 events
150708  3:36:37 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.42-cll'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
150708  3:38:40 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258640 bytes)
150708  3:38:43 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258104 bytes)
150708  3:38:48 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258640 bytes)
150708  3:38:48 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258640 bytes)
150708  3:38:48 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258640 bytes)
150708  3:38:48 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258640 bytes)
150708  3:38:48 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258640 bytes)
150708  3:38:48 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258640 bytes)
150708  3:38:48 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258640 bytes)
150708  3:38:48 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258640 bytes)
150708  3:38:48 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258640 bytes)
150708  3:38:48 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258104 bytes)
150708  3:38:49 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258104 bytes)
150708  3:38:49 InnoDB: Unable to allocate memory of size 289800.
150708  3:38:51  InnoDB: Assertion failure in thread 139869977511680 in file mem0mem.c line 361
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
07:38:51 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.

key_buffer_size=268435456
read_buffer_size=262144
max_used_connections=181
max_threads=200
thread_count=164
connection_count=164
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 366904 K  bytes of memory
Hope thats ok; if not, decrease some variables in the equation.

Thread pointer: 0x3aef460
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7f70e2625e58 thread_stack 0x40000
/usr/sbin/mysqld(my_print_stacktrace+0x35)[0x7aabf5]
/usr/sbin/mysqld(handle_fatal_signal+0x4a4)[0x686324]
/lib64/libpthread.so.0(+0xf710)[0x7f7120768710]
/lib64/libc.so.6(gsignal+0x35)[0x7f711f92f625]
/lib64/libc.so.6(abort+0x175)[0x7f711f930e05]
/usr/sbin/mysqld[0x8fbd91]
/usr/sbin/mysqld[0x8fbdee]
/usr/sbin/mysqld[0x881fc7]
/usr/sbin/mysqld[0x83c104]
/usr/sbin/mysqld[0x83efa5]
/usr/sbin/mysqld[0x81819b]
/usr/sbin/mysqld(_Z13rr_sequentialP11READ_RECORD+0x1f)[0x74de7f]
/usr/sbin/mysqld(_Z10sub_selectP4JOINP13st_join_tableb+0x79)[0x5ace99]
/usr/sbin/mysqld[0x5b16c7]
/usr/sbin/mysqld(_ZN4JOIN4execEv+0xc81)[0x5c6f41]
/usr/sbin/mysqld(_Z12mysql_selectP3THDPPP4ItemP10TABLE_LISTjR4ListIS1_ES2_jP8st_orderSB_S2_SB_yP13select_resultP18st_select_Lex_unitP13st_select_Lex+0x12c)[0x5c873c]
/usr/sbin/mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x165)[0x5c9175]
/usr/sbin/mysqld[0x584392]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x144d)[0x5894cd]
150708  3:39:09 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258064 bytes)
/usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x330)[0x58ce20]
/usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x1af3)[0x58f1e3]
/usr/sbin/mysqld(_Z24do_handle_one_connectionP3THD+0xd7)[0x629297]
/usr/sbin/mysqld(handle_one_connection+0x51)[0x6293d1]
/lib64/libpthread.so.0(+0x79d1)[0x7f71207609d1]
/lib64/libc.so.6(clone+0x6d)[0x7f711f9e58fd]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (7f70e40187c0): is an invalid pointer
Connection ID (thread ID): 234
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
150708 03:39:11 mysqld_safe Number of processes running now: 0
150708 03:39:11 mysqld_safe mysqld restarted
150708  3:39:11 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
150708  3:39:12 [Note] Plugin 'FEDERATED' is disabled.
150708  3:39:12 InnoDB: The InnoDB memory heap is disabled
150708  3:39:12 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150708  3:39:12 InnoDB: Compressed tables use zlib 1.2.3
150708  3:39:12 InnoDB: Using Linux native AIO
150708  3:39:12 InnoDB: Initializing buffer pool, size = 128.0M
150708  3:39:12 InnoDB: Completed initialization of buffer pool
150708  3:39:12 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 48687567559
150708  3:39:12  InnoDB: Database was not shut down n
2
adjc98

MySQLのメモリが不足していると私は完全には確信していません。理由は次のとおりです。

側面#1

Mysqltuner.plを使用すると、最悪のシナリオでの合計使用量が計算されます。それは3つの数字を一緒に加えることによってそれをします

  • key_buffer_size
  • innodb_buffer_pool_size
  • thread_memory:max_connections * の合計
    • sort_buffer_size
    • join_buffer_size
    • read_buffer_size
    • read_rnd_buffer_size

あなたの場合、現在の設定を考えると、それは合計です

  • key_buffer_size(256M)
  • innodb_buffer_pool_size(128M)
  • thread_memory(200M):max_connections(200)*合計

    • sort_buffer_size(256K)
    • join_buffer_size(256K)
    • read_buffer_size(256K)
    • read_rnd_buffer_size(256Kがデフォルト)
  • 特定の設定で、MySQLの絶対最悪のメモリ消費量は584M(256M + 128M + 200M)です。

  • RIBPSを使用する場合、MySQLの絶対最悪のメモリ消費量は939M(256M + 481M + 200M)になります。
  • 500Mを使用する場合、MySQLの絶対最悪のメモリ消費量は958M(256M + 481M + 200M)になります。

したがって、最悪の場合、MySQLはRAMの9.58%しか消費しません。

側面#2

サーバーが専用のDBサーバーであるか、フルスタックを実行しているかは言及していません。フルスタックを実行している場合は、スタックの他の部分(ワニス(よりバニッシュに似ている)、PHP、Munin、Nagios、Tomcat、Hibernateなど)のメモリ依存の設定を低くしてください。

側面#3

午前3時36分頃の最初のクラッシュを見て

150708  3:36:36  InnoDB: Error: table 'thecityo_production_wp/wp_wfNet404s'
InnoDB: in InnoDB data dictionary has tablespace id 20744,
InnoDB: but tablespace with that id or name does not exist. Have
InnoDB: you deleted or moved .ibd files?
InnoDB: This may also be a table created with CREATE TEMPORARY TABLE
InnoDB: whose .ibd and .frm files MySQL automatically removed, but the
InnoDB: table still exists in the InnoDB internal data dictionary.

その時点で、MySQLはwp_wfNet404sデータベース内のテーブルthecityo_production_wpのデータディクショナリエントリがまだシステムテーブルスペース内にあると不平を言っています。

次に、mysqldが再起動し、新しい接続の準備ができました

150708  3:36:37 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.42-cll'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

1分後、再びクラッシュしました。 2番目のクラッシュのスタックトレースには何がありましたか?

stack_bottom = 7f70e2625e58 thread_stack 0x40000
/usr/sbin/mysqld(my_print_stacktrace+0x35)[0x7aabf5]
/usr/sbin/mysqld(handle_fatal_signal+0x4a4)[0x686324]
/lib64/libpthread.so.0(+0xf710)[0x7f7120768710]
/lib64/libc.so.6(gsignal+0x35)[0x7f711f92f625]
/lib64/libc.so.6(abort+0x175)[0x7f711f930e05]
/usr/sbin/mysqld[0x8fbd91]
/usr/sbin/mysqld[0x8fbdee]
/usr/sbin/mysqld[0x881fc7]
/usr/sbin/mysqld[0x83c104]
/usr/sbin/mysqld[0x83efa5]
/usr/sbin/mysqld[0x81819b]
/usr/sbin/mysqld(_Z13rr_sequentialP11READ_RECORD+0x1f)[0x74de7f]
/usr/sbin/mysqld(_Z10sub_selectP4JOINP13st_join_tableb+0x79)[0x5ace99]
/usr/sbin/mysqld[0x5b16c7]
/usr/sbin/mysqld(_ZN4JOIN4execEv+0xc81)[0x5c6f41]
/usr/sbin/mysqld(_Z12mysql_selectP3THDPPP4ItemP10TABLE_LISTjR4ListIS1_ES2_jP8st_orderSB_S2_SB_yP13select_resultP18st_select_Lex_unitP13st_select_Lex+0x12c)[0x5c873c]
/usr/sbin/mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x165)[0x5c9175]
/usr/sbin/mysqld[0x584392]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x144d)[0x5894cd]
150708  3:39:09 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258064 bytes)
/usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x330)[0x58ce20]
/usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x1af3)[0x58f1e3]
/usr/sbin/mysqld(_Z24do_handle_one_connectionP3THD+0xd7)[0x629297]
/usr/sbin/mysqld(handle_one_connection+0x51)[0x6293d1]
/lib64/libpthread.so.0(+0x79d1)[0x7f71207609d1]
/lib64/libc.so.6(clone+0x6d)[0x7f711f9e58fd]

なんらかのSELECT ... JOINクエリを実行していたようです。この行のために、SELECT ... JOINの破損したテーブルにアクセスしていたと思います

/usr/sbin/mysqld(_Z13rr_sequentialP11READ_RECORD+0x1f)[0x74de7f]

これは、ある種の順次読み取りによるものかもしれません。

見続けるなら

150708  3:36:36  InnoDB: Error: table 'thecityo_production_wp/wp_wfNet404s'

mysqldがクラッシュして再起動するたびに、ibdata1からそのエントリを削除する必要があります。

私はだまされません

150708  3:39:09 [ERROR] /usr/sbin/mysqld: Out of memory (Needed 258064 bytes)

252Kを割り当てないことに不満があります。これは、テーブルから読み取ることができない操作に必要なメモリを割り当てる可能性があるため、エラーの副次的な影響です。

エピローグ

データディクショナリのピジョンホールの削除について調べてください。また、DBサーバーで他のメモリ消費コンポーネントを探します。

2
RolandoMySQLDBA

10 GBのRAM-これを攻撃する脅威はありません。
open_files_limit = 10000-2000を試す
query_cache_size = 256M-50M以下
default-storage-engine = MyISAM-すでにいくつかのInnoDBテーブルがない限り、これはinnodb_buffer_pool_sizeも0になる可能性があることを意味します-使用していません。

だから、私はこれの1つが当てはまると思います:

  • 32ビットOS
  • MySQLの32ビットビルド
  • OSは、各プロセスが保持できるメモリの量を制限しています。

どんなOS?

0
Rick James