best mysql config for my vps - mysql

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

Related

Out of memory: Kill process mysqld on cent os 7

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.

How to configure mysql configuration for Ubuntu (RAM: 4GB CPU: 2VCPU SSD Disk: 80GB)

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.

performance tuning of my sql in 12 GB ram with 21 Intel(R) Xeon(R) CPU E5-2620 0 # 2.00GHz

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.

mysqld intermittent restarts under load

To start with, I'm relatively new to web development.
Under reasonable load (500-700 Q/s) the server is restarting frequently (sometimes every hour), and I get the follow in my syslog each time it happens. I don't get any output to mysql.err or mysql/error.log
This is my first real mysql setup, so I'm sure there is lots that could be improved, but I'm surprised that the server is actually going down so often. The machine has 4GB of ram. Thanks for any suggestions or help!
Ubuntu 10.04, mysql is from the lucid packages.
Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (x86_64) using readline 6.1
Oct 10 01:45:33 host init: mysql main process (1199) terminated with status 1
Oct 10 01:45:33 host init: mysql main process ended, respawning
Oct 10 01:45:42 host /etc/mysql/debian-start[1644]: Upgrading MySQL tables if necessary.
Oct 10 01:45:42 host /etc/mysql/debian-start[1648]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
Oct 10 01:45:42 host /etc/mysql/debian-start[1648]: Looking for 'mysql' as: /usr/bin/mysql
Oct 10 01:45:42 host /etc/mysql/debian-start[1648]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Oct 10 01:45:42 host /etc/mysql/debian-start[1648]: This installation of MySQL is already upgraded to 5.1.41, use --force if you still need to run mysql_upgrade
Oct 10 01:45:42 host /etc/mysql/debian-start[1656]: Checking for insecure root accounts.
Oct 10 01:45:43 host /etc/mysql/debian-start[1672]: Triggering myisam-recover for all MyISAM tables
Here's my my.cnf:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld]
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
skip-external-locking
bind-address = host
back_log = 50
max_connections = 100
max_connect_errors = 10
table_open_cache = 2048
max_allowed_packet = 16M
binlog_cache_size = 1M
max_heap_table_size = 64M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency = 8
query_cache_size = 64M
query_cache_limit = 2M
ft_min_word_len = 4
default-storage-engine = innodb
default-character-set = utf8
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 32M
log-bin=trent-bin
binlog_format=mixed
slow_query_log
long_query_time = 2
server-id = 1
key_buffer_size = 32M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 2800M
innodb_data_file_path = ibdata1:100M:autoextend
innodb_file_per_table
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 4M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_flush_method=O_DIRECT
innodb_lock_wait_timeout = 50
ssl-ca=/etc/mysql/cacert.pem
ssl-cert=/etc/mysql/server-cert.pem
ssl-key=/etc/mysql/server-key.pem
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
I have seen mysql behave this way a few times, there are many potential causes.. : to investigatem I would check
1) are there any custom functions that you have written that might be memory leaks? I once saw a median function, custom written on mysql 5, lead to restarts if it was run by two simultaneous queries...
2) if you optimize the tables, does this reduce the restart frequency?
3) are therea ny corrupt tables in the db ?

Configuring MySQL for InnoDB

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/