From b4403fda43093f47b1908165774877b04ba3ef6c Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Tue, 12 Nov 2013 17:35:29 -0500 Subject: [PATCH] enterprise: Generate a 40-postgresql.conf sysctl file (imported from commit ec64d283f88d1b2f4b13e3405d39cfbe8400adc7) --- puppet/zulip/manifests/enterprise.pp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/puppet/zulip/manifests/enterprise.pp b/puppet/zulip/manifests/enterprise.pp index 843db855ba..c30b2cc89b 100644 --- a/puppet/zulip/manifests/enterprise.pp +++ b/puppet/zulip/manifests/enterprise.pp @@ -39,8 +39,25 @@ class zulip::enterprise { source => "puppet:///modules/zulip/postgresql/postgresql.conf.template" } + # We can't use the built-in $memorysize fact because it's a string with human-readable units $total_memory = regsubst(file('/proc/meminfo'), '^.*MemTotal:\s*(\d+) kB.*$', '\1', 'M') * 1024 $half_memory = $total_memory / 2 + $half_memory_pages = $half_memory / 4096 + + file {'/etc/sysctl.d/40-postgresql.conf': + ensure => file, + owner => 'root', + group => 'root', + mode => 644, + content => +"kernel.shmall = $half_memory_pages +kernel.shmmax = $half_memory + +# These are the defaults on newer kernels +vm.dirty_ratio = 10 +vm.dirty_background_ratio = 5 +" + } exec { 'pgtune': require => Package[pgtune], @@ -52,6 +69,6 @@ class zulip::enterprise { exec { 'pg_ctlcluster 9.1 main restart': refreshonly => true, - subscribe => Exec['pgtune'] + subscribe => [ Exec['pgtune'], File['/etc/sysctl.d/40-postgresql.conf'] ] } }