ブログシステム - BLOG.BBTUNE.COM -

サーバー管理

ディレクトリサイズ、ファイル数の確認コマンド

ディレクトリ以下のサイズK
# du -s ./
96728 ./

ディレクトリ以下のサイズM
# du -s ./ -m
95 ./

ファイル数
# ls -laR | grep -c '^-'
12238
2009-05-10 10:45:36

[apache] usage ディレクトリが使われている?

----------------------------------------------------------------

Forbidden

You don't have permission to access /usage/ on this server.
Apache/2.2.3 (CentOS) Server at deepthink.net Port 80


----------------------------------------------------------------

とこんな感じで /usage/ というディレクトリを見る権限がありませんでした。
webalizerは使っていなかったので、別URIに変更します

# vi /etc/httpd/conf.d/webalizer.conf

# This configuration file maps the webalizer log analysis
# results (generated daily) into the URL space. By default
# these results are only accessible from the local host.
#
Alias /usage_new /var/www/usage

>Location /usage_new<
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
# Allow from .example.com
>/Location<


usage を usage_new として利用するよう変更。
2007-11-11 22:59:33

[SSH] sshの設定メモ

キー作成

# ssh-keygen -f /test/.ssh/new_identity -P "" -b 1024
Generating public/private rsa key pair.
Your identification has been saved in /test/.ssh/new_identity.
Your public key has been saved in /test/.ssh/new_identity.pub.
The key fingerprint is:
82:ce:f2:be:d1:73:43:cb:3d:90:21:c1:53:e3:62:bb test@aube.as4.org

ウケ側のユーザディレクトリに
.pub ファイルを authorized_keys として保存

これで rsync もパスワード入力の必要なく自動でOK
rsync -e 'ssh -i /test/.ssh/new_identity' -auz 192.168.1.198:/home/test/ /home/test/
2007-10-29 07:20:20

[HDD]ハードディスクコピーDD

DDコマンドでハードディスクコピーしてみました。

# hdparm /dev/hda
/dev/hda:
multcount = 16 (on)
IO_support = 0 (default 16-bit)
unmaskirq = 0 (off)
using_dma = 1 (on)
keepsettings = 0 (off)
readonly = 0 (off)
readahead = 256 (on)
geometry = 65535/16/63, sectors = 122942324736, start = 0
(このデータは、別のディスクです)

# hdparm /dev/sda

/dev/sda:
IO_support = 0 (default 16-bit)
readonly = 0 (off)
readahead = 256 (on)
geometry = 9730/255/63, sectors = 156312576, start = 0


hda -> sda とコピーしてみます。

hda を読み込み専用に
# hdparm -r 1 /dev/hda
dd コマンドでコピー開始!

# dd if=/dev/hda of=/dev/sda conv=sync,noerror bs=4096

80GB copied , 6438.23 seconds, 12.4MB/s

80GB1時間ほどで終わりました。

いちお中はちゃんとコピーできていたようです。
ただ、IDEからSATAコピーしたためか?
元のIDEにエラーがあったからか?
マシン自体変えたためドライバーが認識しないのか・・・
上手く起動できませんでしたー。ー;
grub を書き直してもダメでした。
とりあえずコピーできることはわかりました;


CentOS の LiveCD を起動してターミナルから
/usr/sbin/grub

grub > device (hd0) /dev/sda

grub > root (hd0,0)

Filesystem type is ext2fs, partition type 0x83

grub > setup (hd0)

Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2hs_stage1_5 exists ... yes
Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded. succeeded
Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded
Done,

こんなことも試しましたが、上手く起動しなかったので諦めました。
シリアルATAじゃなければたぶん問題なかったと思いますが。

次回はSATA同士のコピーをしてみます。
あとクライアントのWindowsもいけるか試して見ます。
2007-10-18 17:24:37

[Pound]Session振り分け

blog.bbtune.com はログインする必要があるので
blog.bbtune.comへアクセスしたときは、IPが同じ場合同じサーバへ接続するように設定。


LogLevel 4
LogFacility -

ListenHTTP
Address 192.168.1.201
Port 80
End


Service
HeadRequire "Host:.*blog.bbtune.com.*"

BackEnd
Address 192.168.1.198
Port 8888
End
Session
Type IP
TTL 6000
End
End

Service
BackEnd
Address 192.168.1.199
Port 80
End
BackEnd
Address 192.168.1.198
Port 8888
Priority 3
End
End


OK。
php の sessionid でもいけるか次回テスト。
2007-10-13 07:32:30

[HDD]HDD復旧。読み取り専用です?

正直あまり良いハードディスクを使っていなかったのが失敗です。
使い古しの80GB・・・
早く入れ替えないと・・・

サブマシンはすぐに動かしましたが。

なんとか5時間で復旧しました。。。
ハードディスクチェックに3時間ほどかかりました。

エラーが大量でした。。。

/dev/VolGroup00/LogVol00 contains a file system with errors, check forced.

再起動したところ、こんなエラーが出て
うう。。。
*** An error occurred during the file system check.
*** Dropping you to a shell; the system will reboot
*** when you leave the shell.
Give root password for maintenance
(or type Control-D to continue):
rootでログインして

# e2fsck -c -f /dev/VolGroup00/LogVol00

チェックが終了するとFixしますか?と聞かれるので
全部Yなので Enterを連打。

終了して、なんとか修復にしたようなメッセージが出たのでログアウトして再起動

・・・kernel panic init errorみたいな
マウントに失敗しています。
/dev/proc not found みたいなのがたくさん。

ぬーOS上がらないので、何も出来ない>。<;

CentOSのディスクを利用して起動。

boot : linux text

新規でCentOSを入れるか、Upgradeか聞かれる

/dev/VolGroup00/LogVol00

は認識されているのでこれをUpgrade!
bootローダーも上書きしてみる。

どきどき。。。

インストールします見たいな。感じで進んで行き。
Upgrade完了と。

ふぅ~OKか?ディスクを取り出して再起動!!!

HDD復旧成功!!!

しかし油断は出来ないので、早いうちに、HDDコピーして交換しないと。
ddコマンドで出来るのかな?15時間とかかかるらしいですが・・・

サブマシンというか最新のメインマシンをそろそろ用意しないと危険です。
2007-09-10 04:31:53

sudo : tty error

apache が rsync を利用できるように sudoを

sorry, you must have a tty to run sudo

# visudo

この行をコメントアウト
# Defaults requiretty

のように変更しました。
2007-08-05 01:27:44

[CentOS 5] Samba の初期設定

Samba の設定。CentOS 5

// ------------------------------
// config

# /etc/samba/smb.conf

#
workgroup = MYGROUP
#
server name = Rooney

# ローカルネットワーク
hosts allow = 192.168.1.

[opt]
comment = Rooney OPT
path = /opt
valid users = jun
public = no
writable = yes
printable = no
create mask = 0765



// -------------------------------
// New User
[ adduser ]で作成済みのユーザに対して

ユーザ作成、パス設定
# smbpasswd -a jun
New SMB password:
Retype new SMB password:
Added user jun.

// -------------------------------
// iptables

# /etc/sysconfig/iptables

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -s 192.168.1.0/26 -p tcp --dport 137:139 -j ACCEPT

137-139を許可する。

再起動したらOK
2007-08-03 16:33:37

[pound apache]ログの ip address

pound 経由の remote_host はpoundサーバのアドレスなので

x-forwarded-for を利用します。

Apache /httpd.conf
のLogFormatディレクティブで

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-Forwarded-For}i\"" combined

%{X-Forwarded-For}i にx-forwarded-forが入ります。

phpから呼び出すときは
$_SERVER['HTTP_X_FORWARDED_FOR']
です。

poundを使ってすべてプロキシ経由なので

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

こうして利用します。
pound だけでログを保管しても良いのですが、まぁログ分散して処理しても同じだから良いかな
でも一括で集計して数値計算までしたほうが良いかな。。。

==================================

httpd.conf と php $_SERVER の関係

例えば独自のフラグでhttpd.confに
SetEnvIf X-FORWARDED-FOR "^192.168.1.11" MY_PC
と書くと
$_SERVER['MY_PC'] = 1;
と設定されていました。

振り分けフラグに使えそうですね。
2007-07-30 07:51:37

[HA][heartbeat][pound][pgpool]落ちないサーバ構成

このような状態で動かし始めます。


すべてが動いている状態

server A | server B
|
virtual ip[Z] | no
|
heartbeat[A] | heartbeat[B]
|
ip[A] | ip[B]
|
pound[A] | pound[B]
|
httpd[A] | httpd[B]
|
pgpool[A] | pgpool[B]
|
postgregsql[A] | postgresql[B]


起動状態

virtual ip[Z] | no
|
heartbeat[A] <監視> heartbeat[B]
|
ip[Z]pound[A]
|
httpd[A] =並列= httpd[B]
|
ip[Z]pgpool[A]
|
postgresql[A] =並列同期= postgresql[B]

[B] が落ちたらそのまま、[B]が切れます。

[A]が落ちたら heartbeat[B] によって仮想IPを変更します。

!フェールオーバー!

| virtual ip[Z]
|
?heartbeat[A]? <監視> heartbeat[B]
|
ip[Z]pound[B]
|
?httpd[A]? =並列= httpd[B]
|
ip[Z]pgpool[B]
|
?postgresql[A]?=並列同期= postgresql[B]


基本的に[A]は落ちているので、[B]だけで動いていると考えます。

!フェールバック!
Aが回復したら自動でフェールバックしたいところですが
ここでは、postgresqlのデータが[B]が最新になっているので、勝手に復活することは許されませんので、
手動で確認するまでフェールバックはさせない。
(Bに関しても同期が取れていないので同じです。)

こんな感じで作ってみたいと思います。
2007-07-26 09:47:58
引越
Google Android
S11HT emonster
windows mobile
silverlight
podcast
apple
ssh
Perl
samba ファイルサーバ
ludia
pound
High Availavility高可用性
pgpool
Google Maps API
Ruby
Postfix
プロバイダー
javascript
PostgreSQL
システム監査
HDD換装
時計
Felica
C#
携帯用サイト作成関連
ネットワーク
XML + XSLT
W-ZERO3 willcom
MySQL
さくらの専用サーバ
ブログ関連
Apache
サーバー管理
情報処理試験
データベース
PHP
Unix-Linux
動画関連メモ
人気商品情報
アマゾン関連
追加機能予定
システムメモ

サーバー管理 記事一覧
ディレクトリサイズ、ファイル数の確認コマンド
[apache] usage ディレクトリが使われている?
[SSH] sshの設定メモ
[HDD]ハードディスクコピーDD
[Pound]Session振り分け
[HDD]HDD復旧。読み取り専用です?
sudo : tty error
[CentOS 5] Samba の初期設定
[pound apache]ログの ip address
[HA][heartbeat][pound][pgpool]落ちないサーバ構成
RSYNC ディレクトリを除外
Bit Torrent = Peer to Peer
WGET のタイムアウト
[Postfix]特定の送信先のみ許可する。
ファイルを大量削除
[Postfix]Postfix で SMTP AUTH
PNG ZLIB GD 入れなおし。
LimitRequestBody / ファイルサイズ制限
.htaccess で 拒否設定。 Referer が自分のサイトか?もしくは・・・の場合^-^。
sudo -u user で他のユーザ権限で実行!
さくらの専用サーバにSSH設定。
さくらの専用サーバ
VMM ? サーバの仮想化で得られるもの?