1187 文字
6 分
YMCのVPSサービスをフルに使う!

@YMCのVPSを借りました。
カスタマイズドなので、root権限でやりたい放題できます。

Xenで動いています。ゲストOSはCentOS 4.5 です。

しかしながら、初期状態ではいくつかいらないアプリケーションが元から入っているので削除します。

以下は、コマンドの意味がわかる方のみ実行してください!かなーり危険です。

以下のコマンドを実行。
このコマンドを実行すると、デーモンはsshd,syslogd,cronぐらいしか動いていない状態となり、
スッキリする。

Terminal window
# yum remove sendmail dhclient squid httpd isdn4k-utils pcmcia-cs mysql bind xinetd at
# yum install subversion rcs bison gcc

このコマンドを実行すると、DNSのキャッシュサーバが無くなります。
DNSサーバの指定を買えましょう。

/etc/resolve.conf を編集して適当なDNSキャッシュサーバを指定する。

VPSでは
・プロセス数の制限
・RAMの制限
・CPU計算時間の制限
・ディスク容量
がきっついのでいらないモノはどんどん削除。

もっとプロセス数を減らしたければ、

/etc/inittab を変更してrebootすればコンソール用のプロセスを5つ消せる。

$ rcsdiff inittab
===================================================================
RCS file: RCS/inittab,v
retrieving revision 1.1
diff -r1.1 inittab
46,50c46,50
< 2:2345:respawn:/sbin/mingetty tty2
< 3:2345:respawn:/sbin/mingetty tty3
< 4:2345:respawn:/sbin/mingetty tty4
< 5:2345:respawn:/sbin/mingetty tty5
< 6:2345:respawn:/sbin/mingetty tty6
---
> #2:2345:respawn:/sbin/mingetty tty2
> #3:2345:respawn:/sbin/mingetty tty3
> #4:2345:respawn:/sbin/mingetty tty4
> #5:2345:respawn:/sbin/mingetty tty5
> #6:2345:respawn:/sbin/mingetty tty6

比較はこんな感じ。

before

[admin@www ~]$ ps axu
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.3 1704 552 ? S Jun11 0:00 init [3]
root 2 0.0 0.0 0 0 ? S Jun11 0:00 [migration/0]
root 3 0.0 0.0 0 0 ? SN Jun11 0:00 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S Jun11 0:00 [watchdog/0]
root 5 0.0 0.0 0 0 ? S> Jun11 0:00 [events/0]
root 6 0.0 0.0 0 0 ? S> Jun11 0:00 [khelper]
root 7 0.0 0.0 0 0 ? S> Jun11 0:00 [kthread]
root 8 0.0 0.0 0 0 ? S> Jun11 0:00 [xenwatch]
root 9 0.0 0.0 0 0 ? S> Jun11 0:00 [xenbus]
root 16 0.0 0.0 0 0 ? S> Jun11 0:00 [kblockd/0]
root 40 0.0 0.0 0 0 ? S Jun11 0:00 [pdflush]
root 41 0.0 0.0 0 0 ? S Jun11 0:00 [pdflush]
root 43 0.0 0.0 0 0 ? S> Jun11 0:00 [aio/0]
root 42 0.0 0.0 0 0 ? S Jun11 0:00 [kswapd0]
root 559 0.0 0.0 0 0 ? S> Jun11 0:00 [kseriod]
root 589 0.0 0.0 0 0 ? S Jun11 0:00 [kjournald]
root 1851 0.0 0.0 0 0 ? S Jun11 0:00 [kjournald]
root 1859 0.0 0.2 1600 472 ? S>s Jun11 0:00 udevd
root 2184 0.0 0.3 1616 540 ? Ss Jun11 0:00 syslogd -m 0
root 2188 0.0 0.2 1560 380 ? Ss Jun11 0:00 klogd -x
named 2203 0.0 1.6 30172 2680 ? Ssl Jun11 0:00 /usr/sbin/named -u named -t /var/named/chroot
rpc 2221 0.0 0.3 1696 524 ? Ss Jun11 0:00 portmap
root 2234 0.0 0.6 4096 1140 ? Ss Jun11 0:00 /usr/sbin/sshd
root 2249 0.0 0.4 2160 760 ? Ss Jun11 0:00 xinetd -stayalive -pidfile /var/run/xinetd.pid
root 2271 0.0 1.2 7388 2000 ? Ss Jun11 0:00 sendmail: accepting connections
smmsp 2282 0.0 0.9 6492 1624 ? Ss Jun11 0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmque
root 2292 0.0 0.5 4540 924 ? Ss Jun11 0:00 crond
root 2309 0.0 0.2 1788 428 ? Ss Jun11 0:00 /usr/sbin/atd
root 2316 0.0 0.2 1548 436 tty1 Ss+ Jun11 0:00 /sbin/mingetty tty1
root 2317 0.0 0.2 1548 440 tty2 Ss+ Jun11 0:00 /sbin/mingetty tty2
root 2318 0.0 0.2 1552 444 tty3 Ss+ Jun11 0:00 /sbin/mingetty tty3
root 2319 0.0 0.2 1552 440 tty4 Ss+ Jun11 0:00 /sbin/mingetty tty4
root 2320 0.0 0.2 1552 444 tty5 Ss+ Jun11 0:00 /sbin/mingetty tty5
root 2321 0.0 0.2 1552 444 tty6 Ss+ Jun11 0:00 /sbin/mingetty tty6
root 4087 0.0 1.5 6972 2596 ? Ss 01:45 0:00 sshd: admin [priv]
admin 4097 0.0 1.0 6972 1788 ? S 01:46 0:00 sshd: admin@pts/0
admin 4104 0.0 0.8 4308 1396 pts/0 Ss 01:46 0:00 -bash
admin 4130 0.0 0.4 2388 784 pts/0 R+ 01:46 0:00 ps axu

after

[admin@www ~]$ ps axu
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.3 1704 552 ? S Jun11 0:00 init [3]
root 2 0.0 0.0 0 0 ? S Jun11 0:00 [migration/0]
root 3 0.0 0.0 0 0 ? SN Jun11 0:00 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S Jun11 0:00 [watchdog/0]
root 5 0.0 0.0 0 0 ? S> Jun11 0:00 [events/0]
root 6 0.0 0.0 0 0 ? S> Jun11 0:00 [khelper]
root 7 0.0 0.0 0 0 ? S> Jun11 0:00 [kthread]
root 8 0.0 0.0 0 0 ? S> Jun11 0:00 [xenwatch]
root 9 0.0 0.0 0 0 ? S> Jun11 0:00 [xenbus]
root 16 0.0 0.0 0 0 ? S> Jun11 0:00 [kblockd/0]
root 40 0.0 0.0 0 0 ? S Jun11 0:00 [pdflush]
root 41 0.0 0.0 0 0 ? S Jun11 0:00 [pdflush]
root 43 0.0 0.0 0 0 ? S> Jun11 0:00 [aio/0]
root 42 0.0 0.0 0 0 ? S Jun11 0:00 [kswapd0]
root 559 0.0 0.0 0 0 ? S> Jun11 0:00 [kseriod]
root 589 0.0 0.0 0 0 ? S Jun11 0:00 [kjournald]
root 1851 0.0 0.0 0 0 ? S Jun11 0:00 [kjournald]
root 1859 0.0 0.2 1600 472 ? S>s Jun11 0:00 udevd
root 2184 0.0 0.3 1616 540 ? Ss Jun11 0:00 syslogd -m 0
root 2188 0.0 0.2 1560 380 ? Ss Jun11 0:00 klogd -x
root 2234 0.0 0.6 4096 1140 ? Ss Jun11 0:00 /usr/sbin/sshd
root 2292 0.0 0.5 4540 924 ? Ss Jun11 0:00 crond
root 2316 0.0 0.2 1548 436 tty1 Ss+ Jun11 0:00 /sbin/mingetty tty1
root 4087 0.0 1.5 6972 2596 ? Ss 01:45 0:00 sshd: admin [priv]
admin 4097 0.0 1.1 7124 1804 ? R 01:46 0:00 sshd: admin@pts/0
admin 4104 0.0 0.8 4308 1420 pts/0 Ss 01:46 0:00 -bash
admin 5076 0.0 0.4 2392 788 pts/0 R+ 02:00 0:00 ps axu

スッキリしました!

起動直後のRAM使用量は30MB。

top - 02:13:53 up 0 min, 1 user, load average: 0.17, 0.06, 0.02
Tasks: 28 total, 2 running, 26 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 163976k total, 32036k used, 131940k free, 3432k buffers
Swap: 1048568k total, 0k used, 1048568k free, 13908k cached
YMCのVPSサービスをフルに使う!
https://blog.teraren.com/posts/ymcのvpsサービスをフルに使う/
作者
Yuki Matsukura
公開日
2007-06-14
ライセンス
CC BY-NC-SA 4.0

コメント