|
CENTER:&size(20){''proxy.niss.co.jp再構築メモ''}; RIGHT:2005.01.16 RIGHT:定村 和彦 #contents #br * 前提条件 [#j0663e33] ** 目的と方針 [#b7d5c460] 2004年11月に発生したHDD障害に関しての対応として、proxy.niss.co.jpを別PCにて再構築する。2,3ヶ月以内に信頼性の高いサーバ機へのリプレースを予定しており、それまでの繋ぎとして運用する。またそのリプレース作業のための手順を確立する。 基本的には、現行機のアプリケーション設定を変更することなく、同設定のまま移行することとする。 ** ハードウェアスペック [#d5c71656] PC : DELL Optiplex GX150 CPU : Intel Celeron (Coppermime) 900GHz stepping 0a Memory : 256MB SDRAM VRAM : 1MB (Intel 815) HDD0 : Hitachi Deskster 160GB ((HDDは新規購入した)) * インストール(1) [#ge422cef] ** OS(Linux) [#p5c12136] Distribution:CentOS 3.3 kernel :Linux Kernel 2.4.21-20.EL.c0 [anaconda] linux text [Welcome CentOS] [インストーラの言語] Japanese [キーボード] jp106 [マウス] WheelMouse(PS/2) [インストールタイプ] カスタム [パーティション] |タイプ|マウント|サイズ| |ext3|/boot|128MB| |ext3|/|64000MB| |swap||512MB| |ext3|/var|92000MB| [ブートローダー1] GRUBを使用 [ブートローダー2] (無変更) [ブートローダー3] (無変更) [ブートローダー4] (無変更) [ブートローダー4] MBR [ネットワーク設定] DHCP (作業利便のため。後ほど固定IPを設定する) [ホスト名] 手動設定 proxy.niss.co.jp [ファイアウオール] ファイアウオールを無効にする [言語] Japanese と English(USA) [標準の言語] English(USA) [時刻] アジア/東京 [rootのパスワード] *** [パッケージ選択] Webサーバ squid メールサーバ sendmail sendmail-cf DNS ネームサーバ bind caching-nameserver レガシーなネットワークサーバー telnet-server 開発ツール rpm-build gcc make ** sendmail [#ud248097] -利用パッケージ sendmail-8.12.11-4.RHEL3.1 sendmail-cf-8.12.11-4.RHEL3.1 +旧proxyからファイルをコピーする。(&color(red){→}; … 配置変更) ++ /etc/sendmail.cf &color(red){→}; /etc/mail/sendmail.cf ++ /etc/aliases ++ /etc/aliases-list/* (全て) ++ /etc/sendmail.localdomain &color(red){→}; /etc/mail/sendmail.cf ++ /etc/sendmail.localdomain.db &color(red){→}; /etc/mail/sendmail.cf ++ /etc/sendmail.localip &color(red){→}; /etc/mail/sendmail.cf ++ /etc/sendmail.relay.map &color(red){→}; /etc/mail/sendmail.cf ++ /etc/sendmail.relay.map.db &color(red){→}; /etc/mail/sendmail.cf +&color(red){sendmail.cfファイル内の記述から、上記配置変更したファイルの記述を検索し、変更する。};(「/etc/」で検索する) -- /etc/aliases と /etc/hosts は変更しないように。 +その他、sendmail.cfの変更点 ++ V9/Berkeley → V10/Berkeley ++ IPC → TCP Msmtp, P=[IPC], F=mDFMuX, S=31/11, R=41/21, T=DNS/RFC822/SMTP, E=\r\n, L=990, TCP; $h Mesmtp, P=[IPC], F=mDFMuXa, S=31/11, R=41/21, T=DNS/RFC822/SMTP, E=\r\n, L=990, A=TCP $h Msmtp8, P=[IPC], F=mDFMuX8, S=31/11, R=41/21, T=DNS/RFC822/SMTP, E=\r\n, L=990, A=TCP $h Mrelay, P=[IPC], F=mDFMuX8, S=11, R=29, T=DNS/RFC822/SMTP, E=\r\n, L=2040, A=TCP $h +エイリアス(NEWDB)を再作成すると同時に、設定ファイルのチェックを行う。 # newaliases ** bind [#d8e043b2] -利用パッケージ bind-9.2.4-EL3_10 bind-utils-9.2.4-EL3_10 +旧proxyからファイルをコピーする。 ++ /etc/named.conf ++ /var/named/* (全て) +自動起動登録されていることを確認する。/etc/rc.d/rc3.d/ ** squid [#hf123f18] -利用パッケージ squid-2.5.STABLE3-6.3E + /etc/squid/squid.conf の編集 ++ http_port # http_port 3128 ↓ # http_port 3128 http_port 80 ++ http_access # And finally deny all other access to this proxy http_access allow localhost http_access deny all ↓ # And finally deny all other access to this proxy http_access allow localhost #http_access deny all http_access allow all +自動起動登録されていることを確認する。/etc/rc.d/rc3.d/ ** FWTK [#d8e043b2] -ソースコード一式 fwtk-2_1.tar.gz +旧proxyからファイルをコピー ++ /etc/services ++ /etc/xinetd.d/ftp ++ /etc/xinetd.d/ftp-gw ++ /etc/xinetd.d/nntp ++ /etc/xinetd.d/nntp2 ++ /etc/xinetd.d/WebObj ++ /etc/xinetd.d/aidu ++ /etc/xinetd.d/veritrans +&color(red){旧proxyからファイルをコピー(動作しませんでした)}; ++ /usr/local/etc/* (全て) -(以下、ファイルコピーで動作しなかった場合) + /usr/local/etc/* (全て) をバックアップ + FWTKをコンパイル&インストール *** FWTKのコンパイル&インストール [#rf8e136e] fwtk-2_1.tar.gz を準備して、 # mkdir fwtk; cp fwtk-2_1.tar.gz fwtk; cd fwtk # tar -zxvf fwtk-2_1.tar.gz # tar -zxvf fwtk2.1.tar.Z # cd fwtk # chown -R root * # vi fixmake sed 's/^include[]*\([^ ].*\).include "\1"/' $name.proto > $name ↓ sed 's/^include[]*\([^ ].*\)include \1/' $name.proto > $name # ./fixmake # mv Makefile.config Makefile.config.org # cp Makefile.config.linux Makefile.config # vi Makefile.config AUXLIB= #AUXLIB= -lcrypt ↓ #AUXLIB= AUXLIB= -lcrypt LDFL= -g -static ↓ #LDFL= -g -static LDFL= -g FWTKSRCDIR=/u/b/mjr/firewall/fwtk #FWTKSRCDIR=/usr/local/src/fwtk ↓ #FWTKSRCDIR=/u/b/mjr/firewall/fwtk FWTKSRCDIR=/usr/local/src/fwtk XLIBDIR=/usr/X11/lib ↓ #XLIBDIR=/usr/X11/lib XLIBDIR=/usr/X11R6/lib XINCLUDE=/usr/X11/include ↓ XINCLUDE=/usr/X11R6/include # vi Makefile DIRS= smap smapd netacl plug-gw ftp-gw tn-gw rlogin-gw http-gw x-gw ↓ #DIRS= smap smapd netacl plug-gw ftp-gw tn-gw rlogin-gw http-gw x-gw DIRS= plug-gw ftp-gw # ln -s /usr/include/gdbm/ndbm.h /usr/include/ndbm.h # make clean # make # make install で、/usr/local/etcへ実行バイナリがコピーされます。 ** ntpd [#o47f604e] -利用パッケージ ntp-4.1.2-4.EL3.1 +旧proxyからファイルをコピー ++ /etc/ntp.conf ++ /etc/ntp/step-tickers +自動起動登録されていることを確認する。/etc/rc.d/rc3.d/ *環境設定(1) [#oba25003] **ユーザ移行 [#xe5b22c9] + /homeのコピー 旧proxyの/homeを、/homeに上書きコピーする。 + /etc/passwd, /etc/shadowファイルの編集 旧proxyのユーザ登録を、passwd, shadowのそれぞれについて、コピーする。 &color(red){※ SIDのバッティングを避けるために、この作業以前にユーザ新規作成はしない。}; ※ 今回は、eto, kawai-t, t-noda, yosiharaを削除した。 + /etc/group, /etc/gshadowファイルの編集 旧proxyのグループ登録を、group, gshadowのそれぞれについて、コピーする。 * インストール(2) [#ge422cef] ** upsd [#j98c58fc] -利用モジュール一式 linux453_glibc.tar +インストール # mkdir upsd; cp linux453_glibc.tar; cd upsd # tar xvf linux453_glibc.tar # ./INSTALL ・installed PowerChute products 1) CD-ROM ・Would you like to see an overview of the Installation?[y/n,q] y ・Which Parts of PowerChute Plus for UNIX do you wish to install? [?] 3) Both the User Interface and Daemon Modules ・Which APC Hardware will PowerChute Plus for UNIX be running with [?] 2) Smart-UPS ・Do you currently have a Measure-UPS attached to the UPS? [y/n,q] y ・Do you currently have TCP/IP Installed? [y/n,q] y ・Which color scheme do you wish to use [1]? 2) Use Monochrome Color scheme ・Which serial device will be dedicated to PowerChute Plus for UNIX [?] 1) /dev/ttyS0 ・Where do you wish to install PowerChute Plus for UNIX? /usr/lib/powerchute ・Do you want to execute command files as root? [y/n,q] y ・Do you want to send e-mail as root? [y/n,q] n ・Would you like to install HTML help? [y/n,q] n ・Are the above selections correct? [y/n,q] y ・Do you wish to increment the UpsTurnOffDelay to its next highest value now? [y/n] y +pwrchuteユーザ作成(SIDのバッティングを避けるために&color(red){旧ユーザ移行後に行う};) useradd -M -s /sbin/nologin pwrchute ** sshd [#tbf8de20] -利用パッケージ openssh-3.6.1p2-33.30.1 openssh-server-3.6.1p2-33.30.1 openssh-clients-3.6.1p2-33.30.1 + /etc/ssh/sshd_config の編集 #PermitRootLogin yes ↓ #PermitRootLogin yes PermitRootLogin no #PasswordAuthentication yes ↓ #PasswordAuthentication yes PasswordAuthentication no + 後で、旧proxyの /home ディレクトリをコピーし、各アカウントび認証鍵を移行するので、認証鍵の新規作成は不要。 *** SSH1の秘密鍵・公開鍵の作成 [#l59174b2] # su - 利用するアカウント $ ssh-keygen -t rsa1 ~ パスフレーズの設定 $ cd .ssh $ cat identity.pub >> authorized_keys $ chmod 644 authorized_keys ← こうしないとログインできない ~ identity(秘密鍵)をクライアント側へ転送して保持する。 $ rm ~/.ssh/identity.pub ~/.ssh/identity ← サーバ側には不要 ** swatch [#b5d7777d] -利用パッケージ swatch-3.1-1.0.rh9.dag ← ftp://rpmfind.net/linux/7/dag/redhat/9/en/i386/dag/RPMS perl-DateManip-5.40-30 perl-Time-HiRes-1.38-3 perl-TimeDate-1.16-0.rhel3.dag perl-File-Tail-0.98-1.1.el3.dag perl-Mail-Sendmail-0.79-1 perl-Date-Calc-5.3-3 perl-Bit-Vector-6.1-33 ※ perl5.8.0のライブラリが必要。(5.8.1, 5.8.3, 5.8.5はNG) ※ RHEL3に見つからなければ、RH9を探す +旧proxyからファイルをコピー ++ /etc/swatchrc +/etc/swatchrc を編集 exec /usr/local/scripts/mailsend.sh sysreport@niss.co.jp system@niss.co.jp 'Swatch Report 1' '$0' ↓ exec /usr/local/scripts/mailsend.sh sysreport@niss.co.jp system@niss.co.jp 'Swatch Report 1' '$_' ※ &color(red){該当箇所を全て変更する}; + /usr/local/scripts/mailsend.sh を作成 /usr/local/scripts/mailsend.sh #!/bin/sh # Usage: # mailsend.sh TO1,TO2,TO3... FROM SUBJECT BODY # echo "From: $2 To: $1 Subject: $3(from $HOSTNAME) $4" | /usr/sbin/sendmail $1 + /etc/rc.d/init.d/swatch を作成 /etc/rc.d/init.d/swatch #!/bin/sh # # swatch swatch is monitaring for logs and specific action from external # will send mail for specific users. # # chkconfig: 2345 42 42 # description: monitaring logs tool. # processname: swatch # config: /etc/swatchrc # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -f /usr/bin/swatch ] || exit 0 [ -f /etc/swatchrc ] || exit 0 RETVAL=0 # See how we were called. case "$1" in start) # Start daemons. echo -n "Starting swatch: " swatch -c /etc/swatchrc -t /var/log/messages & RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/swatch ;; stop) # Stop daemons. echo -n "Shutting down swatch: " #killproc swatch #pid=`pidof tail` pid_message=`ps ax | grep message | awk '{print $1}'` #kill -9 $pid > /dev/null 2>&1 kill -9 $pid_message > /dev/null 2>&1 RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/swatch ;; status) status swatch RETVAL=$? ;; restart|reload) $0 stop $0 start RETVAL=$? ;; *) echo "Usage: swatch {start|stop|restart|reload|status}" exit 1 esac exit $RETVAL * 環境設定(2) [#seaf2673] ** ネットワーク関連 [#y6cde550] +旧proxyからファイルをコピーする。 ++ /etc/hosts ++ /etc/hosts.allow ++ /etc/hosts.deny ++ /etc/resolv.conf ++ /etc/securetty ← sshでログインできるようになってから設定する ++ /etc/sysconfig/network //++ /etc/sysconfig/static-routes ++ /etc/sysconfig/syslog ++ /etc/sysconfig/network-scripts/ifcfg-eth0 ← IPアドレスがバッティングしないように社内LANから隔離すること ++ /etc/sysconfig/network-scripts/ifcfg-eth1 ← IPアドレスがバッティングしないように社内LANから隔離すること +/etc/sysconfig/network-scripts/route-eth1を作成する。 route-eth1 192.168.0.0/16 via 192.168.0.2 192.218.224.0/24 via 192.168.0.2 **その他 [#i9f9c770] +logrotate.conf を編集 rotate 4 ↓ #rotate 4 rotate 96 ← ログを2年(96週)分残す +不要なサービスを停止 # setup ~「System Services」を選択 [ ] FreeWnn [*] WebObj [ ] aep1000 [*] aidu [*] apmd [*] arptable_if [*] atd [ ] autofs [ ] canna [*] crond [*] cups [ ] dc_client [ ] dc_server [*] ftp [*] ftp-gw [*] gpm [*] ip6tables [*] iptables [*] irqbalance [ ] isdn [*] kudzu [*] mdmonitor [ ] mdmpd [*] microcode_ctl [*] named [ ] netdump [ ] netfs [*] network [ ] nfs [*] nfslock [*] nntp [*] nntp2 [*] ntpd [ ] pcmcia [*] portmap [ ] psacct [*] random [*] rawdevices [*] rhnsd [ ] saslauthd [*] sendmail [*] sgi_fam [ ] smartd [ ] snmpd [ ] snmptrapd [*] squid [*] sshd [*] syslog [ ] tux [*] upsd [*] veritrans [ ] winbind [*] xfs [*] xinetd [ ] yum +cronの登録 # crontab -e # TIS FWTK Report Maker # 23:59 everyday #59 23 * * * /usr/local/etc/report-today.sh 2>&1 | /bin/mail -s "TIS Daily Report" rootmaster@niss.co.jp 59 23 * * * /usr/local/etc/report-today.sh 2>&1 | /usr/sbin/sendmail -froot@niss.co.jp rootmaster@niss.co.jp # 03:00 monday #00 03 * * mon /usr/local/etc/report-weekly.sh 2>&1 | /bin/mail -s "TIS Weekly Report" rootmaster@niss.co.jp 00 03 * * mon /usr/local/etc/report-weekly.sh 2>&1 | /usr/sbin/sendmail -froot@niss.co.jp rootmaster@niss.co.jp # CPU Status Report Maker # 00:00 everyday #00 00 * * * /usr/local/etc/CPU/cpustat 2>&1 | /bin/mail -s "CpuUse(proxy.niss.co.jp.)" rootmaster@niss.co.jp 00 00 * * * /usr/local/etc/CPU/cpustat 2>&1 | /usr/sbin/sendmail -froot@niss.co.jp rootmaster@niss.co.jp # SYSLOG Shifter # 00:00 everyday #00 00 * * * /usr/local/etc/newsyslog.sh >/dev/null 2>&1 # SQUID Log Shifter # 00:00 everyday 00 00 * * * /usr/local/etc/newsquidlog.sh >/dev/null 2>&1 # SQUID Log Reporter # 01:00 everyday #00 01 * * * /usr/local/etc/SQUID/ReportSquid.sh 2>&1 | /bin/mail -s "Squid(proxy.niss.co.jp.)" rootmaster@niss.co.jp 00 01 * * * /usr/local/etc/SQUID/ReportSquid.sh 2>&1 | /usr/sbin/sendmail -froot@niss.co.jp rootmaster@niss.co.jp # 01:00 everyday #00 01 * * * /usr/local/etc/SQUID/ReportSquid2HTML.sh > /home/joumura/public_html/squidlog.html *インストール(3) [#e29d1600] ** tripwire [#ub421a75] -利用パッケージ tripwire-2.3.1-17 ← RH9 +初期化 # /etc/tripwire/twinstall.sh Enter the site keyfile passphrase: *** Enter the local keyfile passphrase: *** # /usr/sbin/tripwire --init +/etc/tripwire/twpol.txt を調整する(存在しないファイルを削除しておく) 楽な調整の仕方 # /usr/sbin/tripwire --check > xxx # grep Filename xxx | awk '{print $2}' > yyy # grep -v -f yyy twpol.txt > zzz # cp twpol.txt twpol.txt.bak; mv zzz twpol.txt +再初期化および確認 # /usr/sbin/twadmin --create-polfile /etc/tripwire/twpol.txt # /usr/sbin/tripwire --init # /usr/sbin/tripwire --check +/etc/cron.daily/tripwire-check を編集 自動実行を修正し、結果をメールにて自動送信 test -f /etc/tripwire/tw.cfg && /usr/sbin/tripwire --check ↓ test -f /etc/tripwire/tw.cfg && /usr/local/scripts/mailsend.sh sysreport@niss.co.jp system@niss.co.jp "Tripwire Report" "`/usr/sbin/tripwire --check 2> /dev/null`" /usr/sbin/tripwire --init ← 追加 - Databaseの更新(--updateオプションもありますが…) # /usr/sbin/tripwire --init