-
-
Save rdeavila/8932883 to your computer and use it in GitHub Desktop.
Calcula as configurações de kernel shared memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# http://archives.postgresql.org/pgsql-admin/2010-05/msg00285.php | |
# Gera linhas de configuração que podem ser adicionadas ao sysctl | |
# com base no total de RAM do sistema. A saída | |
# permite até 50% da memória física para ser alocada como | |
# shared memory. | |
# No Linux, você pode usar desta forma (como root): | |
# | |
# ./shmsetup >> /etc/sysctl.conf | |
# sysctl -p | |
# Versões antigas do FreeBSD não suportam a interface sysconf | |
# usada aqui. A versão exata onde esta implementação funciona | |
# ainda não foi confirmada. | |
page_size=`getconf PAGE_SIZE` | |
phys_pages=`getconf _PHYS_PAGES` | |
if [ -z "$page_size" ]; then | |
echo Erro: Não foi possível determinar o page size | |
exit 1 | |
fi | |
if [ -z "$phys_pages" ]; then | |
echo Erro: Não foi possível determinar o número de memory pages | |
exit 2 | |
fi | |
shmall=`expr $phys_pages / 2` | |
shmmax=`expr $shmall \* $page_size` | |
echo \# Maximum shared segment size in bytes | |
echo kernel.shmmax = $shmmax | |
echo \# Maximum number of shared memory segments in pages | |
echo kernel.shmall = $shmall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment