解决KVM以及OpenStack环境下,windows实例重启后比当前时间晚8小时

##KVM环境
kvm虚拟机使用libvirt管理,修改虚拟机libvirt.xml配置文件

virsh edit windows2008r2(虚拟机名字)

修改如下部分

  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>

修改其中的utc为localtime

 <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>

重启实例即可
##OpenStack环境
对于openstack环境,也是上述原理,修改,有一点不同的是不能通过kvm来修改,否则,重启后,时间还会变为原来的时间,需要通过openstack来修改
1:对于还未创建的实例
更新镜像信息,加入os_type选项

glance image-show 1b93fbda-eb17-4b4e-99f3-eb279615630b
glance image-update --property os_type="windows" b1de5e53-b95d-4815-a1e9-179cf1d74ba4(IMAGE ID)
glance image-show 1b93fbda-eb17-4b4e-99f3-eb279615630b

看看是否多了一项os_type
然后就可以创建虚拟机了
2:对于已经创建的windows镜像,可以在数据库中更新os_type字段信息,然后重启实例

MariaDB [(none)]> use nova
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [nova]> select os_type,hostname from instances;
+---------+----------------+
| os_type | hostname       |
+---------+----------------+
| NULL    | test           |
| NULL    | test-centos65  |
| NULL    | test-2         |
| NULL    | test-3         |
| NULL    | win2003     |

MariaDB [nova]> update instances set os_type='windows' where hostname='yunwei03';

重启实例即可
在相应计算节点,查看虚拟机配置文件

virsh edit instance-00000281
  <clock offset='localtime'>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='hpet' present='no'/>
    <timer name='hypervclock' present='yes'/>
  </clock>

可以看到clock以及从utc变成localtime

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值