Mysql MYISAM table keeps crashing

MySQL

I have a Mysql server where the same big table keeps crashing now and then, usully during high load. The table in phpmyadmin gets marked as crashed and need to be repaired. Usually i have to do a myisamchk -r table.MYI to repair it which takes quite a while.

That table is about 6.4 GB with 23.500.000 rows in it and running MYISAM. Is my best bet to convert that table to INODB and how much will that help? or is there anything i can do to my MySQL config to help?

The server has 8GB of RAM and My MySQL config looks like this.

[mysql]

# CLIENT #
port                           = 3306
socket                         = /var/lib/mysql/mysql.sock

[mysqld]
log-error=/var/lib/mysql/server.servername.com.err
performance-schema=0
table_open_cache=2000
innodb_strict_mode="ON"
sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
open_files_limit=40000

# GENERAL #
user                           = mysql
default-storage-engine         = InnoDB
socket                         = /var/lib/mysql/mysql.sock
pid-file                       = /var/lib/mysql/mysql.pid

# MyISAM #
key-buffer-size                = 64M
myisam-sort-buffer-size        = 64M
myisam-recover-options         = FORCE

# SAFETY #
skip-external-locking
max-allowed-packet             = 128M
max-connect-errors             = 1000000
innodb                         = FORCE

# DATA STORAGE #
datadir                        = /var/lib/mysql/

# CACHES AND LIMITS #
tmp-table-size                 = 32M
max-heap-table-size            = 32M
query-cache-type               = 0
query-cache-size               = 32
max-connections                = 500
thread-cache-size              = 286
open-files-limit               = 65535
table-definition-cache         = 1024
table-open-cache               = 512
group-concat-max-len           = 1048576

# INNODB #
#innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-log-file-size           = 512M
innodb-log-buffer-size         = 16M
innodb-flush-log-at-trx-commit = 2
innodb-file-per-table          = 1
innodb-buffer-pool-size        = 4G

# LOGGING #
# log-queries-not-using-indexes  = 1
# slow-query-log                 = 1
# slow-query-log-file            = /var/lib/mysql/mysql-slow.log

max_allowed_packet=268435456
innodb_file_per_table=1
[mysqldump]
quick
max_allowed_packet             = 128M

[myisamchk]
key_buffer_size                = 768M
sort_buffer_size               = 256M
read_buffer                    = 2M
write_buffer                   = 2M

[mysqlhotcopy]
interactive-timeout

Best Answer

If OOM triggers the "crashes", then there is too much running on that machine and/or the processes are using too much ram.

It sounds like you have a mixture of MyISAM and InnoDB tables:

innodb-buffer-pool-size        = 4G  -- change to 3G

That might decrease the frequency of OOMs.

Yes, moving to InnoDB is a good idea for many reasons, including avoiding the need to "repair" that big table. Caution: That big table may grow to 15GB when switching to InnoDB.