大数据高可用集群环境安装与配置(02)——配置ntp服务

浪尽此生 提交于 2020-01-10 05:17:39

大数据高可用集群环境安装与配置(01)——服务器基础配置

NTP服务概述

NTP服务器【Network Time Protocol(NTP)】是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的协议攻击。时间按NTP服务器的等级传播。按照离外部UTC源的远近把所有服务器归入不同的Stratum(层)中。

安装部署

执行命令,安装ntp和ntpdate软件包

yum install ntp -y

配置NTP服务器端

vi /etc/ntp.conf

修改下面内容(没有的就添加,有的就修改):

restrict default ignore
restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap
#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
server 127.127.1.0
fudge 127.127.1.0 stratum 10

 

PS:在配置=中,192.168.10.0 这个是当前服务器所在IP段地址,你需要根据自己服务器的IP段进行修改,它将会开放可访问当前ntp服务器的地址段

启动ntp服务

systemctl start ntpd.service
systemctl enable ntpd.service

 

配置客户端服务器

vi /etc/ntp.conf

将server注释掉,并添加master主机为服务器节点

#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
server master

将同步的系统时间写入到硬件(BIOS)时间里

vi /etc/sysconfig/ntpd

在里面添加

SYNC_HWCLOCK=yes

测试是否可以连主ntp服务

ntpdate -u master

在定时器中添加自动同步设置

vi /etc/crontab

添加下面命令

0 * * * * root /usr/sbin/ntpdate -u master
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!