Форум программистов, компьютерный форум, киберфорум
MySQL
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
0 / 0 / 0
Регистрация: 22.08.2015
Сообщений: 9
1

Оптимизация MySQL на Debian (4 ядра 16 гб оперативной памяти)

23.08.2015, 00:24. Показов 2467. Ответов 0
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Доброе время суток! Есть у меня сервер с Debian. На сервере 4 ядра и 16 гб оперативной памяти. MySQL у меня сильно грузит процессор, поэтому я его хочу оптимизировать, но как не знаю. Знаю что все настройки MySQL в файле my.cnf. Вот собственно его содержание
#
# 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
# http://dev.mysql.com/doc/mysql... ables.html

# 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
default-character-set = cp1251

# 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 = /tmp
language = /usr/share/mysql/english
skip-external-locking
#skip-grant-tables
#
# 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 = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 16
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
max_connections = 110
#table_cache = 64
#thread_concurrency = 8
#
# * Query Cache Configuration
#
query_cache_limit = 64M
query_cache_size = 2M
wait_timeout = 200
interactive_timeout = 200
join_buffer_size = 128M
tmp_table_size = 512M
max_heap_table_size = 512M
table_open_cache = 25000
#
# * 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 = 2
#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
default-character-set = cp1251
init-connect='SET NAMES cp1251'
#ignore-db-dir = lost+found

#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 = 16M

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

[isamchk]
key_buffer = 16M

#
# * 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/

Запустил скрипт для рекомендаций по оптимизации tuning-primer.sh и вот что он мне выдал

:/# sh tuning-primer.sh

-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -

MySQL Version 5.1.63-0+squeeze1-log x86_64

Uptime = 0 days 0 hrs 1 min 20 sec
Avg. qps = 435
Total Questions = 34867
Threads Connected = 22

Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations

To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refma... ables.html
Visit http://www.mysql.com/products/... isors.html
for info about MySQL's Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is enabled.
Current long_query_time = 2.000000 sec.
You have 67 out of 35131 that take longer than 2.000000 sec. to complete
Your long_query_time seems to be fine

BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refma... overy.html

WORKER THREADS
Current thread_cache_size = 8
Current threads_cached = 0
Current threads_per_sec = 3
Historic threads_per_sec = 1
Threads created per/sec are overrunning threads cached
You should raise thread_cache_size

MAX CONNECTIONS
Current max_connections = 100
Current threads_connected = 28
Historic max_used_connections = 47
The number of used connections is 47% of the configured maximum.
Your max_connections variable seems to be fine.

INNODB STATUS
Current InnoDB index space = 115 M
Current InnoDB data space = 354 M
Current InnoDB buffer pool free = 81 %
Current innodb_buffer_pool_size = 512 M
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory

MEMORY USAGE
Max Memory Ever Allocated : 8.55 G
Configured Max Per-thread Buffers : 6.50 G
Configured Max Global Buffers : 5.50 G
Configured Max Memory Limit : 12.00 G
Physical Memory : 15.62 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 4.26 G
Current key_buffer_size = 4.00 G
Key cache miss rate is 1 : 458
Key buffer free ratio = 81 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 1.00 G
Current query_cache_used = 29 M
Current query_cache_limit = 4 M
Current Query cache Memory fill ratio = 2.87 %
Current query_cache_min_res_unit = 4 K
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won't cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 64.00 M
You have had 207 queries where a join could not use an index properly
You have had 12 joins without keys that check for key usage after each row
join_buffer_size >= 4 M
This is not advised
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.

OPEN FILES LIMIT
Current open_files_limit = 100000 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

TABLE CACHE
Current table_open_cache = 20000 tables
Current table_definition_cache = 20000 tables
You have a total of 9214 tables
You have 9428 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 256 M
Current tmp_table_size = 256 M
Of 1667 temp tables, 36% were created on disk
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your
ratio of on disk temp tables.

TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 7166 : 1
You have a high ratio of sequential access requests to SELECTs
You may benefit from raising read_buffer_size and/or improving your use of indexes.

TABLE LOCKING
Current Lock Wait ratio = 1 : 111
You may benefit from selective use of InnoDB.
If you have long running SELECT's against MyISAM tables and perform
frequent updates consider setting 'low_priority_updates=1'

Потом запустил подобный скрипт с рекомендациями по MySQL mysqltuner.pl

:/# perl mysqltuner.pl
[OK] Logged in using credentials from debian maintenance account.
>> MySQLTuner 1.5.1 - Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering
[OK] Currently running supported MySQL version 5.1.63-0+squeeze1-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
[--] Data in MyISAM tables: 18G (Tables: 8308)
[--] Data in InnoDB tables: 469M (Tables: 873)
[--] Data in MEMORY tables: 0B (Tables: 6)
[!!] Total fragmented tables: 978
ERROR 1018 (HY000) at line 1: Can't read dir of './lost+found/' (errno: 13)

-------- Security Recommendations -------------------------------------------
[OK] There is no anonymous account in all database users
[OK] All database users have passwords assigned
[!!] User 'bfi-impla_astec@%' hasn't specific host restriction.
[!!] User 'casino@%' hasn't specific host restriction.
[!!] User 'chantasia_user@%' hasn't specific host restriction.
[!!] User 'crm@%' hasn't specific host restriction.
[!!] User 'firstline_base@%' hasn't specific host restriction.
[!!] User 'kinouser@%' hasn't specific host restriction.
[!!] User 'lookmyinfo_auto@%' hasn't specific host restriction.
[!!] User 'lookmyinfo_sad@%' hasn't specific host restriction.
[!!] User 'lookmyinfo_tclub@%' hasn't specific host restriction.
[!!] User 'lookmyinfo_tourS@%' hasn't specific host restriction.
[!!] User 'myotpusk_puz@%' hasn't specific host restriction.
[!!] User 'myotpusk_samie@%' hasn't specific host restriction.
[!!] User 'myotpusk_user@%' hasn't specific host restriction.
[!!] User 'restoranuser@%' hasn't specific host restriction.
[!!] User 'sconti_user@%' hasn't specific host restriction.
[!!] User 'vesiuser@%' hasn't specific host restriction.
[!!] User 'vukraine_usr@%' hasn't specific host restriction.
[!!] User 'xeyirli_user@%' hasn't specific host restriction.
[!!] There is not basic password file list !

-------- Performance Metrics -------------------------------------------------
[--] Up for: 21m 13s (702K q [552.158 qps], 16K conn, TX: 2B, RX: 95M)
[--] Reads / Writes: 85% / 15%
[--] Binary logging is disabled
[--] Total buffers: 6.0G global + 66.6M per thread (100 max threads)
[OK] Maximum reached memory usage: 12.6G (80.41% of installed RAM)
[OK] Maximum possible memory usage: 12.5G (80.00% of installed RAM)
[OK] Slow queries: 0% (770/702K)
[!!] Highest connection usage: 100% (101/100)
[OK] Aborted connections: 0.12% (20/16733)
[OK] Query cache efficiency: 76.4% (475K cached / 622K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (32 temp sorts / 24K sorts)
[!!] Joins performed without indexes: 3464
[!!] Temporary tables created on disk: 69% (9K on disk / 13K total)
[OK] Thread cache hit rate: 98% (266 created / 16K connections)
[OK] Table cache hit rate: 20% (8K open / 40K opened)
[OK] Open file limit used: 14% (14K/100K)
[OK] Table locks acquired immediately: 99% (219K immediate / 221K locks)

-------- MyISAM Metrics -----------------------------------------------------
[!!] Key buffer used: 19.5% (837M used / 4B cache)
[OK] Key buffer size / total MyISAM indexes: 4.0G/4.3G
[OK] Read Key buffer hit rate: 98.3% (123M cached / 2M reads)
[!!] Write Key buffer hit rate: 69.5% (303K cached / 92K writes)

-------- InnoDB Metrics -----------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB buffer pool / data size: 512.0M/469.2M
[!!] InnoDB Used buffer: 22.69% (7434 used/ 32768 total)
[OK] InnoDB Read buffer efficiency: 98.28% (368246 hits/ 374697 total)
[!!] InnoDB Write buffer efficiency: 0.00% (0 hits/ 1 total)
[OK] InnoDB log waits: 0.00% (0 waits / 55 writes)

-------- AriaDB Metrics -----------------------------------------------------
[--] AriaDB 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
MySQL started within last 24 hours - recommendations may be inaccurate
Reduce or eliminate persistent connections to reduce connection usage
Adjust your join queries to always utilize indexes
Temporary table size is already large - reduce result set size
Reduce your SELECT DISTINCT queries without LIMIT clauses
Variables to adjust:
max_connections (> 100)
wait_timeout (< 200)
interactive_timeout (< 200)
join_buffer_size (> 64.0M, or always use indexes with joins)

Помогите на основе этих данных сформировать оптимальные настройки в my.cnf, ато скоко бы я сам не изменял ситуация особо не меняется
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
23.08.2015, 00:24
Ответы с готовыми решениями:

MySQL таблица в оперативной памяти
Добрый вечер. Мне необходимо закешировать строку в MySQL на определенное время. Строка содержет...

Ошибка при компиляции ядра (Debian)
Здравствуйте, по заданию мне нужно собрать ядро Linux из исходников. На этапе компиляции возникла...

Как отключить автоматические обновления ядра на сервере Debian 9?
Всем привет. Сервер VPS. Debian 9. Периодически происходит автоматическое обновление ядра....

Использование оперативной памяти (вылетают игры из-за нехватки памяти)
Перезагружаю комп, играю часа 3-4 и вся память пропадает куда-то в результате чего игры...

0
23.08.2015, 00:24
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
23.08.2015, 00:24
Помогаю со студенческими работами здесь

Выделение памяти на уровне ядра
Доброго времени суток! На паре задали сделать лабораторную : используя Win32 и Delphi выделить...

Установлено 2 планки оперативной памяти по 32Гб, 8 модулей по 8Гб, отображается только 32Гб памяти
Добрый день! Подскажите пожалуйста, почему система видит только 32 Гб памями, стоит 2 планки...

Частота памяти (оперативной памяти)
Добрый день, хочу купить себе новый компьютер на базе процессора AMD Ryzen 5 3600, в железе...

MySQL connection на C в Debian
Подскажите, что не так делаю Создал файл #vi /usr/bin/hello.c Написал в нем текст ...

Проблемы с mysql + ssl на debian
Есть простейший код QSqlDatabase db = QSqlDatabase::addDatabase(&quot;QMYSQL&quot;,&quot;mydb&quot;); ...

MySQL-connector (Windows <=> Debian)
Доброго времени суток господа. прошу помощи в следующие проблеме: Написал маленькую прогу, которая...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru