1. 安装软件包:
Yum install ntp
Ntp的配置文件是/etc/ntp.conf,工作目录是/etc/ntp/,接着编辑/etc/ntp.conf文件。
2. 服务端配置:
IP:192.168.1.110
编辑/etc/ntp.conf文件:
[root@rhel5 ~]# cat /etc/ntp.conf
# 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
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
# Hosts on local network are less restricted.
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap(允许内网通讯)
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap noquery notrust(禁止其他ip来更新时间)
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.pool.ntp.org(redhat默认情况下是server 0.redhat.pool.ntp.org)
server 1.pool.ntp.org(redhat默认情况下是server 1.redhat.pool.ntp.org)
server 2.pool.ntp.org(redhat默认情况下是server 2.redhat.pool.ntp.org)
#broadcast 192.168.1.255 key 42 # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 key 42 # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 key 42 # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0
fudge 127.127.1.0 stratum 10
# 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 (driftfile 选项,则指定了用来保存系统时钟频率偏差的文件, ntpd程序使用它来自动地补偿时钟的自然漂移, 从而使时钟即使在切断了外来时源的情况下,仍能保持相当的准确度)
# 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
Logfile /var/log/ntp.log(定义日志信息)
# Specify the key identifier to use with the ntpq utility.
#controlkey 8
restrict 0. pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 1. pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 1. pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
如果restric 后面不带参数,表示可以允许全部权限.以上三个影响/etc/ntp/ step-tickers这个文件,它会随着/etc/ntp.conf文件的变化而变化。
/etc/sysconfig/clock是用来设置时区的文件,例如:
[root@rhel5 ntp]# cat /etc/sysconfig/clock
# The ZONE parameter is only evaluated by system-config-date.
# The timezone of the system is defined by the contents of /etc/localtime.
ZONE="Asia/Chongqing"
UTC=true
ARC=false
/usr/share/zoneinfo这个目录里规定了各主要时区的时间设定文件,例如重庆:/usr/share/zoneinfo/Asia/Chongqing
如果想把同步好的时间写入BIOS里,就要设置/etc/sysconfig/ntp文件,将其中的SYNC_HWCLOCK=no更改为SYNC_HWCLOCK=yes。
启动ntp服务:
[root@rhel5 ntp]# service ntpd restart
Shutting down ntpd: [ OK ]
ntpd: Synchronizing with time server: [ OK ]
Starting ntpd: [ OK ]
[root@rhel5 ntp]#chkconfig ntpd on
3. 客户端的设置:
可以通过使用system-config-time来设置,将其中的时间服务器更改为192.168.1.110即可,或者使用ntpdate -u 192.168.1.110来和时间服务器同步。切记更改完以后要重新启动NTP服务,使其生效。或者使用crontab -e来编辑:
*/5 * * * * /usr/sbin/ntpdate -u 192.168.1.110 表示每五分钟同步一次。重启crond服务即可。
可以使用ntpq –p查看同步状态

Rhel5 之NTP服务配置相关推荐

  1. linux设置ntp后不生效,Linux时间设置与NTP服务配置

    第一部分:时间设置 一.时间和时区 格林威治时间(GMT),是0时区时间.计算机中是UTC.它是Coordinated Universal Time的简写.虽然UTC和GMT的值相等(误差相当之小), ...

  2. Linux NTP服务配置 for Oracle RAC

    安装Oracle 11g RAC时,我们需要配置ntp服务.在使用虚拟机的情况下对于时钟同步方式的配置有很多种方式,可以使用vmware自带的时钟同步功能,也可以直接将本地的一个节点用作时间服务器.本 ...

  3. Linux NTP服务配置

    一.NTP对时原理 NTP同步的方向是从stratum值较小的节点向较大的节点传播,如果某个NTP客户端接收到stratum比自己还要大,那么NTP客户端认为自己的时间比接受到的时间更为精确,不会进行 ...

  4. NTP 服务的配置和使用

    NTP 服务可以用来当做客户端所在服务器的时间,也可以作为服务端当做时间校准的服务. 安装 NTP $ yum -y install ntp # 开机自启 $ systemctl enable ntp ...

  5. linux ntp时间同步配置,Linux ntp 时间同步服务配置

    一.基础环境 1.操作系统:CentOS 7.3 2.ntp:4.2.6 3.机器,服务端(192.168.1.210)客户端(192.168.1.211) 二.安装ntp yum -y instal ...

  6. linux常用的服务配置

     说明:由于本人比较喜欢使用有道云笔记,为了避免重复性的笔记记录,下面都是有道云笔记的链接QAQ apache服务配置 http://note.youdao.com/noteshare?id=c85e ...

  7. 奥塔在线:Centos7下NTP服务的详细部署说明

    一.NTP 是什么?   NTP即Network Time Protocol(网络时间协议),是一个互联网协议,用于同步网络设备[如计算机.手机]之间的系统时钟.   二.NTP 实现什么目的?   ...

  8. 利用ntp服务同步时间(史上最简单)

    说明(文末附XShell下载地址): 本文仅适用于测试环境下,解决集群时间同步问题. 生产环境ntp服务配置一般不能连外网,需要自行指定一台服务器作为ntp服务器,此服务器可以通过手动设置时间并写入c ...

  9. CentOS7配置ntp服务

    安装ntp # yum install ntp 开启ntp服务 # systemctl start ntpd 配置防火墙,允许其他主机可以连接到此主机上的ntp服务 # firewall-cmd -- ...

最新文章

  1. 如何使用:before和:after伪元素?
  2. 测试架构师的目标和价值
  3. c51语言的设计步骤,第3章节单片机c51语言程序的设计基本.ppt
  4. android系统耗电量大待机,安卓手机耗电快有什么解决办法吗 安卓手机待机耗电量大怎么办...
  5. 线程下的udp和tcp局域网聊天
  6. 如何快速获取properties中的配置属性值
  7. Java项目--俄罗斯方块
  8. 【flume】flume案例集锦
  9. python几行代码识别验证码_Python有多强?文字识别(验证码识别)只需三行代码!...
  10. 学习 Message(11): 测试 TWMMouse 结构相关的鼠标消息
  11. 谜题40:不情愿的构造器
  12. php5.6/7.0,浅谈PHP5.6 与 PHP7.0 区别
  13. python实现归结演绎推理_归结演绎推理
  14. Office word 列表级别不显示解决办法
  15. python将图片帧生成视频
  16. java excel 多列排序,《excel表格调取行和列的数据》 excel列排序的时候怎么让所有行的信息跟着排(其它的非数据行)...
  17. Android--热修复,补丁实战
  18. 95后女孩从月入3000到月入10万
  19. CopyWebpackPlugin的ignore
  20. Springboot集成Brpc

热门文章

  1. mysql查其它用户的表_mysql sql查询如何实现发私信用户和其他用户的列表?要求消重所有重复的用户结果...
  2. vue页面跳转数据传递
  3. wps中,点空格或者enter之后首字母变大写问题
  4. 《天天数学》连载26:一月二十六日
  5. HTML学习笔记:演示HTML页面之间传递数据
  6. 【codevs3732】【BZOJ3751】解方程,hash+秦九韶算法
  7. 【BZOJ2818】Gcd,数论练习之欧拉筛
  8. 提出邀请Do you want..._43
  9. delphi 发送网络消息_《新手学习ISO网络模型》(1)如何直观理解物理层?
  10. c语言block内部的实现原理,iOS中block变量捕获原理详析