VMWare Esxi 6.5(实际为5.x,6.x)时区问题

摘要:
Esxi不支持修改时区,但是可以使用ESX或者Centos6/7的localtime文件进行替换以实现时区修改,问题是,重启后文件会被还原。将以下shell脚本代码段添加到ESXI的/etc/rc.local.d/local.sh文件中,贴在exit0之前重启便可。如果想立刻生效,只需将以下代码段贴到任意位置的将建shell脚本文件中后执行此脚本就行。#Addscriptto/etc/rc.local.d/local.shbefore'exit0'inVMWareesxi5.x/6.x#以下请设置临时文件路径/Settempscriptfilepathtemp_shell_script_path="/tmp/set_timezone.sh"#以下请设置localtime路径,Setlocaltimefilepath,e.g."/etc/localtime"sys_localtime_path="/etc/localtime"#Inpythonechobase64,becauseVMWareESxihavenocommand"base64".echo"#BeijingJoycoreTechnologyCo.,Ltd."˃$temp_shell_script_pathecho"#SetTimezoneForVMWARE-ESXI5.x/6.x"˃˃$temp_shell_script_pathecho"importbase64"˃˃$temp_shell_script_pathecho"str_timezone='VFppZjIAAAAAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAARAAAAAwAAAAyw/pqgyFwBgMj6J3DJ'"˃˃$temp_shell_script_pathecho"str_timezone=str_timezone+'1Q6Aytta8B66NgAfaX9wIH5ogCFJYXAiXkqAIylDcCRHZwAlEl/wJidJACbyQfAoBysAKNIj8AIB'"˃˃$temp_shell_script_pathecho"str_timezone=str_timezone+'AgECAQIBAgECAQIBAgECAABx4AAAAAB+kAEEAABwgAAITE1UAENEVABDU1QAAAAAAAAAVFppZjIA'"˃˃$temp_shell_script_pathecho"str_timezone=str_timezone+'AAAAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAARAAAAAwAAAAz/////sP6aoP/////IXAGA////'"˃˃$temp_shell_script_pathecho"str_timezone=str_timezone+'/8j6J3D/////ydUOgP/////K21rwAAAAAB66NgAAAAAAH2l/cAAAAAAgfmiAAAAAACFJYXAAAAAA'"˃˃$temp_shell_script_pathecho"str_timezone=str_timezone+'Il5KgAAAAAAjKUNwAAAAACRHZwAAAAAAJRJf8AAAAAAmJ0kAAAAAACbyQfAAAAAAKAcrAAAAAAAo'"˃˃$temp_shell_script_pathecho"str_timezone=str_timezone+'0iPwAgECAQIBAgECAQIBAgECAQIAAHHgAAAAAH6QAQQAAHCAAAhMTVQAQ0RUAENTVAAAAAAAAAAK'"˃˃$temp_shell_script_pathecho"str_timezone=str_timezone+'Q1NULTgK'"˃˃$temp_shell_script_pathecho"#Printfile/usr/share/zoneinfo/Asia/ShanghaisourcefromCentos6.x"˃˃$temp_shell_script_pathecho"fout=open"˃˃$temp_shell_script_pathecho"fout.write"˃˃$temp_shell_script_pathecho"fout.close"˃˃$temp_shell_script_path#deleteoldfilewhonameslocaltimerm-f$sys_localtime_path#rebuildnewfilewithlocaltimepython$temp_shell_script_path#deletetemppythonscriptrm-f$temp_shell_script_pathecho"JOYCORE:TIMEZONEUPDATED..........OK"在esxi/etc/rc.local.d/local.shexit0前添加sh/vmfs/volumes/datastore1/set_time_zone.sh----------------------------------------------------------------------#!

Esxi不支持修改时区,但是可以使用ESX或者Centos 6/7的localtime文件进行替换以实现时区修改,问题是,重启后文件会被还原。

详细的纠结过程就不说了,终级解决方案如下(给公司写的,现分享出来):

大概思路是:将centos 6中/usr/share/zoneinfo/Asia/Shanghai文件(如果是它国时区,请自行替换base64内容)进行base64编码,然后使用shell脚本生成python脚本并执行后进行解码。

将以下shell脚本代码段添加到ESXI的/etc/rc.local.d/local.sh文件中,贴在exit 0之前重启便可。

如果想立刻生效,只需将以下代码段贴到任意位置的将建shell脚本文件中(如:/tmp/set_time_zone.sh)后执行此脚本就行。

#Add script to /etc/rc.local.d/local.sh before 'exit 0' in VMWare esxi 5.x/6.x
#以下请设置临时文件路径/Set temp script file path
temp_shell_script_path="/tmp/set_timezone.sh"
#以下请设置localtime路径(如需测试请填写其它自定义路径,默认请填写/etc/localtime),Set localtime file path,e.g. "/etc/localtime"
sys_localtime_path="/etc/localtime"
#In python echo base64,because VMWare ESxi have no command "base64".
echo "#Beijing Joycore Technology Co., Ltd. " > $temp_shell_script_path
echo "#Set Timezone For VMWARE-ESXI 5.x/6.x" >> $temp_shell_script_path
echo "import base64" >> $temp_shell_script_path
echo "str_timezone = 'VFppZjIAAAAAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAARAAAAAwAAAAyw/pqgyFwBgMj6J3DJ'" >> $temp_shell_script_path
echo "str_timezone = str_timezone + '1Q6Aytta8B66NgAfaX9wIH5ogCFJYXAiXkqAIylDcCRHZwAlEl/wJidJACbyQfAoBysAKNIj8AIB'" >> $temp_shell_script_path
echo "str_timezone = str_timezone + 'AgECAQIBAgECAQIBAgECAABx4AAAAAB+kAEEAABwgAAITE1UAENEVABDU1QAAAAAAAAAVFppZjIA'" >> $temp_shell_script_path
echo "str_timezone = str_timezone + 'AAAAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAARAAAAAwAAAAz/////sP6aoP/////IXAGA////'" >> $temp_shell_script_path
echo "str_timezone = str_timezone + '/8j6J3D/////ydUOgP/////K21rwAAAAAB66NgAAAAAAH2l/cAAAAAAgfmiAAAAAACFJYXAAAAAA'" >> $temp_shell_script_path
echo "str_timezone = str_timezone + 'Il5KgAAAAAAjKUNwAAAAACRHZwAAAAAAJRJf8AAAAAAmJ0kAAAAAACbyQfAAAAAAKAcrAAAAAAAo'" >> $temp_shell_script_path
echo "str_timezone = str_timezone + '0iPwAgECAQIBAgECAQIBAgECAQIAAHHgAAAAAH6QAQQAAHCAAAhMTVQAQ0RUAENTVAAAAAAAAAAK'" >> $temp_shell_script_path
echo "str_timezone = str_timezone + 'Q1NULTgK'" >> $temp_shell_script_path
echo "#Print file /usr/share/zoneinfo/Asia/Shanghai source from Centos 6.x" >> $temp_shell_script_path
echo "fout = open(r'$sys_localtime_path', 'wb')" >> $temp_shell_script_path
echo "fout.write(base64.b64decode(str_timezone))" >> $temp_shell_script_path
echo "fout.close" >> $temp_shell_script_path
#delete old file who names localtime
rm -f $sys_localtime_path
#rebuild new file with localtime
python $temp_shell_script_path
#delete temp python script
rm -f $temp_shell_script_path
echo "JOYCORE:TIMEZONE UPDATED .......... OK"

在esxi/etc/rc.local.d/local.sh exit 0 前添加
sh /vmfs/volumes/datastore1/set_time_zone.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.

exit 0
[root@localhost:/vmfs/volumes/509bfdd0-b00970e0-556e-90b11c9da899] vi /etc/rc.local.d/local.sh
[root@localhost:/vmfs/volumes/509bfdd0-b00970e0-556e-90b11c9da899] cat /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.
sh /vmfs/volumes/datastore1/set_time_zone.sh

exit 0

----------------------------------------------------------------------

免责声明:文章转载自《VMWare Esxi 6.5(实际为5.x,6.x)时区问题》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇几个串口协议学习整理craco 配置 less.module下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

ssh secure Shell连接阿里云服务器,报错的问题,openssh无法登录:server responded "algorithm negotiation failed”

1、putty登录连接到阿里云服务器 2、修改ssh的配置文件 vi /etc/ssh/sshd_config 切换编辑模式(i),设置参数 PasswordAuthentication yes 在配置文件末尾添加: Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-...

linux SFTP用户创建 不允许用户登录,并且连接只允许在制定的目录下进行操作

1.创建用户 groupadd sftp 2.添加用户并设置为sftp组  useradd -g sftp -s /sbin/nologin -M sftp    (/sbin/nologin为禁止登录shell的用户) 3.设置用户密码 passwd sftp 4.创建用户目录。并设置权限。 cd /home mkdir sftp chown root:...

转:Linux 编译安装 Mysql5.7

http://broqiang.com/2017/04/18/Mysql-Install-5.7.18-Linux-Compile/ 原文 Linux 编译安装 Mysql5.7 Ubuntu 下快速安装直接 apt 方式即可, 一般的开发环境也足够了 个人比较喜欢新版本,一般有新版本就会尝试一下 此文档适用于 Ubuntu 16.10 和 CentOS...

搭建Kubernetes集群时DNS无法解析问题的处理过程 k8s

作者:simpleapples ,来源:简书,原文链接 问题描述 在搭建Kubernetes集群过程中,安装了kube-dns插件后,运行一个ubuntu容器,发现容器内无法解析集群外域名,一开始可以解析集群内域名,一段时间后也无法解析集群内域名。 $ nslookup kubernetes.default Server: 10.99.0.2 Add...

DNS相关配置文件

我们晓得主机名对应到 IP 有两种方法,早期的方法是直接写在档案里面来对应, 后来比较新的方法则是透过 DNS 架构!那么这两种方法分别使用什么配置文件?可不可以同时存在? 若同时存在时,那个方法优先?嗯!我们先来谈一谈几个配置文件吧!* /etc/hosts :这个是最早的 hostname 对应 IP 的档案;* /etc/resolv.conf :这...

linux之bash shell

GNU bash ======================================================== 通常计算机硬件是由运算器、控制器、存储器、输入/输出设备等等这些物理设备共同组成的,而能够让机箱内各种硬件设备各司其职的东西就叫做系统内核。Linux系统的内核负责驱动硬件、管理活动和分配/管理硬件资源等等任务,如此说来系统内...