ImageVerifierCode 换一换
格式:DOC , 页数:12 ,大小:112.50KB ,
资源ID:6113572      下载积分:10 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/6113572.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(linux下NTP服务的配置.doc)为本站上传会员【pc****0】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

linux下NTP服务的配置.doc

1、 Network Time Protocol(NTP,网络时间协议)用于同步它所有客户端时钟的服务。NTP服务器将本地系统的时钟与一个公共的NTP服务器同步然后作为时间主机提供服务,使本地网络的所有客户端能同步时钟。     同步时钟最大的好处就是相关系统上日志文件中的数据,如果网络中使用中央日志主机集中管理日志,得到的日志结果就更能反映真实情况。在同步了时钟的网络中,集中式的性能监控、服务监控系统能实时的反应系统信息,系统管理员可以快速的检测和解决系统错误。    安装配置NTP服务     下面将介绍NTP服务器的简单配置:    第一步,安装NTP服务    

2、 一般的Linux发行版都会带ntp软件包,如果你的系统中还没有安装,就使用rpm命令安装此包 ,以下以centos系统为例配置一台时间服务器:  查找当前系统是否已安装ntp  [root@localhost ~]# rpm -qa | grep ntp  chkfontpath-1.10.1-1.1  ntp-4.2.2p1-8.el5.centos.1       (这个就是已经安装的RPM包)  如果没有安装,可用下例命令安装:  [root@localhost ~]# rpm -ivh ntp-4.2.2p1-8.el5.centos.1.rpm     第

3、二步,配置NTP服务器      NTP服务器配置如下:     编辑配置文件/etc/ntp.conf    restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery restrict 127.0.0.1 restrict -6 ::1 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap server 192.168.146.225 server 0.ce

4、ntos.pool.ntp.org server 1.centos.pool.ntp.org server 2.centos.pool.ntp.org server  127.127.1.0     # local clock fudge   127.127.1.0 stratum 10    配置文件说明如下:     第一行restrict、default定义默认访问规则,nomodify禁止远程主机修改本地服务器配置,notrap拒绝特殊的ntpdq捕获消息,noquery拒绝btodq/ntpdc查询(这里的查询是服务器本身状态查询)。     restrict 19

5、2.168.1.0 mask 255.255.255.0 nomodify notrap     这句是手动增加的,意思是从192.168.1.1-192.168.1.254的服务器都可以使用我们的NTP服务器来同步时间。     server 192.168.146.225     这句也是手动增加的,指明局域网中作为NTP服务器的IP;   配置文件的最后两行作用是当服务器与公用的时间服务器失去联系时以本地时间为客户端提供时间服务。    端口   ntp使用udp协议,记得开放其123端口。   启动NTPD     为了使NTP服务可以在系统引导的时候自动启动,

6、执行:     #chkconfig ntpd on     启动ntpd:   service ntpd start    NTP客户端配置:     在客户端手动执行“ntpdate 服务器IP”来同步时间;     另可以使用crond来定时同步时间:     以root身份运行周期性任务:   [root@supersun root]# crontab -e   添加以下内容,每15分钟更新一下时间:   15 * * * * ntpdate 服务器IP     此处的ntpdate命令包含在ntp软件包中,记得确认系统中是否已安装。    第三步,

7、检查时间服务器是否正确同步     使用下面的命令检查时间服务器同步的状态:     #ntpq -p         一个可以证明同步有问题的证据是:所有远程服务器的jitter值是4000并且delay和reach的值是0。 可能的原因有:     有防火墙阻断了与server之间的通讯,即123端口是否正常开放;     此外每次重启NTP服务器之后大约要3-5分钟客户端才能与server建立正常的通讯连接,否则你在客户端执行“ntpdate 服务器ip”的时候将返回:     27 Jun 10:20:17 ntpdate[21920]: no server suita

8、ble for synchronization found   Linux下NTP服务器的配置     Linux下的ntp软件不但能自动与互联网上的时钟保持同步,同时本身已经是一台SNTP服务器了,可以供局域网内的电脑校对时间。服务配置如下: 第一步 安装软件包     我用的是RPM包安装的,或者到http://www.eecis.udel.edu/~ntp/去下载xntp重新编译一个新的。     #rpm -qa | grep ntp     ntp-4.2.0-7     chkfontpath-1.10.0-1 第二步 让LAN的时间服务器

9、第三级)与互联网上的时间服务器(第一或者第二级)同步     修改/etc/ntp.conf      这是NTP的主要配置文件,里面设置了你用来同步时间的时间服务器的域名或者IP地址,下面是到 互联网同步时间的最基本的配置:     首先定义我们喜欢的时间服务器:     server ntp.research.gov     server otherntp.research.gov     接下来,我们设置上面两台服务器的访问权限,在这个例子中我们不允许它们修改或者查询我们配置在Linux上的NTP服务器     restrict ntp.research.go

10、v mask 255.255.255.255 nomodify notrap noquery     restrict otherntp.research.gov mask 255.255.255.255 nomodify notrap noquery     掩码255.255.255.255是用来 限制远程NTP服务器的掩码地址。     接下来设置允许访问我们时间服务器的客户机地址,通常这些服务器都应该位于我们自己局域网内。请注意,配置中noquery已经去掉了:     restrict 192.168.0.0 mask 255.255.255.0 notrust nomo

11、dify notrap     在上例中,掩码地址扩展为255,因此从192.168.0.1-192.168.0.254的服 务器都可以使用我们的NTP服务器来同步时间。     最后,也是最重要的是默认的限制配置要从你配置文件中删除,否则它将覆盖你所有的配置选项,你将发现如果不删除该配置,你的时间服务器将只能和自己通讯。 如果ntp.conf中有以下一行,请将它注释:     #restrict default ignore     保存你的配置文件,然后对每个你在ntp.conf里配置的时间服务器执行2编查询命令:              #ntpdate ntp.resea

12、rch.gov     27 Jun 10:12:01 ntpdate[25475]: adjust time server ntp.research.gov offset -0.127154 sec     #ntpdate ntp.research.gov     27 Jun 10:12:06 ntpdate[25478]: adjust time server ntp.research.gov offset 0.010008 sec 第三步 启动NTP进程     为了使NTP服务可以在系统引导的时候自动启动,执行:     #chkconfig ntpd on     

13、启动/关闭/重启NTP/查看状态的命令是:     #/etc/init.d/ntpd start     #/etc/init.d/ntpd stop     #/etc/init.d/ntpd restart     #/etc/init.d/ntpd status     切记每次修改了配置文件后都需要重新启动服务来使配置生效。可以使用下面的命令来检查NTP服务 是否启动,你应该可以得到一个进程ID号:     #pgrep ntpd 第四步 检查时间服务器是否正确同步          使用下面的命令检查时间服务器同步的状态:     #ntpq -p  

14、        一个可以证明同步问题的证据是所有远程服务器的jitter值是4000并且delay和reach的值是0。 可能的原因有:     配置文件中的restrict default ignore没有被注释     有防火墙阻断了与server之间的通讯     此外每次重启NTP服务器之后大约要3-5分钟客户端才能与server建立正常的通讯连接,否则你执行ntpdate ip的时候将返回:     27 Jun 10:20:17 ntpdate[21920]: no server suitable for synchronization found 第五步 客

15、户端与ntp服务器同步时间 在客户端安装NTP,安装过程同NTP在服务器端。     客户端开启ntp服务     #service ntpd start     与ntp服务器同步     #ntpdate (ntp服务器地址) 接下来编辑 /etc/ntp.conf ntp.conf ############################################################################################# server 127.127.1.0 # local clock fudge 127.

16、127.1.0 stratum 10 server stdtime.gov.hk # A stratum 1 server at server.org server 192.168.x.y #x.y为你前面所装机器在局域网里的IP driftfile /etc/ntp/drift broadcastdelay 0.008 authenticate no keys /etc/ntp/keys restrict 192.168.x.0 mask 255.255.255.0 notrust nomodify notrap//x.0为你 所在局域网段 restrict 127

17、0.0.1 restrict 192.168.x.y #x.y为你前面所装机器在局域网里的IP #restrict default ignore ############################################################################################# 同时配置 #/sbin/service ntpd start //启动ntpd 参数可为restart start stop #/sbin/chkconfig --add ntpd #/sbin/chkconfig --level 234 ntp

18、d on //配置在开机时运行 如何检查? #netstat -unl | grep 123 //查看123端口 #ndptrace 192.168.x.y //看校对时间过程,出现offset即为正常 否则为time out # ntpq -p 如果出现 jitter的值 为4000则是防火墙或者网络问题 正常为 remote refid st t when poll reach delay offset jitter ===================================================================

19、 *clock.nc.fukuok .GPS. 1 u 43 64 37 19.067 -6.884 10.339 +clock.tl.fukuok .GPS. 1 u 36 64 35 19.670 -3.259 2.341 LOCAL(0) LOCAL(0) 5 l 45 64 37 0.000 0.000 0.001 几点注意: 1.虽然ntp溢出问题较少 ,但建议配置大型网罗的时候,不要装在重要数据库服务 器或者Web主机上(Ntp是root权限) 2.在遇到问题之前,先看看ntp自带的文档。 3.防火墙问题的话,送一句配置 $T

20、MP -t filter -A INPUT -p udp --destination-port 123 -j ACCEPT 也就是123 udp in 全部接受。 如果子网IP仍然提示4000错误,可以把 restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap 改为 restrict 192.168.0.0 mask 255.255.255.0 nomodify 对于权限参数的说明可以参考台湾鸟哥的文章的说明: [root@root]# vi /etc/ntp.conf # 1.

21、 關於權限設定部分 #  權限的設定主要以restrict 這個參數來設定,主要的語法為: # #  restrict IP mask netmask_IP parameter # #  其中IP可以是軟體位址,也可以是 default ,default 就類似 0.0.0.0 咯! #  至於 paramter則有: #   ignore:關閉所有的NTP 連線服務 #   nomodify:表示Client 端不能更改 Server 端的時間參數,不過, #        Client端仍然可以透過 Server 端來進行網路校時。 #   notrust:該 Clie

22、nt 除非通過認證,否則該 Client 來源將被視為不信任網域 #   noquery:不提供 Client 端的時間查詢 #  如果 paramter完全沒有設定,那就表示該 IP (或網域) 『沒有任何限制!』 # #  在我們這個例子當中,因為拒絕所有,僅開放192.168.0.0/24 , #  並且讓127.0.0.1 以及本機 IP 192.168.0.2 可以不受限制,所以: restrict default ignore # 關閉所有的 NTP 要求封包 restrict 127.0.0.1  #開啟內部遞迴網路介面 lo restrict 192.1

23、68.0.2  # 主機本身的 IP 也同時開啟! restrict 192.168.100.20 mask 255.255.255.255 nomodify # 針對另一個IP 開放讓他可以更新時間! restrict 192.168.0.0 mask 255.255.255.0 nomodify # 在網域裡面的client 可以進行網路校時,但不會影響 Server ! # 2. 上層主機的設定 #  上層主機我們選擇time.stdtime.gov.tw ,要設定上層主機主要以 server  #  這個參數來設定,語法為: # #  serv

24、er [IP|FQDN] [prefer] # #  Server 後面接的就是我們上層 Time Server 囉!而如果 Server 參數 #  後面加上perfer 的話,那表示我們的 NTP 主機主要以該部主機來作為 #  時間校正的對應。另外,為了解決更新時間封包的傳送延遲動作, #  所以可以使用driftfile 來規定我們的主機 #  在與 Time Server 溝通時所花費的時間,可以記錄在 driftfile  #  後面接的檔案內,例如下面的範例中,我們的NTP server 與  #  time.stdtime.gov.tw連線時所花費的時間會記錄在

25、 /etc/ntp/drift 檔案內 # 先輸入第二層主機的IP server 210.59.157.10 prefer server 210.59.157.30 prefer server 202.39.157.155 prefer # 第一層的主機就列為參考用! server 210.59.157.40 server 210.59.157.41 server 202.39.157.151 # 當然要讓Server 可以進入我們的 NTP 主機啦!權限要開放啊! restrict 210.59.157.10 restrict 210.59.157.

26、30 restrict 202.39.157.155 restrict 210.59.157.40 restrict 210.59.157.41 restrict 202.39.157.151 driftfile /etc/ntp/drift 最后附上我的修改过后的/etc/ntp.conf文件。 参考了以下几篇文章: 在RedHat9下配置时间服务器 [时间同步]NTP服务器的配置 [原创]linux NTP配置 簡易 NTP 伺服器設定 # Prohibit general access to this service. #restrict def

27、ault ignore restrict 66.187.224.4 mask 255.255.255.255 nomodify notrap noquery restrict 66.187.224.4 mask 255.255.255.255 nomodify notrap noquery restrict 66.187.224.4 mask 255.255.255.255 nomodify notrap noquery restrict 66.187.233.4 mask 255.255.255.255 nomodify notrap noquery # Permit all

28、access over the loopback interface. This could # be tightened as well, but to do so would effect some of # the administrative functions. restrict 127.0.0.1 # -- CLIENT NETWORK ------- # Permit systems on this network to synchronize with this # time service. Do not permit those systems t

29、o modify the # configuration of this service. Also, do not use those # systems as peers for synchronization. restrict 192.168.28.0 mask 255.255.255.0 nomodify # --- OUR TIMESERVERS ----- # or remove the default restrict line # Permit time synchronization with our time source, but do not

30、 # permit the source to query or modify the service on this system. # restrict mytrustedtimeserverip mask 255.255.255.255 nomodify notrap noquery # server mytrustedtimeserverip # --- NTP MULTICASTCLIENT --- #multicastclient # listen on default 224.0.1.1 # restrict 224.0.1.1 mask 255.

31、255.255.255 notrust nomodify notrap # restrict 192.168.1.0 mask 255.255.255.0 notrust nomodify notrap # --- GENERAL CONFIGURATION --- # # Undisciplined Local Clock. This is a fake driver intended for backup # and when no outside source of synchronized time is available. The # default str

32、atum is usually 3, but in this case we elect to use stratum # 0. Since the server line does not have the prefer keyword, this driver # is never used for synchronization, unless no other other # synchronization source is available. In case the local host is # controlled by some external source, s

33、uch as an external oscillator or # another protocol, the prefer keyword would cause the local host to # disregard all other synchronization sources, unless the kernel # modifications are in use and declare an unsynchronized condition. # server 66.187.224.4 fudge 127.127.1.0 stratum 10 # #

34、 Drift file. Put this in a directory which the daemon can write to. # No symbolic links allowed, either, since the daemon updates the file # by creating a temporary in the same directory and then rename()'ing # it to the file. # driftfile /var/lib/ntp/drift broadcastdelay 0.008 # # Authen

35、tication delay. If you use, or plan to use someday, the # authentication facility you should make the programs in the auth_stuff # directory and figure out what this number should be on your machine. # authenticate yes # # Keys file. If you want to diddle your server at run time, make a #

36、 keys file (mode 600 for sure) and define the key number to be # used for making requests. # # PLEASE DO NOT USE THE DEFAULT VALUES HERE. Pick your own, or remote # systems might be able to reset your clock at will. Note also that # ntpd is started with a -A flag, disabling authentication, that

37、 # will have to be removed as well. # keys /etc/ntp/keys Linux 配置NTP服务器   2012-06-14 11:11:41|  分类: Linux|字号 订阅   1.验证Server上的NTP版本 [root@testdb ~]# rpm -q ntp ntp-4.2.2p1-9.el5_4.1 如果没有安装,需要在安装光盘的Server目录下找到ntp-*.rpm并安装 2.修改有关权限的设置 [root@testdb ~]# vim /etc/ntp.conf 常用选项: ign

38、ore: 禁止所有的NTP请求包进入 nomodify: 禁止其他计算机更改本机NTP服务的设置,但可以通过NTP服务器进行网络校时 notrust: 禁止所有未通过认证的NTP包进入 noquery: 禁止其他计算机查询本机NTP服务的状态 我这里的设置: restrict default nomodify notrap noquery restrict 127.0.0.1 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap restrict 192.168.0.0 mask 255.255.255.0 nomo

39、dify notrap server 0.asia.pool.ntp.org server 1.asia.pool.ntp.org server 2.asia.pool.ntp.org server 3.asia.pool.ntp.org server 127.127.1.0 fudge 127.127.1.0 stratum 10 3.启动NTP [root@testdb ~]# /etc/init.d/ntpd start 4.停止NTP [root@testdb ~]# /etc/init.d/ntpd stop 5.重启NTP [root@testdb ~]#

40、/etc/init.d/ntpd restart 6.设置NTP随系统启动自动加载 [root@testdb ~]# chkconfig ntpd on 7.检查NTP服务同步状态 [root@testdb ~]# ntpq -p 8.客户端时间同步命令 ntpdate 192.168.0.18 (此IP地址为配置的本地NTP服务器的IP地址) 当用ntpdate -d 来查询时会发现导致 no server suitable for synchronization found 的错误的信息有以下2个:   错误1.Server dropped: Strata too high

41、  在ntp客户端运行ntpdate serverIP,出现no server suitable for synchronization found的错误。  在ntp客户端用ntpdate –d serverIP查看,发现有“Server dropped: strata too high”的错误,并且显示“stratum 16”。而正常情况下stratum这个值得范围是“0~15”。  这是因为NTP server还没有和其自身或者它的server同步上。 以下的定义是让NTP Server和其自身保持同步,如果在/etc/ntp.conf中定义的server都不可用时,将使用loc

42、al时间作为ntp服务提供给ntp客户端。  server 127.127.1.0  fudge 127.127.1.0 stratum 8 在ntp server上重新启动ntp服务后,ntp server自身或者与其server的同步的需要一个时间段,这个过程可能是5分钟,在这个时间之内在客户端运行ntpdate命令时会产生no server suitable for synchronization found的错误。 那么如何知道何时ntp server完成了和自身同步的过程呢?  在ntp server上使用命令:  # watch ntpq -p  出现画面:  [r

43、oot@RHEL5 etc]# ntpq -p      remote           refid      st t when poll reach   delay   offset  jitter ============================================================================== *clock1.redhat.c .CDMA.           1 u   45   64  277  375.752   -4.900   3.338 注意reach这个值,在启动ntp server服务后,这个值就从0开

44、始不断增加,当增加到17的时候,从0到17是5次的变更,每一次是poll的值的秒数,是64秒*5=320秒的时间。  如果之后从ntp客户端同步ntp server还失败的话,用ntpdate –d来查询详细错误信息,再做判断。 错误2.the NTP socket is in use, exiting [root@RHEL5 etc]# ntpdate 192.168.2.226 14 Jun 11:08:19 ntpdate[3504]: the NTP socket is in use, exiting 在NTP服务器上不能私用ntpdate命令,可以使用ntpq -p查看同步

45、状态 错误3.Server dropped: no data  从客户端执行netdate –d时有错误信息如下: 28 Jul 17:42:24 ntpdate[14148]: no server suitable for synchronization found 出现这个问题的原因可能有2: 1.检查ntp的版本,如果你使用的是ntp4.2(包括4.2)之后的版本,在restrict的定义中使用了notrust的话,会导致以上错误。 2.检查ntp server的防火墙。可能是server的防火墙屏蔽了upd 123端口。 可以用命令  #service iptables stop  来关掉iptables服务后再尝试从ntp客户端的同步,如果成功,证明是防火墙的问题,需要更改iptables的设置。

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服