📄 runtime.sgml
字号:
semaphores can be in a set, must be at least 17 for <productname>PostgreSQL</>. </para> <para> Various other settings related to <quote>semaphore undo</>, such as <varname>SEMMNU</> and <varname>SEMUME</>, are not of concern for <productname>PostgreSQL</>. </para> <variablelist> <varlistentry> <term><systemitem class="osname">BSD/OS</></term> <indexterm><primary>BSD/OS</><secondary>IPC configuration</></> <listitem> <formalpara> <title>Shared Memory</> <para> By default, only 4 MB of shared memory is supported. Keep in mind that shared memory is not pageable; it is locked in RAM. To increase the amount of shared memory supported by your system, add something like the following to your kernel configuration file:<programlisting>options "SHMALL=8192"options "SHMMAX=\(SHMALL*PAGE_SIZE\)"</programlisting> <varname>SHMALL</> is measured in 4KB pages, so a value of 1024 represents 4 MB of shared memory. Therefore the above increases the maximum shared memory area to 32 MB. For those running 4.3 or later, you will probably also need to increase <varname>KERNEL_VIRTUAL_MB</> above the default <literal>248</>. Once all changes have been made, recompile the kernel, and reboot. </para> </formalpara> <para> For those running 4.0 and earlier releases, use <command>bpatch</> to find the <varname>sysptsize</> value in the current kernel. This is computed dynamically at boot time.<screen>$ <userinput>bpatch -r sysptsize</><computeroutput>0x9 = 9</></screen> Next, add <varname>SYSPTSIZE</> as a hard-coded value in the kernel configuration file. Increase the value you found using <command>bpatch</>. Add 1 for every additional 4 MB of shared memory you desire.<programlisting>options "SYSPTSIZE=16"</programlisting> <varname>sysptsize</> cannot be changed by <command>sysctl</command>. </para> <formalpara> <title>Semaphores</> <para> You will probably want to increase the number of semaphores as well; the default system total of 60 will only allow about 50 <productname>PostgreSQL</productname> connections. Set the values you want in your kernel configuration file, e.g.:<programlisting>options "SEMMNI=40"options "SEMMNS=240"</programlisting> </para> </formalpara> </listitem> </varlistentry> <varlistentry> <term><systemitem class="osname">FreeBSD</></term> <indexterm><primary>FreeBSD</><secondary>IPC configuration</></> <listitem> <para> The default settings are only suitable for small installations (for example, default <varname>SHMMAX</varname> is 32 MB). Changes can be made via the <command>sysctl</command> or <command>loader</command> interfaces. The following parameters can be set using <command>sysctl</command>:<screen><prompt>$</prompt> <userinput>sysctl -w kern.ipc.shmall=32768</userinput><prompt>$</prompt> <userinput>sysctl -w kern.ipc.shmmax=134217728</userinput><prompt>$</prompt> <userinput>sysctl -w kern.ipc.semmap=256</userinput></screen> To have these settings persist over reboots, modify <filename>/etc/sysctl.conf</filename>. </para> <para> The remaining semaphore settings are read-only as far as <command>sysctl</command> is concerned, but can be changed before boot using the <command>loader</command> prompt:<screen><prompt>(loader)</prompt> <userinput>set kern.ipc.semmni=256</userinput><prompt>(loader)</prompt> <userinput>set kern.ipc.semmns=512</userinput><prompt>(loader)</prompt> <userinput>set kern.ipc.semmnu=256</userinput></screen> Similarly these can be saved between reboots in <filename>/boot/loader.conf</filename>. </para> <para> You might also want to configure your kernel to lock shared memory into RAM and prevent it from being paged out to swap. This can be accomplished using the <command>sysctl</command> setting <literal>kern.ipc.shm_use_phys</literal>. </para> <para> If running in FreeBSD jails by enabling <application>sysctl</>'s <literal>security.jail.sysvipc_allowed</>, <application>postmaster</>s running in different jails should be run by different operating system users. This improves security because it prevents non-root users from interfering with shared memory or semaphores in a different jail, and it allows the PostgreSQL IPC cleanup code to function properly. (In FreeBSD 6.0 and later the IPC cleanup code doesn't properly detect processes in other jails, preventing the running of postmasters on the same port in different jails.) </para> <para> <systemitem class="osname">FreeBSD</> versions before 4.0 work like <systemitem class="osname">NetBSD</> and <systemitem class="osname"> OpenBSD</> (see below). </para> </listitem> </varlistentry> <varlistentry> <term><systemitem class="osname">NetBSD</></term> <term><systemitem class="osname">OpenBSD</></term> <indexterm><primary>NetBSD</><secondary>IPC configuration</></> <indexterm><primary>OpenBSD</><secondary>IPC configuration</></> <listitem> <para> The options <varname>SYSVSHM</> and <varname>SYSVSEM</> need to be enabled when the kernel is compiled. (They are by default.) The maximum size of shared memory is determined by the option <varname>SHMMAXPGS</> (in pages). The following shows an example of how to set the various parameters (<systemitem class="osname">OpenBSD</> uses <literal>option</> instead):<programlisting>options SYSVSHMoptions SHMMAXPGS=4096options SHMSEG=256options SYSVSEMoptions SEMMNI=256options SEMMNS=512options SEMMNU=256options SEMMAP=256</programlisting> </para> <para> You might also want to configure your kernel to lock shared memory into RAM and prevent it from being paged out to swap. This can be accomplished using the <command>sysctl</command> setting <literal>kern.ipc.shm_use_phys</literal>. </para> </listitem> </varlistentry> <varlistentry> <term><systemitem class="osname">HP-UX</></term> <indexterm><primary>HP-UX</><secondary>IPC configuration</></> <listitem> <para> The default settings tend to suffice for normal installations. On <productname>HP-UX</> 10, the factory default for <varname>SEMMNS</> is 128, which might be too low for larger database sites. </para> <para> <acronym>IPC</> parameters can be set in the <application>System Administration Manager</> (<acronym>SAM</>) under <menuchoice><guimenu>Kernel Configuration</><guimenuitem>Configurable Parameters</></>. Hit <guibutton>Create A New Kernel</> when you're done. </para> </listitem> </varlistentry> <varlistentry> <term><systemitem class="osname">Linux</></term> <indexterm><primary>Linux</><secondary>IPC configuration</></> <listitem> <para> The default settings are only suitable for small installations (the default max segment size is 32 MB). However the remaining defaults are quite generously sized, and usually do not require changes. The max segment size can be changed via the <command>sysctl</command> interface. For example, to allow 128 MB, and explicitly set the maximum total shared memory size to 2097152 pages (the default):<screen><prompt>$</prompt> <userinput>sysctl -w kernel.shmmax=134217728</userinput><prompt>$</prompt> <userinput>sysctl -w kernel.shmall=2097152</userinput></screen> In addition these settings can be saved between reboots in <filename>/etc/sysctl.conf</filename>. </para> <para> Older distributions may not have the <command>sysctl</command> program, but equivalent changes can be made by manipulating the <filename>/proc</filename> file system:<screen><prompt>$</prompt> <userinput>echo 134217728 >/proc/sys/kernel/shmmax</userinput><prompt>$</prompt> <userinput>echo 2097152 >/proc/sys/kernel/shmall</userinput></screen> </para> </listitem> </varlistentry> <varlistentry> <term><systemitem class="osname">MacOS X</></term> <indexterm><primary>MacOS X</><secondary>IPC configuration</></> <listitem> <para> In OS X 10.2 and earlier, edit the file <filename>/System/Library/StartupItems/SystemTuning/SystemTuning</> and change the values in the following commands:<programlisting>sysctl -w kern.sysv.shmmaxsysctl -w kern.sysv.shmminsysctl -w kern.sysv.shmmnisysctl -w kern.sysv.shmsegsysctl -w kern.sysv.shmall</programlisting> In OS X 10.3 and later, these commands have been moved to <filename>/etc/rc</> and must be edited there. Note that <filename>/etc/rc</> is usually overwritten by OS X updates (such as 10.3.6 to 10.3.7) so you should expect to have to redo your editing after each update. In all versions, you'll need to reboot to make changes take effect. </para> <para> In OS X 10.3.9 and later, the file <filename>/etc/sysctl.conf</> allows shared memory setting to be saved across operating system upgrades, and is the recommended method for setting these parameters. When using this file, all five shared memory values must be set or the changes will be ignored. </para> <para> <varname>SHMALL</> is measured in 4KB pages on this platform, and recent releases of OS X reject attempts to set <varname>SHMALL</> and <varname>SHMMAX</> to a value that isn't an exact multiple of 4096. </para> </listitem> </varlistentry> <varlistentry> <term><systemitem class="osname">SCO OpenServer</></term> <indexterm><primary>SCO OpenServer</><secondary>IPC configuration</></> <listitem> <para> In the default configuration, only 512 kB of shared memory per segment is allowed. To increase the setting, first change to the directory <filename>/etc/conf/cf.d</>. To display the current value of <varname>SHMMAX</>, run<programlisting>./configure -y SHMMAX</programlisting> To set a new value for <varname>SHMMAX</>, run<programlisting>./configure SHMMAX=<replaceable>value</></programlisting> where <replaceable>value</> is the new value you want to use (in bytes). After setting <varname>SHMMAX</>, rebuild the kernel:<programlisting>./link_unix</programlisting> and reboot. </para> </listitem> </varlistentry> <varlistentry> <term><systemitem class="osname">AIX</></term> <indexterm><primary>AIX</><secondary>IPC configuration</></> <listitem> <para> At least as of version 5.1, it should not be necessary to do any special configuration for such parameters as <varname>SHMMAX</varname>, as it appears this is configured to allow all memory to be used as shared memory. That is the sort of configuration commonly used for other databases such as <application>DB/2</application>.</para> <para> It may, however, be necessary to modify the global <command>ulimit</command> information in <filename>/etc/security/limits</filename>, as the default hard limits for file sizes (<varname>fsize</varname>) and numbers of files (<varname>nofiles</varname>) may be too low. </para> </listitem> </varlistentry> <varlistentry> <term><systemitem class="osname">Solaris</></term> <indexterm><primary>Solaris</><secondary>IPC configuration</></> <listitem> <para> At least in version 2.6, the default maximum size of a shared memory segments is too low for <productname>PostgreSQL</>. The relevant settings can be changed in <filename>/etc/system</>, for example:<programlisting>set shmsys:shminfo_shmmax=0x2000000set shmsys:shminfo_shmmin=1set shmsys:shminfo_shmmni=256set shmsys:shminfo_shmseg=256set semsys:seminfo_semmap=256set semsys:seminfo_semmni=512set semsys:seminfo_semmns=512
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -