Allow to override the max connections for MySQL

In large deployment when we want to launch more than 100 vms at the same time
we reach the maximum of connections in haproxy and MySQL.
This patch increase the default value from 1000 to 4096 and allow to override
this value with Hiera.

Change-Id: I1f0d02c3125ce27266ac1198e32e39b1a34ce670
This commit is contained in:
Dimitri Savineau 2015-06-11 15:54:44 -04:00
parent b74f306ba1
commit 1b6bd9247f
5 changed files with 28 additions and 5 deletions

View File

@ -173,6 +173,10 @@
# (optional) An integer that specifies the open_files_limit for MySQL
# Defaults to 65535
#
# [*max_connections*]
# (optional) An integer that specifies the max_connections for MySQL
# Defaults to 4096
#
# [*mysql_systemd_override_settings*]
# (optional) An hash of setting to override for MariaDB unit file.
# Defaults to {}
@ -222,6 +226,7 @@ class cloud::database::sql::mysql (
$galera_clustercheck_dbpassword = 'clustercheckpassword',
$galera_clustercheck_ipaddress = '127.0.0.1',
$open_files_limit = 65535,
$max_connections = 4096,
$mysql_systemd_override_settings = {},
$firewall_settings = {},
) {

View File

@ -489,6 +489,10 @@
# *_db_idle_timeout for all services to be a little less
# than this timeout.
#
# [*galera_connections*]
# (optional) An integer that specifies the maxconn for MySQL
# Defaults to '4096'
#
# [*api_timeout*]
# (optional) Timeout for API services connections
# Defaults to '90m'.
@ -611,6 +615,7 @@ class cloud::loadbalancer(
$sensu_api_port = 4568,
$redis_port = 6379,
$galera_timeout = '90m',
$galera_connections = '4096',
$api_timeout = '90m',
$vip_public_ip = ['127.0.0.1'],
$vip_internal_ip = false,
@ -978,7 +983,7 @@ class cloud::loadbalancer(
ipaddress => $galera_ip,
ports => 3306,
options => {
'maxconn' => '1000',
'maxconn' => $galera_connections,
'mode' => 'tcp',
'balance' => 'roundrobin',
'option' => ['tcpka', 'tcplog', 'httpchk'], #httpchk mandatory expect 200 on port 9000
@ -1001,7 +1006,7 @@ class cloud::loadbalancer(
ipaddress => $galera_ip,
ports => 3307,
options => {
'maxconn' => '1000',
'maxconn' => $galera_connections,
'mode' => 'tcp',
'balance' => 'roundrobin',
'option' => ['tcpka', 'tcplog', 'httpchk'], #httpchk mandatory expect 200 on port 9000

View File

@ -122,6 +122,18 @@ describe 'cloud::database::sql::mysql' do
it { is_expected.to contain_file('/etc/my.cnf').with_content(/open_files_limit = 666/) }
end
context 'configure max_connections' do
before :each do
facts.merge!( :hostname => 'os-ci-test1',
:osfamily => 'RedHat',
:operatingsystemmajrelease => 7 )
end
before :each do
params.merge!(:max_connections => 2048)
end
it { is_expected.to contain_file('/etc/my.cnf').with_content(/max_connections = 2048/) }
end
context 'configure databases on the galera master server' do
before :each do

View File

@ -73,6 +73,7 @@ describe 'cloud::loadbalancer' do
:vip_public_ip => '10.0.0.1',
:galera_ip => '10.0.0.2',
:galera_slave => false,
:galera_connections => '4096',
:horizon_ssl => false,
:horizon_ssl_port => false,
:ks_ceilometer_public_port => '8777',
@ -254,7 +255,7 @@ describe 'cloud::loadbalancer' do
:ipaddress => params[:galera_ip],
:ports => '3306',
:options => {
'maxconn' => '1000',
'maxconn' => params[:galera_connections],
'mode' => 'tcp',
'balance' => 'roundrobin',
'option' => ['tcpka','tcplog','httpchk'],
@ -276,7 +277,7 @@ describe 'cloud::loadbalancer' do
:ipaddress => params[:galera_ip],
:ports => '3307',
:options => {
'maxconn' => '1000',
'maxconn' => params[:galera_connections],
'mode' => 'tcp',
'balance' => 'roundrobin',
'option' => ['tcpka','tcplog','httpchk'],

View File

@ -7,7 +7,7 @@ default_storage_engine = innodb
collation_server = utf8_general_ci
init_connect = 'SET NAMES utf8'
character_set_server = utf8
max_connections = 1000
max_connections = <%= @max_connections %>
skip_name_resolve = 1
connect_timeout = 5
wait_timeout = 600