Page 2 of 2

Re: MySQL probleme bei optimierung

Posted: 2013-06-08 15:01
by Joe User
Das passende Passwort für den entsprechenden MySQL-User (auch MySQL-root) musst Du schon angeben, wenn Du Dich verbindest.
Alternativ kannst Du auch eine /root/.my.cnf mit den Logindaten für den MySQL-root-User anlegen, dann brauchst Du die Logindaten für MySQL-root nicht per Commandline übergeben. Hat auch den Vorteil, dass das MySQL-root Passwort nicht in irgendwelchen Logs oder .history auftaucht.
Desweiteren heisst der MySQL-root bei Debian bekloppterweise nicht root sondern debian-maint oder so ähnlich, siehe /etc/mysql/debian.conf (AFAIR).

EDIT: Ja, am + im Passwort kann es auch liegen.

Re: MySQL probleme bei optimierung

Posted: 2013-06-08 15:11
by fulltilt
also bis auf mysqltuner und tuning-primer funktioniert alles:

Code: Select all

mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11308
es scheint irgendein parameter in der my.cnf löst dies aus ...
habe gerade auf einer VM getestet ohne sonderzeichen im Passwort, hier bekomme ich die selbe Meldung
- FINAL LOGIN ATTEMPT FAILED -
Unable to log into socket: /var/run/mysqld/mysqld.sock

Re: MySQL probleme bei optimierung

Posted: 2013-06-08 15:29
by Joe User

Code: Select all

ls -alh /var/run/mysqld /var/tmp/mysql

Re: MySQL probleme bei optimierung

Posted: 2013-06-08 15:38
by fulltilt
hmm, die Rechte scheinen OK zu sein ...
wenn ich in der VM mit der alten my.cnf starte gehts ...

Code: Select all

ls -alh /var/run/mysqld /var/tmp/mysql
/var/run/mysqld:
total 12K
drwxr-xr-x  2 mysql root  4,0K Jun  8 14:39 .
drwxr-xr-x 13 root  root  4,0K Jun  5 12:42 ..
-rw-rw----  1 mysql mysql    6 Jun  8 14:39 mysqld.pid
srwxrwxrwx  1 mysql mysql    0 Jun  8 14:39 mysqld.sock

/var/tmp/mysql:
total 8,0K
drwxrwx--T 2 mysql mysql 4,0K Jun  8 15:34 .
drwxrwxrwt 3 root  root  4,0K Jun  8 12:58 ..

Re: MySQL probleme bei optimierung

Posted: 2013-06-08 15:48
by fulltilt
also mit diesem alten basics funktioniert es

Code: Select all

[client]
port		= 3306
socket		= /var/run/mysqld/mysqld.sock

[mysqld_safe]
socket		= /var/run/mysqld/mysqld.sock

[mysqld]
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_name_resolve
skip_locking
bind-address		= 127.0.0.1
spielt die reihenfolge da vieleicht eine Rolle?

Re: MySQL probleme bei optimierung

Posted: 2013-06-08 15:54
by Joe User
Nein, aber es könnte sein, dass bei Debian mal wieder die rc-Scripts verhunzt sind.
Füge bitte mal diese Zeilen vor [mysqld] ein:

Code: Select all

[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock

Re: MySQL probleme bei optimierung

Posted: 2013-06-08 16:19
by fulltilt
seltsam so geht es:

Code: Select all

[client]
port      = 3306
socket      = /var/run/mysqld/mysqld.sock
und damit nicht:

Code: Select all

[client]
port      = 3306
max_allowed_packet              = 64M
socket      = /var/run/mysqld/mysqld.sock
kann ich die folgende my.cnf so verwenden?

Code: Select all

[client]
port      = 3306
socket      = /var/run/mysqld/mysqld.sock

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

[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock

[mysqld]
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/tmp/mysql
secure-file-priv     = /var/tmp/mysql
language   = /usr/share/mysql/english
skip-external-locking
skip_name_resolve
skip_locking
bind-address      = 127.0.0.1
symbolic-links          = 0
server-id                       = 1


log_bin			= /var/log/mysql/mysql-bin.log
back_log                        = 500
sync_binlog                     = 1
#binlog_cache_size               = 4M
#binlog_stmt_cache_size          = 4M
max_binlog_size                 = 500M
binlog-format                   = MIXED
expire_logs_days                = 30
slow-query-log                  = 1
slow-query-log-file             = /var/log/mysql/mysql-slow.log

delay-key-write                 = ALL
myisam-recover                  = FORCE,BACKUP

key_buffer_size                 = 256M
max_allowed_packet              = 64M
max_heap_table_size             = 64M
tmp_table_size                  = 64M
thread_stack                    = 192K
table_cache                     = 32768
table_open_cache                = 32768
table_definition_cache          = 16384
query_cache_type                = 1
query_cache_size                = 64M
thread_cache_size               = 150
max_connections                 = 200
ft_max_word_len                 = 20
ft_min_word_len                 = 3
long_query_time                 = 2
local-infile                    = 0

log-warnings                    = 2
log-queries-not-using-indexes

innodb_thread_concurrency       = 8
innodb_buffer_pool_size         = 2G
#innodb_buffer_pool_instances    = 4
innodb_additional_mem_pool_size = 16M
innodb_data_file_path           = ibdata1:500M;ibdata2:50M: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  = 2
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

#myisam_sort_buffer_size         = 32M

[mysqldump]
max_allowed_packet              = 64M
quote_names
quick

[isamchk]
key_buffer_size                 = 256M

[myisamchk]
key_buffer_size                 = 256M

[mysqlhotcopy]
interactive_timeout

Re: MySQL probleme bei optimierung

Posted: 2013-06-08 16:42
by Joe User
fulltilt wrote:seltsam so geht es:
Hmm, gut werde ich bei Gelegenheit mal näher betrachten.
fulltilt wrote:kann ich die folgende my.cnf so verwenden?
Ja.

Re: MySQL probleme bei optimierung

Posted: 2013-06-09 11:52
by fulltilt
kann ich hier noch etwas höher gehen und das low_priority_updates=1 noch setzen?
(hierbei handelt es sich um einen anderen mysql server)

Code: Select all

TABLE CACHE
Current table_open_cache = 35000 tables
Current table_definition_cache = 16384 tables
You have a total of 17636 tables
You have 34943 open tables.
Current table_cache hit rate is 32%, while 99% of your table cache is in use
You should probably increase your table_cache
You should probably increase your table_definition_cache value.               

TEMP TABLES
Current max_heap_table_size = 256 M
Current tmp_table_size = 256 M
Of 141433 temp tables, 58% 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 LOCKING
Current Lock Wait ratio = 1 : 99
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'
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=2'.

Re: MySQL probleme bei optimierung

Posted: 2013-06-09 12:21
by Joe User
Die table_*_cache kannst Du auf 20000 und 50000 setzen.

Die *_table_size sind eigentlich schon zu hoch, 64MB reichen normalerweise. Dein Problem dürften hier eher Tabellen sein, die Spalten vom Typ TEXT enthalten, denn diese Tabellen werden grundsätzlich immer auf Disk geschrieben. Dagegen hilft nur die Datenbankschema zu überarbeiten und wo nur irgendwie möglich auf TEXT und BLOB Spalten zu verzichten, oder diese Spalten in eigene Tabellen auszulagern, damit wenigstens der Rest der ursprünglichen Tabelle direkt im RAM verarbeitet werden kann.

low_priority_updates ist nur bei langlaufenden SELECTS auf MyISAM-Tabellen hilfreich. Du solltest eher versuchen, so viele Tabellen wie möglich auf InnoDB umzustellen.

Re: MySQL probleme bei optimierung

Posted: 2013-06-09 13:27
by fulltilt
Joe User wrote:Du solltest eher versuchen, so viele Tabellen wie möglich auf InnoDB umzustellen.
Danke, ich versuche es nochmal die tmp_sizes wieder auf 64MB zu setzen und teste morgen noch einmal mit tuning-primer ...
Gibt es irgendeine eine Möglichkeit alle Datenbanken auf einmal auf InnoDB Format umzustellen?
Es sind hier sehr viele Datenbanken vorhanden und die einzelnen Tabellen alle mit ALTER TABLE zu ändern ist enorm zeitaufwendig ;-)

Re: MySQL probleme bei optimierung

Posted: 2013-06-09 15:12
by Joe User
ACHTUNG: Bitte unbedingt ein vollständiges Backup aller Datenbanken anlegen!

Der folgende Aufruf stellt gnadenlos alle Datenbanken-Tabellen auf InnoDB um:

Code: Select all

mysql -uroot -pPaSsWoRd -e "SHOW DATABASES" -s | egrep -v '^(Database|information_schema|mysql|performance_schema)$' | xargs -I "@@" mysql -uroot -pPaSsWoRd -D "@@" -e "ALTER TABLE @@ ENGINE=InnoDB"
Es ist zwingend erforderlich anschliessend Tabellen welche nicht InnoDB sein dürfen/sollen manuell zurückzusetzen.

Re: MySQL probleme bei optimierung

Posted: 2013-06-09 15:33
by fulltilt
Joe User wrote:ACHTUNG: Bitte unbedingt ein vollständiges Backup aller Datenbanken anlegen!

Der folgende Aufruf stellt gnadenlos alle Datenbanken-Tabellen auf InnoDB um:

Code: Select all

mysql -uroot -pPaSsWoRd -e "SHOW DATABASES" -s | egrep -v '^(Database|information_schema|mysql|performance_schema)$' | xargs -I "@@" mysql -uroot -pPaSsWoRd -D "@@" -e "ALTER TABLE @@ ENGINE=InnoDB"
Es ist zwingend erforderlich anschliessend Tabellen welche nicht InnoDB sein dürfen/sollen manuell zurückzusetzen.
sehr beeindruckend - Danke ;-)
also alles ausser der mysql Datenbank - Standard CMS DBs (joomla, typo3, prestashop usw.) kann doch umgestellt werden ...
ich bin mir nur noch nicht sicher mit dem ControlPanel (modifitierte ISPCP) ...
bei den quota und awstats tables wäre eine Umstellung sicher vorteilhaft

Re: MySQL probleme bei optimierung

Posted: 2013-06-09 16:00
by Joe User
Die MySQL-internen Datenbanken habe ich bereits mit dem egrep ausgenommen.

Tabellen mit FULLTEXT-Spalten müssen erstmal MyISAM bleiben und Tabellen mit MEMORY-Engine müssen manuell zurückgestellt werden. Der Rest sollte weitestgehend problemlos mit InnoDB laufen.

Re: MySQL probleme bei optimierung

Posted: 2013-08-30 11:35
by fulltilt
nach ein paar Monaten mit diesen Settings kommt mir jetzt die Reaktionszeit etwas langsam vor, besteht hier noch die Möglichkeit an der my.cnf etwas zu optimieren?

Code: Select all

SLOW QUERIES
The slow query log is enabled.
Current long_query_time = 2.000000 sec.
You have 10808430 out of 278570215 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 enabled

WORKER THREADS
Current thread_cache_size = 16
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 = 130
Current threads_connected = 3
Historic max_used_connections = 58
The number of used connections is 44% of the configured maximum.
Your max_connections variable seems to be fine.

MEMORY USAGE
Max Memory Ever Allocated : 2 G
Configured Max Per-thread Buffers : 1 G
Configured Max Global Buffers : 1 G
Configured Max Memory Limit : 2 G
Physical Memory : 15.64 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 257 M
Current key_buffer_size = 256 M
Key cache miss rate is 1 : 564
Key buffer fill ratio = 99.00 %
You could increase key_buffer_size
It is safe to raise this up to 1/4 of total system memory;
assuming this is a dedicated database server.

QUERY CACHE
Query cache is enabled
Current query_cache_size = 128 M
Current query_cache_used = 83 M
Current query_cache_limit = 4 M
Current Query cache Memory fill ratio = 65.04 %
Current query_cache_min_res_unit = 4 K
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 = 2 M
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 5.00 M
You have had 2225152 queries where a join could not use an index properly
You have had 260289 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 = 100140 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 = 50000 tables
Current table_definition_cache = 20000 tables
You have a total of 17745 tables
You have 37512 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 15309996 temp tables, 51% 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 = 2 M
Current table scan ratio = 116 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 86
You may benefit from selective use of InnoDB.
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=2'.


Re: MySQL probleme bei optimierung

Posted: 2013-08-30 11:51
by fulltilt
hier ist noch die my.cnf

Code: Select all

[client]
port      = 3306
socket      = /var/run/mysqld/mysqld.sock

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

[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock

[mysqld]
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/tmp/mysql
secure-file-priv     = /var/tmp/mysql
language   = /usr/share/mysql/english
skip-external-locking
skip_name_resolve
skip_locking
bind-address      = 127.0.0.1
symbolic-links          = 0
server-id                       = 1

log_bin                 = /var/log/mysql/mysql-bin.log
back_log                        = 500
sync_binlog                     = 1
max_binlog_size                 = 500M
binlog-format                   = MIXED
expire_logs_days                = 30
slow-query-log                  = 1
slow-query-log-file             = /var/log/mysql/mysql-slow.log

delay-key-write                 = ALL
myisam-recover                  = FORCE,BACKUP

key_buffer_size                 = 256M
max_allowed_packet              = 64M
max_heap_table_size             = 128M
tmp_table_size                  = 128M
thread_stack                    = 192K
thread_cache_size       = 16
table_cache                     = 50000
table_open_cache                = 50000
table_definition_cache          = 20000
query_cache_limit       = 4M
query_cache_size        = 128M
#thread_cache_size               = 150
max_connections                 = 130
ft_max_word_len                 = 20
ft_min_word_len                 = 3
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 2M

join_buffer_size     = 5M
long_query_time                 = 2
max_connect_errors = 10
low_priority_updates = 1
#concurrent_insert = 2
local-infile                    = 0

log-warnings                    = 2
log-queries-not-using-indexes

innodb_thread_concurrency       = 8
innodb_buffer_pool_size         = 1G
innodb_flush_log_at_trx_commit  = 2
innodb_additional_mem_pool_size = 16M
innodb_data_file_path           = ibdata1:500M;ibdata2:50M: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  = 2
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

#myisam_sort_buffer_size         = 32M

[mysqldump]
max_allowed_packet              = 64M
quote_names
quick

[isamchk]
key_buffer_size                 = 256M

[myisamchk]
key_buffer_size                 = 256M

[mysqlhotcopy]
interactive_timeout