1.安装ntp
rpm -qa | grep ntp (先查看一下,安装系统可能安装了)
rpm -ivh ntp-4.2.6p5-18.el7.centos.x86_64.rpm
2、服务器配置:(/etc/ntp.conf)
[root@localhost etc]# vi /etc/ntp.conf
//然后添加这两行 ,意思是 允许IPV4 IPV6 查询 拒绝修改
restrict -4 default kod notrap nomodify
restrict -6 default kod notrap nomodify
//添加修改上层时间服务器,如果能联通外网,则不需要修改,
//server 0.rhel.pool.ntp.org iburst
//server 1.rhel.pool.ntp.org iburst
//server 2.rhel.pool.ntp.org iburst
//server 3.rhel.pool.ntp.org iburst
//如果联不通外网,则把上面几行注释,然后添加下面两行,意思是设置成时间服务器是自己
server 127.127.1.0
fudge 127.127.1.0 stratum 8
[root@localhost etc]# /bin/systemctl start ntpd.service
3、客户端配置:(/etc/ntp.conf)
[root@localhost etc]# vi /etc/ntp.conf
//然后添加这两行 ,意思是 允许IPV4 IPV6 查询 拒绝修改
restrict -4 default kod notrap nomodify
restrict -6 default kod notrap nomodify
//允许上层进行修改本机时间
//restrict 10.173.24.27 nomodify notrap noquery
//配置上层server(要同步的),在这里配置的是实际的物理地址
server 192.168.6.171
fudge 192.168.6.171 stratum 8
//同步主节点ntp服务器
[root@localhost etc]# ntpdate -u master.msxf.hadoop
[root@localhost etc]# /bin/systemctl start ntpd.service
通过date 查看时间
4.注意
如果你同步之后,发现时间还是不对,你看看你的两台的机器的时差CST和EDT