Chinaunix首页 | 论坛 | 博客
  • 博客访问: 784882
  • 博文数量: 179
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1536
  • 用 户 组: 普通用户
  • 注册时间: 2015-01-27 11:05
个人简介

MySQL工程师 QQ:1815357042

文章分类

全部博文(179)

文章存档

2015年(179)

分类: LINUX

2015-03-06 11:12:14

用ntpdate同步时间
  1. [root@steven ~]# ntpdate time.windows.com
  2.  6 Mar 11:04:09 ntpdate[1937]: step time server 64.4.10.33 offset 66.227650 sec


返回类似以下结果表示同步成功:
6 Mar 11:04:09 ntpdate[1937]: step time server 64.4.10.33 offset 66.227650 sec

当然可以局域网内自己搭建一台ntpd时间服务器,用来同步局域网内机器的时间
一、安装
  1. [root@steven ~]# yum install ntp -y
  2. Loaded plugins: fastestmirror, security
  3. Loading mirror speeds from cached hostfile



二、用cat命令查看ntp的配置:
  1. [root@steven ~]# cat /etc/ntp.conf
  2. # For more information about this file, see the man pages
  3. # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).

  4. driftfile /var/lib/ntp/drift

  5. # Permit time synchronization with our time source, but do not
  6. # permit the source to query or modify the service on this system.
  7. restrict default kod nomodify notrap nopeer noquery
  8. restrict -6 default kod nomodify notrap nopeer noquery

  9. # Permit all access over the loopback interface. This could
  10. # be tightened as well, but to do so would effect some of
  11. # the administrative functions.
  12. restrict 127.0.0.1
  13. restrict -6 ::1

  14. # Hosts on local network are less restricted.
  15. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

  16. # Use public servers from the pool.ntp.org project.
  17. # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  18. server 0.centos.pool.ntp.org iburst
  19. server 1.centos.pool.ntp.org iburst
  20. server 2.centos.pool.ntp.org iburst
  21. server 3.centos.pool.ntp.org iburst

  22. #broadcast 192.168.1.255 autokey    # broadcast server
  23. #broadcastclient            # broadcast client
  24. #broadcast 224.0.1.1 autokey        # multicast server
  25. #multicastclient 224.0.1.1        # multicast client
  26. #manycastserver 239.255.254.254        # manycast server
  27. #manycastclient 239.255.254.254 autokey # manycast client

  28. # Enable public key cryptography.
  29. #crypto

  30. includefile /etc/ntp/crypto/pw

  31. # Key file containing the keys and key identifiers used when operating
  32. # with symmetric key cryptography.
  33. keys /etc/ntp/keys

  34. # Specify the key identifiers which are trusted.
  35. #trustedkey 4 8 42

  36. # Specify the key identifier to use with the ntpdc utility.
  37. #requestkey 8

  38. # Specify the key identifier to use with the ntpq utility.
  39. #controlkey 8

  40. # Enable writing of statistics records.
  41. #statistics clockstats cryptostats loopstats peerstats
========================
红色部分是默认的ntp服务器地址,找出来以备ntpdate 使用

阅读(2354) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~