一.故障1:机器hangs

本地一台cloudstack计算节点无故连不上了,cloudstack也坏了,后查看有一台系统虚拟机在这台计算节点上,导致cs挂了。去找到这台机器后,发现这台机器卡住了,重启后卡在starting udev,等好久也不行,即使进入单用户也是一样,重启很多次也是卡在这。最后查到一篇文章,原话:

Remove quiet from the kernel command line and you should get enough output to see the cause of the hang.

然后进入系统菜单,在编辑kernel行,quiet静默模式。相当于设置"loglevel=4"(WARNING)。将quiet删除后,等待进入系统。大概一个小时后,进去系统了,能ssh了,问题解决了一个,得查一下机器为什么重启。

二.故障2:kvm计算机点为什么无故重启

通过查看cloudstack-agent的日志。

[root@kvm204 ~]# tail -1000f /var/log/cloudstack/agent/cloudstack-agent.out 

看到了这里有报警,并且执行了reboot命令。继续往上面翻,又看到一条信息,如下:

看到很多这样的报错,但最后一次报错是下面这个,可能是它导致了kvm检测脚本执行了reboot命令,然后就出现了本文第一张图片日志里reboot the host。

现在知道了是谁重启了电脑,但kvm为什么会重启这台计算节点呢?带着疑问,我去查看了一下那个脚本,也就是kvmheartbeat.sh脚本。内容如下:

#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License. help() {
printf "Usage: $0
-i nfs server ip
-p nfs server path
-m mount point
-h host
-r write/read hb log
-c cleanup
-t interval between read hb log\n"
exit
}
#set -x
NfsSvrIP=
NfsSvrPath=
MountPoint=
HostIP=
interval=
rflag=
cflag= while getopts 'i:p:m:h:t:rc' OPTION
do
case $OPTION in
i)
NfsSvrIP="$OPTARG"
;;
p)
NfsSvrPath="$OPTARG"
;;
m)
MountPoint="$OPTARG"
;;
h)
HostIP="$OPTARG"
;;
r)
rflag=
;;
t)
interval="$OPTARG"
;;
c)
cflag=
;;
*)
help
;;
esac
done if [ -z "$NfsSvrIP" ]
then
exit
fi #delete VMs on this mountpoint
deleteVMs() {
local mountPoint=$
vmPids=$(ps aux| grep qemu | grep "$mountPoint" | awk '{print $2}' > /dev/null)
if [ $? -gt ]
then
return
fi if [ -z "$vmPids" ]
then
return
fi for pid in $vmPids
do
kill - $pid &> /dev/null
done
} #checking is there the same nfs server mounted under $MountPoint?
mounts=$(cat /proc/mounts |grep nfs|grep $MountPoint)
if [ $? -gt ]
then
# remount it
mount $NfsSvrIP:$NfsSvrPath $MountPoint -o sync,soft,proto=tcp,acregmin=,acregmax=,acdirmin=,acdirmax=,noac,timeo=,retrans= &> /dev/null
if [ $? -gt ]
then
printf "Failed to remount $NfsSvrIP:$NfsSvrPath under $MountPoint"
exit
fi
if [ "$rflag" == "" ]
then
deleteVMs $MountPoint
fi
fi hbFolder=$MountPoint/KVMHA/
hbFile=$hbFolder/hb-$HostIP write_hbLog() {
#write the heart beat log
stat $hbFile &> /dev/null
if [ $? -gt ]
then
# create a new one
mkdir -p $hbFolder &> /dev/null
touch $hbFile &> /dev/null
if [ $? -gt ]
then
printf "Failed to create $hbFile"
return
fi
fi timestamp=$(date +%s)
echo $timestamp > $hbFile
return $?
} check_hbLog() {
now=$(date +%s)
hb=$(cat $hbFile)
diff=`expr $now - $hb`
if [ $diff -gt $interval ]
then
return
fi
return
} if [ "$rflag" == "" ]
then
check_hbLog
if [ $? == ]
then
echo "=====> ALIVE <====="
else
echo "=====> DEAD <======"
fi
exit
elif [ "$cflag" == "" ]
then
reboot
exit $?
else
write_hbLog
exit $?
fi

上面这个脚本是我们现在的计算节点上的版本。从上面可以看出,有判断reboot命令,也就是知道了为什么会重启。但这很坑爹呀,你检测检测,你还重启。。。。

下面这个脚本是我在github上看到的。而且版本已经更新。距离现在8月。应该是最新的,从下面看出,这个坑爹的reboot命令已经被修改了。

#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License. help() {
printf "Usage: $0
-i nfs server ip
-p nfs server path
-m mount point
-h host
-r write/read hb log
-c cleanup
-t interval between read hb log\n"
exit
}
#set -x
NfsSvrIP=
NfsSvrPath=
MountPoint=
HostIP=
interval=
rflag=
cflag= while getopts 'i:p:m:h:t:rc' OPTION
do
case $OPTION in
i)
NfsSvrIP="$OPTARG"
;;
p)
NfsSvrPath="$OPTARG"
;;
m)
MountPoint="$OPTARG"
;;
h)
HostIP="$OPTARG"
;;
r)
rflag=
;;
t)
interval="$OPTARG"
;;
c)
cflag=
;;
*)
help
;;
esac
done if [ -z "$NfsSvrIP" ]
then
exit
fi #delete VMs on this mountpoint
deleteVMs() {
local mountPoint=$
vmPids=$(ps aux| grep qemu | grep "$mountPoint" | awk '{print $2}' > /dev/null)
if [ $? -gt ]
then
return
fi if [ -z "$vmPids" ]
then
return
fi for pid in $vmPids
do
kill - $pid &> /dev/null
done
} #checking is there the same nfs server mounted under $MountPoint?
mounts=$(cat /proc/mounts |grep nfs|grep $MountPoint)
if [ $? -gt ]
then
# remount it
mount $NfsSvrIP:$NfsSvrPath $MountPoint -o sync,soft,proto=tcp,acregmin=,acregmax=,acdirmin=,acdirmax=,noac,timeo=,retrans= &> /dev/null
if [ $? -gt ]
then
printf "Failed to remount $NfsSvrIP:$NfsSvrPath under $MountPoint"
exit
fi
if [ "$rflag" == "" ]
then
deleteVMs $MountPoint
fi
fi hbFolder=$MountPoint/KVMHA/
hbFile=$hbFolder/hb-$HostIP write_hbLog() {
#write the heart beat log
stat $hbFile &> /dev/null
if [ $? -gt ]
then
# create a new one
mkdir -p $hbFolder &> /dev/null
touch $hbFile &> /dev/null
if [ $? -gt ]
then
printf "Failed to create $hbFile"
return
fi
fi timestamp=$(date +%s)
echo $timestamp > $hbFile
return $?
} check_hbLog() {
now=$(date +%s)
hb=$(cat $hbFile)
diff=`expr $now - $hb`
if [ $diff -gt $interval ]
then
return
fi
return
} if [ "$rflag" == "" ]
then
check_hbLog
if [ $? == ]
then
echo "=====> ALIVE <====="
else
echo "=====> DEAD <======"
fi
exit
elif [ "$cflag" == "" ]
then
/usr/bin/logger -t heartbeat "kvmheartbeat.sh rebooted system because it was unable to write the heartbeat to the storage."
sync &
sleep
echo b > /proc/sysrq-trigger
exit $?
else
write_hbLog
exit $?
fi

为什么KVM计算机点无故重启?的更多相关文章

  1. ACPI引起linux系统无故重启

    新装机器无故重启多次. centos6 64bit uname -a Linux Eos 2.6.32-71.el6.x86_64 #1 SMP Fri May 20 03:51:51 BST 201 ...

  2. centos7无故重启-内核升级

    最近有一台物理服务器,centos7操作系统,无故重启,每天都会发生这种情况: 解决: 升级内核 CentOS 允许使用 ELRepo,这是一个第三方仓库,可以将内核升级到最新版本,使用ELRepo升 ...

  3. PowerShell工作流学习-4-工作流中重启计算机

    关键点: a)工作流中重新启动计算机,请使用Restart-Computer的Wait参数,Wait参数不仅适用于本地计算机,也适用于远程计算机. b)重启运行工作流的计算机,手工恢复请使用Resum ...

  4. Win10自动重启原因怎么查Windows10无故自动重启

    电脑偶尔自动重启,可能很少用户会在意,若电脑经常无故重启,那么应该怎么办,怎么查找电脑无故自动重启原因呢?下面就以Windows10系统自动重启为例,来查查WIN10无故重启是什么原因导致.百度经验: ...

  5. kvm 使用入门详解

    kvm 是虚拟化技术的一个典型实现,功能非常强大,使用很方便.kvm 本身主要实现对 CPU 的虚拟化,内存和IO的虚拟化使用了开源软件 qemu,qemu 是纯软件层面的虚拟化,其实就是个模拟器.k ...

  6. Linux 修改计算机名

    查看计算机名:在终端输入hostname 修改的话 hostname +计算机名(重启后失效) 要永久修改的话要修改配置文件/etc/sysconfig/network 修改hostname=你要改的 ...

  7. centos linux中怎么查看和修改计算机名/etc/sysconfig/network

    centos linux中怎么查看和修改计算机名 查看计算机名:在终端输入hostname 修改的话 hostname +计算机名(重启后失效)要永久修改的话要修改配置文件/etc/sysconfig ...

  8. cmd 更改计算机名

    bat  更改计算机名 不用重启电脑就生效^_^ @Echo off Color 0A title --更改计算机名 :A cls echo. echo. [0]退出 echo. echo. 不用重启 ...

  9. KVM之五:KVM日常管理常用命令

    1.查看.编辑及备份KVM 虚拟机配置文件 以及查看KVM 状态: 1.1.KVM 虚拟机默认的配置文件在 /etc/libvirt/qemu 目录下,默认是以虚拟机名称命名的.xml 文件,如下,: ...

随机推荐

  1. OkHttp之BridgeInterceptor简单分析

    在< Okhttp源码简单解析(一) >这篇博客简单分析了Okhttp请求的执行流程,通过该篇博客我们知道OkHttp的核心网络请求中内置"拦截器"发挥了重大作用:本篇 ...

  2. Uncaught TypeError: jQuery.i18n.browserLang is not a function

    /********************************************************************* * Uncaught TypeError: jQuery. ...

  3. 音乐随想——德沃夏克《From The New World》

    第一乐章 前奏拖的很长,低音,再低音.突然转向,好像漂泊数月的水手看到了新大陆. 第二乐章 前奏很优美,到双簧管出现的时候宛若紫霞仙子撑船自芦苇荡中飘过. 之后又一段较前奏稍快的旋律,好像看到了梦寐的 ...

  4. WPF 应用完全模拟 UWP 的标题栏按钮

    WPF 自定义窗口样式有多种方式,不过基本核心实现都是在修改 Win32 窗口样式.然而,Windows 上的应用就应该有 Windows 应用的样子嘛,在保证自定义的同时也能与其他窗口样式保持一致当 ...

  5. iOS设备是否越狱的判断代码

    苹果是非常看重产品的安全性的,所以给用户设计了一套复杂的安全机制.这让喜爱自由,崇尚一切开放的程序员们极度不爽,于是越狱就成了苹果和黑客们反复斗法的场所.总体来说,越狱可以让我们随意安装.共享应用,但 ...

  6. windows下PyCharm运行和调试scrapy

    Scrapy是爬虫抓取框架,Pycharm是强大的python的IDE,为了方便使用需要在PyCharm对scrapy程序进行调试 python PyCharm Scrapy scrapy指令其实就是 ...

  7. 重温CLR(十四) 可空类型

    我们知道,一个值类型的变量永远不可能为null.它总是包含值类型本身.遗憾的是,这在某些情况下会成为问题.例如,设计一个数据库时,可将一个列定义成为一个32位的整数,并映射到FCL的Int32数据类型 ...

  8. [Luogu4715]「英语」Z 语言

    luogu description 你有一个长度为\(n\)的串\(A\)和一个长度为\(m\)的串\(B\),字符集大小\(2^{31}\),且同一个串中没有相同的元素. 定义\(B\)串与\(A_ ...

  9. globalalloc、malloc和new的区别

    简单来说: malloc是c分配内存的库函数,new是c++分配内存的操作符,而globalalloc是win32提供的分配内存的API malloc不能自动调用构造和析构函数,在c++中没什么实用价 ...

  10. 静态和全局变量的作用域zz

    全局变量和静态变量的存储方式是一样的,只是作用域不同.如果它们未初始化或初始化为0则会存储在BSS段,如果初始化为非0值则会存储在DATA段,见进程的地址空间分配一文. 静态变量的作用域是当前源文件, ...