成都创新互联网站制作重庆分公司

ntp时间服务器

1、NTP时间服务器

10年积累的成都网站设计、成都网站制作经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计制作后付款的网站建设流程,更有新林免费网站建设让你可以放心的选择与我们合作。

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

NTP服务器是用于局域网服务器时间同步使用的,可以保证局域网所有的服务器与时间服务器的时间保持一致,某些应用对时间实时性要求高的必须统一时间。

基于Client/server模式,udp123端口

 

2、安装步骤:

2.1、 服务器端: 

NTP服务器监听端口为UDP的123,那就需要在本地防火墙开启运行客户端访问123端口,vi /etc/sysconfig/iptables添加如下规则:

-A INPUT -m state --state NEW -m udp -pudp --dport 123 -j ACCEPT

2.1.1、首先关闭防火墙:   /etc/init.d/iptables stop

    或关闭Selinux软件服务: Setenforce 0临时关闭

2.1.2、[root@haikang~]#yum install ntp* -y  //安装ntp软件

        [root@haikang ~]# cp /etc/ntp.conf/etc/ntp.conf.bak  //备份ntp主配置文件

       [root@haikang ~]#vi /etc/ntp.conf  //修改ntp主配置文件 

        [root@haikang~]# cat /etc/ntp.conf  //查看主配置文件

          driftfile /var/lib/ntp/drift 

           //在与上级时间服务器联系时所花费的时间,记录在driftfile参数后面的文件内

restrictdefault kod nomodify notrap nopeer noquery

//允许所有来跟我进行同步

          restrict 127.0.0.1  //开启内部递归网络接口 lo

          restrict 192.168.1.0 mask255.255.255.0 nomodify notrap

           //定义可访问的内部子网客户端,但不能修改NTP服务器的时间参数。

server 0.centos.pool.ntp.org iburst    

//上级时间服务器

server 127.127.1.0     # local clock//设置与本机ntp同步时钟

        [root@haikang~]# /etc/init.d/ntpd start 

        //启动ntp服务,客户端需要几分钟后才能同步,否则会提示错误.

        [root@haikang ~]# netstat -nulp|grep ntp   //查看是否有ntp进程

[root@haikang ~]# ntpq -p   //查看ntp服务器的上级服务器

[root@haikang ~]# watch ntpq -p

     remote           refid      st t when poll reach   delay  offset  jitter

==============================================================================

 ntp1.ams1.nl.le 130.133.1.10     2 u  15   64  153 337.087  -705047 7050475

注释:remote -本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先

refid  -参考上一层ntp主机地址

st    - stratum阶层

when   -多少秒前曾经同步过时间

poll   -下次更新在多少秒后

reach  -已经向上层ntp服务器要求更新的次数

delay  -网络延迟

offset  -时间补偿

jitter  -系统时间与bios时间差 

    2.2、客户端:           

[root@localhost ~]# ntpdate172.16.30.12  //与NTP进行同步

30 May 01:15:35 ntpdate[1096]: adjust timeserver 172.16.30.12 offset 0.003669 sec

备注:如果客户机没有ntpdate,可以yum –y install ntp 即可!

客户端创建计划任务:

crontab -e 创建客户端定期同步,需创建计划任务。

如:增加一行,在每天的6点10分与时间同步服务器进行同步

10(分)  06(时) *(日) *(月) *(周)/usr/sbin/ntpdate ntp-server的ip (172.16.30.10)>>/usr/local/logs/crontab/ntpdate.log

crontab -l //查看计划任务

备注:如果客户机没有crontab,可以yum  install cron*  -y 即可。

crontab主要用来创建计划任务

2.3、ntp客户端同步时的错误解决方案:

[root@localhost~]# ntpdate 172.16.30.12

30 May11:50:29 ntpdate[1136]: no server suitable for synchronization found

  客户端用[root@localhost~]# ntpdate  -d 172.16.30.12

   错误1.Serverdropped: no data

       关闭防火墙或者加入规则-AINPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT

 


当前标题:ntp时间服务器
文章分享:http://cxhlcq.com/article/ijdcgs.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部