环境

软件:fedora14,装在virtualbox虚拟机上

硬件:x86

具体步骤

检查是否安装了ntp

运行如下命令:

rpm -qa | grep ntp

如果有如下输出,表示有安装ntp 服务器

ntp-4********

如果有如下输出,表示有安装ntp客户端

ntpdate-******

如果没有安装,执行 yum -y install ntp

修改ntp的配置文件

用文件ntp.conf替换掉/etc/ntp.conf文件,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. # rongp comment
#restrict default kod nomodify notrap nopeer noquery
#restrict -6 default kod nomodify notrap nopeer noquery
restrict 192.168.1.94
restrict 192.168.1.0 mask 255.255.255.0 nomodify
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
# rongp comment
# 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
server ntp.amnic.net prefer
server time.windows.com prefer
server time-nw.nist.gov prefer
server time.nist.gov prefer restrict ntp.amnic.net
restrict time.windows.com
restrict time-nw.nist.gov
restrict time.nist.gov prefer # Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# rongp comment
# server 0.fedora.pool.ntp.org iburst
# server 1.fedora.pool.ntp.org iburst
# server 2.fedora.pool.ntp.org iburst
# server 3.fedora.pool.ntp.org iburst #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 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 # local clock
fudge 127.127.1.0 stratum 10 # Enable public key cryptography.
#crypto includefile /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

重启ntp服务器

执行命令: service ntpd restart

检查是否正常开启ntp服务器

执行命令: ps -ef | grep ntpd | grep -v grep

如果有输出表示已开启,然后用客户端进一步测试能否正常同步到该ntp服务器,用另外一台电脑(需要安装ntpdate),执行ntpdate ntp服务器地址 eg: ntpdate 192.168.1.94

如果有如下类似输出:

28 May 17:33:39 ntpdate[29134]: step time server 192.168.1.94 offset 3.174187 sec

表示同步成功。

注意:刚开启的ntp服务器需要过几分钟后客户端才能够去同步,因为ntp服务器本身要和远程ntp服务器同步需要时间,因此可能会遇到如下出错信息:

28 May 17:32:00 ntpdate[29104]: no server suitable for synchronization found

这种情况,过几分钟后再试试,这个情况还可能是其他原因导致,这里不再描述。

附录

配置文件说明:

restrict开头的行,表示设置客户端连接到本ntp服务器的权限

server开头的行,表示设置本ntp服务器连接到远程ntp服务器的地址

server 127.127.1.0 # local clock

fudge 127.127.1.0 stratum 10

上面两行的意思是如果server指定的服务器连接失败,采用本地的时间来同步时间

完!

2012年6月

linux下ntp服务器搭建方法的更多相关文章

  1. Linux下SVN服务器搭建配置

    Linux下SVN服务器搭建配置 1.SVN服务安装 yum install subversion 2.创建SVN代码仓库 mkdir /data/svn svnadmin create /data/ ...

  2. linux下的服务器搭建集成环境

    linux下的服务器搭建集成环境 ——写给初学者的我们 1.准备工具 1.1 SecureCRT SecureCRT是一款支持SSH(SSH1和SSH2)的终端仿真程序,简单地说是Windows下登录 ...

  3. Linux下dns服务器搭建

    Linux下dns服务器搭建1-环境Red Hat Enterprise Linux Server release 6.7 (Santiago)2-配置本地yum源安装dns相关包yum -y ins ...

  4. 《Linux下FTP服务器搭建及FTP使用》

    .LOGAndy:mxtd114 <Linux下FTP服务器搭建> 0.root登录 1.安装ftp # yum -y install ftp 2.安装vsftpd # yum -y in ...

  5. Linux下DNS服务器搭建详解

    Linux下DNS服务器搭建详解 DNS  即Domain Name System(域名系统)的缩写,它是一种将ip地址转换成对应的主机名或将主机名转换成与之相对应ip地址的一种机制.其中通过域名解析 ...

  6. Windows下SVN服务器搭建方法整理(apache)

    http://skydream.iteye.com/blog/437959 http://www.cnblogs.com/liuke209/archive/2009/09/23/1572858.htm ...

  7. Linux下Jenkins服务器搭建

    系统环境 操作系统:CentOS6.9 java jdk:java 8 Jenkins版本:jenkins-2.78-1.1.noarch.rpm 关闭防火墙 注意:如果是基于msbuild构建.ne ...

  8. linux下FTP服务器搭建教程1

    你买了个主机就像是买了块地皮,搭建FTP就像是盖房子,我在地皮上建房子,然后创建的用户就像是钥匙,我给谁钥匙(权限),谁就可以到我家去玩,去放东西,拿东西. 虽然我们买不起现实的房子,但是我们可以买互 ...

  9. Linux 下 SVN服务器搭建

    使用Linux(CentOS)搭建SVN服务器全攻略 虽然在windows上搭建SVN很简单,但是效能却不高,这当然是和linux相比了.然而在linux上搭建SVN却非常繁琐,所以今天这篇文章就来一 ...

随机推荐

  1. 第二十二篇 正在表达式 re模块

    re模块****** 就本质而言,正则表达式时一种小型的,高度专业化的编程语言,在python里,它内嵌在python中,并通过re模块实现.正则表达式模式被编译成一系列的字节码.然后用C编写的匹配引 ...

  2. 实现网页布局的自适应 利用@media screen

    利用@media screen实现网页布局的自适应,IE9一下不支持 @media screen /*1280分辨率以上(大于1200px)*/ @media screen and (min-widt ...

  3. LeetCode 3——无重复字符的最长子串

    1. 题目 2. 解答 2.1. 方法一 我们从前往后遍历字符串,start 代表最长子串的起始位置,一开始设置为零. 如果没有遇到重复字符,则更新子串的长度,向后遍历. 如果遇到重复字符时,则更新字 ...

  4. TensorFlow 调用预训练好的模型—— Python 实现

    1. 准备预训练好的模型 TensorFlow 预训练好的模型被保存为以下四个文件 data 文件是训练好的参数值,meta 文件是定义的神经网络图,checkpoint 文件是所有模型的保存路径,如 ...

  5. hibernate 批量插入

    Session session = sessionFactoryUpLowLimit.openSession(); session.beginTransaction(); for(int i=0 ;i ...

  6. asp.net页面中的Console.WriteLine结果如何查看

    其实用Console.WriteLine("xxxxx"),在asp.net Web程序,在输出窗口是不会输出结果的,应该用Debug.WriteLine("xxxxx& ...

  7. 对TDD的实践感悟

    文章:我的TDD实践:可测试性驱动开发(上) 文章表达的思想是,达到一个目的并非只有一种套路,作者用写代码时,时刻考虑代码的可测试性,来推动项目的合理开发.

  8. 一个台阶总共有n级,如果一次可以跳1级,也可以跳2级。求总共有 多少总跳法?

    首先我们考虑最简单的情况:如果只有1 级台阶,那显然只有一种跳法,如果有2 级台阶,那就有两种跳的方法了:一种是分两次跳,每次跳1 级:另外一种就是一次跳2 级.现在我们再来讨论一般情况:我们把n 级 ...

  9. Win7/8, convert dynamic disk volume to basic volume.

    之前不小心用了Win8自带的Disk Management 来调整磁盘分区的大小,当时跳出来一个warning窗口,说如果继续操作会变成dynamic disk,然后xxxx. 我心想都是Window ...

  10. Aspose.Pdf合并图片到PDF文件

    将图片和PDF文件合成为新的PDF文件,可以先将图片转换为PDF文件, 然后合成PDF即可, 将图片转换成PDF文件有如下方法: Aspose.Pdf.Document Aspose.Pdf.Gene ...