Benutzer-Werkzeuge

Webseiten-Werkzeuge


mysql_tuning

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
mysql_tuning [2024-03-28 16:31:27] manfredmysql_tuning [2026-05-22 10:14:22] (aktuell) – [Beispiel MySQL 8.0 mit 16GB RAM] manfred
Zeile 3: Zeile 3:
 siehe auch: siehe auch:
   * [[https://github.com/major/MySQLTuner-perl]]   * [[https://github.com/major/MySQLTuner-perl]]
 +    * ''> git clone https://github.com/major/MySQLTuner-perl.git''
 +    * ''> ls -1 MySQLTuner-perl/mysqltuner.pl''
 +    * ''MySQLTuner-perl/mysqltuner.pl''
   * [[::MySQL - Benchmark]]   * [[::MySQL - Benchmark]]
   * [[::MySQL-Lasttest]]   * [[::MySQL-Lasttest]]
Zeile 54: Zeile 57:
     * ''16384MB * 0,84 - ( 16M * 70 ) = 12642,56 ~ 12GB''     * ''16384MB * 0,84 - ( 16M * 70 ) = 12642,56 ~ 12GB''
     * ''16384MB * 0,84 - ( 64M * 145 ) = 4482,56 ~ 4GB''     * ''16384MB * 0,84 - ( 64M * 145 ) = 4482,56 ~ 4GB''
 +
 +
 +==== I/O-Optimierung ====
 +
 +<code bash>
 +iostat -x 1 /dev/nvme0n1
 +IOPS = r/s + w/s
 +
 +2209-4900 wkB/s → Write throughput
 +   5-297  rkB/s → Read throughput
 +2200-5200 IOPS
 +
 +innodb_io_capacity -> durchschnittliche IOPS des Datenträgers
 +innodb_io_capacity_max -> maximale IOPS des Datenträgers
 +
 +innodb_redo_log_capacity = Schreibrate * 10 Minuten (abhängig von innodb_flush_method) = innodb_redo_log_capacity -> ca.~ 5–15% vom innodb_buffer_pool_size
 +bei O_DSYNC und O_DIRECT sollte innodb_redo_log_capacity etwas größer sein (z.B.: 32G)
 +aber bei innodb_fast_shutdown=0 kann innodb_redo_log_capacity wieder deutlich kleiner sein (z.B.: 8G)
 +</code>
 +
 +<code bash>
 +### bei O_DSYNC und O_DIRECT sollte innodb_redo_log_capacity etwas größer sein => innodb_redo_log_capacity=32G
 +### aber wenn innodb_fast_shutdown = 0, dann kann innodb_redo_log_capacity deutlich kleiner => innodb_redo_log_capacity=8G
 +### SET GLOBAL innodb_io_capacity=3000; SET GLOBAL innodb_io_capacity_max=8000; SET GLOBAL innodb_redo_log_capacity = 8 * 1024 * 1024 * 1024;
 +innodb_io_capacity              = 3000  # wird von innodb_redo_log_capacity benötigt -> durchschnittliche IOPS des Datenträgers
 +innodb_io_capacity_max          = 8000  # wird von innodb_redo_log_capacity benötigt -> maximale IOPS des Datenträgers
 +innodb_redo_log_capacity        = 8G    # Schreibrate * 10 Minuten (abhängig von innodb_flush_method) = innodb_redo_log_capacity -> ca.~ 5–15% vom innodb_buffer_pool_size
 +innodb_buffer_pool_instances    = 8
 +join_buffer_size                = 2M
 +tmp_table_size                  = 32M
 +max_heap_table_size             = 32M
 +
 +### LRU Scan Depth bestimmt, wie weit InnoDB vorausschaut, um Platz zu schaffen
 +### Zu klein: Threads warten auf freie Pages, „buffer pool free list“ wird knapp, spontane Flush-Spikes
 +### Zu groß: hohe CPU-Last im Hintergrund, unnötige IO, keine echte Performanceverbesserung
 +### echo "SHOW GLOBAL VARIABLES WHERE VARIABLE_NAME IN ('Innodb_buffer_pool_size', 'innodb_lru_scan_depth', 'Innodb_page_size'); SHOW GLOBAL STATUS WHERE variable_name IN ('Innodb_buffer_pool_pages_free', 'Innodb_buffer_pool_pages_total', 'Innodb_buffer_pool_pages_dirty', 'Innodb_buffer_pool_wait_free', 'Innodb_page_size');" | mysql -t
 +### Innodb_buffer_pool_wait_free  > 0 (muß "0" sein)                                 # innodb_lru_scan_depth & innodb_io_capacity erhöhen
 +### Innodb_buffer_pool_pages_free ~ 0 (sollte mind. bei 1-5% vom Buffer Pool sein)   # innodb_lru_scan_depth & innodb_io_capacity erhöhen
 +### echo "SET GLOBAL innodb_lru_scan_depth=1024;" | mysql
 +### Innodb_buffer_pool_pages_total = Innodb_buffer_pool_size / Innodb_page_size
 +### max. Innodb_buffer_pool_pages_free = Innodb_buffer_pool_pages_total /  20
 +### min. Innodb_buffer_pool_pages_free = Innodb_buffer_pool_pages_total / 100
 +### max. Innodb_buffer_pool_pages_free = 4194304 /  20 = ca. 210000 freie Pages
 +### min. Innodb_buffer_pool_pages_free = 4194304 / 100 = ca.  42000 freie Pages
 +#innodb_lru_scan_depth           = 256
 +#innodb_lru_scan_depth           = 512
 +innodb_lru_scan_depth           = 1024
 +################################################################################
 +innodb_page_cleaners            = 8
 +innodb_flush_log_at_trx_commit  = 1
 +sync_binlog                     = 0
 +innodb_doublewrite_batch_size   = 64
 +innodb_doublewrite_pages        = 128
 +################################################################################
 +</code>
 +
 +<file bash /etc/mysql/conf.d/max_flushing.cnf>
 +[mysqld]
 +### https://www.percona.com/blog/2020/05/07/prepare-mysql-for-a-safe-shutdown/
 +### 4. Configure InnoDB for Max Flushing.
 +### SET GLOBAL innodb_fast_shutdown=0; SET GLOBAL innodb_max_dirty_pages_pct=0; SET GLOBAL innodb_change_buffering='none';
 +### SHOW VARIABLES LIKE 'innodb_fast_shutdown'; SHOW VARIABLES LIKE 'innodb_max_dirty_pages_pct'; SHOW VARIABLES LIKE 'innodb_change_buffering';
 +innodb_fast_shutdown = 0
 +#innodb_max_dirty_pages_pct = 0 # so ist sie im Dauerstress
 +innodb_max_dirty_pages_pct = 50 # damit sie schneller startet
 +#innodb_max_dirty_pages_pct_lwm = 0
 +innodb_max_dirty_pages_pct_lwm = 20 # damit sie schneller startet
 +innodb_change_buffering = 'none'
 +</file>
  
  
Zeile 166: Zeile 238:
   query_cache_size= 512M   query_cache_size= 512M
   query_cache_type= 1   query_cache_type= 1
 +
  
  
Zeile 342: Zeile 415:
  
 ==== Performance Schema ==== ==== Performance Schema ====
 +
  
  
Zeile 407: Zeile 481:
  
   > perl mysqltuner.pl --defaults-file ~/.my.cnf 2>&1 | tee mysqltuner_-_$(date +'%F_%H-%M-%S').log   > perl mysqltuner.pl --defaults-file ~/.my.cnf 2>&1 | tee mysqltuner_-_$(date +'%F_%H-%M-%S').log
 +
 +
 +==== mysqltuner.pl funktioniert nicht mit PXC ====
 +
 +<code c Der Fehler>
 +# wget http://mysqltuner.pl/ -O mysqltuner.pl
 +# perl mysqltuner.pl --forcemem 8000000000 --forceswap 8000000000 --defaults-file /root/.my.cnf --defaults-extra-file /etc/mysql/conf.d_23357/my.cnf --port 23357
 + >>  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
 +mysql: [ERROR] unknown option '--print-defaults'
 +mysql: [ERROR] unknown option '--print-defaults'
 +[--] Assuming 8000000000 MB of physical memory
 +[--] Assuming 8000000000 MB of swap space
 +[!!] Failed to execute: SELECT VERSION()
 +[!!] FAIL Execute SQL / return code: 1792
 +[!!] You probably do not have enough privileges to run MySQLTuner ...
 +</code>
 +
 +<code c Fehler nachstellen>
 +# /usr/bin/mysql --port 23357 --print-defaults
 +mysql: [ERROR] unknown option '--print-defaults'
 +</code>
 +
 +<code c Client-Ursprung ermitteln>
 +# dpkg -S mysql | grep -F bin | grep -E mysql$
 +percona-xtradb-cluster-client-5.7: /usr/bin/mysql
 +</code>
 +
 +<code c Der Grund steht in der Hilfe>
 +# /usr/bin/mysql --help
 +...
 +The following options may be given as the first argument:
 +--print-defaults        Print the program argument list and exit.
 +...
 +</code>
 +
 +<code c Test ist nicht befriedigend>
 +# /usr/bin/mysql --print-defaults --port 23357
 +/usr/bin/mysql would have been started with the following arguments:
 +--port=3306 --socket=/var/run/mysqld/mysqld.sock --host=localhost --user=root --password=***** --port 23357 
 +</code>
 +
  
 ===== Memory-Tabellen / Heap-Tables ===== ===== Memory-Tabellen / Heap-Tables =====
/home/http/wiki/data/attic/mysql_tuning.1711643487.txt · Zuletzt geändert: von manfred