在内网中,让几台Linux时间同步
1,安装好ntp
可以用 rpm -aq | grep ntp 看是否安好,一般自带安好。
2,用一台作为服务端配置:
配置:
Vim /etc/ntp.conf
restrict default mask 255.255.255.0 nomodify #权限设置,default 表示所有ip ,客户端可以同步该服务器时间,但不能修改。
server 127.127.1.0 # local clock (LCL) 读取本机时间
fudge 127.127.1.0 stratum 1 # LCL is unsynchronized 设置级别
启动ntp服务
service ntp start
chkconfig ntp on 开机启动服务
修改配置文件后须要从启:
service ntp restart
查看是否成功启动:
netstat -tlunp | grep ntp
3,多个客户端配置:
配置:
Vim /etc/ntp.conf
restrict 10.100.213.156 # 权限设置,允许这个服务器,对本机的所有操作
server 10.100.213.156
fudge 10.100.213.156 stratum 2 # LCL is unsynchronized
启动ntp服务
service ntp start
chkconfig ntp on 开机启动服务
查看是否正常与10.100.213.156进行时间同步:
ntpq -p
可手动同步看看:
sntp 10.100.213.156