Centos-时间服务器


一,CentOS服务器
 
测试ntp服务:
[root@localhost ~]# ntpdate time.nist.gov 22 Oct 21:11:43 ntpdate[5014]: adjust time server 207.200.81.113 offset -0.018788 sec
 
1,不存在ntp服务
yum install ntp
 
测试ntp服务成功, 编辑/etc/crontab添加:
*/10 * * * * ntpdate time.nist.gov   #域名或IP  (每隔十分钟同步一次)
推荐几个时间服务器。
time.nist.gov
time.nuri.net
asia.pool.ntp.org
asia.pool.ntp.org
asia.pool.ntp.org
asia.pool.ntp.org
 
2, 存在ntp服务
<1>,创建时间服务器
[1], 编辑/etc/ntp.conf
restrict 192.168.20.0 mask 255.255.255.0 nomodify notrap
 
nomodify - 用户端不能更改ntp服务器的时间参数
noquery - 用户端不能使用ntpq,ntpc等命令来查询ntp服务器
notrap - 不提供trap远端登陆
 
[2], 开启ntp服务
chkconfig ntpd on  // 让ntp服务开机启动 
/etc/init.d/ntpd start // 启动ntp服务
 
[3], 查看ntp服务端口
netstat -unlnp  (如果正常,应该可以看到123端口已经开启)
<2>, 设置子服务器
[1], 编辑/etc/ntp.conf添加时间服务器地址
server 192.168.20.91
 
[2],   启动ntp服务
chkconfig ntpd on  // 让ntp服务开机启动 
/etc/init.d/ntpd start // 启动ntp服务
 
NTP服务进程 :
netstat -upnl |grep ntpd //查看时程
ntpq -pn //查看同步的服务器IP
ntpstat //同步的结果


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM