開発メモ

開発関係のメモをいろいろと。たぶん。

CentOSの不要なサービスを止める

VirtualBoxにインストールしたCentOSでいろいろ実験するシリーズ。

不要なサービスをばっさり停止。無駄なサービスはCentOS 5みたいに多くないし、そんなに気にする必要は無いかも?

作業前

作業開始前の状況はこんな感じ。

サービスの一覧

以下のコマンドで、サービスの一覧を出力。

# chkconfig --list

こんな結果になった。気にする必要があるのはランレベル3でONになってるサービス。

[root@localhost ~]# chkconfig --list
auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
blk-availability        0:off   1:on    2:on    3:on    4:on    5:on    6:off
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
ip6tables       0:off   1:off   2:on    3:on    4:on    5:on    6:off
iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off
iscsi           0:off   1:off   2:off   3:on    4:on    5:on    6:off
iscsid          0:off   1:off   2:off   3:on    4:on    5:on    6:off
lvm2-monitor    0:off   1:on    2:on    3:on    4:on    5:on    6:off
mdmonitor       0:off   1:off   2:on    3:on    4:on    5:on    6:off
multipathd      0:off   1:off   2:off   3:off   4:off   5:off   6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off
rdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:off
restorecond     0:off   1:off   2:off   3:off   4:off   5:off   6:off
rsyslog         0:off   1:off   2:on    3:on    4:on    5:on    6:off
saslauthd       0:off   1:off   2:off   3:off   4:off   5:off   6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
udev-post       0:off   1:on    2:on    3:on    4:on    5:on    6:off

メモリの使用状況

何もしてない状況で、メモリの使用状況はこんな感じ。

[root@localhost ~]# free
             total       used       free     shared    buffers     cached
Mem:        510984      91776     419208          0       6344      36652
-/+ buffers/cache:      48780     462204
Swap:      1048568          0    1048568

サービスの内容の調べ方

一番手っ取り早いのはググることなんだけど、もっとまじめに調べたいと思った場合、どうすればいいのか? 例として「saslauthd」を調査。

まず、yum providesを使ってサービスが含まれてるパッケージを検索。

# yum provides "*/saslauthd"

必要に応じてDBが更新され、「saslauthd」が含まれるパッケージを調べてくれる。出力された結果を眺めてみると、インストール済みになってるのがこれ。

cyrus-sasl-2.1.23-13.el6_3.1.i686 : The Cyrus SASL library
Repo        : installed
Matched from:
Filename    : /etc/rc.d/init.d/saslauthd
Filename    : /usr/sbin/saslauthd
Filename    : /etc/sysconfig/saslauthd

これでパッケージ名がわかるので、yum infoでさらに詳細を調査。

# yum info cyrus-sasl

結果はこんな感じ。

Installed Packages
Name        : cyrus-sasl
Arch        : i686
Version     : 2.1.23
Release     : 13.el6_3.1
Size        : 125 k
Repo        : installed
From repo   : anaconda-CentOS-201303020136.i386
Summary     : The Cyrus SASL library
URL         : http://asg.web.cmu.edu/sasl/sasl-library.html
License     : BSD
Description : The cyrus-sasl package contains the Cyrus implementation of SASL.
            : SASL is the Simple Authentication and Security Layer, a method for
            : adding authentication support to connection-based protocols.

これで詳細がわかったので・・・ 結局、必要かどうかはよくわからないなorz 素直にググるのが正解か。

不要なサービスを停止

サービスを停止

以下のサービスを停止してみた。

  • blk-availability
  • netfs
  • postfix
  • iscsi
  • iscsid
  • mdmonitor
  • udev-post

サービスの停止はこんな感じで。

# chkconfig blk-availability off

作業が終わったら再起動。

メモリの使用状況

作業後のメモリの使用状況はこんな感じ。

[root@localhost ~]# free
             total       used       free     shared    buffers     cached
Mem:        510984      83940     427044          0       5624      31976
-/+ buffers/cache:      46340     464644
Swap:      1048568          0    1048568

使用メモリが8MBほど減少・・・ そんなに、気にするほどの差でもなかったかorz

不要なコンソールも停止

ついでに、不要な仮想コンソールも停止しておく。「/etc/sysconfig/init」を以下のように編集。

・変更前

ACTIVE_CONSOLES=/dev/tty[1-6]

・変更後

ACTIVE_CONSOLES=/dev/tty[1-1]

これで、使用メモリが3MBぐらい減ったか。

情報元

CentOSをサーバーとして活用するための基本的な設定 - さくらインターネット創業日記
http://tanaka.sakura.ad.jp/archives/001065.html

PostfixSMTP認証で利用するCyrus SASLライブラリについて | Oxy notes
http://oxynotes.com/?p=4428

CentOS 6 - 初期設定 - サービス設定 : Server World
http://www.server-world.info/query?os=CentOS_6&p=initial_conf&f=4

必要/不要デーモン(Centos)
http://ry.tl/daemon.html

cloudpackブログ - cloudpack(クラウドパック)Amazon EC2などクラウドの導入設計、運用・保守サービス: CentOS6で仮想コンソール(/dev/ttyN)を1個にする
http://blog.cloudpack.jp/2011/08/server-news-centos6-virtual-console.html