强制禁止虚拟机和esxi同步时间

简介:

即使在虚拟机guest os vmwaretools命令行中关闭了时间同步,当重启guestos或vmtools服务时,虚拟机仍会跟esxi同步,要彻底禁止虚拟机和esxi同步,还需在该虚拟机vmx文件中添加以下代码:

1
2
3
4
5
6
7
8
tools.syncTime =  "0"
time.synchronize. continue  "0"
time.synchronize.restore =  "0"
time.synchronize.resume.disk =  "0"
time.synchronize.shrink =  "0"
time.synchronize.tools.startup =  "0"
time.synchronize.tools.enable =  "0"
time.synchronize.resume.host =  "0"


也可通过powercli编写脚本文件批量执行:

1
2
3
4
5
6
  $vm  get-view  ( get-vm  test-time ).Id        #虚机名为test-time
  $vmConfigSpec  New-Object  VMware.Vim.VirtualMachineConfigSpec
  $vmConfigSpec .extraconfig =  New-Object  VMware.Vim.optionvalue
  $vmConfigSpec .extraconfig[0].Key= "time.synchronize.continue"   #键名
  $vmConfigSpec .extraconfig[0].Value= "0"              #键值  
  $vm .ReconfigVM( $vmConfigSpec )

#执行脚本后,会创建time.synchronize.continue键值,并且值为0,但是这个脚本有个缺点,就是每添加一个键值都需要重新运行一次新的脚本。

以下脚本可以一次运行,添加所有键值:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  $spec  New-Object  VMware.Vim.VirtualMachineConfigSpec
  $spec .extraConfig =  New-Object  VMware.Vim.OptionValue[] (8)
  $spec .extraConfig[0] =  New-Object  VMware.Vim.optionvalue
  $spec .extraConfig[0].Key= "tools.syncTime"
  $spec .extraConfig[0].Value= "0"
  $spec .extraConfig[1] =  New-Object  VMware.Vim.optionvalue
  $spec .extraConfig[1].Key= "time.synchronize.continue"
  $spec .extraConfig[1].Value= "0"
  $spec .extraConfig[2] =  New-Object  VMware.Vim.optionvalue
  $spec .extraConfig[2].Key= "time.synchronize.restore"
  $spec .extraConfig[2].Value= "0"
  $spec .extraConfig[3] =  New-Object  VMware.Vim.optionvalue
  $spec .extraConfig[3].Key= "time.synchronize.resume.disk"
  $spec .extraConfig[3].Value= "0"
  $spec .extraConfig[4] =  New-Object  VMware.Vim.optionvalue
  $spec .extraConfig[4].Key= "time.synchronize.shrink"
  $spec .extraConfig[4].Value= "0"
  $spec .extraConfig[5] =  New-Object  VMware.Vim.optionvalue
  $spec .extraConfig[5].Key= "time.synchronize.tools.startup"
  $spec .extraConfig[5].Value= "0"
  $spec .extraConfig[6] =  New-Object  VMware.Vim.optionvalue
  $spec .extraConfig[6].Key= "time.synchronize.tools.enable"
  $spec .extraConfig[6].Value= "0"
  $spec .extraConfig[7] =  New-Object  VMware.Vim.optionvalue
  $spec .extraConfig[7].Key= "time.synchronize.resume.host"
  $spec .extraConfig[7].Value= "0"
  $_this  get-view  ( get-vm  test).Id
  $_this .ReconfigVM_Task( $spec )

get-vm test是选择test这个VM做为对象,如果想对所有关机的VM进行修改,可以把()里的内容替换成如下两种代码的任意一种:

1
2
  get-vm  where-object  { $_ .powerstate  -eq  "poweredoff" }  
  get-vm  | ? { $_ .PowerState  -like  "poweredoff" }









本文转自 qq8658868 51CTO博客,原文链接:http://blog.51cto.com/hujizhou/1979336,如需转载请自行联系原作者
目录
相关文章
|
4月前
|
存储 网络协议 虚拟化
如何操作VMware ESXi虚拟机的迁移?
如何操作VMware ESXi虚拟机的迁移?
195 1
|
4月前
|
存储 虚拟化 数据中心
如何操作VMware ESXi虚拟机的克隆?
如何操作VMware ESXi虚拟机的克隆?
86 1
|
存储 Linux 虚拟化
Vsphere创建内容库Iso以及创建esxi虚拟机
Vcenter创建虚拟机 1.创建iso内容库 1)点击内容库
1477 0
Vsphere创建内容库Iso以及创建esxi虚拟机
|
7月前
|
存储 网络安全 虚拟化
Proxmox VE导入ESXI格式OVA、VMDK虚拟机文件
按照正常步骤建好虚拟机,之后删除掉该虚拟机的虚拟硬盘。本例中虚拟机VM ID为103,通过qm importdisk 进行导入挂载。具体导入位置,根据虚拟机存储情况进行确定,本示例为local-lvm。使用SCP工具,将OPNsense_22.7.4_ufs-disk1.vmdk上传到系统的root目录下。需要使用的文件为:OPNsense_22.7.4_ufs-disk1.vmdk。导入成功后,就能看到该硬盘,在该硬盘上点编辑,添加即可。
|
Linux
虚拟机的IP经常变化,日期不同步
虚拟机的IP经常变化,日期不同步
638 0
虚拟机的IP经常变化,日期不同步