20090326
■現状確認
[root@Cent-web ~]# df -m
Filesystem 1M-ブロック 使用 使用可 使用% マウント位置
/dev/sda4 5946 2708 2936 48% /
/dev/sda1 99 12 82 13% /boot
none 252 0 252 0% /dev/shm
/dev/sda3 2016 132 1782 7% /var
■fdisk実行
[root@Cent-web ~]# fdisk /dev/sdb
デバイスは正常な DOS 領域テーブルも、Sun, SGI や OSF ディスクラベルも
含んでいません
新たに DOS ディスクラベルを作成します。あなたが書き込みを決定するまで、変更は
メモリ内だけに残します。その後はもちろん以前の内容は修復不可能になります。
このディスクのシリンダ数は 1566 に設定されています。
間違いではないのですが、1024 を超えているため、以下の場合
に問題を生じうる事を確認しましょう:
1) ブート時に実行するソフトウェア (例. バージョンが古い LILO)
2) 別の OS のブートやパーティション作成ソフト
(例. DOS FDISK, OS/2 FDISK)
警告: 領域テーブル 4 の不正なフラグ 0x0000 は w(書き込み)によって正常になります
コマンド (m でヘルプ): m
コマンドの動作
a ブート可能フラグをつける
b bsd ディスクラベルを編集する
c dos 互換フラグをつける
d 領域を削除する
l 既知の領域タイプをリスト表示する
m このメニューを表示する
n 新たに領域を作成する
o 新たに空の DOS 領域テーブルを作成する
p 領域テーブルを表示する
q 変更を保存せずに終了する
s 空の Sun ディスクラベルを作成する
t 領域のシステム ID を変更する
u 表示/項目ユニットを変更する
v 領域テーブルを照合する
w テーブルをディスクに書き込み、終了する
x 特別な機能 (エキスパート専用)
コマンド (m でヘルプ): p
Disk /dev/sdb: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes
デバイス Boot Start End Blocks Id System
コマンド (m でヘルプ): n
コマンドアクション
e 拡張
p 基本領域 (1-4)
p
領域番号 (1-4): 1
最初 シリンダ (1-1566, default 1): 1
終点 シリンダ または +サイズ または +サイズM または +サイズK (1-1566, default 1566): 700
コマンド (m でヘルプ): n
コマンドアクション
e 拡張
p 基本領域 (1-4)
p
領域番号 (1-4): 2
最初 シリンダ (701-1566, default 701): 701
終点 シリンダ または +サイズ または +サイズM または +サイズK (701-1566, default 1566): 1100
コマンド (m でヘルプ): n
コマンドアクション
e 拡張
p 基本領域 (1-4)
p
領域番号 (1-4): 3
最初 シリンダ (1101-1566, default 1101): 1101
終点 シリンダ または +サイズ または +サイズM または +サイズK (1101-1566, default 1566): 1566
コマンド (m でヘルプ): p
Disk /dev/sdb: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes
デバイス Boot Start End Blocks Id System
/dev/sdb1 1 700 5622718+ 83 Linux
/dev/sdb2 701 1100 3213000 83 Linux
/dev/sdb3 1101 1566 3743145 83 Linux
コマンド (m でヘルプ): w
領域テーブルは交換されました!
ioctl() を呼び出して領域テーブルを再読込みします。
ディスクを同期させます。
■ext3でフォーマット
[root@Cent-web ~]# mke2fs -j /dev/sdb1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
703136 inodes, 1405679 blocks
70283 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1442840576
43 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
■同様にパーティション2,3もフォーマット
[root@Cent-web ~]# mke2fs -j /dev/sdb2
[root@Cent-web ~]# mke2fs -j /dev/sdb3
■ラベルの割当
[root@Cent-web ~]# e2label /dev/sdb1 /iw
[root@Cent-web ~]# e2label /dev/sdb2 /apps
[root@Cent-web ~]# e2label /dev/sdb3 /export
■ファイルシステムチェック
[root@Cent-web ~]# e2fsck /dev/sdb1
e2fsck 1.35 (28-Feb-2004)
/ts: clean, 11/703136 files, 33027/1405679 blocks
[root@Cent-web ~]# e2fsck /dev/sdb2
e2fsck 1.35 (28-Feb-2004)
/apps: clean, 11/402400 files, 22021/803250 blocks
[root@Cent-web ~]# e2fsck /dev/sdb3
e2fsck 1.35 (28-Feb-2004)
/export: clean, 11/468640 files, 24751/935786 blocks
■マウントポイントの作成
[root@Cent-web ~]# mkdir /nfs/iw
[root@Cent-web ~]# mkdir /nfs/apps
[root@Cent-web ~]# mkdir /nfs/export
■/etc/fstabに追記
LABEL=/iw /nfs/iw ext3 defaults 1 2
LABEL=/apps /nfs/apps ext3 defaults 1 2
LABEL=/export /nfs/export ext3 defaults 1 2
■マウント
[root@Cent-web ~]# mount -a
確認
[root@Cent-web ~]# mount grep sdb
/dev/sdb1 on /nfs/iw type ext3 (rw)
/dev/sdb2 on /nfs/apps type ext3 (rw)
/dev/sdb3 on /nfs/export type ext3 (rw)
■公開ディレクトリの設定
[root@Cent-web ~]# vi /etc/exports
/nfs/iw *(rw,sync,no_root_squash)
/nfs/apps *(rw,sync,no_root_squash)
/nfs/export *(rw,sync,no_root_squash)
■NFSサービス起動
[root@Cent-web ~]# /etc/init.d/nfs start
NFS サービスを起動中: [ OK ]
NFS クォータを起動中: [ OK ]
NFS デーモンを起動中: [ OK ]
NFS mountd を起動中: [ OK ]
■NFSサービス起動設定
[root@Cent-web ~]# chkconfig --level 3 nfs on
[root@Cent-web ~]# chkconfig --level 5 nfs on
■NFSクライアントが起動時にマウントする設定
[root@iwts04 iw]# cat /etc/fstab
(下記を追記)
# NFS mount settings
192.168.216.180:/nfs/iw /opt/iw nfs nfsvers=3,rsize=32768,wsize=32768,rw,hard,intr 0 0
192.168.216.180:/nfs/apps /apps nfs nfsvers=3,rsize=32768,wsize=32768,rw,hard,intr 0 0
192.168.216.180:/nfs/export /export nfs defaults 0 0
■手動マウント
mount -t nfs -o nfsvers=3,rsize=32768,wsize=32768,rw,hard,intr 192.168.216.180:/nfs/export /export
mount -t nfs -o nfsvers=3,rsize=32768,wsize=32768,rw,hard,intr 192.168.216.180:/nfs/iw /opt/iw
2009年3月26日木曜日
2008年6月14日土曜日
アクセスログ出力サンプル
_____________________________
index_access.pl
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
#!/usr/bin/perl --
#=================================================================
# 時刻設定
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
$mon = $mon + 1;
$thisday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$wday];
$jikoku = sprintf("%04d/%02d/%02d (%03s) %02d:%02d:%02d", $year, $mon, $mday, $thisday, $hour, $min, $sec);
# 環境変数の取得
$ip = $ENV{'REMOTE_ADDR'}; #// リモート端末のIP アドレス
$port = $ENV{'REMOTE_PORT'}; #// リモート端末のポート番号
$url = $ENV{'HTTP_REFERER'}; #// リモート端末の直前の URL
$blws = $ENV{'HTTP_USER_AGENT'}; #// ブラウザ情報
$path = $ENV{'PATH_INFO'}; #// 現 CGI のパス情報
$rtpc = $ENV{'REMOTE_HOST'}; #// リモート端末のホスト名
$svpc = $ENV{'SERVER_NAME'}; #// サーバのホスト名
$webs = $ENV{'SERVER_SOFTWARE'}; #// ウェブサーバのソフト名と ver
$wcgi = $ENV{'GATEWAY_INTERFACE'}; #// ウェブサーバの CGI ver
#===============================================================
open(FILE,">>index_access.log") or die "$!";
flock(FILE,2);
print FILE "$jikoku,$ip,$port,$url,$rtpc,$blws\n";
flock(FILE,8);
close(FILE);
#// 終了
exit(0);
_____________________________
呼び出し側HTML(一部)
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
index_access.pl
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
#!/usr/bin/perl --
#=================================================================
# 時刻設定
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
$mon = $mon + 1;
$thisday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$wday];
$jikoku = sprintf("%04d/%02d/%02d (%03s) %02d:%02d:%02d", $year, $mon, $mday, $thisday, $hour, $min, $sec);
# 環境変数の取得
$ip = $ENV{'REMOTE_ADDR'}; #// リモート端末のIP アドレス
$port = $ENV{'REMOTE_PORT'}; #// リモート端末のポート番号
$url = $ENV{'HTTP_REFERER'}; #// リモート端末の直前の URL
$blws = $ENV{'HTTP_USER_AGENT'}; #// ブラウザ情報
$path = $ENV{'PATH_INFO'}; #// 現 CGI のパス情報
$rtpc = $ENV{'REMOTE_HOST'}; #// リモート端末のホスト名
$svpc = $ENV{'SERVER_NAME'}; #// サーバのホスト名
$webs = $ENV{'SERVER_SOFTWARE'}; #// ウェブサーバのソフト名と ver
$wcgi = $ENV{'GATEWAY_INTERFACE'}; #// ウェブサーバの CGI ver
#===============================================================
open(FILE,">>index_access.log") or die "$!";
flock(FILE,2);
print FILE "$jikoku,$ip,$port,$url,$rtpc,$blws\n";
flock(FILE,8);
close(FILE);
#// 終了
exit(0);
_____________________________
呼び出し側HTML(一部)
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
2008年4月16日水曜日
nkfのインストール
20080416
■ダウンロード
http://www01.tcp-ip.or.jp/~furukawa/nkf_utf8/nkf205.tar.gz
[root@asp-eim-apdb installer]# tar zxvf nkf205.tar.gz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: 処理中にエラーが起きましたが、最後まで処理してからエラー終了させました
↑サーバ上で解凍しようとしたがうまくいかないのでWindowsで解凍してからFTP。
[root@asp-eim-apdb nkf205]# make
cc -O -c utf8tbl.c
cc -O -o nkf nkf.c utf8tbl.o
[root@asp-eim-apdb nkf205]# make test
perl test.pl
Basic Conversion test
JIS to JIS ... Ok
JIS to SJIS... Ok
JIS to EUC ... Ok
(中略)
test_data/z1space-1 Ok
test_data/z1space-2 Ok
■バイナリファイルを配置
[root@asp-eim-apdb nkf205]# cp nkf /usr/bin/
■英語のマニュアルを配置
[root@asp-eim-apdb nkf205]# cp nkf.1 /usr/share/man/man1/
使用例)UTF8コードに変換する
nkf -w oracle_sjis/create_documentdb.sql > oracle_utf8/create_documentdb.sql
使用例)シフトJISコードに変換する
nkf -s oracle_utf8/create_documentdb.sql > oracle_sjis/create_documentdb.sql
※EUCコードに変換するなら、-e オプション。
■ダウンロード
http://www01.tcp-ip.or.jp/~furukawa/nkf_utf8/nkf205.tar.gz
[root@asp-eim-apdb installer]# tar zxvf nkf205.tar.gz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: 処理中にエラーが起きましたが、最後まで処理してからエラー終了させました
↑サーバ上で解凍しようとしたがうまくいかないのでWindowsで解凍してからFTP。
[root@asp-eim-apdb nkf205]# make
cc -O -c utf8tbl.c
cc -O -o nkf nkf.c utf8tbl.o
[root@asp-eim-apdb nkf205]# make test
perl test.pl
Basic Conversion test
JIS to JIS ... Ok
JIS to SJIS... Ok
JIS to EUC ... Ok
(中略)
test_data/z1space-1 Ok
test_data/z1space-2 Ok
■バイナリファイルを配置
[root@asp-eim-apdb nkf205]# cp nkf /usr/bin/
■英語のマニュアルを配置
[root@asp-eim-apdb nkf205]# cp nkf.1 /usr/share/man/man1/
使用例)UTF8コードに変換する
nkf -w oracle_sjis/create_documentdb.sql > oracle_utf8/create_documentdb.sql
使用例)シフトJISコードに変換する
nkf -s oracle_utf8/create_documentdb.sql > oracle_sjis/create_documentdb.sql
※EUCコードに変換するなら、-e オプション。
2008年1月17日木曜日
シスログ管理
20080117
システムログを別ホストのログ管理サーバに出力させるための手順。
■手順概要
1) ログ管理サーバ側でリモートホストから出力されるログを受け取れるようにする。
2) リモートホスト側でログ管理サーバにログを出力する。
_______________________________
1) ログ管理サーバの設定 192.168.24.17
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
■/etc/init.d/syslog の設定
[root@RHEL4 ~]# vi /etc/init.d/syslog
--------------------vi syslog------------------------------------
SYSLOGD_OPTIONS="-m 0 -r" ← -r オプションを追記
-----------------------------------------------------------------
■設定を反映させる
[root@RHEL4 ~]# /etc/init.d/syslog restart
カーネルロガーを停止中: [ OK ]
システムロガーを停止中: [ OK ]
システムロガーを起動中: [ OK ]
カーネルロガーを起動中: [ OK ]
/var/log/messages には下記のように出力される
Jan 17 18:56:13 RHEL4 kernel: Kernel logging (proc) stopped.
Jan 17 18:56:13 RHEL4 kernel: Kernel log daemon terminating.
Jan 17 18:56:14 RHEL4 syslog: klogd 停止 succeeded
Jan 17 18:56:14 RHEL4 exiting on signal 15
Jan 17 18:56:14 RHEL4 syslogd 1.4.1: restart (remote reception).
Jan 17 18:56:15 RHEL4 syslog: syslogd 起動 succeeded
Jan 17 18:56:15 RHEL4 syslog: klogd 起動 succeeded
Jan 17 18:56:15 RHEL4 kernel: klogd 1.4.1, log source = /proc/kmsg started.
Jan 17 18:56:14 RHEL4 syslog: syslogd 停止 succeeded
_______________________________
2) リモートホストの設定 192.168.24.18
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
■/etc/syslog.conf の設定
[root@hoge2 ~]# vi /etc/syslog.conf
--------------------vi syslog.conf-----------------------------------
*.info;mail.none;authpriv.none;cron.none @192.168.24.17
---------------------------------------------------------------------
■設定を反映させる
[root@hoge2 ~]# /etc/init.d/syslog restart
カーネルロガーを停止中: [ OK ]
システムロガーを停止中: [ OK ]
システムロガーを起動中: [ OK ]
カーネルロガーを起動中: [ OK ]
ログ管理サーバの /var/log/messages には下記のように出力された!
Jan 17 19:06:59 192.168.24.18 syslogd 1.4.1: restart.
Jan 17 19:06:59 192.168.24.18 syslog: syslogd 起動 succeeded
Jan 17 19:06:59 192.168.24.18 kernel: klogd 1.4.1, log source = /proc/kmsg started.
Jan 17 19:06:59 192.168.24.18 syslog: klogd 起動 succeeded
Jan 17 19:07:02 192.168.24.18 syslog: syslogd 停止 succeeded
■参考サイト
http://www.atmarkit.co.jp/flinux/rensai/root03/root03a.html
システムログを別ホストのログ管理サーバに出力させるための手順。
■手順概要
1) ログ管理サーバ側でリモートホストから出力されるログを受け取れるようにする。
2) リモートホスト側でログ管理サーバにログを出力する。
_______________________________
1) ログ管理サーバの設定 192.168.24.17
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
■/etc/init.d/syslog の設定
[root@RHEL4 ~]# vi /etc/init.d/syslog
--------------------vi syslog------------------------------------
SYSLOGD_OPTIONS="-m 0 -r" ← -r オプションを追記
-----------------------------------------------------------------
■設定を反映させる
[root@RHEL4 ~]# /etc/init.d/syslog restart
カーネルロガーを停止中: [ OK ]
システムロガーを停止中: [ OK ]
システムロガーを起動中: [ OK ]
カーネルロガーを起動中: [ OK ]
/var/log/messages には下記のように出力される
Jan 17 18:56:13 RHEL4 kernel: Kernel logging (proc) stopped.
Jan 17 18:56:13 RHEL4 kernel: Kernel log daemon terminating.
Jan 17 18:56:14 RHEL4 syslog: klogd 停止 succeeded
Jan 17 18:56:14 RHEL4 exiting on signal 15
Jan 17 18:56:14 RHEL4 syslogd 1.4.1: restart (remote reception).
Jan 17 18:56:15 RHEL4 syslog: syslogd 起動 succeeded
Jan 17 18:56:15 RHEL4 syslog: klogd 起動 succeeded
Jan 17 18:56:15 RHEL4 kernel: klogd 1.4.1, log source = /proc/kmsg started.
Jan 17 18:56:14 RHEL4 syslog: syslogd 停止 succeeded
_______________________________
2) リモートホストの設定 192.168.24.18
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
■/etc/syslog.conf の設定
[root@hoge2 ~]# vi /etc/syslog.conf
--------------------vi syslog.conf-----------------------------------
*.info;mail.none;authpriv.none;cron.none @192.168.24.17
---------------------------------------------------------------------
■設定を反映させる
[root@hoge2 ~]# /etc/init.d/syslog restart
カーネルロガーを停止中: [ OK ]
システムロガーを停止中: [ OK ]
システムロガーを起動中: [ OK ]
カーネルロガーを起動中: [ OK ]
ログ管理サーバの /var/log/messages には下記のように出力された!
Jan 17 19:06:59 192.168.24.18 syslogd 1.4.1: restart.
Jan 17 19:06:59 192.168.24.18 syslog: syslogd 起動 succeeded
Jan 17 19:06:59 192.168.24.18 kernel: klogd 1.4.1, log source = /proc/kmsg started.
Jan 17 19:06:59 192.168.24.18 syslog: klogd 起動 succeeded
Jan 17 19:07:02 192.168.24.18 syslog: syslogd 停止 succeeded
■参考サイト
http://www.atmarkit.co.jp/flinux/rensai/root03/root03a.html
2007年10月14日日曜日
swap領域追加
■現状確認
[root@tanyao /]# cat /proc/swaps
Filename Type Size Used Priority
/dev/mapper/VolGroup00-LogVol01 partition 524280 37132 -1
■2GB(1024k x 2048byte = 2097152)のswap領域を/swap/swapに作成する
[root@tanyao /]# mkdir swap
[root@tanyao /]# dd if=/dev/zero of=/swap/swap bs=1024 count=2097152
2097152+0 records in
2097152+0 records out
2147483648 bytes (2.1 GB) copied, 58.53 seconds, 36.7 MB/s
[root@tanyao /]# mkswap /swap/swap
Setting up swapspace version 1, size = 2147479 kB
[root@tanyao /]# swapon /swap/swap
→完了
確認してみると、
[root@tanyao /]# cat /proc/swaps
Filename Type Size Used Priority
/dev/mapper/VolGroup00-LogVol01 partition 524280 37132 -1
/swap/swap file 2097144 0 -2
または、
[root@tanyao /]# swapon -s
Filename Type Size Used Priority
/dev/mapper/VolGroup00-LogVol01 partition 524280 37132 -1
/swap/swap file 2097144 0 -2
■起動時に確保されるように…。
/etc/fstab を vi で開いて、下記を追加。
/swap/swap swap swap defaults 0 0
[root@tanyao /]# cat /proc/swaps
Filename Type Size Used Priority
/dev/mapper/VolGroup00-LogVol01 partition 524280 37132 -1
■2GB(1024k x 2048byte = 2097152)のswap領域を/swap/swapに作成する
[root@tanyao /]# mkdir swap
[root@tanyao /]# dd if=/dev/zero of=/swap/swap bs=1024 count=2097152
2097152+0 records in
2097152+0 records out
2147483648 bytes (2.1 GB) copied, 58.53 seconds, 36.7 MB/s
[root@tanyao /]# mkswap /swap/swap
Setting up swapspace version 1, size = 2147479 kB
[root@tanyao /]# swapon /swap/swap
→完了
確認してみると、
[root@tanyao /]# cat /proc/swaps
Filename Type Size Used Priority
/dev/mapper/VolGroup00-LogVol01 partition 524280 37132 -1
/swap/swap file 2097144 0 -2
または、
[root@tanyao /]# swapon -s
Filename Type Size Used Priority
/dev/mapper/VolGroup00-LogVol01 partition 524280 37132 -1
/swap/swap file 2097144 0 -2
■起動時に確保されるように…。
/etc/fstab を vi で開いて、下記を追加。
/swap/swap swap swap defaults 0 0
登録:
投稿 (Atom)