[文章作者:张宴 本文版本:v1.0 最后修改:2007.08.09 转载请注明出处:http://blog.s135.com]

一、搭建时间同步服务器
1、编译安装ntp server
wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2.4p4.tar.gz
tar zxvf ntp-4.2.4p4.tar.gz
cd ntp-4.2.4p4
./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 nomodify notrap 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.s135.com/attachment/200708/ntdate.tar.gz
cd /usr/sbin/
tar zxvf ntpdate.tar.gz
Tags:
纯粹技术 | 评论(7) | 引用(0) | 阅读(4050)
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来完成的
gamin
2008-3-29 22:37
zanstupid
AWE
2008-4-30 10:29
ntp.conf在源码目录内,需要自己拷贝过去。

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

没有啊
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]