Kapow Katalystの稼働環境としてLinux(CentOS)サーバを構築する際の標準的な手順について解説します。
調達するサーバはクラウド環境のサーバを前提とします。
クラウドサーバ契約後の新規サーバを yum update で最新化します。
[root@xxxx ~]# yum update
ビズロボ利用グループ、及びユーザの作成。
[root@xxxx ~]# /usr/sbin/groupadd bizrobo
[root@xxxx ~]# /usr/sbin/useradd bizrobo -g bizrobo
[root@xxxx ~]# passwd bizrobo
Changing password for user bizrobo.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
sudo の設定
[root@xxxx ~]# visudo
Cmnd_Alias SHUTDOWN = /sbin/halt, /sbin/shutdown, /sbin/poweroff, /sbin/reboot, /sbin/fastboot, /sbin/init
Cmnd_Alias REMOVE = /bin/rm, /usr/sbin/unlink, /bin/rmdir, /sbin/newfs
Cmnd_Alias IFCONFIG = /sbin/ifconfig
Cmnd_Alias NDD = /usr/sbin/ndd
:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
bizrobo ALL=(ALL) NOPASSWD: ALL, !SHUTDOWN,!REMOVE,!IFCONFIG,!NDD
SSHの設定
[root@xxxx ~]# vi /etc/ssh/sshd_config
:
#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
:
[root@ANA-Dtour ~]# /etc/rc.d/init.d/sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
ntpの設定(日本国内用)
[root@xxxx ~]# vi /etc/ntp.conf
:
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp1.jst.mfeed.ad.jp
server ntp2.jst.mfeed.ad.jp
server ntp3.jst.mfeed.ad.jp
:
[root@xxxx ~]# /etc/rc.d/init.d/ntpd restart
Shutting down ntpd: [ OK ]
Starting ntpd: [ OK ]
ntpが正常に動いていることを確認
[root@xxxx ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*ntp1.jst.mfeed. 133.243.236.17 2 u 61 64 1 5.487 0.395 0.000
ntp2.jst.mfeed. 133.243.236.17 2 u 60 64 1 5.703 1.809 0.000
ntp3.jst.mfeed. 133.243.236.17 2 u 59 64 1 5.709 0.206 0.000
起動時にntpを起動する
[root@xxxx ~]# chkconfig ntpd on
設定内容を確認
[root@xxxx ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
ip6tablesの無効化
[root@xxxx ~]# chkconfig ip6tables off
[root@xxxx ~]# /etc/init.d/ip6tables stop
[root@xxxx ~]# chkconfig --list ip6tables
ip6tables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
cronのインストール
[root@xxxx ~]# yum -y install cronie-noanacron
cronの設定(bizrobo用ユーザ)
[bizrobo@xxxx ~]$ crontab -e
0,6,12,18,24,30,36,42,48,54 * * * * /home/bizrobo/keepVMSTAT_wrap.sh
[bizrobo@xxxx ~]$ touch /home/bizrobo/keepVMSTAT.sh
[bizrobo@xxxx ~]$ vi keepVMSTAT.sh
#!/bin/bash
echo ""
echo ""
echo "----------------------------------------------------------------->>------------"
# uptime
echo "Following information is a CPU load average in last 1, 5, 15 minutes."
echo ""
uptime
#
echo ""
ps ux | cut -c1-120 | grep -v bash | grep -v cut | grep -v ps | grep -v cron
echo ""
vmstat -S M 10 10
echo ""
date
echo ""
echo ""
[bizrobo@xxxx ~]$ touch /home/bizrobo/keepVMSTAT_wrap.sh
[bizrobo@xxxx ~]$ vi keepVMSTAT_wrap.sh
/home/bizrobo/keepVMSTAT.sh >> /home/bizrobo/monitor_logs/monitor_`date +"%m%d"`.log
[bizrobo@xxxx ~]$ ll
total 8
-rw-rw-r--. 1 bizrobo bizrobo 364 Oct 26 05:24 keepVMSTAT.sh
-rw-rw-r--. 1 bizrobo bizrobo 85 Oct 26 05:26 keepVMSTAT_wrap.sh
[bizrobo@xxxx ~]$ chmod +x keep*
[bizrobo@xxxx ~]$ ll
total 8
-rwxrwxr-x. 1 bizrobo bizrobo 364 Oct 26 05:24 keepVMSTAT.sh
-rwxrwxr-x. 1 bizrobo bizrobo 85 Oct 26 05:26 keepVMSTAT_wrap.sh
[bizrobo@xxxx ~]$ mkdir monitor_logs