[文章作者:张宴 本文版本:v1.1 最后修改:2010.02.21 转载请注明出处:http://blog.zyan.cc]

一、搭建时间同步服务器
1、编译安装ntp server
wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2.6.tar.gz
tar zxvf ntp-4.2.6.tar.gz
cd ntp-4.2.6
./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks
make && make install

注:如以上下载地址无法访问,请从ntp官方下载网页(http://www.ntp.org/downloads.html)寻找下载地址。

2、修改ntp.conf配置文件
vi /etc/ntp.conf

①、第一种配置:允许任何IP的客户机都可以进行时间同步
将“restrict default kod nomodify notrap nopeer noquery”这行修改成:
restrict default nomodify

配置文件示例:/etc/ntp.conf

②、第二种配置:只允许192.168.18.***网段的客户机进行时间同步
在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同步)之后增加一行:
restrict 192.168.18.0 mask 255.255.255.0 nomodify

配置文件示例:/etc/ntp.conf

3、以守护进程启动ntpd
/usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid

4、ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。

二、配置时间同步客户机
vi /var/spool/cron/root

增加一行,在每天的5点13分、9点13分、14点13分、19点13分与时间同步服务器进行同步
13 5,9,14,19 * * * /usr/sbin/ntpdate 192.168.18.2

备注:如果客户机没有ntpdate,可以下载ntpdate.tar.gz到/usr/sbin/目录,然后解压:
wget http://blog.zyan.cc/attachment/200708/ntdate.tar.gz
cd /usr/sbin/
tar zxvf ntpdate.tar.gz


Tags:



技术大类 » 其他Unix技术 | 评论(60) | 引用(0) | 阅读(87823)
domini Homepage
2007-8-9 17:04
你的时间服务器没有和标准时间服务器去同步,提供的时间也就不可行了。

加入和公开时间服务器同步的配置会更好
张宴 回复于 2007-8-9 18:17
这个不用担心,ntp编译安装的时候默认已经在/etc/ntp.conf配置中增加三组标准时间服务器,每组服务器的域名(0.pool.ntp.org)下有世界各地的十多台标准时间服务器,非常强大,不会像中国国家授时中心的标准时间服务器(210.72.145.44)那样经常因为负载过大无法访问,所以无须去修改,本文中也就没有写出来。
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org

[root@zhangyan ~]# dig 0.pool.ntp.org
0.pool.ntp.org.         1598    IN      A       210.167.182.10
0.pool.ntp.org.         1598    IN      A       212.12.50.232
0.pool.ntp.org.         1598    IN      A       212.92.16.193
0.pool.ntp.org.         1598    IN      A       213.133.98.226
0.pool.ntp.org.         1598    IN      A       216.234.161.11
0.pool.ntp.org.         1598    IN      A       66.36.239.104
0.pool.ntp.org.         1598    IN      A       80.69.93.212
0.pool.ntp.org.         1598    IN      A       81.15.165.16
0.pool.ntp.org.         1598    IN      A       83.137.16.7
0.pool.ntp.org.         1598    IN      A       140.112.137.130
0.pool.ntp.org.         1598    IN      A       192.33.214.57
0.pool.ntp.org.         1598    IN      A       193.40.133.142
0.pool.ntp.org.         1598    IN      A       200.43.64.72
0.pool.ntp.org.         1598    IN      A       208.97.105.139
john
2007-9-24 15:52
我编译ntp-4.2.4p4 后,没有发现/etc/ntp.conf,奇怪了。我的系统是CentOS 5.
john
2007-9-25 14:23
编译的ntp无ntp.conf文件,需要rpm包安装。
张宴 回复于 2007-9-25 18:36
ntp.conf在源码目录内,需要自己拷贝过去。
本文中的两种配置文件,点击链接即可查看。
gregorian
2007-11-21 14:56
感觉你这样设置后,系统时间会有抖动现象,要让客户机不出现抖动,还是要使用ntpd来完成的
AWE
2008-4-30 10:29
ntp.conf在源码目录内,需要自己拷贝过去。

没有啊
AWE
2008-4-30 10:29
ntp.conf在源码目录内,需要自己拷贝过去。

没有啊
你就是老师
2008-9-11 09:08
又一个国际贸易系毕业干技术地
看来国际贸易系没前途
学习
请教
2008-10-6 22:26
你好
我想问一下,时间服务器同步上一层服务器时间,如何修改配置文件?比如我上一层时间服务器的IP 172.1.1.1
是不是只用加一行service 172.1.1.1
可是为什么我用ntpq -p不能查看到?
请高手赐教。谢谢
聚云seo Homepage
2010-1-25 10:43
好长时间没了这里了  特地来看看
策略网页游戏 Homepage
2010-2-19 18:57
呵呵  网上看到的 过来瞧瞧
007 Homepage
2010-4-19 18:37
搭建步骤看起来也不多啊。。学习下
sailing123 Email Homepage
2010-9-17 17:12
②、第二种配置:只允许192.168.18.***网段的客户机进行时间同步
在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同步)之后增加一行

noquery 不是指时间同步,是指查询 ntp 服务器自身状态,阻止客户端同步是使用ignore  参数..
www.201xtop.com Homepage
2010-11-21 11:11
学习一下 收藏了 以后可能会用到
liuyuexue
2012-3-6 16:30
/usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid
-bash: /usr/local/ntp/bin/ntpd: 没有那个文件或目录
为什么我执行启动的时候说没有ntpd文件呢?我看了下 那个路径下就是没有,试了好几次都是这样的,请问我哪里弄错了?
coach factory outlet Email Homepage
2012-5-17 10:59
Today, following half a century, mentor leather-bases coach factory outlet continues to be the delicate craft of leather-based master is accountable for,Would you like to meet more friends, or go with the times? If yes, coach factory online is opening welcome doors to you.in the market you definitely can find various colorways that are designed in as well as the high quality that applied in. For most of you would like to come. So just come to our coach factory outlet online store to choose one.
louis vuitton sale Email Homepage
2012-5-17 10:59
Louis Vuitton belt at louis vuitton sale is one kind of fashion accessory with high cost performance among the Louis Vuitton accessories.Offering quality LV products with favorable prices, louis vuitton outlet store is at your service. Hurry up, or you can not seize the chance.in fact, louis vuitton is one of the most famous fashion design master.he opened the fist suitcase shop called after his name.
coach outlet online Email Homepage
2012-5-17 10:59
I heard of coach outlet online through the advertisement when I was shopping. And now I often brow the webpage and buy Coach bags online.It is a symbol regarding position not to mention nature.Here I would like to launch a excellent bags pertaining to business men.Which may be coach outlet store.coach outlet has always been simple,durable style features to win consumers.The products are more flexible,with easy bleaching,wear characteristics,and simply use a damp cloth.
coach outlet, Email Homepage
2012-5-17 10:59
Remember the coach outlet provide coach bags which won't be deteriorated into its overall styles by any means. It will maintain its looks, colors, and uniqueness for long time.coach outlet store online has been voted by Hour Detroit magazine readers as the Best of Detroit in their 12th annual readers'poll.Lots of women like which usually amount normally include a coach outlet online ,it provides coziness to many girls that don't even think it is a great bushel of great interest directly to them.
xujie777 Email
2012-5-18 15:48
We aim to make all our customers satisfy with our products. You will find a variety of Men's fashion louis vuitton uk, fashion Women's cheap Louis Vuitton bags in our store at affordable price.Thinking of interesting ways to cost a milestone birthday? louis vuitton online shop had one of the most distinctive distinctive celebrations.bakery along with living room operated by means of about three moment louis vuitton online Most effective Pastry Chef’s of the year Rammy Nominee Chef’s.
xujie777 Email
2012-5-18 15:48
The choices are likely to be basically countless seeing that louis vuitton outlet occurs with the help of completely new and also incredible concepts once in a while.Louis vuitton Wholesale Monogram Canvas HandbagsLouis Vuitton Collection Beach Handbags louis vuitton bags outlet Damier Canvas HandbagsLouis vuitton Mahina HandbagsLouis Vuitton Monogram Mini Lin HandbagsLouis Vuitton Monogram Multicolore HandbagsLouis vuitton Monogram Vernis HandbagsLouis Vuitton Wholesale Epi Leather HandbagsLouis Vuitton For Men HandbagsLouis Vuitton Damier Canvas WalletsLouis Vuitton Epi Leather WalletsLouis Vuitton Monogram Canvas WalletsLouis Vuitton Monogram Vernis WalleLouis Vuitton ShoesLouis Vuitton Men wallets.As the Authentic Louis Vuitton are so high-priced, so came the louis vuitton handbags outlet.
分页: 1/3 第一页 1 2 3 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]