linux基础之NTP

一、NTP简介

NTP是网络时间协议(Network Time Protocol),它是用来同步网络中各个计算机的时间的协议,使用的端口是123。

 

二、NTP安装

1、查看是否安装

使用命令rpm -qa | grep ntp-*查看系统是否已经安装有NTP软件,如显示如下图则证明已经安装NTP,若执行命令无返回值则证明尚未安装NTP。

 

2、NTP安装

直接yum安装比较简单直接一条命令搞定。命令:yum install -y ntp。

 

3、启动命令

启动命令:/etc/init.d/ntpd start

开机自启:chkconfig ntpd on

 

三、配置服务

1、使用ntp配置时间服务器

进入配置文件:vim /etc/ntp.cong

去掉#号:#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

修改能同步的网段:restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap --由于这里网段就是该网段,所有未修改。

重启服务:/etc/init.d/ntpd restart

问题:若客户端执行 ntpdate 192.168.1.82时报26 Aug 14:42:52 ntpdate[7417]: the NTP socket is in use, exiting错误,则

是因为客户端也开启了ntpd服务,所有导致socket被占用。

 

2、使用xinetd配置时间服务器

进入配置文件:vim /etc/xinetd.d/time-dgram 修改disable =  no

进入配置文件:vim /etc/xinetd.d/time-stream 修改disable =  no

重启服务:/etc/init.d/xinetd restart

客户端执行:rdate -s 192.168.1.82 

 

posted @ 2018-01-04 14:14  帅气的搬砖工  阅读(792)  评论(0编辑  收藏  举报