#navi(../)

* makewhatis,updatedbが起動しないようにする [#l3045ae1]

マシンを立ち上げるといきなりCPU使用率が高く、topコマンドなどで見てみるとmakewhatisが動作しておりCPUを占有している状態になった場合の対処方法を記します。~
本資料はCentOSにてmakewhatisでCPU使用率が高い状態になったので以下の手順で停止しました。

#contents

 top - 16:27:11 up  1:21,  1 user,  load average: 1.65, 1.35, 1.33
 Tasks:  94 total,   2 running,  92 sleeping,   0 stopped,   0 zombie
 Cpu(s):  5.2%us, 11.7%sy,  3.4%ni, 64.4%id,  8.6%wa,  0.7%hi,  5.9%si,  0.0%st
 Mem:    251636k total,   246740k used,     4896k free,    20100k buffers
 Swap:  1048568k total,      100k used,  1048468k free,   123100k cached
 
   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
  3901 root      39  19 64224 1544 1000 S  9.9  0.6   0:56.08 makewhatis         
   125 root      10  -5     0    0    0 S  2.0  0.0   0:00.33 kswapd0            
     1 root      18   0 10372  696  584 S  0.0  0.3   0:01.83 init               
 <snip>


#htmlinsertpcsp(linux_ads_top.html,linux-sp.html)

* makewhatisとは? [#o4fe1123]
makewhatisはwhatisデータベースを生成するために動作します。~
以下、man whatisをした時の抜粋です。
 WHATIS(1)                             Manual pager utils                             WHATIS(1)
 
 名前
        whatis - マニュアルページの要約を表示する
 
 書式
        [-dhV] [-r|-w] [-m system[,...]] [-M path] name ...
 
 説明
        それぞれのマニュアルページには、先頭に短い要約文が書かれている。
        whatis はマニュアルページの名前を検索し、name
        にマッチしたすべてのマニュアルから、この要約文を取り出して表示する。
 
 <snip>

* makewhatisはどこで起動されているのか? [#ob587a0d]
makewhatis.cronがmakewhatisを起動していました。

以下、/etc/crontabの設定です。
 [root@centos ~]# cat /etc/crontab 
 SHELL=/bin/bash
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 MAILTO=root
 HOME=/
 
 # run-parts
 01 * * * * root run-parts /etc/cron.hourly
 02 4 * * * root run-parts /etc/cron.daily
 22 4 * * 0 root run-parts /etc/cron.weekly
 42 4 1 * * root run-parts /etc/cron.monthly

makewhatis.cronは以下の2つが存在していました。

 [root@centos ~]# cat /etc/cron.weekly/makewhatis.cron 
 #!/bin/bash
 
 LOCKFILE=/var/lock/makewhatis.lock
 
 # the lockfile is not meant to be perfect, it's just in case the
 # two makewhatis cron scripts get run close to each other to keep
 # them from stepping on each other's toes.  The worst that will
 # happen is that they will temporarily corrupt the database...
 [ -f $LOCKFILE ] && exit 0
 trap "{ rm -f $LOCKFILE; exit 255; }" EXIT
 touch $LOCKFILE
 makewhatis -w
 exit 0

 [root@centos ~]# cat /etc/cron.daily/makewhatis.cron 
 #!/bin/bash
 
 LOCKFILE=/var/lock/makewhatis.lock
 
 # the lockfile is not meant to be perfect, it's just in case the
 # two makewhatis cron scripts get run close to each other to keep
 # them from stepping on each other's toes.  The worst that will
 # happen is that they will temporarily corrupt the database...
 [ -f $LOCKFILE ] && exit 0
 trap "{ rm -f $LOCKFILE ; exit 255; }" EXIT
 touch $LOCKFILE
 makewhatis -u -w
 exit 0

* makewhatis.cronを起動しないようにする [#w1609f33]
対処方法として、以下のcronファイルのパーミッションを644に変更しました。

 chmod 644 /etc/cron.daily/makewhatis.cron
 chmod 644 /etc/cron.weekly/makewhatis.cron


* mlocate.cronも停止 [#jd80c639]
locateコマンド用のデータベース更新を行うmlocate.cronも停止させました。~
(updatedbコマンドによりlocateコマンド用のデータベースを更新する)

locateコマンドのためにupdatedbコマンドを実行している
 [root@centos ~]# cat /etc/cron.daily/mlocate.cron 
 #!/bin/sh
 nodevs=$(< /proc/filesystems awk '$1 == "nodev" { print $2 }')
 renice +19 -p $$ >/dev/null 2>&1
 /usr/bin/updatedb -f "$nodevs"

makewhatis.cronと同様にパーミッションを644にして停止させました。
 chmod 644 /etc/cron.daily/mlocate.cron

* まとめ [#t61ed21f]
makewhatis, updatedbが起動し、CPU使用率が上がったままになったのでmakewhatis, updatedbがcronで起動されないようにした。~
何らかの性能測定を行うサーバだったり、makewhatis, updatedbが不要なサーバであれば止めも良いのではないでしょうか?

#br
#htmlinsertpcsp(linux_ads_btm.html,linux-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS