I'm converting a lot of tables from MyISAM to InnoDB (you've convinced me) and I'm wondering what recommendations as to my MySQL configuration you guys might have...
I'm running a 16GB of RAM with 4x QUAD Core 3.0 GHz processor.
#
# * Fine Tuning
#
key_buffer = 1024M
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 = 1500
table_cache = 128
thread_concurrency = 4
#
# * Query Cache Configuration
#
query_cache_limit = 2M
query_cache_size = 32M
query_cache_type = 1
#
# * Custom Configuration
#
tmp_table_size = 512M
max_heap_table_size = 128M
join_buffer_size = 128M
myisam_sort_buffer_size = 512M
http://www.mysqlperformanceblog.com/2006/09/29/what-to-tune-in-mysql-server-after-installation/
Related
I am facing issue the kernal is again and agin killing mysql
And due to this tomcat stops arbitrarily.
My db size is approx 700 MB.
My application is fetching much more data on regular basis.
JVM memory usages
=================
-Xms3000m
-Xmx12000m
-XX:MaxMetaspaceSize=4000m
my.cnf
======
[mysqld]
performance-schema=0
max_connections = 150
max_user_connections = 100
query_cache_size = 64M
skip-external-locking
key_buffer_size = 64M
max_allowed_packet=268435456
table_open_cache = 256
sort_buffer_size = 1M
net_buffer_length = 16K
read_buffer_size = 1M
read_rnd_buffer_size = 1M
myisam_sort_buffer_size = 32M
innodb_file_per_table
tmp_table_size = 64M
max_heap_table_size = 64M
thread_cache_size = 8
query_cache_type = on
#innodb_force_recovery = 1
performance-schema=0
# This setting allows the use of asynchronous I/O in InnoDB.
# The following files track usage of this resource:
# - /proc/sys/fs/aio-max-nr
# - /proc/sys/fs/aio-nr
# Default limit is 65536, of which a single instance of mysql uses 2661 out of the box
innodb_use_native_aio = 1
default_storage_engine = MyISAM
open_files_limit=50000
default-storage-engine=MyISAM
Ehcache enabled in my application.
Any solution will be appreciated.
Since we are rookies on this, we are having a hard time trying to setup a Wordpress server to support around 200K monthly visiting users. We have two boxes (details below).
The issue here is when the users start accessing the server, MySQL CPU goes to 149%. Here is a copy of the apache2.conf and the mysql.cnf files. Our MySQL database is InnoDB. Any suggestions on how to fix it?
1. Apache Server
Configuration
8 GB Memory / 25 GB Disk + 200 GB / Ubuntu 16.04
apache.conf excerpt
Timeout 40
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 2
2. MySQL Server
Configuration
8 GB Memory / 25 GB Disk + 50 GB / Ubuntu 16.04
my.cnf file
root#mundo-mysql01-c-2-4gib-nyc3-01:/etc/mysql# cat 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/server-system-variables.html
#
# * 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/
!includedir /etc/mysql/mysql.conf.d/
[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
lc-messages-dir = /usr/share/mysql
skip-external-locking
general_log_file = /var/log/mysql/mysql.log
general_log = 0
# CACHES AND LIMITS #
open_files_limit = 65535
table_definition_cache = 1024
table_open_cache = 2048
# MyISAM Settings
max_connections = 300
key_buffer_size = 256M
myisam_sort_buffer_size = 32M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 16M
thread_cache_size = 32
wait_timeout = 300
connect_timeout = 300
tmp_table_size = 32M
max_heap_table_size = 128M
max_allowed_packet = 128M
max_connect_errors = 10000
read_rnd_buffer_size = 1M
bulk_insert_buffer_size = 1M
query_cache_limit = 4M
query_cache_size = 128M
query_cache_type = 1
query_prealloc_size = 65536
query_alloc_block_size = 131072
low_priority_updates = 1
max_write_lock_count = 1
# * InnoDB
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 256M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
innodb-buffer-pool-size = 2048M
I'm trying to improve my mysql performance. So I add more memory. But still slow in some part. Im most LEFT JOINs and UPDATE.
My database have 40GB of data.
My current mysql configuration is:
key_buffer = 1024M
max_connections = 3000
query_cache_size = 256M
query_cache_limit = 512M
thread_stack = 32M
innodb_buffer_pool_size = 512M
innodb_lock_wait_timeout= 150
table_cache = 2048
max_allowed_packet = 16M
max_heap_table_size = 64M
binlog_cache_size = 1M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency = 8
thread_stack = 192K
query_cache_size = 128M
query_cache_type = 1
query_cache_limit = 2M
tmp_table_size = 64M
key_buffer_size = 64M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 2G
The question is. This is the best configuration ?
MY Serve is running: Digitalocean/Ubuntu16.04
RAM: 4GB
CPU: 2VCPU
SSD Disk: 80GB
Suggestions for your my.cnf-ini [mysqld] section from the limited information posted in the original question,
thread_cache_size=50 # from 8 and monitor threads_created
thread_concurrency=16 # from 8 and monitor response time
# LEAD the following lines to allow DEFAULTS to work for you
# key_buffer=1024M # lead with # to ignore, you have only 4G RAM
# max_connections=3000 # lead with # for default of 151, until more needed
# sort_buffer_size=8M
# read_buffer_size=2M
# read_rnd_buffer_size=8M
# join_buffer_size=8M
# thread_stack=32M
Take two minutes at www.mysqlcalculator.com to see how the above
values unnecessarily increase your RAM footprint for each connection.
DEFAULTS frequently work very well for you.
From my personal experience, the best approach would profile some of the slowest queries and check why they are slow. Sometimes you are using a "where" (query criteria) without any index, sometimes you have too many indexes to be updated once you add/update values.
Please note that every field should be based over what you are running. A very dummy example. max_allowed_packet = 16M
You can make it smaller if you don't have batch queries or if you don't use Blobs. But if you store large blobs, you need this big enough to fit the bigger attachment you will store.
Hi are trying to optimize MySQL for a huge traffic web server, we are using Apache 2.4 , and MySQL 5.6 version.
We have put these parameters in MySQL configuration file
cat /etc/my.cnf
[mysqld]
skip-external-locking
key_buffer = 500M
max_allowed_packet=64M
max_connections = 2000
max_user_connections = 50000
wait_timeout=180
connect_timeout=120
table_open_cache=4096
table_definition_cache=4096
myisam_sort_buffer_size = 64M
thread_cache_size = 128
query_cache_size = 190M
query_cache_limit = 3M
open_files_limit=10000
log_error = /var/log/mysql/error.log
default-storage-engine=MyISAM
[mysqld]
log-bin=mysql-bin
binlog-do-db=******
server-id=1
[mysql]
no-auto-rehash
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
replicate-do-db=*****
auto_increment_increment = 2
auto_increment_offset = 1
replicate-same-server-id = 0
slave-skip-errors=all
[mysqld]
slave-skip-errors=1062
skip-slave-start
query_cache_type=1
[mysqld]
innodb_lock_wait_timeout=120
slave_compressed_protocol=1
query_cache_size = 190M
The QC is inefficient when it is big; limit to about 50M.
slave-skip-errors=1062
This is a flavor of "sweeping bugs under the rug".
default-storage-engine=MyISAM
passé.
key_buffer = 500M
If you do stick with MyISAM, and this server is running just MySQL, then use 1000M.
server-id=1
Make sure each server has a different value.
But that is only configuration. If you have slow queries, let's see them and try to improve them.
what best config for my.cnf file i have big size sql
Total processors: 4
Processor #1
Vendor
GenuineIntel
Name
Intel(R) Core(TM) i7-3930K CPU # 3.20GHz
Speed
3200.058 MHz
Cache
12288 KB
Memory Information
Memory: 14243308k/15728640k available
There is no straight forward answer of this question as one configuration can be suitable for one but not for other..
If you are using innodb engine then You can start with below configuration initially and can optimize as per your requirement/problems-
default_storage_engine = InnoDB
innodb_file_per_table
lower_case_table_names = 1
wait_timeout = 120
innodb_buffer_pool_size = 10G
key_buffer_size = 20M
max_allowed_packet = 64M
max_connections = 100
query_cache_type = 1
query_cache_size = 20M
query_cache_limit = 2M
read_buffer_size = 2M
sort_buffer_size = 2M
join_buffer_size = 2M
tmp_table_size = 512M
max_heap_table_size = 512M
for the mysql optimization, I will suggest you please try with MySQL tuner script. You can try it with the following command
wget https://launchpad.net/mysql-tuning-primer/trunk/1.6-r1/+download/tuning-primer.sh
chmod 755 tuning-primer.sh
./tuning-primer.sh