linux 手动同步时钟,Linux下同步系统时钟

LINUX服务器系统时钟同步

说明:同步8部LINUX服务器。

l以192.168.1.1为NTP服务器,其它7部服务器为NTP Client。

其他的服务器IP分别为192.168.1.2 1.3 1.4 1.5 1.6 1.7 1.8

1.配置NTP SERVER

(1)查看1.1上是否安装NTP服务器

#rpm -qa | grep^ntp

ntp-4.2.2p1-15.el5_7.1

(2)修改配置文件/etc/ntp.conf

#vim/etc/ntp.conf

restrict defaultkod nomodify notrap nopeer noquery

restrict -6default kod nomodify notrap nopeer noquery

restrict127.0.0.1

restrict -6 ::1

restrict192.168.1.0 mask 255.255.255.0 nomodify

server 127.127.1.0 # local clock

fudge 127.127.1.0 stratum 10

driftfile/var/lib/ntp/drift

keys /etc/ntp/key

(3)启动ntp服务

service ntpdstart

Startingntpd: [ OK ]

(4)查看端口

netstat -tlunp |grep ntp

udp 0 0 192.168.1.1:123 0.0.0.0:* 6604/ntpd

udp 0 0 127.0.0.1:123 0.0.0.0:* 6604/ntpd

udp 0 0 0.0.0.0:123 0.0.0.0:* 6604/ntpd

udp 0 0 ::1:123 :::* 6604/ntpd

udp 0 0 fe80::a00:27ff:fe02:123 :::* 6604/ntpd

udp 0 0 :::123 :::* 6604/ntpd

(5)查看NTP服务器是否与上层联机。

# ntpstat

unsynchronised

time server re-starting

polling server every 64 s

上面表示未同步,注意,严格来说,这并不是一个错误,而是由于每次重启NTP服务器之后大约要3-5分钟客户端才能与server建立正常的通讯连接。当此时用客户端连接服务端就会报这样的信息。一般等待几分钟就可以了

# ntpstat

synchronised tolocal net at stratum 11

timecorrect to within 73 ms

polling server every 64 s

当显示如上面时,表示已经同步。

(6)需要放行NTP SERVER port123防火墙( iptables)。

2.配置NTP Client

(1)在NTP Client端主机中crontab –e中新增一行(192.168.1.1为NTP SERVER的IP),表示每天00:00同步NTP SERVER时钟,并将系统时钟同步到硬件时钟

# crontab –e

00 00 * * *(/usr/sbin/utpdate 192.168.1.1 && hwclock -w)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值