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