Windows MySQL: Out of memory - mysql

We are not able to create a stable configuration of a production server with MySQL and Tomcat Application Server. The MySQL throws very often an error:
MySQL: Out of memory (Needed 429496728 bytes)
It was a Windows Server 2012 with 64 GB of RAM. We see in the process tab, that the MySQLd commited 64 GB of RAM (that means all the available RAM in the server).
For your explaination, the Application uses completly inMemory based Tables in the MySQL Server.
See the my.ini Configuration
[client]
port=3306
[mysql]
default-character-set=utf8
[mysqld]
port=3306
basedir="F:/MySQL Server 5.6/"
datadir="F:/MySQL Server 5.6/data/"
character-set-server=utf8
default-storage-engine=MyISAM
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
max_connections=200
query_cache_size=0
# table_cache=256
tmp_table_size=6G
max_heap_table_size=6G
max_tmp_tables=2048
open_files_limit=40000
thread_cache_size=8
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=32M
myisam_use_mmap=0
concurrent_insert=2
key_buffer_size=2G
read_buffer_size=512M
read_rnd_buffer_size=512M
sort_buffer_size=128M
bulk_insert_buffer_size=32M
#skip-innodb
innodb_additional_mem_pool_size=15M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=7M
innodb_buffer_pool_size=686M
innodb_log_file_size=343M
innodb_thread_concurrency=34
slow_query_log=1
log-queries-not-using-indexes=1
long_query_time=1
log-output=FILE,TABLE
slow_query_log_file="F:/MySQL Server 5.6/localhost-slow-query.log"
event-scheduler=ON
Does anybody have a suitable solution to get this fixed?
We also use the MySQL Tuner to get informations, here the results:
What I cannot attach is the MySQL Tuner results as image (too few reputations). But look here.
Up for 39days
Data in Memory Tables 42G (Tables:281)
Data in MyISAM tables 31G (Tables 668)
total buffers: 2.3G global + 144.5M per Thread (200 max threads)
maximum possible memory usage: 30.5G (47% of installed RAM)
Key buffer size /total MyISAM indixes: 640M/7.0G
query cache disabled
joins performed without indixes: 337737

Related

Mysql "memory usage" increasing and increasing

I have a really big website built old fashioned with PHP & MYSQL.
I have more than 1,000 different queries in my website, on different PHP pages, and it's really hard to update all of them to MYSQLI.
I bought VPS server with 4GB RAM and in the past months I experience really slow page loads.
When I restart my server, everything runs smoothly, but after couple of hours/days the website is getting muchu slower with loading time of 3+ seconds for a page load. I notice that the mysqld service is increasing and increasing in memory usage, from 80MB on server restart it reached about 400MB and more of usage.
I put in the end of my index.php mysql_close() but it seem like the connection number still increasing.
Questions
What can cause unlimited increment in mysql memory usage?
Updating all my queries to MYSQLI may improve the performance?
Some information:
innodb_version
5.5.31
protocol_version
10
slave_type_conversions
version
5.5.31-log
version_comment
MySQL Community Server (GPL)
version_compile_machine
x86_64
version_compile_os
Linux
storage engine: Mixed (Somes tables are INNODB,some tables are MyISAM.
my.cnf:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
max-connections=100000
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
thread_cache_size=5
table_open_cache=99390
sort_buffer_size=512M
read_rnd_buffer_size=512M
query_cache_size=512M
query_cache_limit = 16M
query_cache_type = 1
slow_query_log=1
slow_query_log_file=slow_query_log.log #
long_query_time=5
log-queries-not-using-indexes=1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
I have about ~6-7 queries running when I use show processlist
max-connections=100000 -- Yikes! Drop to 1000
table_open_cache=99390 -- drop to, say, 2000
sort_buffer_size=512M -- drop to 1% of RAM, say, 40M
read_rnd_buffer_size=512M -- ditto
query_cache_size=512M -- too big; slows things down; drop to 40M
long_query_time=5 -- not low enough to catch much; drop to 2
log-queries-not-using-indexes=1 -- clutters the slowlog without providing much info; change to 0
You did not say which Engine you are using. Read this for advice on MyISAM and InnoDB.
1000 pages -- that's not too many.
Which web server? If Apache, don't set MaxClients to more than 20.
2022 postscript: The query_cache_size and query_cache_type variables have been removed from mySQL 8.0.3+.

MySQL memory usage (InnoDB, Win)

I have MySQL 5.6 (InnoDB) installed on Win 2008 server with 1Gb. mysqld uses 415Mb memory. How to reduce memory usage? I read that it is possible to do by configuring my.ini: key_buffer_size, innodb_buffer_pool_size, etc. Please, tell me the correct settings to minimize memory usage.
You can check Configuring MySQL to use minimal memory:
# /etc/my.cnf:
innodb_buffer_pool_size=5M
innodb_log_buffer_size=256K
query_cache_size=0
max_connections=10
key_buffer_size=8
thread_cache_size=0
host_cache_size=0
innodb_ft_cache_size=1600000
innodb_ft_total_cache_size=32000000
# per thread or per operation settings
thread_stack=131072
sort_buffer_size=32K
read_buffer_size=8200
read_rnd_buffer_size=8200
max_heap_table_size=16K
tmp_table_size=1K
bulk_insert_buffer_size=0
join_buffer_size=128
net_buffer_length=1K
innodb_sort_buffer_size=64K
#settings that relate to the binary log (if enabled)
binlog_cache_size=4K
binlog_stmt_cache_size=4K

Why does mySQL use over 200000 handles on startup?

I have a server (MS Windows Server 2012 R2 Datacenter 64GB RAM 2TB+ disk space) running mySQL 5.0. When I start the mySQL server, right off the bat it allocates 214,000 handles. Is that normal? I've been looking into this because I am trying to run an application that executes multiple unique queries over thousands of records and it is just crawling.
I have changed query_cache_size from 160M to 0M in the my.ini file as query caching will not benefit this application. Still no change in handles. I'm not sure what else I can do to fix this. Does anyone have any ideas?
The server is:
MySQL 5.0.60sp1-enterprise-gpl-nt
There are a ton of options. Here are what I think are the relevant ones (I could be wrong I am not an expert)
[mysqld]
default_storage_engine=InnoDB
innodb_file_per_table
innodb_flush_method=unbuffered
lower_case_table_names=2
max_allowed_packet=48M
max_heap_table_size=64777216
max_connections=3010
query_cache_size=0M
table_cache=6020
tmp_table_size=16M
thread_cache_size=64
myisam_max_sort_file_size=100G
myisam_max_extra_sort_file_size=100G
key_buffer_size=20M
read_buffer_size=64K
read_rnd_buffer_size=256K
innodb_additional_mem_pool_size=15M
innodb_flush_log_at_trx_commit=1
innodb_buffer_pool_size=709M
innodb_thread_concurrency=50

MySQL NDB cluster slow for no reason

I have a mysql ndb cluster (details below). The problem is when I do the simplest thing such as restore a database that was dumped using mysqldump, it take an absolute age! IE 6 hours to restore a db that's 745MB in size and has approx 2.7 million rows across about 30 tables, all pretty standard stuff.
I've looked for bottlenecks, no 1 cpu core is overloaded, nor the disks, nor the network, so why so slow?
FYI, while importing a database the network is utilised at approx 2Mbit/s and the ndb nodes are writing to disk at about 1MB per second... hardly utilised. There is no swapping... the db is entirely in memory... no single core is maxed out by a process... no wait-state to note....
I've got two machines each with 4 quad core xeon cpus, 32GB ram. Between them they host a mysql cluster, the nodes are hosted with virtualbox and specs are as follows:
sql API * 2: 4GB ram 4 cores
sql NDB * 2: 19GB ram 8 cores
management node: 4GB 4 cores
Note: I run the NDB nodes using ndbmtd, the sql api nodes use the ndb-cluster-connection-pool=4 param.
Does anyone have any idea why its so slow? I'm simply unable to find a single bottleneck?!?
config.ini
[ndb_mgmd default]
DataDir=/var/lib/mysql-cluster
[ndb_mgmd]
HostName=mgm-alpha
NodeId=1
[TCP DEFAULT]
SendBufferMemory=12M
ReceiveBufferMemory=12M
[ndbd default]
NoOfReplicas=2
DataMemory=15000M
IndexMemory=1048M
MaxNoOfConcurrentOperations=100000
RedoBuffer=32M
MaxNoOfAttributes=5000
MaxNoOfOrderedIndexes=1000
TimeBetweenEpochs=500
DiskCheckpointSpeed=20M
DiskCheckpointSpeedInRestart=100M
MaxNoOfExecutionThreads=8
DataDir=/var/lib/mysql-cluster
[ndbd]
HostName=cl1-alpha
NodeId=2
[ndbd]
HostName=cl2-bravo
NodeId=3
[mysqld]
HostName=sq1-alpha
NodeId=4
[mysqld]
HostName=sq1-alpha
NodeId=5
[mysqld]
HostName=sq1-alpha
NodeId=6
[mysqld]
HostName=sq1-alpha
NodeId=7
[mysqld]
HostName=sq2-bravo
NodeId=8
[mysqld]
HostName=sq2-bravo
NodeId=9
[mysqld]
HostName=sq2-bravo
NodeId=10
[mysqld]
HostName=sq2-bravo
NodeId=11
my.cnf on mysql api nodes
[mysqld]
# Options for mysqld process:
ndbcluster
ndb-connectstring=mgm-alpha
default_storage_engine=ndbcluster
ndb-mgmd-host = mgm-alpha:1186
ndb-cluster-connection-pool=4
[mysql_cluster]
# Options for MySQL Cluster processes:
ndb-connectstring=mgm-alpha # location of management server
One reason is ndb cluster does not handle large transactions well. Some answers and tips can be found here:
http://dev.mysql.com/doc/refman/5.5/en/mysql-cluster-limitations-transactions.html
http://johanandersson.blogspot.co.nz/2012/04/mysql-cluster-how-to-load-it-with-data.html

MySQL NOT using the available memory

I'm moving from a shared web hosting company to a VPS. And I'm trying to find the optimum configuration for my system.
For 1 specific table with half a million record, 1 query that was taking few seconds on the previous server is now taking minutes.
I'm trying to improve the response time of my server, so I bought more memory (I have 2GB of RAM, and I can still buy more resources if needed and 2 cores). I have also "cheated" by copying my.cnf of the old company to my VPS:
[mysqld]
read_buffer_size=8M
read_rnd_buffer_size=8M
sort_buffer_size=32M
innodb_additional_mem_pool_size=503M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=16M
innodb_buffer_pool_size=1007M
innodb_log_file_size=256M
innodb_thread_concurrency=8
innodb_autoextend_increment=128
max_connections=8059
max_user_connections=50
thread_cache_size=128
thread_stack=196608
binlog_cache_size=2M
net_read_timeout=30
net_retry_count=10
net_write_timeout=30
thread_concurrency=10
open_files_limit=9940
max_heap_table_size=32M
tmp_table_size=64M
key_buffer_size=512M
key_buffer=128M
myisam_sort_buffer_size=64M
join_buffer=16M
record_buffer=8M
wait_timeout=300
connect_timeout=10
max_allowed_packet=16M
max_connect_errors=100
table_cache=1024
query_cache_size=32M
query_cache_type=1
ft_min_word_len=4
datadir=/var/lib/mysql
tmpdir=/tmp
socket=/var/lib/mysql/mysql.sock
old-passwords=0
[mysqldump]
quick
max_allowed_packet=16M
[myisamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M
The problem is that the query is still slow, and the server does not use the available memory!
total used free shared buffers cached
Mem: 2002 1986 15 0 6 1079
-/+ buffers/cache: 901 1101
Swap: 1747 2 1745
Any suggestions?
Regards
You can have a look at using
https://github.com/rackerhacker/MySQLTuner-perl
Which you can use to analyse MySQL and it will output recommended settings.
Your settings seem way high for 2gb memory.
IE max_connections=8059
That in its self would require way more memory than you have.
[mysqld]
max_connections=100
innodb_buffer_pool_size=256M
query_cache_size=256M
key_buffer_size=256M
innodb_flush_log_at_trx_commit=0
innodb_flush_method=O_DIRECT
query_cache_type=1
query_cache_limit=2M
table_cache=1024
join_buffer_size=4M
thread_cache_size=128
tmp_table_size=256M
max_heap_table_size=256MB
For 2gb RAM you could try using these settings in MySQL
These are the recommended settings for one of the 2gb servers I am currently using