电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 1848 人浏览分享

centos服务器搭建ntp服务

[复制链接]
1848 0
1、安装前的准备


查看系统上面设置的时区


[
  1. root@linux-node1 ~]# cat /etc/sysconfig/clock
  2. ZONE="Asia/Shanghai"
  3. 思想:怎么修改linux主机上面的解决办法:
  4. 修改时区
  5. vim /etc/sysconfig/clock
  6. ZONE="Asia/Shanghai"
  7. UTC=true
  8. ARC=false
  9. 覆盖系统时间文件
  10. cp -a /usr/share/zoneinfo/Asia/Shanghai /etc/localtime#2、开始安装ntp服务器
  11. 采用yum/rpm方式安装
  12. yum install ntp -y
  13. 查看安装是否成功
  14. [root@linux-node1 ~]# rpm -qa ntp
  15. ntp-4.2.6p5-10.el6.centos.1.x86_64
复制代码



3、开始配置ntp服务器


  1. vim /etc/ntp.conf
  2. 下面为我修改的/etc/ntp.conf配置文件,下面为大家解释一部分参数的意思:
  3. # Permit time synchronization with our time source, but do not
  4. # permit the source to query or modify the service on this system.
  5. restrict default kod nomodify notrap nopeer noquery
复制代码


  1.      #默认是拒绝所有的ntp连线
  2. restrict -6 default kod nomodify notrap nopeer noquery      #拒绝IP-V6的ntp连线
复制代码


  1. # Permit all access over the loopback interface.  This could
  2. # be tightened as well, but to do so would effect some of
  3. # the administrative functions.[/code

  4. [code]restrict 127.0.0.1                                          #这里也可以允许单个ip进行对时服务
  5. restrict -6 ::1
复制代码

  1. # Hosts on local network are less restricted.
  2. restrict 192.168.17.0 mask 255.255.255.0 nomodify notrap    #允许哪些网段可以使用这个ntp对时服务

  3. # Use public servers from the pool.ntp.org project.
  4. # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  5. #server 0.centos.pool.ntp.org iburst
  6. #server 1.centos.pool.ntp.org iburst
  7. #server 2.centos.pool.ntp.org iburst
  8. #server 3.centos.pool.ntp.org iburst

  9. [code]server 2.cn.pool.ntp.org                                    #上层ntp服务器
  10. server time.nist.gov prefer
  11. server 1.cn.pool.ntp.org
复制代码

[/code]

4、时间同步服务器上面的操作

[
  1. root@linux-node1 ~]# /etc/init.d/ntpd restart
  2. Shutting down ntpd:                                        [  OK  ]
  3. Starting ntpd:                                             [  OK  ]

  4. [root@linux-node1 ~]# ntpq -p
  5.      remote           refid      st t when poll reach   delay   offset  jitter
复制代码

==============================================================================
  1. +panel.gerardope 116.49.102.213   2 u   24   64    1  211.688  -17.119   0.122
  2. *time-d.nist.gov .ACTS.           1 u   22   64    1  348.603    3.607   0.122
  3. static-5-103-12 .GPS.            1 u   22   64    1  311.951  -16.711   0.122
复制代码


解释:

*号的意思:表示正在使用的上层NTP
+号的意思:表示已经连线成功的,可提供替补的时间同步服务器





您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

关注

0

粉丝

9021

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.