PostgreSQLスキルアップノート(自己啓発のための個人サイト)

PostgreSQL用カーネル関連の設定(Linux)「リソースの制限」


【一覧に戻る】


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
■■■■ PostgreSQL スキルアップノート
■■■■
■◆■■ PostgreSQL用カーネル関連の設定(Linux)「リソースの制限」
■■■■
■■■■
■■■■ 2013/01/20
■■■■ 使用環境: (CentOS6.2)
                                                                   (C) 2013 ohdb
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

【マニュアル】

カーネル関連の設定→●[マニュアル]

【参考記事】

Let's Postgres PostgreSQLの導入と初期設定→●[記事]
誰でも簡単!PostgreSQLのインストールと初期設定(インストール編)→●[記事]



マニュアルに記載されているカーネルリソース関連と本書対象

・共有メモリ/セマフォ    
・リソースの制限                   ★←本ページ対象
・ Linuxのメモリオーバーコミット


設定する場所  /etc/security/limits.conf   (シェル制限)




■1■  シェル制限 /etc/security/limits.conf
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

PostgreSQLのマニュアルでは以下の項目が記載されている程度。
・ユーザごとのプロセス数の制限
・プロセスごとのオープンファイルの数
・プロセスごとの利用可能なメモリの量

具体的な値の設定は自分で判断しなければいけない。

そこで
誰でも簡単!PostgreSQLのインストールと初期設定(インストール編)→●[記事]

を参考にして値を設定する。
なお、上の記事のカーネル関連はOracleを構築する際と値がよく似ている。



【□】 cat /etc/security/limits.conf

       デフォルトの内容は■2■参考の項を参照



【□】 vi  /etc/security/limits.conf

以下を設定する。

#domain          type    item      value
postgres         soft    nproc      2047
postgres         hard    nproc     16384
postgres         soft    nofile     1024
postgres         hard    nofile    65536
postgres         soft    stack     10240


soft(soft limit ソフト制限)・・実際に有効な制限
hard(hard limit ハード制限)・・設定の上限 soft limitはここまで設定が可能

itemについては次項の説明を参照。


【補足】stackについて

stackについてはpostgreSQLのマニュアルには記述がなかった。
が、上記記事の中で設定していたため、一応設定をするようにする。(要検討)




■2■ 参考 デフォルトのlimits.con)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

例)以下はデフォルトの内容 (一部整形・注記)

# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#            
#
#Where:
# can be:
#        - an user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
# can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
# can be one of the following:
#        - core         - limits the core file size (KB)
#        - data         - max data size (KB)
#        - fsize        - maximum filesize (KB)  
#        - memlock      - max locked-in-memory address space (KB)
#        - nofile   ★  - max number of open files
#        - rss          - max resident set size (KB)
#        - stack    ☆  - max stack size (KB)
#        - cpu          - max CPU time (MIN)
#        - nproc    ★  - max number of processes
#        - as           - address space limit (KB)
#        - maxlogins    - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority     - the priority to run user process with
#        - locks        - max number of file locks the user can hold
#        - sigpending   - max number of pending signals
#        - msgqueue     - max memory used by POSIX message queues (bytes)
#        - nice         - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio       - max realtime priority
#
#                 
#

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4

# End of file
-------------------------------------------------------------------








以上 
inserted by FC2 system