公開日:2009/4/1 0:00:00

CentOS 5

CentOS 5 最小構成化

普通にインストールしていても、不要なパッケージが含まれていたりするので、そういうモノを削除する。
最も、ハードウェアによって状況が異なるのでそこはそこで調整する事。

まずは、リモートからputtyを使ってrootでログイン。

login as: root
root@172.16.2.70's password: (表示されないけれどパスワード)
Last login: Sat Jul 12 13:41:16 2008
[root@fivestar-dom0 ~]#

パッケージ整理

不要と思われるパッケージを削除します。

[root@sixwish ~]# rpm -ev anthy kasumi scim-anthy \
 dhcdbd dhclient dhcpv6_client \
 wvdial isdn4k-utils rp-pppoe irda-utils NetworkManager \
 bluez-gnome bluez-libs bluez-utils \
 ipsec-tools wpa_supplicant yp-tools ypbind firstboot-tui \
 system-config-network-tui system-config-securitylevel-tui \
 nscd nss_ldap dos2unix
[root@sixwish ~]#

上記コマンドで、まとめて不要なパッケージを削除します。

消したのは、DHCPのクライアントとか、無線関係、Bluetooh関係、ypモジュール、system-config関係と初回ブート時のスクリプト、IMEなどです。
それ以外にも消して構わないものもあるのですが、個人的に使っているものなので、残してあります。

[root@sixwish ~]# chkconfig --list
acpid           0:off   1:off   2:off   3:on    4:on    5:on    6:off
anacron         0:off   1:off   2:on    3:on    4:on    5:on    6:off
apmd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
autofs          0:off   1:off   2:off   3:on    4:on    5:on    6:off
avahi-daemon    0:off   1:off   2:off   3:on    4:on    5:on    6:off
avahi-dnsconfd  0:off   1:off   2:off   3:off   4:off   5:off   6:off
conman          0:off   1:off   2:off   3:off   4:off   5:off   6:off
cpuspeed        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
cups            0:off   1:off   2:on    3:on    4:on    5:on    6:off
gpm             0:off   1:off   2:on    3:on    4:on    5:on    6:off
haldaemon       0:off   1:off   2:off   3:on    4:on    5:on    6:off
ibmasm          0:off   1:off   2:off   3:off   4:off   5:off   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
irqbalance      0:off   1:off   2:on    3:on    4:on    5:on    6:off
kudzu           0:off   1:off   2:off   3:on    4:on    5:on    6:off
mcstrans        0:off   1:off   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
mdmpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
messagebus      0:off   1:off   2:off   3:on    4:on    5:on    6:off
microcode_ctl   0:off   1:off   2:on    3:on    4:on    5:on    6:off
netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off
netplugd        0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off
nfslock         0:off   1:off   2:off   3:on    4:on    5:on    6:off
oddjobd         0:off   1:off   2:off   3:off   4:off   5:off   6:off
pcscd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
portmap         0:off   1:off   2:off   3:on    4:on    5:on    6:off
psacct          0:off   1:off   2:off   3:off   4:off   5:off   6:off
rdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:off
readahead_early 0:off   1:off   2:on    3:on    4:on    5:on    6:off
readahead_later 0:off   1:off   2:off   3:off   4:off   5:on    6:off
restorecond     0:off   1:off   2:on    3:on    4:on    5:on    6:off
rpcgssd         0:off   1:off   2:off   3:on    4:on    5:on    6:off
rpcidmapd       0:off   1:off   2:off   3:on    4:on    5:on    6:off
rpcsvcgssd      0:off   1:off   2:off   3:off   4:off   5:off   6:off
saslauthd       0:off   1:off   2:off   3:off   4:off   5:off   6:off
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
smartd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
syslog          0:off   1:off   2:on    3:on    4:on    5:on    6:off
xend            0:off   1:off   2:on    3:on    4:on    5:on    6:off
xendomains      0:off   1:off   2:off   3:on    4:on    5:on    6:off
xfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off
yum-updatesd    0:off   1:off   2:off   3:on    4:on    5:on    6:off
[root@sixwish ~]# chkconfig apmd off
[root@sixwish ~]# chkconfig cups off
[root@sixwish ~]# chkconfig gpm off
[root@sixwish ~]# chkconfig mdmonitor off
[root@sixwish ~]# chkconfig netfs off
[root@sixwish ~]# chkconfig rdisc off
[root@sixwish ~]# chkconfig rpcgssd off
[root@sixwish ~]# chkconfig rpcidmapd off
[root@sixwish ~]# chkconfig rpcsvcgssd off
[root@sixwish ~]# chkconfig yum-updatesd off
[root@sixwish ~]# chkconfig --list
acpid           0:off   1:off   2:off   3:on    4:on    5:on    6:off
anacron         0:off   1:off   2:on    3:on    4:on    5:on    6:off
apmd            0:off   1:off   2:off   3:off   4:off   5:off   6:off
atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
autofs          0:off   1:off   2:off   3:on    4:on    5:on    6:off
avahi-daemon    0:off   1:off   2:off   3:on    4:on    5:on    6:off
avahi-dnsconfd  0:off   1:off   2:off   3:off   4:off   5:off   6:off
conman          0:off   1:off   2:off   3:off   4:off   5:off   6:off
cpuspeed        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
cups            0:off   1:off   2:off   3:off   4:off   5:off   6:off
gpm             0:off   1:off   2:off   3:off   4:off   5:off   6:off
haldaemon       0:off   1:off   2:off   3:on    4:on    5:on    6:off
ibmasm          0:off   1:off   2:off   3:off   4:off   5:off   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
irqbalance      0:off   1:off   2:on    3:on    4:on    5:on    6:off
kudzu           0:off   1:off   2:off   3:on    4:on    5:on    6:off
mcstrans        0:off   1:off   2:on    3:on    4:on    5:on    6:off
mdmonitor       0:off   1:off   2:off   3:off   4:off   5:off   6:off
mdmpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
messagebus      0:off   1:off   2:off   3:on    4:on    5:on    6:off
microcode_ctl   0:off   1:off   2:on    3:on    4:on    5:on    6:off
netfs           0:off   1:off   2:off   3:off   4:off   5:off   6:off
netplugd        0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off
nfslock         0:off   1:off   2:off   3:on    4:on    5:on    6:off
oddjobd         0:off   1:off   2:off   3:off   4:off   5:off   6:off
pcscd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
portmap         0:off   1:off   2:off   3:on    4:on    5:on    6:off
psacct          0:off   1:off   2:off   3:off   4:off   5:off   6:off
rdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:off
readahead_early 0:off   1:off   2:on    3:on    4:on    5:on    6:off
readahead_later 0:off   1:off   2:off   3:off   4:off   5:on    6:off
restorecond     0:off   1:off   2:on    3:on    4:on    5:on    6:off
rpcgssd         0:off   1:off   2:off   3:off   4:off   5:off   6:off
rpcidmapd       0:off   1:off   2:off   3:off   4:off   5:off   6:off
rpcsvcgssd      0:off   1:off   2:off   3:off   4:off   5:off   6:off
saslauthd       0:off   1:off   2:off   3:off   4:off   5:off   6:off
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
smartd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
syslog          0:off   1:off   2:on    3:on    4:on    5:on    6:off
xend            0:off   1:off   2:on    3:on    4:on    5:on    6:off
xendomains      0:off   1:off   2:off   3:on    4:on    5:on    6:off
xfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off
yum-updatesd    0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@sixwish ~]#

さて、上からなにを止めたかというと……

apmd
電源管理関係。APM BIOSが載っていないマザーなので切っても問題ないと思われ。
cups
印刷関係。プリンタとは縁遠い存在なので切断。
gpm
マウスは繋がっているけれど、使っていないので止める。
mdmonitor
ソフトウェアRAID の状態監視サービス
netfs、netfs
UNIX系OSでよく使われているNFS(network file system)サーバーを関係。
rdisc
ルートディスカバリー。ルート検知用。ちょくちょく変わるわけでも無いので止める。
rpcgssd、rpcidmapd、rpcsvcgssd
nfsを使うときにRPCでどうこうするためのものらしい。
yum-updatesd
勝手にアップデートされるのも困りものの場合があるので止めておく。

という感じ。

アップデート

インストール直後ですが、特に設定することもないので、初回アップデートをかけます。
それなりにセキュリティアップデートなども含まれているはずなので、初回インストール後には必ず実行することをお奨め。
運用に入ってからは、試験してから本番もアップデートするほうがいいです。パッケージングに失敗して、confが飛ぶというバグが含まれていたこともありますので……

### yumとは

Linux版のWindowsUpdateみたいなモノ。とか書くと怒られそうですが、そんなような物だと思っておけば問題は少ないのかも。

正確には、rpm系ディストリビューションで採用されているパッケージ管理ツールの1つです。親戚関係にaptなどがあります。

[root@sixwish ~]# yum update
Loading "installonlyn" plugin
Setting up Update Process
Setting up repositories

*中略*

Total download size: XX M
Is this ok [y/N]: y
Downloading Packages:

*中略*

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) <centos-5-key@centos.org>" from http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
Is this ok [y/N]: y
*中略*

Complete!
[root@sixwish ~]# 

ntpd

インストール

yumを使用して、パッケージを取得、インストール。

[root@sixwish ~]# yum -y install ntp
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
  *中略*

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 ntp                     i386       4.2.2p1-5.el5    base              1.3 M

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 1.3 M
Downloading Packages:
(1/1): ntp-4.2.2p1-5.el5. 100% |=========================| 1.3 MB    xx:xx
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: ntp                          ################### [1/1]

Installed: ntp.i386 0:4.2.2p1-5.el5
Complete!
[root@sixwish ~]#

設定

ntpは、GPSや原子時計を使って時刻を正確に刻んでいるntpサーバー(Stratum1)などから、ネットワーク経由で時刻情報を得て自分の時間を合わせるという仕組みを持っています。
よって、設定ではこの上位ntpのサーバーを指定したりします。

[root@sixwish ~]# cp /etc/ntp.conf /etc/ntp.conf.org
[root@sixwish ~]# vi /etc/ntp.conf
*** /etc/ntp.conf.org   YYYY-mm-dd --:--:--.000000000 +0900
--- /etc/ntp.conf       YYYY-mm-dd --:--:--.000000000 +0900
***************
*** 14,22 ****

        # Use public servers from the pool.ntp.org project.
        # Please consider joining the pool (http://www.pool.ntp.org/join.html).
!       server 0.rhel.pool.ntp.org
!       server 1.rhel.pool.ntp.org
!       server 2.rhel.pool.ntp.org

        #broadcast 192.168.1.255 key 42         # broadcast server
        #broadcastclient                        # broadcast client
--- 17,25 ----

        # Use public servers from the pool.ntp.org project.
        # Please consider joining the pool (http://www.pool.ntp.org/join.html).
!       server ntp1.jst.mfeed.ad.jp
!       server ntp2.jst.mfeed.ad.jp
!       server ntp3.jst.mfeed.ad.jp

        #broadcast 192.168.1.255 key 42         # broadcast server
        #broadcastclient                        # broadcast client
[root@sixwish ~]# 

編集後、 ntpdateを使用してPCの時刻を合わせます。これをしない場合、ntpサーバーとの時間差が大きすぎてntpdが時刻あわせをしてくれない……ということもあるからです。
時刻あわせ後、サービスとして自動起動するようになるまで設定してしまいましょう。

[root@sixwish ~]# ntpdate ntp1.jst.mfeed.ad.jp
dd MMM --:--:-- ntpdate[----]: step time server xxx.xxx.xxx.xxx offset ---.------ sec
[root@sixwish ~]# hwclock --systohc
[root@sixwish ~]# /etc/rc.d/init.d/ntpd start
ntpdを起動中:                                              [  OK  ]
[root@sixwish ~]# chkconfig ntpd on
[root@sixwish ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 ntp1.jst.mfeed. xxx.xxx.xxx.xxx  2 u    9   64    1    7.353  -1414.6   0.001
 ntp2.jst.mfeed. xxx.xxx.xxx.xxx  2 u    8   64    1    6.994  -1414.7   0.001
 ntp3.jst.mfeed. xxx.xxx.xxx.xxx  2 u    7   64    1    7.031  -1414.6   0.001
 LOCAL(0)        LOCAL(0)        10 l    6   64    1    0.000    0.000   0.002
[root@sixwish root]# 

とりあえず、ここまでで最小構成化が完了となります。