在上半部分中,TechTarget中国的特约虚拟化专家Andrew Kutz在发生错误时,Linux文件系统能配置成哪三种不同的模式,并且描述了为什么我们要使用第二种重启后为只读的模式以及这种模式在结合使用ESX时有什么问题。本文我们将详细解释解决这些问题的方法。
现在我们来详细讲解这些选项。
选项1:执行VMware修复
许多用户在VMware论坛上抱怨关于路径故障的问题,VMware必须作出反应,所以他们为一小部分Linux版本发布了技术基础文章和解决方案。现在为止,补丁所支持的Linux版本有Red Hat Enterprise Linux 3和4以及SUSE Linux Enterprise Server 9 SP3。如果你所管理的虚拟机使用的是这些操作系统里的一种作为子操作系统的话,那么可以得到在“VMware's support Web site under KB 51306”得到修复支持。
选项2:修复内核模块源(kernel module source)
如果你的Linux版本不属于VMware补丁支持的范畴,也可以修复这个问题。我们可以对虚拟机隐瞒文件里发生了一个问题,以便阻止文件系统错误。
现在,多数装载软件包管理系统的Linux版本装载了内核源和内核header包,如RPM或DEB。要修补的话,内核源和内核header包都要设置,因为header包里包含最新的.config文件。为了下载Ubuntu Linux源和header包,只需输入:
sudo apt-get install linux-source-`uname -r | sed "s/-.*//g"` linux- headers-`uname -r`
更改目录到/usr/src,这有个目录用于存放header包,不过不存放源。你需要释放源工具包:
tar xjf linux-source-`uname -r | sed "s/-.*//g"`.tar.bz2
用编辑器打开文件“/usr/src/linux-source- `uname -r | sed "s/-.*//g"`/drivers/message/fusion/mptscsi.h”。在739行左右出现下面这样的字段:
if (scsi_status == MPI_SCSI_STATUS_BUSY)
sc->result = (DID_BUS_BUSY << 16) | scsi_status; else
sc->result = (DID_OK << 16) | scsi_status;
更换这个字段的第二行,如下所示:
if (scsi_status == MPI_SCSI_STATUS_BUSY)
// sc->result = (DID_BUS_BUSY << 16) | scsi_status;
sc->result = (DID_OK << 16) | scsi_status; else
sc->result = (DID_OK << 16) | scsi_status;
保存文件退出编辑。从header的根目录复制.config文件到源的根目录。www.britepic.org更改目录到源目录并运行:
make oldconfig
这个命令将从复制到源目录的header包解析.config文件,接下来的命令需要执行一段时间:
make modules
下一步是用新内核模式取代旧的。在这样做之前,请确保备份了旧内核模式,然后输入:
cp /lib/modules/`uname -r`/kernel/drivers/message/fusion/mptscsih.ko / lib/modules/`uname -r`/kernel/drivers/message/fusion/mptscsih.ko.bak
现在复制新文件取代上面的:
cp /usr/src/linux-source-`uname -r | sed "s/-.*//g"`/drivers/message/ fusion/mptscsih.ko /lib/modules/`uname -r`/kernel/drivers/message/ fusion/
重启服务器,系统就不再那么容易出现路径故障了。
如果你运行的是Ubuntu虚拟机,内核版本为2.6.15-28-686,想走捷径的话继续往下看。我已经上传了已修改好的源和内核对象文件到我的网站上,你可以直接去网站下载。这个文件是mptscsih.tar.gz。
选项3:Email通知
如果Linux虚拟机不受VMware补丁的支持,你也不太愿意修改内核源的话,你至少应该配置虚拟机,以便发生问题时你能知道。一种方法是创建一个脚本,每10分钟运行一次或随你所选。下面是一个脚本例子:
#!/bin/bash
#
# use the first argument to this script as the
# email address to send notifications to
TO="$1"
#
# get the output from the mount command
#
MOUNT_OUT=`mount`
#
# see if the string 'ro' exists in the
# output of the mount command. be careful,
# if there is a CD-ROM inserted into the
# server this will always be true and you
# will get a lot of false positives
echo $MOUNT_OUT | grep \(ro\)
#
# get the return code for the grep
# operation.
#
RO=$?
#
# grep returns an exit code
# of 0 if there is a match
#
if [ "$RO" = "0" ]
then
#
# send an e-mail notification saying
# that there is a file-system that
# has been mounted as read-only
#
BODY=$MOUNT_OUT
echo read-only file systems found
echo $BODY
`which sendmail` -f root@`hostname --fqdn` -t << FooBar
From: root@`hostname --fqdn`
To: $TO
Subject: `hostname` has read-only file systems $BODY
FooBar
#
# exit with a status code of 1 if
# read-only file systems were found
#
exit 1
fi
#
# exit with a status code of 0 if no
# read-only file systems were found
#
exit 0
安装这个脚本,不要忘记给它一个邮箱地址。如果虚拟机的一个文件系统重启为只读时,它会提醒你,给你忽略这个问题的机会。记住,这个脚本假定你运行的是本地邮件服务器,不过也可以修改成通过中继主机发送邮件。
在ESX上的虚拟机文件系统重启为只读时会发生问题,不过有多种方法解决这个问题。如果你还有其他问题的话,请发送邮件到editor@searchservervirtualization.com。
