VM虚拟机系统时间同步网络时间(Centos)

本地虚拟机上centos系统的时间与北京时间不一致,如下命令可以直接更改:

shell:ntpdate -u ntp.api.bz

shell:clock -w

执行完上面两步即可,命令行执行date查看当前系统时间,显示正确。

注意:

若不加上-u参数, 会出现以下提示:no server suitable for synchronization found

如果没有ntpdate命令,直接安装:yum -y install ntpdate ntp

-u:从man ntpdate中可以看出-u参数可以越过防火墙与主机同步;

clock -w 是同步到BIOS时钟,强制把系统时间写入CMOS:

登录用户自动校准时间:

挂起客户端操作会经常用到,但是每次执行同步命令,不方便,所以加入到登录自动执行命令。

echo "ntpdate -u ntp.api.bz && clock -w" >> /etc/profile

ntp常用服务器:

中国国家授时中心:210.72.145.44

NTP服务器(上海) :ntp.api.bz

美国:time.nist.gov
复旦:ntp.fudan.edu.cn
微软公司授时主机(美国) :time.windows.com
台警大授时中心(台湾):asia.pool.ntp.org

你可能感兴趣的:(linux,hadoop,centos)