大数据环境对时间要求很高,所以必须在集群中同步时间。本例中,一台master主机用来同步外部时间,另外两台slave用来同步master的时间。时区选择在三台机器上执行timedatectlset-timezone"Asia/Shanghai"统一设置时区安装ntp在三台机器上执行yuminstall-yntp配置ntp服务(1)master主机(192.168.21.161)修改/etc/ntp.conf文件restrict192.168.21.161nomodifynotrapnopeernoquery192.168.21.161为master主机IP地址restrict192.168.21.1mask255.255.255.0nomodifynotrap网关和子网掩码并注释掉server0~n,添加同步时间服务器地址服务器ntp1.aliyun.comiburstserverntp2.aliyun.comiburstserverntp3.aliyun.comiburstserverntp4.aliyun.comiburstserverntp5.aliyun.comiburstserverntp6.aliyun.comiburstserverntp7.aliyun.com详情iburst的如下(2)slave1(192.168.21.162)修改/etc/ntp.conf文件restrict192.168.21.162nomodifynotrapnopeernoquery192.168.21.162isslave1'shostipaddressrestrict192.168.21.1mask255.255.255.0nomodifysubnetmask并注释掉notrapserver0~n,指定master为serverserver192.168.21.161Fudge192.168.21.161stratum10具体内容如下(3)slave2(192.168.21.163)修改/etc/ntp.conf文件为类似于slave1restrict192.168.21.163nomodifynorapnopeer2.168.21.163是slave2的主机ip地址restrict192.168.21。1mask255.255.255.0nomodifynotrapgateway和子网掩码并注释掉server0~n,指定master为serverserver192.168.21.161Fudge192.168.21.161stratum10具体内容如下启动ntp服务systemctlstartntpd.service设置bootsystemctlenablentpd.serviceviewstatusntpstatsynchronisedtoNTPserver(192.168.21.161)atstratum4timecorrecttowithin84mspollingserverevery1024sntp服务启动后不会立即同步时间,所以ntpstat状态不会同步5~10分钟后PS会同步:查看网关命令iprouteshow关闭防火墙,否则可能会阻塞ntp服务的123端口systemctlstopfirewalld查看防火墙状态systemctlstatusfirewalld
