随笔 - 105  文章 - 2 评论 - 9 阅读 - 19万
< 2025年3月 >
23 24 25 26 27 28 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 29
30 31 1 2 3 4 5

相信会考虑这个问题的人,都是因为要设置虚拟机的调度任务吧:)

一开始我还是想着打开NTP服务,通过NTP服务校准时间,不过后来经过了解,NTP漏洞也比较多,如果在物理机上开放NTP服务和端口,风险比较大

权衡之后,还是觉得:1.修改物理机ESXI系统时区,2修改物理机ESXI为正确时间即可

废话不多说,直接上操作

1.拷贝一份时区正常的虚拟机的文件

/usr/share/zoneinfo/Asia/Shanghai

date命令查看时间和时区
CST即为中国时区

 

2.上传Shanghai文件至要配置的物理机上的 /vmfs/volumes/*** 磁盘目录下

注意:一定要上传到数据存储目录,其它目录ESXI重启系统都会还原,文件也会丢失

我这里上传的目录如下

 

3.重命名/etc/localtime,并给/etc/localtime建立软连接

mv /etc/localtime /etc/localtime_bak
ln -s /vmfs/volumes/5be449f9-281acc6a-2bf4-20040fec50ba/zoneinfo/Asia/Shanghai  /etc/localtime

 

4.把以上步骤加入开机启动脚本

/etc/rc.local.d/local.sh

复制代码
#!/bin/sh

# local configuration options

# Note: modify at your own risk!  If you do/use anything in this
# script that is not part of a stable API (relying on files to be in
# specific places, specific tools, specific output, etc) there is a
# possibility you will end up with a broken system after patching or
# upgrading.  Changes are not supported unless under direction of
# VMware support.

# Note: This script will not be run when UEFI secure boot is enabled.


mv /etc/localtime /etc/localtime_bak
ln -s /vmfs/volumes/5be449f9-281acc6a-2bf4-20040fec50ba/zoneinfo/Asia/Shanghai  /etc/localtime



exit 0
复制代码

 

5.校准物理机时间

可以在物理机控制台操作

配置>时间配置>编辑>编辑时间配置

 

 也可以直接命令行操作

esxcli system time set -d 08 -H 16 -m 01 -M 03 -y 2016

我是通过界面操作的

 

6.检查修改结果

 重启物理机后,时间依旧正常即可

 

参考文档:

https://blog.51cto.com/jdonghong/1957118

https://www.pianshen.com/article/42901992875/

posted on   06  阅读(7977)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示