Помощь Поделитесь опытом настройки my.cnf для Престы?

lightman555

Гуру форума
Регистрация
7 Мар 2013
Сообщения
396
Реакции
67
Конфигурация сервера:
Память: 8 GB
Процессор: 2 ядра
Дисковая система: 50 GB SSD

Два магазина на престе - основной на 1.4.11

Уникальных посетителей за сутки 600-1000
подключен мемкешед и выделено под него 2Гига оперативки
периодически возникает бешеная нагрузка на MySQL в виду большого числа запросов.
анализ кеширования базу говорит, что база закеширована плохо и только 5-10% её кеша используется.
Изучая долго интернет создал файл конфигурации для MySQL - подскажите что не так я делаю - не перемудрил ли?:

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# Для просмотра ссылки Войди или Зарегистрируйся

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /var/tmpfs
lc-messages-dir = /usr/share/mysql
skip-external-locking
bind-address = 127.0.0.1
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#
# * Fine Tuning
#
key_buffer_size = 16M
key_buffer = 1024M
max_join_size = 1000000
max_allowed_packet = 256M
thread_stack = 512K
thread_cache_size = 50
#table_open_cache = 6000
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
table_cache = 60000
thread_concurrency = 5
#
# * Query Cache Configuration
#

query_cache_limit = 2M
query_cache_size = 256M

table_cache = 512
sort_buffer = 8M
myisam_sort_buffer_size = 256M
tmp_table_size = 256M
max_heap_table_size = 128M

read_buffer_size = 16M
read_rnd_buffer_size = 4M

sort_buffer_size = 2M
join_buffer_size = 18M
open_files_limit = 4096
table_open_cache = 4096
max_sort_length = 512

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 3
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet = 256M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer = 32M

#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
 
Это гугл транслейт. Для набивки постов наши англоязычные друзья юзают.

Да я уже понял! :) Получается что кеш не используется как таковой и результат проделанной работы получается не эффективным
нужно было оставлять формат таблиц как есть - тогда кешировалось явно лучше
 
спустя примерно 10-ть дней после перехода полностью на InnoDB и перестройки конфигурационного файла
тюнер показывает следующее:
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
[--] Data in MyISAM tables: 184M (Tables: 183)
[--] Data in InnoDB tables: 400M (Tables: 509)
[!!] Total fragmented tables: 509

-------- Security Recommendations -------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned

-------- CVE Security Recommendations ---------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -------------------------------------------------
[--] Up for: 11d 1h 3m 50s (35M q [36.966 qps], 331K conn, TX: 41B, RX: 8B)
[--] Reads / Writes: 99% / 1%
[--] Binary logging is disabled
[--] Total buffers: 2.4G global + 36.5M per thread (151 max threads)
[OK] Maximum reached memory usage: 3.2G (40.03% of installed RAM)
[!!] Maximum possible memory usage: 7.8G (97.50% of installed RAM)
[OK] Slow queries: 0% (2K/35M)
[OK] Highest usage of available connections: 14% (22/151)
[OK] Aborted connections: 0.17% (565/331357)
[OK] Query cache efficiency: 67.4% (22M cached / 33M selects)
[!!] Query cache prunes per day: 329903
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 5M sorts)
[OK] Temporary tables created on disk: 7% (50K on disk / 703K total)
[OK] Thread cache hit rate: 99% (22 created / 331K connections)
[OK] Table cache hit rate: 99% (1K open / 1K opened)
[OK] Open file limit used: 4% (415/8K)
[OK] Table locks acquired immediately: 100% (15M immediate / 15M locks)

-------- MyISAM Metrics ------------------------------------------------------
[!!] Key buffer used: 18.3% (3M used / 16M cache)
[OK] Key buffer size / total MyISAM indexes: 16.0M/78.3M
[OK] Read Key buffer hit rate: 100.0% (134M cached / 4 reads)
[OK] Write Key buffer hit rate: 100.0% (36M cached / 10 writes)

-------- InnoDB Metrics ------------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB buffer pool / data size: 2.0G/400.0M
[OK] InnoDB buffer pool instances: 2
[!!] InnoDB Used buffer: 18.79% (24631 used/ 131071 total)
[OK] InnoDB Read buffer efficiency: 100.00% (19269783584 hits/ 19269804303 total)
[!!] InnoDB Write Log efficiency: 6.21% (5547 hits/ 89301 total)
[OK] InnoDB log waits: 0.00% (0 waits / 83754 writes)

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

-------- AriaDB Metrics ------------------------------------------------------
[--] AriaDB is disabled.

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

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

-------- Replication Metrics -------------------------------------------------
[--] No replication slave(s) for this server.
[--] This is a standalone server..

-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Restrict Host for user@% to user@SpecificDNSorIp
Reduce your overall MySQL memory footprint for system stability
Increasing the query_cache size over 128M may reduce performance
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
query_cache_size (> 256M) [see warning above]
 
Прошло 39-ть дней с момента последней оптимизации - данные теперь вот такие. Подскажите что нужно подправить теперь?

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 39d 8h 6m 45s (2 q [0.000 qps], 1M conn, TX: 181B, RX: 149B)
[--] Reads / Writes: 100% / 0%
[--] Binary logging is disabled
[--] Physical Memory : 8.0G
[--] Max MySQL memory : 11.0G
[--] Other process memory: 1.4G
[--] Total buffers: 2.7G global + 56.5M per thread (151 max threads)
[--] P_S Max memory usage: 0B
Argument "*main::get_wsrep_option" isn't numeric in numeric ge (>=) at
mysqltuner.pl line 285 (#2)
Argument "*main::get_wsrep_option" isn't numeric in numeric ge (>=) at
mysqltuner.pl line 288 (#2)
Argument "*main::get_wsrep_option" isn't numeric in numeric ge (>=) at
mysqltuner.pl line 291 (#2)
[--] Galera GCache Max memory usage: *main::get_wsrep_optionB
[OK] Maximum reached memory usage: 4.5G (56.11% of installed RAM)
[!!] Maximum possible memory usage: 11.0G (137.49% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/2)
[OK] Highest usage of available connections: 21% (33/151)
[OK] Aborted connections: 0.01% (132/1002978)
[!!] Query cache should be disabled by default due to mutex contention.
[OK] No Sort requiring temporary tables
[OK] No joins without indexes
[OK] No tmp tables created on disk
[OK] Thread cache hit rate: 99% (33 created / 1M connections)
[OK] Table cache hit rate: 100% (1K open / 0 opened)
[OK] Open file limit used: 3% (448/12K)
[OK] Table locks acquired immediately: 100% (43M immediate / 43M locks)

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

-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.3% (1M used / 8M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/78.3M
[OK] Read Key buffer hit rate: 100.0% (341M cached / 5 reads)
[OK] Write Key buffer hit rate: 100.0% (98M cached / 4 writes)

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is disabled.

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB buffer pool / data size: 2.0G/451.2M
[OK] InnoDB buffer pool instances: 2
[!!] InnoDB Used buffer: 59.66% (78200 used/ 131071 total)
[OK] InnoDB Read buffer efficiency: 100.00% (32426650467 hits/ 32426671365 total)
[!!] InnoDB Write Log efficiency: 65.55% (1794591 hits/ 2737623 total)
[OK] InnoDB log waits: 0.00% (0 waits / 943032 writes)

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

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

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] This is a standalone server.

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Restrict Host for user@% to user@SpecificDNSorIp
Reduce your overall MySQL memory footprint for system stability
Dedicated this server to your database for highest performance.
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
query_cache_type (=0)
 
меня больше всего в этом вопросе настораживает вот этот параметр - получается кеш не работает?:
[!!] InnoDB Write buffer efficiency: 0.00% (0 hits/ 1 total)
У меня вообще такое не пишет
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB buffer pool / data size: 512.0M/51.8M
[OK] InnoDB buffer pool instances: 1
[!!] InnoDB Used buffer: 12.50% (4096 used/ 32767 total)
[OK] InnoDB Read buffer efficiency: 100.00% (484599167 hits/ 484602448 total)
[!!] InnoDB Write Log efficiency: 66.75% (139843 hits/ 209504 total)
[OK] InnoDB log waits: 0.00% (0 waits / 69661 writes)

это все по разделу InnoDB... скрипт тюнера скачан на прошлой неделе
uptime 3 days
 
Назад
Сверху