MySQL richtig konfigurieren

MySQL, PostgreSQL, SQLite
User avatar
Joe User
Project Manager
Project Manager
Posts: 11138
Joined: 2003-02-27 01:00
Location: Hamburg

Re: MySQL richtig konfigurieren

Post by Joe User » 2014-12-02 18:09

/tmp/mysqldump.sql darf nicht leer sein, gab es da keine Fehlermeldung? Hast Du aktuelle Backups Deiner Datenbanken?

Plesk wirst Du dann leider von Hand komplett neu installieren müssen, sorry. Dazu bitte als Erstes die Plesk-Lizenzinformationen sichern. Wie das Alles im Einzelnen funktioniert, steht im Plesk-Manual beim Hersteller online. Ich bin kein Plesk-Nutzer und kann dabei somit nicht viel helfen.
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.

Maestro2k5
Posts: 9
Joined: 2014-11-24 23:12

Re: MySQL richtig konfigurieren

Post by Maestro2k5 » 2014-12-02 19:01

Ah, habe jetzt das Backup von der Plesk DB gefunden, macht Plesk ja selbst. Gut das habe ich also wieder. Puhhh

Ansonsten:
/tmp/mysqldump.sql ist leer. Gut das jetzt für mich nicht so tragisch da ich alle dbs vorher manuell gesichert hatte. Aber komischer weise habe ich auch kein mysql log

Maestro2k5
Posts: 9
Joined: 2014-11-24 23:12

Re: MySQL richtig konfigurieren

Post by Maestro2k5 » 2014-12-02 19:17

DA wir vorhin vom Thema abkamen.

Dies hier habe ich auskommentiert ...

#relay-log = /var/lib/mysql/relay.log
#relay-log-index = /var/lib/mysql/relay.index
#relay-log-info-file = /var/lib/mysql/relay.info
#relay-log-info-repository = TABLE
#relay-log-recovery = 1
#master-info-file = /var/lib/mysql/master.info
#master-info-repository = TABLE

DA sonst der Server garnicht gestartet wäre. Ist dies nun ein Problem?

User avatar
Joe User
Project Manager
Project Manager
Posts: 11138
Joined: 2003-02-27 01:00
Location: Hamburg

Re: MySQL richtig konfigurieren

Post by Joe User » 2014-12-02 19:52

Nein, das ist kein Problem. Diese Optionen sind nur für die Replikation notwendig.
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.

User avatar
Joe User
Project Manager
Project Manager
Posts: 11138
Joined: 2003-02-27 01:00
Location: Hamburg

Re: MySQL richtig konfigurieren

Post by Joe User » 2014-12-02 19:55

Kann es sein, dass bei Deinem Debian der MySQL-root-User nicht root heisst?
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.

Maestro2k5
Posts: 9
Joined: 2014-11-24 23:12

Re: MySQL richtig konfigurieren

Post by Maestro2k5 » 2014-12-26 13:53

Ja, sieht wohl so aus, hatte ja den Server neu aufgesetzt und da immernoch kein SQL Backup über die Console geht die .sql Datei ist nur 1,3k groß, habe ich mich nicht an die komplette Datei getraut. Hier mal meine aktuelle Konfig:

Code: Select all

#
# 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/en/server-system-variables.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

# 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]
local-infile=0
#
# * 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
lc-messages-dir   = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
# bind-address      = 127.0.0.1
bind-address=127.0.0.1
#
# * Fine Tuning
#
key_buffer      = 256M
max_allowed_packet   = 16M
thread_stack      = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
max_connections        = 50
#table_cache            = 64
#thread_concurrency     = 10
innodb_flush_log_at_trx_commit = 2
join_buffer_size = 128K
table_open_cache = 8192
table_definition_cache = 8192
max_heap_table_size = 64M
tmp_table_size = 64M
open_files_limit = 32768
#
# * Query Cache Configuration
#
query_cache_limit   = 2M
query_cache_size        = 128M
#
# * 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 log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# 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
#binlog_do_db      = include_database_name
#binlog_ignore_db   = include_database_name
#
# * InnoDB
#
innodb_thread_concurrency       = 8
innodb_buffer_pool_size         = 4G
innodb_buffer_pool_instances    = 4
#
# 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]
max_allowed_packet              = 256M
quote_names
quick

[isamchk]
key_buffer_size                 = 256M

[myisamchk]
key_buffer_size                 = 256M

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



Die Ausgabe von tuning-primer.sh


Code: Select all

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

MySQL Version 5.5.40-0ubuntu0.14.04.1 x86_64

Uptime = 11 days 15 hrs 37 min 50 sec
Avg. qps = 41
Total Questions = 41745008
Threads Connected = 3

Server has been running for over 48hrs.
It should be safe to follow these recommendations

To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 10.000000 sec.
You have 13 out of 41745029 that take longer than 10.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/refman/5.5/en/point-in-time-recovery.html

WORKER THREADS
Current thread_cache_size = 8
Current threads_cached = 5
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

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

INNODB STATUS
Current InnoDB index space = 190 M
Current InnoDB data space = 554 M
Current InnoDB buffer pool free = 78 %
Current innodb_buffer_pool_size = 4.00 G
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 : 4.42 G
Configured Max Per-thread Buffers : 134 M
Configured Max Global Buffers : 4.39 G
Configured Max Memory Limit : 4.52 G
Physical Memory : 31.31 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 162 M
Current key_buffer_size = 256 M
Key cache miss rate is 1 : 213
Key buffer free ratio = 81 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 128 M
Current query_cache_used = 19 M
Current query_cache_limit = 2 M
Current Query cache Memory fill ratio = 15.44 %
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 = 132.00 K
You have had 1819 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.

Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.

OPEN FILES LIMIT
Current open_files_limit = 32768 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 = 8192 tables
Current table_definition_cache = 8192 tables
You have a total of 945 tables
You have 960 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 64 M
Current tmp_table_size = 64 M
Of 103539 temp tables, 42% 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 = 58 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 23830
Your table locking seems to be fine


Geht das erstmal so in Ordung oder kann ich da noch etwas pfeilen, am besten ohne Plesk abzuschießen :D

User avatar
Joe User
Project Manager
Project Manager
Posts: 11138
Joined: 2003-02-27 01:00
Location: Hamburg

Re: MySQL richtig konfigurieren

Post by Joe User » 2014-12-26 17:16

Aktuell scheint es ausreichend zu sein, regelmässiges Nachschauen würde ich aber empfehlen, denn der Workload wird ja eher steigen als fallen.
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.

chongs45
Posts: 6
Joined: 2015-01-01 17:01
Location: Bad X-Nach

Re: MySQL richtig konfigurieren

Post by chongs45 » 2015-01-01 17:22

Hallo,

nach dem ich ohne Erfolg probiere meinen MySql Server zu optimieren, dachte ich mir ich Poste hier auch mal meine Settings.
Zu meinen System:
Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz mit 8 GB RAM und 1TB als RAID5-Software.
Swap 4GB

Ca. 50 Webblogs mit Wordpress mit InnoDB und Myisam als ENGINE!

Problem hier das meine Swap 98% ausgelastet ist, hoffe Ihr könnt mir weiterhelfen, bin am überlegen alle Wordpress Tabellen auf InnoDB umzustellen.

Hier meine Tuner und Mysltuner Daten:


Code: Select all

MySQL Version 5.5.37-0ubuntu0.12.10.1-log x86_64

Uptime = 1 days 5 hrs 28 min 57 sec
Avg. qps = 27
Total Questions = 2932505
Threads Connected = 4

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/refman/5.5/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is enabled.
Current long_query_time = 0.900000 sec.
You have 7360 out of 2932526 that take longer than 0.900000 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/refman/5.5/en/point-in-time-recovery.html

WORKER THREADS
Current thread_cache_size = 80
Current threads_cached = 13
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 150
Current threads_connected = 4
Historic max_used_connections = 17
The number of used connections is 11% of the configured maximum.
Your max_connections variable seems to be fine.

INNODB STATUS
Current InnoDB index space = 16 M
Current InnoDB data space = 207 M
Current InnoDB buffer pool free = 94 %
Current innodb_buffer_pool_size = 4.00 G
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 : 4.59 G
Configured Max Per-thread Buffers : 684 M
Configured Max Global Buffers : 4.51 G
Configured Max Memory Limit : 5.18 G
Physical Memory : 7.70 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 93 M
Current key_buffer_size = 256 M
Key cache miss rate is 1 : 806
Key buffer free ratio = 76 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 256 M
Current query_cache_used = 206 M
Current query_cache_limit = 4 M
Current Query cache Memory fill ratio = 80.80 %
Current query_cache_min_res_unit = 9 K
However, 65516 queries have been removed from the query cache due to lack of memory
Perhaps you should raise query_cache_size
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 = 2.00 M
You have had 3 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.

Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.

OPEN FILES LIMIT
Current open_files_limit = 32768 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 = 8192 tables
Current table_definition_cache = 8192 tables
You have a total of 1253 tables
You have 2174 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 128 M
Current tmp_table_size = 128 M
Of 38637 temp tables, 33% 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 = 25 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 95385
Your table locking seems to be fine


und

Code: Select all

 >>  MySQLTuner 1.2.0 - 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] Logged in using credentials from debian maintenance account.

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.37-0ubuntu0.12.10.1-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 561M (Tables: 946)
[--] Data in InnoDB tables: 207M (Tables: 257)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[--] Data in MEMORY tables: 372K (Tables: 9)
[!!] Total fragmented tables: 301

-------- Security Recommendations  -------------------------------------------
[OK] All database users have passwords assigned

-------- Performance Metrics -------------------------------------------------
[--] Up for: 1d 5h 30m 40s (2M q [27.627 qps], 89K conn, TX: 18B, RX: 500M)
[--] Reads / Writes: 75% / 25%
[--] Total buffers: 4.6G global + 4.6M per thread (150 max threads)
[OK] Maximum possible memory usage: 5.3G (68% of installed RAM)
[OK] Slow queries: 0% (7K/2M)
[OK] Highest usage of available connections: 11% (17/150)
[OK] Key buffer size / total MyISAM indexes: 256.0M/93.4M
[OK] Key buffer hit rate: 99.9% (14M cached / 18K reads)
[OK] Query cache efficiency: 72.5% (1M cached / 2M selects)
[!!] Query cache prunes per day: 53330
[OK] Sorts requiring temporary tables: 0% (38 temp sorts / 69K sorts)
[!!] Temporary tables created on disk: 33% (19K on disk / 58K total)
[OK] Thread cache hit rate: 99% (17 created / 89K connections)
[!!] Table cache hit rate: 19% (2K open / 11K opened)
[OK] Open file limit used: 7% (2K/32K)
[OK] Table locks acquired immediately: 99% (859K immediate / 859K locks)
[OK] InnoDB data size / buffer pool: 207.5M/4.0G

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    Increasing the query_cache size over 128M may reduce performance
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries without LIMIT clauses
    Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
    query_cache_size (> 256M) [see warning above]
    tmp_table_size (> 128M)
    max_heap_table_size (> 128M)
    table_cache (> 8192)


meine my.cnf

Code: Select all

#
# 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/en/server-system-variables.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

# 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
tmpdir          = /var/tmp/mysql
lc-messages-dir = /usr/share/mysql
skip-external-locking
low_priority_updates =1
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1
#
# * Fine Tuning
#
#key_buffer             = 16M
key_buffer_size         = 256M
join_buffer_size        = 2M
myisam_sort_buffer_size = 64M

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover          = FORCE,BACKUP
max_connections         = 150
max_heap_table_size     = 128M
tmp_table_size          = 128M
max_allowed_packet      = 128M
open_files_limit        = 32768
table_cache             = 8192
table_definition_cache  = 8192
thread_concurrency      = 4
thread_cache_size       = 80
thread_stack            = 192K
#
# * Query Cache Configuration
#
query_cache_limit       = 4M
query_cache_size        = 256M
query_cache_type        = 1
query_cache_min_res_unit  = 9K
#
# * 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 log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
log_slow_queries        = /var/log/mysql/mysql-slow-new.log
long_query_time = 0.9
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_buffer_pool_size         = 4G
innodb_buffer_pool_instances    = 4
#
# 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      = 128M
#key_buffer_size         = 128M

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


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

[isamchk]
key_buffer              = 256M

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


Eine Idee wie ich das Optimiert bekomme? War am Überlegen alles auf InnoDB umzulegen, aber selbst das hilft wohl nicht!?!
free -m

Code: Select all

 total       used       free     shared    buffers     cached
Mem:          7893       7525        368          0        112       3226
-/+ buffers/cache:       4186       3707
Swap:         3906       3647        259


top

Code: Select all

top - 18:18:21 up 11 days,  5:29,  1 user,  load average: 0.59, 0.50, 0.53
Tasks: 423 total,   2 running, 421 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.4 us,  0.4 sy,  0.0 ni, 95.4 id,  2.5 wa,  0.0 hi,  0.2 si,  0.0 st
KiB Mem:   8083396 total,  7737500 used,   345896 free,   115960 buffers
KiB Swap:  4000700 total,  3735332 used,   265368 free,  3319780 cached


Hoffe Ihr könnt da etwas helfen.

Soll ich Wirklich diese Werte erhöhen?

Code: Select all

query_cache_size (> 256M) [see warning above]
    tmp_table_size (> 128M)
    max_heap_table_size (> 128M)
    table_cache (> 8192)


mfg
ch45
Der eine Mag das eine und andere! - Rund um Affiliate Blogs ;)

User avatar
Joe User
Project Manager
Project Manager
Posts: 11138
Joined: 2003-02-27 01:00
Location: Hamburg

Re: MySQL richtig konfigurieren

Post by Joe User » 2015-01-01 20:09

Grundsätzlich ist InnoDB seit MySQL 5.5 in vielen Fällen MyISAM vorzuziehen, was insbesondere bei 0815-WebApps wie Wordpress zutrifft. Also ja, eine Umstellung auf InnoDB schadet nicht und könnte auch noch einen leichten Performancezuwachs bringen.

Ansonsten ist Dein MySQLd für Deinen Workload bereits ausreichend optimal konfiguriert.
Die von mysqltuner.pl vorgeschlagenen Änderungen in diesem Fall bitte nicht durchführen, da Du bereits an den jeweiligen oberen Grenzwerten bist. Gehst Du dort höher, dann erreichst Du im Worst-Case gar das genaue Gegenteil.



Dein eigentliches Problem mit dem Swap liegt aber höchstwarscheinlich nicht an MySQL, daher würde ich Dich darum bitten, einen neuen Post in "Systemadministration" oder "Smalltalk" zu erstellen, wir verschieben ihn dann später in ein passenderes Themengebiet. Danke.
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.

seocom
Posts: 2
Joined: 2015-11-27 23:24

Re: MySQL richtig konfigurieren

Post by seocom » 2015-11-27 23:57

Hallo Joe,
ich hoffe du kannst mir helfen. Ich habe auf unserem Server HP Proliant G7 48GB, eine neue openvz (Speicher 10GB) mit debian 8 mit ispconfig3, postfix, dovecot, fail2ban etc., rondcube, mysql 5.5.47 in der vz läuft im Moment ispconfig 3 als serververwaltung, roundcube (webmail) und als Test ein JTL 4 Testshop so weit so gut.
Ich habe deine my.cnf als Grundlage benutzt und an debian angepasst und die replikation weggelassen (währe gut wenn du auch eine my.cnf ohne Replikation online stellen würdest).
Mein Problem laut mysqltuner sehr viele - Aborted connections, kann jemand helfen an was liegt es wie kann ich das beheben?
Hier mal meine my.cnf und die Ausgabe von mysqltuner - Danke euch in voraus für die Hilfe.

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/en/serve ... 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

[mysql]
prompt = \u@\h [\d]>\_
no_auto_rehash

# 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
tmpdir = /var/tmp/mysql
lc-messages-dir = /usr/share/mysql
#explicit_defaults_for_timestamp
skip-external-locking
skip-symbolic-links
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
back_log = 300
safe-user-create = 1
delay-key-write = ALL
#low_priority_updates =1
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size = 256M
join_buffer_size = 128k
sort_buffer_size = 2M
read_buffer_size = 128K
read_rnd_buffer_size = 256K
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
performance_schema = OFF

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options = FORCE,BACKUP
max_connections = 100
ft_max_word_len = 20
ft_min_word_len = 3
max_heap_table_size = 64M
tmp_table_size = 64M
max_allowed_packet = 64M
open_files_limit = 32768
table_open_cache = 8192
table_definition_cache = 8192
thread_concurrency = 4
thread_cache_size = 80
thread_stack = 192K
#
# * Query Cache Configuration
#
query_cache_type = 1
query_cache_size = 128M
query_cache_limit = 2M
query_cache_min_res_unit = 4K
#
# * 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 log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 0.9
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
#net_retry_count = 16384
#
# * InnoDB
innodb_thread_concurrency = 8
innodb_buffer_pool_size = 2G
innodb_buffer_pool_instances = 2
innodb_data_home_dir = /var/lib/mysql
innodb_log_group_home_dir = /var/lib/mysql
innodb_data_file_path = ibdata1:1000M;ibdata2:1000M;ibdata3:10M:autoextend
innodb_flush_method = O_DIRECT
innodb_log_file_size = 256M
innodb_log_buffer_size = 16M
innodb_log_files_in_group = 2
innodb_flush_log_at_trx_commit = 1
innodb_max_dirty_pages_pct = 90
innodb_file_per_table = 1
innodb_purge_threads = 1
innodb_strict_mode = 1
innodb_old_blocks_time = 1000
innodb_stats_on_metadata = 0
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_io_capacity = 200
innodb_open_files = 8192
#
# 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]
max_allowed_packet = 256M
key_buffer_size = 256M
quote_names
quick

[isamchk]
key_buffer_size = 256M

[myisamchk]
key_buffer_size = 256M

[mysqlhotcopy]
interactive_timeout

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

----> mysqltuner:
[OK] Logged in using credentials from debian maintenance account.
>> MySQLTuner 1.6.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
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.46-0+deb8u1-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
[--] Data in InnoDB tables: 576K (Tables: 19)
[--] Data in MyISAM tables: 6M (Tables: 381)
[!!] Total fragmented tables: 4

-------- 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 !

-------- Performance Metrics -------------------------------------------------
[--] Up for: 1d 11h 41m 4s (177K q [1.381 qps], 9K conn, TX: 121M, RX: 75M)
[--] Reads / Writes: 22% / 78%
[--] Binary logging is disabled
[--] Total buffers: 2.5G global + 2.7M per thread (100 max threads)
[OK] Maximum reached memory usage: 2.5G (25.13% of installed RAM)
[OK] Maximum possible memory usage: 2.7G (27.23% of installed RAM)
[OK] Slow queries: 1% (2K/177K)
[OK] Highest usage of available connections: 20% (20/100)
[!!] Aborted connections: 26.81% (2650/9886)
[OK] Query cache efficiency: 92.6% (118K cached / 128K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 1K sorts)
[OK] Temporary tables created on disk: 6% (90 on disk / 1K total)
[OK] Thread cache hit rate: 99% (20 created / 9K connections)
[OK] Table cache hit rate: 80% (426 open / 528 opened)
[OK] Open file limit used: 2% (775/32K)
[OK] Table locks acquired immediately: 100% (50K immediate / 50K locks)

-------- MyISAM Metrics -----------------------------------------------------
[!!] Key buffer used: 18.5% (49M used / 268M cache)
[OK] Key buffer size / total MyISAM indexes: 256.0M/3.2M
[OK] Read Key buffer hit rate: 99.9% (344K cached / 267 reads)
[OK] Write Key buffer hit rate: 100.0% (140K cached / 37 writes)

-------- InnoDB Metrics -----------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB buffer pool / data size: 2.0G/576.0K
[OK] InnoDB buffer pool instances: 2
[!!] InnoDB Used buffer: 0.22% (289 used/ 131071 total)
[OK] InnoDB Read buffer efficiency: 91.02% (2839 hits/ 3119 total)
[!!] InnoDB Write buffer efficiency: 0.00% (0 hits/ 1 total)
[OK] InnoDB log waits: 0.00% (0 waits / 11 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
Reduce or eliminate unclosed connections and network issues

Gruss
micha

User avatar
Joe User
Project Manager
Project Manager
Posts: 11138
Joined: 2003-02-27 01:00
Location: Hamburg

Re: MySQL richtig konfigurieren

Post by Joe User » 2015-12-18 14:18

Was steht denn im MySQL-Error-Log zu den aborted connections?
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.

seocom
Posts: 2
Joined: 2015-11-27 23:24

Re: MySQL richtig konfigurieren

Post by seocom » 2016-01-26 02:06

Hallo Joe das Mysql-Error-Log ist leider leer!

User avatar
Joe User
Project Manager
Project Manager
Posts: 11138
Joined: 2003-02-27 01:00
Location: Hamburg

Re: MySQL richtig konfigurieren

Post by Joe User » 2016-03-22 22:38

Originalpost angepasst:
* Update auf MySQL 5.7 (MySQL 5.6 supported)
* my.cnf vollständig überarbeitet
* mysqldump angepasst
* /var/lib/mysql_secure hinzugefügt
* /var/lib/mysql_tmpdir hinzugefügt
* Support für MySQL 5.5 und älter eingestellt
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.

Olli
Posts: 3
Joined: 2016-10-29 22:53

Re: MySQL richtig konfigurieren

Post by Olli » 2016-10-29 23:04

Danke für deine Beiträge im ssf.

Das hört sich sehr vielversprechend an, bekomme aber schon beim ausführen von:

Code: Select all

mysqldump --master-data=2 --delete-master-logs --flush-logs --add-locks --create-options --allow-keywords --complete-insert --triggers --routines --events --order-by-primary --set-gtid-purged=OFF --tz-utc --hex-blob --single-transaction --all-databases -uroot -p > /tmp/mysqldump.sql
folgende Fehlermeldung:

Code: Select all

mysqldump: unknown variable 'set-gtid-purged=OFF'
Username und Passwort habe ich natürlich mit meinen ersetzt. :D

Außerdem habe ich mehrere Datenbanken. Da alle Datenbanken gesichert werden (--all-databases ), wie werden die gepeichert? Die können ja nicht alle "mysqldump.sql" heißen.

Ich nutze noch MySQL 5.5 und möchte updaten.

User avatar
Joe User
Project Manager
Project Manager
Posts: 11138
Joined: 2003-02-27 01:00
Location: Hamburg

Re: MySQL richtig konfigurieren

Post by Joe User » 2016-10-30 00:43

Bei MySQL 5.5 musst Du die gtid Optionen weglassen, die gibt es erst ab MySQL 5.6.

Bei --all-databases werden alle Datenbanken (ausser mysql, sys und performance_schema) in einer gemeinsamen Datei gespeichert und auch wiederhergestellt. Das ist bei Fullbackups praktischer als jede DB einzeln zu verarbeiten. Du kannst aber selbstverständlich auch --all-databases durch die jeweiligen DB ersetzen.

Der Dateiname spielt keine Rolle, den kannst Du auch foobar.sql oder watweissich.sql nennen.
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.

Olli
Posts: 3
Joined: 2016-10-29 22:53

Re: MySQL richtig konfigurieren

Post by Olli » 2016-11-03 22:52

So habe jetzt ein Update auf 5.7 gemacht, allerdings nicht nach der Anleitung in Post #1 sondern über Plesk reconfigure. Die Datenbank und meine Websites rennen. Allerdings ist die my.cnf leer, bzw. es steht nur das hier drin:

Code: Select all

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

[client]
port                            = 3306
socket                          = /var/run/mysqld/mysqld.sock
pid-file                        = /var/run/mysqld/mysqld.pid
Wtf? Wo sind die Einstellungen hin?

User avatar
Joe User
Project Manager
Project Manager
Posts: 11138
Joined: 2003-02-27 01:00
Location: Hamburg

Re: MySQL richtig konfigurieren

Post by Joe User » 2016-11-04 00:45

Schau mal in die Verzeichnisse die in den ersten zwei Zeilen Deiner geposteten my.cnf.
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.

Olli
Posts: 3
Joined: 2016-10-29 22:53

Re: MySQL richtig konfigurieren

Post by Olli » 2016-11-04 01:43

Code: Select all

root@srv:/etc/mysql/conf.d# ls
plesk.cnf  mysql.cnf

Code: Select all

root@srv:/etc/mysql/mysql.conf.d# ls
mysqld.cnf
In der plesk.cnf steht folgendes:

Code: Select all

[mysqldump]
host     = localhost
port     = 3306
user     = "plesk_user"
password = "xxxxxx"

[mysqld]
event_scheduler = DISABLED
default_password_lifetime = 0
innodb_use_native_aio = 1
performance_schema = 0
sql_mode = "NO_AUTO_CREATE_USER"
max_connections = 500

[mysql_upgrade]
host     = localhost
port     = 3306
user     = "plesk_user"
password = "xxxxxx"
socket   = /var/run/mysqld/mysqld.sock
Dann wird das wohl die plesk.cnf sein, die ich bearbeiten muss oder?

Hier alle my.cnf auf dem Server:

Code: Select all

root@srv:~# locate my.cnf
/etc/alternatives/my.cnf
/etc/mysql/my.cnf
/etc/mysql/my.cnf.bak
/etc/mysql/my.cnf.fallback
/var/lib/dpkg/alternatives/my.cnf
Die sind aber alle leer, außer die my.cnf.bak, das ist das Backup was ich vorm Update gemacht habe.

User avatar
Joe User
Project Manager
Project Manager
Posts: 11138
Joined: 2003-02-27 01:00
Location: Hamburg

Re: MySQL richtig konfigurieren

Post by Joe User » 2016-11-04 11:39

In dem Fall erweiterst Du am Besten die /etc/mysql/my.cnf nur um die Optionen, die nicht bereits in plesk.cnf stehen und hoffst, dass Plesk da nicht drin rumfummelt.
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.