您的位置:首页 > 运维架构 > Linux

linux 下的时间同步服务器NTP

2010-05-13 09:36 218 查看
安装平台:CentOS 5.3 64位
NTP服务器设置
通过yum 安装,也可以直接用安装光盘里的rpm 文件安装
# yum install ntp
配置ntp 配置文件:/etc/ntp.conf
restrict 192.168.1.0子mask 255.255.255.0 nomodify
只需要设置上面这一句即可,上面这一句的意思是允许内网中某一个网段的客户端通过这台ntp服务器同步时间
启动ntp 服务
# /etc/init.d/ntpd start
# /sbin/chkconfig --level 35 ntpd on
查看同步的状态
#ntpstat
synchronised to NTP server (221.7.129.79) at stratum 3
time correct to within 115 ms
polling server every 64 s
出现以上内容时,说明同步成功。
客户端设置
客户端两种方式:一种是用ntpdate 同步,一种是用 ntp 服务同步
1、ntpdate 同步
# yum install ntp
通过crontabe 设置同步频率
*/20 * * * * /root/ntpsync.sh
# cat /root/ntpsync.sh
#!/bin/bash
/usr/sbin/ntpdate 192.168.1.1
/sbin/hwclock -w
192.168.1.1 是内部NTP服务器IP

2、ntp服务同步
# yum install ntp
编辑/etc/ntp.conf
将以下三行注释掉
#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org
添加如下这一行
server 192.168.1.1
192.168.1.1 是内部NTP服务器IP
# /etc/init.d/ntpd start
# /sbin/chkconfig --level 35 ntpd on
查看同步状态
# ntpstat
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: