【实验Linux版本:Red Hat Enterprise Linux Server release 6.4】

1、  安装ntp

yum -y install ntp

2、  修改ntp.conf的配置

1)vim /etc/ntp.conf

①  配置方法一:只允许100.100.100.0网段的客户机进行时间同步

#在restrict default kod nomodify notrap nopeer noquery(表示默认拒绝所有IP的时间同步)之后增加一行:
restrict 100.100.100.0 mask 255.255.255.0 nomodify notrap

②  配置方法二:允许任何ip的客户机都可以进行时间同步

#将restrict default kod nomodify notrap nopeer noquery修改为如下行:
restrict default nomodify
  • 权限的设定主要以restrict这个参数来设定,主要的语法为:

restrict  IP地址  mask 子网掩码 参数

其中IP可以是IP地址也可以是default,default是指所有的IP

  • 参数主要有以下几个:

ignore :关闭所有的 NTP 联机服务

nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。

notrust:客户端除非通过认证,否则该客户端来源将被视为不信任子网

noquery:不提供客户端的时间查询

2)用server这个参数设定上级时间服务器,语法为:

server  IP地址或域名 [prefer]
  • IP地址或域名就是我们指定的上级时间服务器,如果 Server 参数最后加上 prefer,表示我们的 NTP 服务器主要以该部主机时间进行校准。

[参考/etc/ntp.conf文件]

# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).driftfile /var/lib/ntp/drift# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
#restrict default kod nomodify notrap nopeer noquery
# 允许任何ip的客户机都可以进行时间同步
restrict default nomodify
restrict -6 default kod nomodify notrap nopeer noquery# Permit all 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
restrict -6 ::1# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#iserver 0.rhel.pool.ntp.org
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org# IP地址或域名就是我们指定的上级时间服务器,如果 Server 参数最后加上 prefer,表示我们的 NTP 服务器主要以该部主机时间进行校准
server 100.100.100.27 prefer#broadcast 192.168.1.255 autokey    # broadcast server
#broadcastclient            # broadcast client
#broadcast 224.0.1.1 autokey        # multicast server
#multicastclient 224.0.1.1      # multicast client
#manycastserver 239.255.254.254     # manycast server
#manycastclient 239.255.254.254 autokey # manycast clientUndisciplined Local Clock. This is a fake driver intended for backupand when no outside source of synchronized time is available.
server  127.127.1.0 # local clock
#fudge  127.127.1.0 stratum 10  #/etc/init.d/ntpd start  #启动时间服务器
#service ntpd status
#service ntpd start# Enable public key cryptography.
#cryptoincludefile /etc/ntp/crypto/pw# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys# Specify the key identifiers which are trusted.
#trustedkey 4 8 42# Specify the key identifier to use with the ntpdc utility.
#requestkey 8# Specify the key identifier to use with the ntpq utility.
#controlkey 8# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats

-------以下内容可以不做------------

3)、解决NTP服务器校准时间时的传送延迟

使用driftfile参数设置:

driftfile 文件名

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

注意:  driftfile 后面接的文件需要使用完整的路径文件名,不能是链接文件,并且文件的权限需要设定成 ntpd守护进程可以写入。

/usr/share/zoneinfo  这个目录下存放的是各个时区对应的设定文件

/etc/localtime        本地系统时间设定文件

/etc/sysconfig/clock  本机时区设定文件

为了使NTP服务可以在系统引导的时候自动启动,执行:chkconfig ntpd on将同步好的时间写到CMOS里边vim /etc/sysconfig/ntpdSYNC_HWCLOCK=yes切记每次修改配置文件后重新启动服务使配置生效,可使用如下命令来检查NTP服务是否启动,启动的话可以得到一个进程ID号;pgrep ntpd使用下面的命令检查时间服务器同步的状态ntpq -p用ntpstat也可以查看一些同步状态信息,安装完毕客户端需要过5-10分钟才能从服务器端更新时间客户端设置:crontab -e加入一行*/15 * * * * /usr/sbin/ntpdate 100.100.100.27(服务器端IP)

Linux下安装ntp时间同步服务器相关推荐

  1. Windows下安装NTP时间同步服务器

    [实验系统版本为WIndows Server 2008 R2 Enterprise] 1.修改NTP服务相关注册表 #打开"运行" #打开注册表(regedit) #注册表定位到 ...

  2. Linux下配置NTP时间服务器

    2019独角兽企业重金招聘Python工程师标准>>> Linux下配置NTP服务器 一.前言: Network Time Protocol(NTP)是用来使计算机时间同步化的一种协 ...

  3. Linux完全离线RPM安装NTP(时间同步)服务器及基本配置

    RHEL完全离线安装NTP服务器 内网环境安装NTP服务,一般有2种方式.1.如果没有现成的时间同步服务器.一台主机A做为NTP服务器,其它主机B只安装ntpdate服务,B主机们通过ntpdate命 ...

  4. Linux下 配置NTP时间服务器

    多台linux服务器时间同步 时间服务器作用: 若计算机时间不同步,如E-MAIL信息.文件创建和访问时间.数据库处理时间等这些应用或操作或将无法正常进行. 时间同步是业务能够得到正确处理的基础保障. ...

  5. suse linux 安装oracle,SUSE Linux下安装Oracle 11g服务器

    安装环境 Linux服务器:SUSE10 sp2 64位 Oracle服务器:Oracle11gR2 64位 系统要求 Linux安装Oracle系统要求 系统要求 说明 内存 必须高于1G的物理内存 ...

  6. [Linux基础环境/软件]Linux下安装resin web服务器(涉及gcc、jdk环境部署)

    由于Ubuntu自带是没有jdk和gcc编译器的,而安装resin需要C编译器和jdk的支持,而且resin本身是java写的.另外我本身的网站是zip打包的,所以linux也要安装了gcc.jdk. ...

  7. linux搭建ldap服务器搭建,Linux下安装配置OpenLDAP服务器

    东西多了,为了好管理,我们会将它们别类:服务器中信息.资源多了,不言而喻也是这个道理,而目录服务器是这个原理.那么支持IPV6协议的OpenLDAP如何在Linux服务器上安装配置? 一.安装Open ...

  8. 在linux下安装配置DNS服务器

    详细步骤如下: 1. 在虚拟机上安装红帽6.5. 2. 所在网络:内部局域网192.168.0.0网段. 机器一作为服务器,IP:192.168.0.10, 主机名:Hostname: test.co ...

  9. linux下安装配置DHCP服务器

    前提是已经安装了 core 及 base 两个组 1 2 3 4 5 # cat /etc/redhat-release   Red Hat Enterprise Linux Server relea ...

最新文章

  1. klib库下的kroundup32(二进制的四舍五入)算法
  2. client高性能组件化框架React简单介绍、特点、环境搭建及经常使用语法
  3. [置顶]       设计模式之六大原则——单一职责原则(SRP)
  4. 7、Ktor学习-配置服务器;
  5. Apache Dubbo集群容错
  6. tomcat8.5配置优化
  7. 详细了解 clientWidth、clientHeight、clientLeft、clientTop 以及几个常用的场景
  8. Spring Boot设置匹配指定后缀*.action *.do的路径
  9. 粒子群优化算法的实现
  10. iwebAx产品家族之iweb SNS v0.6体验版--不错的开源软件~~
  11. yui3dialog
  12. jQuery 版本升级迁移
  13. jquery timepicker
  14. 六轴UR机械臂正逆运动学求解_MATLAB代码(标准DH参数表)
  15. mysql after 不起作用_mysql之触发器before和after的区别(2)
  16. 正态分布(用python画出相应的图)
  17. 无线射频专题《射频信号,链路预算与衰落容限》
  18. android ca,如何在Android设备上安装可信CA证书?
  19. JS字符串转Byte[]
  20. 接口并发测试之:WebSocket从原理到代码实战,我没草率~

热门文章

  1. redhat自带mysql_rhel4卸载系统自带的mysql4.1
  2. kitti数据集简介、百度网盘分享 kitti-object、kitti-tracking 全套数据集 自动驾驶
  3. 吴恩达机器学习(一)单变量线性回归(假设函数、代价函数、梯度下降)
  4. centos php open_basedir,CentOS 5服务器安全基本设置
  5. canvas 实现图片局部模糊_Canvas 在高清屏下绘制图片变模糊的解决方法
  6. 若依前端table中如何显示图片?
  7. Docker安装Oracle教程
  8. idea 添加servlet依赖_详解如何使用IntelliJ IDEA新建一个Servlet项目
  9. win10多合一原版系统_手把手教你制作官方原版的WIN10系统安装盘
  10. poj3254(状压dp入门第一道题,很详细)