Skip to content

Instantly share code, notes, and snippets.

@thattommyhall
Created February 10, 2012 13:20
Show Gist options
  • Select an option

  • Save thattommyhall/1789631 to your computer and use it in GitHub Desktop.

Select an option

Save thattommyhall/1789631 to your computer and use it in GitHub Desktop.
mycnf generator
#!/bin/bash
CORES="`cat /proc/cpuinfo | grep processor | wc -l`"
CORES16="`echo "$CORES * 16" | bc`"
STRINGRAM="`cat /proc/meminfo | head -n 1 | awk '{print $2}'` / 1024"
RAM=`echo $STRINGRAM | bc`
RAM64="`echo "$RAM / 64" | bc`"
if [ "$RAM64" -lt "128" ]; then
RAM64="128M";
else
RAM64=`echo "$RAM64"M`
fi
RAM16="`echo "$RAM / 16" | bc`M"
RAM3="`echo "$RAM / 3" | bc`M"
echo "
# Log slow queries
long_query_time=1
log-slow-queries=/var/log/log-slow-queries.log
#Performance tweeks
query_cache_size = $RAM3
key_buffer_size = $RAM64
tmp_table_size = 6G
max_heap_table_size = $RAM3
join_buffer_size = $RAM64
bulk_insert_buffer_size = $RAM64
myisam_sort_buffer_size = 1G
innodb_buffer_pool_size = $RAM3
innodb_flush_method=O_DIRECT
innodb_log_file_size = 1G
innodb_log_files_in_group = 2
myisam_sort_buffer_size = 1G
innodb_data_home_dir = /var/lib/mysql
innodb_file_per_table
innodb_table_locks = 0
innodb_open_files = 6000
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment