6.14.2013

[VMware]ESXi Shellを有効にするとSSHへのクラスタ警告が出る

vSphereでホストにログイン後、下記の警告が出る







「構成」タブを選択
「ソフトウェア」枠の「詳細設定」を選択
「UserVars」を選択
「UserVars.SuppressShellWarning」の値を0から1に変更

上記、設定後確認すると警告が消える

4.22.2013

[Linux] File systemがおかしくなったときの対処方法

Linuxが不意のシャットダウンや強制終了をした際に、起動時に
file systemがおかしくなり起動できなくなった場合に対処する方法をメモ

例えば下記のerrorが発生したとき
----------------------------------------------------
Checking filesystems
/dev/VolGroup00/LogVol00 contains a file system with errors, check forced.
/dev/VolGroup00/LogVol00: Inodes that were part of a corrupted orphan linked list found.
/dev/VolGroup00/LogVol00: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
        (i.e., without -a or -p options)
                                                         [FAILED]

*** An error occurred during the file system check.
*** Dropping you to a shell; the system will rebbot
*** when you leave the shell.
Give root password for maintenance
(or type Control-D to continue):【root passwordを入力】
----------------------------------------------------

ログイン後、下記が表示される
(Repair filesystem) 1 # 

mountにてディスク情報を取得
(Repair filesystem) 1 # mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

mount: warning: /etc/mtab is not writable (e.g. read-only filesystem). 
       It's possible that information reported by mount(8) is not
       up to date. For actual information about system mount points
       check the /proc/mounts file.

(Repair filesystem) 2 # 

ディスク修復作業(途中でtab押せば保管される)
パーティションやディスクブロックは、修復箇所により変更されます。
自分が修復した際は下記の内容が出てました。

(Repair filesystem) 2 # fsck -t ext3 /dev/mapper/VolGroup00-LogVol00
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
/dev/mapper/VolGroup00-LogVol00 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inodes that were part of a corrupted orphan linked list found. Fix? y

Inode 2555572 was part of the orphaned inode list. FIXED.
Inode 9059010 was part of the orphaned inode list. FIXED.
Deleted inode 9059012 has zero dtime. Fix? y

Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences:  -(2603277--2603283) -(2603289--2603291) -(2603315--2603321)
-(2603323--2603329) -(2603331--2603333) -(2603336--2603344) -9077760 -(9082880--9082882)
Fix? yes

Free blocks count wrong for group #79 (8309, counted=8345).
Fix? y

Free blocks count wrong for group #277 (31735, counted=31739).
Fix? y

Free bolock count wrong (11323080, counted=11323120).
Fix? y

Inode bitmap differences: -2555572 -9059010 -9059012
Fix? y

Free inodes count wrong for group #78 (27706, counted=27707).
Fix? y

Free inodes count wrong for group #277 (32698, counted=32700).
Fix? y

Directories count wrong for group #277 (3, counted=2).
Fix? y

Free inodes count wrong (12444755, counted=12444758).
Fix? y


/dev/mapper/VolGroup00-LogVol00: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mapper/VolGroup00-LogVol00: ***** REBOOT LINUX *****
/dev/mapper/VolGroup00-LogVol00: 113578/12558336 files (1.7% non-contiguous), 1235216/12558336 blocks
(Repair filesystem) 3 # reboot

再起動して完了

3.12.2013

[Linux]shell上のwhile内の変数をwhileの外で利用したい

暫くはまったのでメモ

shellで作ったスクリプトのwhile内で利用した配列変数を
whileの外で利用しようとして、使えないという落とし穴に
はまってしまう人がいるかと・・・・Orz

whileの利用方法に問題があるんですねぇ^^;

例えば、外部ファイルをwhileで行単位に読み込んで
配列変数に入れ込み、それをwhileの外で利用したい場合に
下記2パターンで試すと片方は使えない。

1パターンは成功
2パターンは失敗

「test.txt」ファイル内容
A
B
C

「test.sh」ファイル内容
-------------------
■1パターン
#!/bin/sh

FILENAME=$1
i=0
ARRAY=()

while read line
do
 ARRAY[${i}]="${line}"
 ((i++))
done < ${FILENAME}

echo "${ARRAY[@]}"

結果
#./test.sh test.txt
A B C

-------------------
■2パターン
#!/bin/sh

FILENAME=$1
i=0
ARRAY=()

cat ${FILENAME} | while read line
do
 ARRAY[${i}]="${line}"
 ((i++))
done

echo "${ARRAY[@]}"

結果
#./test.sh test.txt
【空白】
-------------------

1と2の違い
<(レフトアングル)でwhileにファイルを読み込ませるか、
|(パイプ)でwhileにファイルを読み込ませるか。

結果
|(パイプ)を利用してwhileに読み込ませると、whileの
外で変数を使用しても結果は【空白】になってしまう。

いやぁ、簡単なことだけに簡単に落とし穴にはまって出てこれないというワナ。。。Orz

以上