您现在的位置是:首页 > 文章详情

Centos7部署ntp服务器同步时间

日期:2017-10-09点击:845

查看时区列表: timedatectl list-timezones|grep Asia 

设置中国时区: timedatectl set-timezone Asia/Shanghai 执行完后时间就变为北京时间了 

查看当前时间: date 

查看当前设置: 

[root@localhost ~]# timedatectl 

Local time: Mon 2017-10-09 16:44:08 CST 

Universal time: Mon 2017-10-09 08:44:08 UTC 

RTC time: Mon 2017-10-09 08:44:08 

Time zone: Asia/Shanghai (CST, +0800) 

NTP enabled: yes 

NTP synchronized: yes 

RTC in local TZ: no 

DST active: n/a 

如果没有系统没有安装ntp服务器的话可以安装yum install ntp -y 

然后编辑ntp的配置文件vi /etc/ntp.conf (日志文件默认在/var/log/messages中),添加以下几个服务器域名,如果原配置文件没有的话 

server 0.centos.pool.ntp.org iburst 

server 1.centos.pool.ntp.org iburst 

server 2.centos.pool.ntp.org iburst 

server 3.centos.pool.ntp.org iburst

systemctl restart ntpd 

systemctl enable ntpd

这样,服务器端就配置得差不多了,但我为了让效果更明显,把服务器修改为纽约时区,另一台需要同步的linux客户端的时区修改为非洲时间,结果导致,客户端ntpdate之后没有同步,后来才发现,需要在同一时区内才能同步时间,也就是说,服务端和客户端的时区必须在中国这个时区内才可以

下面来测试我们的ntp服务器配置有没有成功 

在服务器端(ip:10.0.3.66)上 

使用date -s 23:30:30 (时间可以随便改,反正改一个跟客户端时间不一样的就可以了),然后date可以看到时间变成了23:30:30 

在客户端上 

ntpdate 10.0.3.66 执行后发现,时间也变成了23:30:30

原文链接:https://www.centoschina.cn/course/intermediate/9020.html
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章