十五年测试老手,长期负责WEB\APP 项目测试,目前主要负责团队管理工作。

Linux下快速搭建ntp时间同步服务器

上一篇 / 下一篇  2010-01-09 18:50:18 / 个人分类:其它

一、搭建时间同步服务器
&ZT^T@7@v01、编译安装ntp server
;Y d4{B?pqm0
wgethttp://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2.4p4.tar.gz51Testing软件测试网Y[wCg8u&^3}
tar zxvf ntp-4.2.4p4.tar.gz
wO0@W]m0cd ntp-4.2.4p451Testing软件测试网NGGv+j4e
./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks51Testing软件测试网L)Uc{(m8Z xM(O:d
make && make install
51Testing软件测试网 f t&j WJN(GO-nl
注:如以上下载地址无法访问,请从ntp官方下载网页(http://www.ntp.org/downloads.html)寻找下载地址。
#[[wbb+a0
uRD R S'Lx02、修改ntp.conf配置文件51Testing软件测试网|.n;g,~ C
vi /etc/ntp.conf
51Testing软件测试网bm.nfHB
①、第一种配置:允许任何IP的客户机都可以进行时间同步
OC G*Vu.c0将“restrict default nomodify notrap noquery”这行修改成:51Testing软件测试网 VO/y,C"_&iW
restrict default nomodify
51Testing软件测试网'[(Dz"yo"H4l V H6OJ
配置文件示例:/etc/ntp.conf51Testing软件测试网4`3xSC,s"SeK

ap|gy0②、第二种配置:只允许192.168.18.***网段的客户机进行时间同步
Lmaqn,I0在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同步)之后增加一行:51Testing软件测试网9O2gv9D"L EN8_9J r}
restrict 192.168.18.0 mask 255.255.255.0 nomodify
51Testing软件测试网C4Zbs]1| z@(K
配置文件示例:/etc/ntp.conf51Testing软件测试网6U1VC.m2[5{"ku(xo0b

/_ qE Fl x!BA03、以守护进程启动ntpd51Testing软件测试网3jb$r-f*}~.IXy
/usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid
51Testing软件测试网O#Ll'Hn.J
4、ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。51Testing软件测试网YV(D!l%V

.DS y4s.D E8o0二、配置时间同步客户机51Testing软件测试网pR'p4[ j
vi /var/spool/cron/root
51Testing软件测试网q/}+{+]/y
增加一行,在每天的5点13分、9点13分、14点13分、19点13分与时间同步服务器进行同步
R'@6m"oMVjmL0
13 5,9,14,19 * * * /usr/sbin/ntpdate 192.168.18.2

V_3q4K s5Y4d%RL0备注:如果客户机没有ntpdate,可以下载ntpdate.tar.gz到/usr/sbin/目录,然后解压:
2W ZK,Q.J3Xlx-KZ0
wgethttp://blog.s135.com/attachment/200708/ntdate.tar.gz51Testing软件测试网!AN)i_-ERJ8`4_
cd /usr/sbin/
Kq_^RL2m0tar zxvf ntpdate.tar.gz

TAG: Linux ntp 时间同步服务器

 

评分:0

我来说两句

Open Toolbar