• Support
  • mariadb crashing. looking for database optimization help

I seem to be having a crashing issue with mariadb. once every few days my wordpress websites aren't able to connect to the database and I noticed someone else was having this mariadb crashing issue as well

so I was hoping to get some help as to how I can optimize/troubleshoot the issue.
I saw someone recommending mysqltuner, so I would be curious if I could get some help optimizing mine for the hardware I'm using (2cpu cores 2gb ram, 2gb swap)

here's the output for mysqltuner. . .

`root@debian-2gb-ash-2:~# mysqltuner

MySQLTuner 2.5.3
* Jean-Marie Renouard jmrenouard@gmail.com
* Major Hayden major@mhtx.net
Bug reports, feature requests, and downloads at http://mysqltuner.pl/
Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
[OK] Logged in using credentials from Debian maintenance account.
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
[--] Data in Aria tables: 32.0K (Tables: 1)
[--] Data in InnoDB tables: 314.2M (Tables: 275)
[OK] Total fragmented tables: 0

[!!] Your MySQL version 11.4.3-MariaDB-deb12-log is EOL software. Upgrade soon!

-------- Log file Recommendations ------------------------------------------------------------------
[!!] Log file doesn't exist

-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.

-------- Views Metrics -----------------------------------------------------------------------------

-------- Triggers Metrics --------------------------------------------------------------------------

-------- Routines Metrics --------------------------------------------------------------------------

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] There is no basic password file list!

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined
-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 1m 2s (4K q [77.339 qps], 56 conn, TX: 27M, RX: 1M)
[--] Reads / Writes: 94% / 6%
[--] Binary logging is disabled
[--] Physical Memory : 1.9G
[--] Max MySQL memory : 1.6G
[--] Other process memory: 0B
[--] Total buffers: 894.0M global + 7.6M per thread (100 max threads)
[--] Performance_schema Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 916.7M (47.77% of installed RAM)
[!!] Maximum possible memory usage: 1.6G (86.02% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (0/4K)
[OK] Highest usage of available connections: 3% (3/100)
[OK] Aborted connections: 0.00% (0/56)
[!!] Name resolution is active: a reverse name resolution is made for each new connection which can reduce performance
[OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 494 sorts)
[OK] No joins without indexes
[OK] Temporary tables created on disk: 20% (100 on disk / 485 total)
[OK] Thread cache hit rate: 94% (3 created / 56 connections)
[OK] Table cache hit rate: 98% (5K hits / 5K requests)
[!!] table_definition_cache (400) is less than number of tables (571)
[OK] Open file limit used: 0% (60/500K)
[OK] Table locks acquired immediately: 100% (196 immediate / 196 locks)

-------- Performance schema ------------------------------------------------------------------------
[!!] Performance_schema should be activated.
[--] Sys schema is installed.
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.

-------- MyISAM Metrics ----------------------------------------------------------------------------
[--] General MyIsam metrics:
[--] +-- Total MyISAM Tables : 0
[--] +-- Total MyISAM indexes : 0B
[--] +-- KB Size :16.0M
[--] +-- KB Used Size :2.9M
[--] +-- KB used :18.3%
[--] +-- Read KB hit rate: 0% (0 cached / 0 reads)
[--] +-- Write KB hit rate: 0% (0 cached / 0 writes)
[--] No MyISAM table(s) detected ....

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB File per table is activated
[OK] InnoDB Buffer Pool size ( 575.0M ) under limit for 64 bits architecture: (17179869184.0G )
[OK] InnoDB buffer pool / data size: 575.0M / 314.2M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (12.3478260869565%): 71.0M * 1 / 575.0M should be equal to 25%
[--] Number of InnoDB Buffer Pool Chunk: 64 for 1 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 97.02% (396270 hits / 408428 total)
[!!] InnoDB Write Log efficiency: 84.81% (1306 hits / 1540 total)
[OK] InnoDB log waits: 0.00% (0 waits / 234 writes)

-------- Aria Metrics ------------------------------------------------------------------------------
[--] Aria Storage Engine is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/352.0K
[!!] Aria pagecache hit rate: 90.7% (788 cached / 73 reads)

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: ROW
[--] XA support enabled: ON
[--] Semi synchronous replication Master: OFF
[--] Semi synchronous replication Slave: OFF
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
You are using an unsupported version for production environments
Upgrade as soon as possible to a supported version !
MySQL was started within the last 24 hours: recommendations may be inaccurate
Reduce your overall MySQL memory footprint for system stability
Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=ON
Performance schema should be activated for better diagnostics
Be careful, increasing innodb_log_file_size / innodb_log_files_in_group means higher crash recovery mean time
Variables to adjust:
skip-name-resolve=ON
table_definition_cache (400) > 571 or -1 (autosizing if supported)
performance_schema=ON
innodb_log_file_size should be (=143M) if possible, so InnoDB total log file size equals 25% of buffer pool size.
innodb_log_buffer_size (> 143M)`

any help would be greatly appreciated (my vps is running the latest stable debian 12 (if that helps)

You need to give the DB some uptime before mysqltuner can give any useful analysis, i.e.

[--] Up for: 1m 2s

and

MySQL was started within the last 24 hours: recommendations may be inaccurate

I generally avoid using any swap though. I prefer to tune MySQL to better handle the memory it has, or upgrade the server if it needs more memory.

There's also a useful thread on using MySQLTuner to optimize memory usage here:
https://community.wordops.net/d/1129-random-error-establishing-a-database-connection-but-no-errors-in-log

    marty thanks for that tip about needing to wait longer

    I'll run it again tomorrow.
    I did see this thread linked recently, and saw the highlighted answer/comment giving suggestions
    but I wasn't sure if those my.conf changes should be made for everyone using wordops

    or if they were recommended just for them with the VPS hardware/limitations that they were dealing with

    would you say this tip should be applied to all/most wordops users?
    further reduce key_buffer_size to 32M
    further reduce myisam_sort_buffer_size to 32M
    if you don't trying to find slow queries, disable slow_query_log = 0, instead of 1.
    reduce both
    innodb_open_files = 500000
    innodb_io_capacity = 500000 to say 400.
    add innodb_buffer_pool_instances = 4
    add innodb_file_format = barracuda

    here's an updated output of mysqltuner. . .

    `root@debian-2gb-ash-2:~# mysqltuner

    MySQLTuner 2.5.3
    * Jean-Marie Renouard jmrenouard@gmail.com
    * Major Hayden major@mhtx.net
    Bug reports, feature requests, and downloads at http://mysqltuner.pl/
    Run with '--help' for additional options and output filtering

    [--] Skipped version check for MySQLTuner script
    [OK] Logged in using credentials from Debian maintenance account.
    [OK] Operating on 64-bit architecture

    -------- Storage Engine Statistics -----------------------------------------------------------------
    [--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
    [--] Data in Aria tables: 32.0K (Tables: 1)
    [--] Data in InnoDB tables: 313.0M (Tables: 275)
    [OK] Total fragmented tables: 0

    [!!] Your MySQL version 11.4.3-MariaDB-deb12-log is EOL software. Upgrade soon!

    -------- Log file Recommendations ------------------------------------------------------------------
    [!!] Log file doesn't exist

    -------- Analysis Performance Metrics --------------------------------------------------------------
    [--] innodb_stats_on_metadata: OFF
    [OK] No stat updates during querying INFORMATION_SCHEMA.

    -------- Views Metrics -----------------------------------------------------------------------------

    -------- Triggers Metrics --------------------------------------------------------------------------

    -------- Routines Metrics --------------------------------------------------------------------------

    -------- Security Recommendations ------------------------------------------------------------------
    [OK] There are no anonymous accounts for any database users
    [OK] All database users have passwords assigned
    [!!] There is no basic password file list!

    -------- CVE Security Recommendations --------------------------------------------------------------
    [--] Skipped due to --cvefile option undefined
    -------- Performance Metrics -----------------------------------------------------------------------
    [--] Up for: 2d 6h 39m 16s (6M q [31.452 qps], 32K conn, TX: 41G, RX: 1G)
    [--] Reads / Writes: 97% / 3%
    [--] Binary logging is disabled
    [--] Physical Memory : 1.9G
    [--] Max MySQL memory : 1.6G
    [--] Other process memory: 0B
    [--] Total buffers: 894.0M global + 7.6M per thread (100 max threads)
    [--] Performance_schema Max memory usage: 0B
    [--] Galera GCache Max memory usage: 0B
    [OK] Maximum reached memory usage: 1.1G (56.84% of installed RAM)
    [!!] Maximum possible memory usage: 1.6G (86.02% of installed RAM)
    [OK] Overall possible memory usage with other process is compatible with memory available
    [OK] Slow queries: 0% (0/6M)
    [OK] Highest usage of available connections: 26% (26/100)
    [OK] Aborted connections: 0.01% (4/32487)
    [!!] Name resolution is active: a reverse name resolution is made for each new connection which can reduce performance
    [OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
    [OK] Sorts requiring temporary tables: 0% (3 temp sorts / 817K sorts)
    [OK] No joins without indexes
    [OK] Temporary tables created on disk: 21% (161K on disk / 766K total)
    [OK] Thread cache hit rate: 99% (30 created / 32K connections)
    [OK] Table cache hit rate: 99% (7M hits / 7M requests)
    [!!] table_definition_cache (400) is less than number of tables (571)
    [OK] Open file limit used: 0% (64/500K)
    [OK] Table locks acquired immediately: 100% (777 immediate / 777 locks)

    -------- Performance schema ------------------------------------------------------------------------
    [!!] Performance_schema should be activated.
    [--] Sys schema is installed.

    -------- ThreadPool Metrics ------------------------------------------------------------------------
    [--] ThreadPool stat is disabled.

    -------- MyISAM Metrics ----------------------------------------------------------------------------
    [--] General MyIsam metrics:
    [--] +-- Total MyISAM Tables : 0
    [--] +-- Total MyISAM indexes : 0B
    [--] +-- KB Size :16.0M
    [--] +-- KB Used Size :2.9M
    [--] +-- KB used :18.3%
    [--] +-- Read KB hit rate: 0% (0 cached / 0 reads)
    [--] +-- Write KB hit rate: 0% (0 cached / 0 writes)
    [--] No MyISAM table(s) detected ....
    -------- InnoDB Metrics ----------------------------------------------------------------------------
    [--] InnoDB is enabled.
    [OK] InnoDB File per table is activated
    [OK] InnoDB Buffer Pool size ( 575.0M ) under limit for 64 bits architecture: (17179869184.0G )
    [OK] InnoDB buffer pool / data size: 575.0M / 313.0M
    [!!] Ratio InnoDB log file size / InnoDB Buffer pool size (12.3478260869565%): 71.0M * 1 / 575.0M should be equal to 25%
    [--] Number of InnoDB Buffer Pool Chunk: 64 for 1 Buffer Pool Instance(s)
    [OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
    [OK] InnoDB Read buffer efficiency: 100.00% (597830686 hits / 597846280 total)
    [!!] InnoDB Write Log efficiency: 87.71% (883230 hits / 1006943 total)
    [OK] InnoDB log waits: 0.00% (0 waits / 123713 writes)

    -------- Aria Metrics ------------------------------------------------------------------------------
    [--] Aria Storage Engine is enabled.
    [OK] Aria pagecache size / total Aria indexes: 128.0M/352.0K
    [OK] Aria pagecache hit rate: 98.5% (5M cached / 82K reads)

    -------- TokuDB Metrics ----------------------------------------------------------------------------
    [--] TokuDB is disabled.

    -------- XtraDB Metrics ----------------------------------------------------------------------------
    [--] XtraDB is disabled.

    -------- Galera Metrics ----------------------------------------------------------------------------
    [--] Galera is disabled.

    -------- Replication Metrics -----------------------------------------------------------------------
    [--] Galera Synchronous replication: NO
    [--] No replication slave(s) for this server.
    [--] Binlog format: ROW
    [--] XA support enabled: ON
    [--] Semi synchronous replication Master: OFF
    [--] Semi synchronous replication Slave: OFF
    [--] This is a standalone server

    -------- Recommendations ---------------------------------------------------------------------------
    General recommendations:
    You are using an unsupported version for production environments
    Upgrade as soon as possible to a supported version !
    Reduce your overall MySQL memory footprint for system stability
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=ON
    Performance schema should be activated for better diagnostics
    Be careful, increasing innodb_log_file_size / innodb_log_files_in_group means higher crash recovery mean time
    Variables to adjust:
    skip-name-resolve=ON
    table_definition_cache (400) > 571 or -1 (autosizing if supported)
    performance_schema=ON
    innodb_log_file_size should be (=143M) if possible, so InnoDB total log file size equals 25% of buffer pool size.
    innodb_log_buffer_size (> 143M)
    `

    Items it considers ok have [OK] next to them. Things to look into have [!!] next to them. 'Recommendations' are at the bottom.
    I wouldn't blindly follow what it says though. There are loads of guides online to using MySQLTuner (plus the thread above).

    5 months later
    • EEndda

        Level 14

      my issue seems to have stemmed from the default mysql config file wanting to use 100 connections
      dropping this down to around 25-30 has fixed the mariadb crashing issue I was having

      Hosted by VirtuBox