通过上一节部署出来的 Windows instance 有时候会发现操作系统时间总是慢 8 个小时,即使手工调整好时间和时区,下次 instance 重启后又会差 8 个小时

这是 OpenStack 实施经验分享系列的第 3 篇。

 

问题描述

 

通过上一节部署出来的 Windows instance 有时候会发现操作系统时间总是慢 8 个小时,即使手工调整好时间和时区,下次 instance 重启后又会差 8 个小时。

 

原因

 

KVM 对 Linux 和 Windows 虚拟机在系统时间上处理有所不同,Windows 需要额外一些设置。

 

解决办法一

 

给 Windows 镜像添加 os_type 属性。

glance image-update --property os_type="windows" <IMAGE-ID>
 

明确指定这就是一个 windows 镜像。通过此镜像部署 instance 的时候,KVM 会在其 XML 描述文件中设置相应参数,保证时间的同步。

 

解决办法二

 

对于之前部署的 Windows instance,用第一种方法就没有效果了,只能采取一点非常规手段:Hack Database!

 

假设要 hack 的 instance 的名字是 win-test,用下面的 MySQL 命令:

 

$ use nova;

$ update instances set os_type='windows' where hostname='win-test';

$ select hostname,os_type from instances where hostname='win-test';

+------------+----------+

| hostname  | os_type  |

+------------+----------+

| win-test     | windows |

+------------+----------+


需要重启 win-test,KVM 会获取修改后的数据库信息,更新 XML 配置,保证时间同步。

 

下一节继续讨论镜像使用上的经验和技巧。

原文地址:https://www.cnblogs.com/ruiy/p/6437191.html