あるお客様からのメールなどが spam 扱いされてしまい、そのままでは
マズイ事になってしまうので面倒ですが、ホワイトリストにメールアドレス
を追加して対応する事にしました。
そのメモです
foo@example.com をホワイトリストに追加する場合は以下のようにします。
$ cd ~/.spamassassin $ echo whitelist_from foo@example.com >> user_prefs |
あるお客様からのメールなどが spam 扱いされてしまい、そのままでは
マズイ事になってしまうので面倒ですが、ホワイトリストにメールアドレス
を追加して対応する事にしました。
そのメモです
foo@example.com をホワイトリストに追加する場合は以下のようにします。
$ cd ~/.spamassassin $ echo whitelist_from foo@example.com >> user_prefs |
またディスク障害が発生しました 😥
前回障害が発生してからまだ2ヶ月しか経っていません…。
前回交換したディスクとは別のディスクが壊れました。
[root@ns1 ~]# cat /proc/mdstat Personalities : [raid1] md1 : active raid1 hdc2[1] hda2[0] 2096384 blocks [2/2] [UU] md2 : active raid1 hdc3[1] hda3[2](F) 75762432 blocks [2/1] [_U] md0 : active raid1 hdc1[1] hda1[0] 264960 blocks [2/2] [UU] unused devices: <none> |
壊れたディスクは /dev/hda、つまり1番目のディスクです。
復旧作業は基本的に前回と同じですが、違うところはディスクの物理的な接続を入れ替えるところです。
入れ替えと言っているのは、壊れたディスクは1番目のディスクですが、新しく交換するディスクはセカンダリの IDE に接続して、元々セカンダリ IDE に接続していたディスクをプライマリ IDE に接続します。
入れ替えをしなければならない理由は、1番目のディスクが壊れてしまったからです。
入れ替えをしないで OS を起動しようとすると、MBR が 1 本目のディスクの stage1 を読み込もうとしますが、交換したまっさらなディスクなので stage1 が存在しないので OS の起動に失敗してしまいます。
OS が起動できなければ復旧作業ができません
ディスクを入れ替えてしまえば後は前回と同じ復旧作業をするだけです。 🙂
前回の記事を見ながら無事復旧できました 🙂
もう壊れないでほしいけど、この暑さじゃまた壊れてしまうかも 🙁
lsyncd でコンテンツの同期を行っていたところ大量のエラーが 😥
rsync error: some files could not be transferred (code 23) at main.c(892) [sender=2.6.8] |
php のファイルアップロード処理で一時保存用のディレクトリを同期対象にしているのがエラーの原因と推測しました 💡
そこで、tmp ディレクトリを除外してみたところエラーが収まりました 🙂
ディレクトリの除外ではまったので設定をメモしておきます。
/home/hoge/syncdir/ が同期対象のディレクトリです。
その配下にある cms/tmp ディレクトリを除外します。
rsyncd.conf
[hoge] path=/home/hoge/syncdir/ uid = hoge gid = hoge read only = false exclude from = /etc/rsyncd.exclude |
そして/etc/rsyncd.exclude
- cms/tmp - cms/tmp/* |
いろいろ試行錯誤した結果この設定になりました。
これで今のところうまく除外できています。
lsyncd 便利ですね 😎
箱根大涌谷の玉子茶屋で温泉たまごを作っているところです 🙂
5 つで 500 円でした。
塩もついてます 😎
Software RAID のハードディスクが壊れたっぽいのでディスクを交換して RAID の復旧を行いました。
ハードディスクが壊れたっぽい、もしくはそろそろ壊れそうと思ったのはこんなメールが送られて来たからです。
Jun 30 10:55:21 ns1 smartd[3428]: Device: /dev/hdc, FAILED SMART self-check. BACK UP DATA NOW! |
RAID の状態は以下のとおり正常だったのですが、早めの対処という事でディスク交換しました。
[root@ns1 ~]# cat /proc/mdstat Personalities : [raid1] md1 : active raid1 hdc2[1] hda2[0] 2096384 blocks [2/2] [UU] md2 : active raid1 hdc3[1] hda3[0] 75762432 blocks [2/2] [UU] md0 : active raid1 hdc1[1] hda1[0] 264960 blocks [2/2] [UU] unused devices: <none> |
ディスク交換をする前に現在の設定を控えておきました。
[root@ns1 ~]# fdisk -l /dev/hda Disk /dev/hda: 80.0 GB, 80000000000 bytes 255 heads, 63 sectors/track, 9726 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 33 265041 fd Linux raid autodetect /dev/hda2 34 294 2096482+ fd Linux raid autodetect /dev/hda3 295 9726 75762540 fd Linux raid autodetect [root@ns1 ~]# smartctl -a /dev/hdc 結果が長いので省略しました。 |
それと、IDE のディスクだったのでセカンダリコントローラのマスターに接続されている事や、ディスクのジャンパーをどうすればよいのか調べておきました。
[root@ns1 ~]# mdadm --manage /dev/md0 --fail /dev/hdc1 mdadm: set /dev/hdc1 faulty in /dev/md0 [root@ns1 ~]# mdadm --manage /dev/md1 --fail /dev/hdc2 mdadm: set /dev/hdc2 faulty in /dev/md1 [root@ns1 ~]# mdadm --manage /dev/md2 --fail /dev/hdc3 mdadm: set /dev/hdc3 faulty in /dev/md2 すると mdstat はこんな風になります。 [root@ns1 ~]# cat /proc/mdstat Personalities : [raid1] md1 : active raid1 hdc2[2](F) hda2[0] 2096384 blocks [2/1] [U_] md2 : active raid1 hdc3[2](F) hda3[0] 75762432 blocks [2/1] [U_] md0 : active raid1 hdc1[2](F) hda1[0] 264960 blocks [2/1] [U_] unused devices: <none> さらに続けて以下を実施。 [root@ns1 ~]# mdadm --manage /dev/md0 --remove /dev/hdc1 mdadm: hot removed /dev/hdc1 [root@ns1 ~]# mdadm --manage /dev/md1 --remove /dev/hdc2 mdadm: hot removed /dev/hdc2 [root@ns1 ~]# mdadm --manage /dev/md2 --remove /dev/hdc3 mdadm: hot removed /dev/hdc3 /dev/hdc が RAID デバイスから削除されました。 [root@ns1 ~]# cat /proc/mdstat Personalities : [raid1] md1 : active raid1 hda2[0] 2096384 blocks [2/1] [U_] md2 : active raid1 hda3[0] 75762432 blocks [2/1] [U_] md0 : active raid1 hda1[0] 264960 blocks [2/1] [U_] unused devices: <none> |
[root@ns1 ~]# sync;sync;sync;shutdown -h now 電源停止後ディスク交換。 |
デフォルトの状態はこんな風になっていました。 [root@ns1 ~]# fdisk /dev/ -l /dev/hdc last_lba(): I don't know how to handle files with mode 41ed Disk /dev/hdc: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/hdc doesn't contain a valid partition table で、/dev/hda と同じようにパーティションを切りました。 [root@ns1 ~]# fdisk /dev/hdc Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-9729, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-9729, default 9729): 33 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (34-9729, default 34): Using default value 34 Last cylinder or +size or +sizeM or +sizeK (34-9729, default 9729): 294 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (295-9729, default 295): Using default value 295 Last cylinder or +size or +sizeM or +sizeK (295-9729, default 9729): 9726 Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): fd Changed system type of partition 1 to fd (Linux raid autodetect Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): fd Changed system type of partition 2 to fd (Linux raid autodetect) Command (m for help): t Partition number (1-4): 3 Hex code (type L to list codes): fd Changed system type of partition 3 to fd (Linux raid autodetect) Command (m for help): p Disk /dev/hdc: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hdc1 1 33 265041 fd Linux raid autodetect /dev/hdc2 34 294 2096482+ fd Linux raid autodetect /dev/hdc3 295 9726 75762540 fd Linux raid autodetect Command (m for help): a Partition number (1-4): 1 Command (m for help): p Disk /dev/hdc: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hdc1 * 1 33 265041 fd Linux raid autodetect /dev/hdc2 34 294 2096482+ fd Linux raid autodetect /dev/hdc3 295 9726 75762540 fd Linux raid autodetect Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. そして、以下で確認しました。 [root@ns1 ~]# fdisk -l /dev/hdc Disk /dev/hdc: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hdc1 * 1 33 265041 fd Linux raid autodetect /dev/hdc2 34 294 2096482+ fd Linux raid autodetect /dev/hdc3 295 9726 75762540 fd Linux raid autodetect |
RAID デバイスに各パーティションを追加するとリシンクします。
[root@ns1 ~]# mdadm --manage /dev/md0 --add /dev/hdc1 mdadm: hot added /dev/hdc1 [root@ns1 ~]# mdadm --manage /dev/md1 --add /dev/hdc2 mdadm: hot added /dev/hdc2 [root@ns1 ~]# mdadm --manage /dev/md2 --add /dev/hdc3 mdadm: hot added /dev/hdc3 mdstat を見るとリシンクしている状況を確認できます。 [root@ns1 ~]# cat /proc/mdstat Personalities : [raid1] md1 : active raid1 hdc2[2] hda2[0] 2096384 blocks [2/1] [U_] [=====>...............] recovery = 25.7% (540800/2096384) finish=0.9min speed=27040K/sec md2 : active raid1 hdc3[2] hda3[0] 75762432 blocks [2/1] [U_] resync=DELAYED md0 : active raid1 hdc1[1] hda1[0] 264960 blocks [2/2] [UU] unused devices: <none> 立て続けに複数のパーティションを --add しても同時に複数のリシンクが走らないみたいです。 最終的に完了すると以下のようになります。 [tatsu@ns1 ~]$ cat /proc/mdstat Personalities : [raid1] md1 : active raid1 hdc2[1] hda2[0] 2096384 blocks [2/2] [UU] md2 : active raid1 hdc3[1] hda3[0] 75762432 blocks [2/2] [UU] md0 : active raid1 hdc1[1] hda1[0] 264960 blocks [2/2] [UU] unused devices: <none> |
これで RAID デバイスの復旧は完了ですが、交換したディスクからも起動できるようにする為にブートローダをインストールする必要があります。
[root@ns1 ~]# grub GNU GRUB version 0.95 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename.] grub> device (hd0) /dev/hdc grub> root (hd0,0) Filesystem type is ext2fs, partition type 0xfd grub> install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf grub> quit 確認はこうするようです。 [root@ns1 ~]# dd if=/dev/hdc bs=512k count=1 | strings ZRrI D|f1 GRUB Geom Hard Disk Read Error ZRrI D|f1 GRUB Geom Hard Disk Read Error qH*L sH*L 1+0 records in 1+0 records out |
これで復旧作業は完了です 🙂
Software RAID はリシンク中に OS を起動してサービスをすぐに再開させる事ができて
ダウンタイムが短くて良いですね。
以下を参考にさせていただきました。
大変助かりました。ありがとうございました。
ssh brute force attack 対策に fail2ban を試してみました。
ssh でログインを試みる攻撃が沢山来ているので、fail2ban を使って同じ IP から指定した回数以上認証に失敗した場合には、その IP からのアクセスを一定期間拒否しするようにしました。
# yum install --enablerepo=rpmforge fail2ban |
jail.conf を変更しました。
# cd /etc/fail2ban # cp -p jail.conf jail.conf.ORG # vi jail.conf |
[DEFAULT] と [ssh-iptables] の部分を変更しました。
[DEFAULT] ignoreip = 127.0.0.1 10.0.0.0/24 maxretry = 5 |
[ssh-iptables] enabled = true filter = sshd action = iptables[name=SSH, port=ssh, protocol=tcp] sendmail-whois[name=SSH, dest=root, sender=foo@example.com] logpath = /var/log/secure maxretry = 5 |
# chkconfig fail2ban on # chkconfig --list fail2ban fail2ban 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
# service fail2ban start Starting fail2ban: [ OK ] |
起動するとログファイルができます。
# ll /var/log/fail2ban.log -rw------- 1 root root 2306 May 10 10:42 /var/log/fail2ban.log |
実際にアタックを受け、fail2ban が動作すると以下のようなメールが jail.conf で指定したアドレスに届きました。(アドレスなどは書き換えてあります)
Subject: [Fail2Ban] SSH: banned 111.222.333.444 From: Fail2Ban <foo@example.com> To: root@example.com Date: Tue, 11 May 2010 14:23:00 +0900 (JST) Hi, The IP 111.222.333.444 has just been banned by Fail2Ban after 5 attempts against SSH. Here are more information about 111.222.333.444: [Querying whois.arin.net] [Redirected to whois.lacnic.net] [Querying whois.lacnic.net] [whois.lacnic.net] % Joint Whois - whois.lacnic.net % This server accepts single ASN, IPv4 or IPv6 queries % LACNIC resource: whois.lacnic.net % Copyright LACNIC lacnic.net % The data below is provided for information purposes % and to assist persons in obtaining information about or % related to AS and IP numbers registrations % By submitting a whois query, you agree to use this data % only for lawful purposes. % 2010-05-11 02:22:59 (BRT -03:00) inetnum: 111.222/14 status: allocated owner: XXXXXXX ownerid: XX-XX-XX-XX responsible: XXXXXXXX address: XXXXX,1,2,3 address: 12345 country: XX phone: +11 11 1111111 owner-c: XXX tech-c: XXX abuse-c: XXX inetrev: 111.222/16 nserver: NS.example.com nsstat: 2010XXXX AA nslastaa: 2010XXXX nserver: NS2.example.com nsstat: 2010XXXX AA nslastaa: 2010XXXX created: 2010XXXX changed: 2010XXXX nic-hdl: XXX person: XXXXX e-mail: XXX@example.com address: XXXX 1 2 3 address: 1 XX address: XXXX 1 2 3 address: 1 XX country: XX phone: +XX XX XXXXXXX created: 20010XXXX changed: 2010XXXX % whois.lacnic.net accepts only direct match queries. % Types of queries are: POCs, ownerid, CIDR blocks, IP % and AS numbers. Regards, Fail2Ban |
また、/var/log/secure を見たところ実際に該当する IP からの ssh 認証失敗が数回(5回?)でストップしていました 🙂
これなかなか良いですね。
やられっぱなしではないというところが精神的に良いです
先日アウトレットへ行きました。
買い物をして楽しく過ごす予定でしたが、結果的に自分の体が太っている事を認識する為に行ったようなもので、帰る頃にはがっかり 😥
以前は履けたズボンがきつくて履けませんでした 😎
やばぃやばぃ
運動をしているのに太るって…
最近筋トレさぼっているのでまた再開しないとダメですね ❗
目標はベンチプレスで自分の体重と同じ重さを下まで深く降ろせるようにがんばります 🙂
下半身のトレーニングは嫌いなんですが膝強化もしたいのでレッグエクステンションを地道に続けます… 🙂
それからこれが一番大切なんですが、原因の間食をやめなくては 😉
#この時期は夏に向けてジムが混むんですよね~