一、搭建时间同步服务器
1、编译安装ntp server
rpm -qa | grep ntp
若没有找到,则说明没有安装ntp包,从光盘上找到ntp包,使用
rpm -Uvh ntp***.rpm
进行安装
2、修改ntp.conf配置文件
vi /etc/ntp.conf
①、第一种配置:允许任何IP的客户机都可以进行时间同步
将“restrict default nomodify notrap noquery”这行修改成:
restrict default nomodify notrap
配置文件示例:/etc/ntp.conf
②、第二种配置:只允许192.168.211.***网段的客户机进行时间同步
在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同步)之后增加一行:
restrict 192.168.211.0 mask 255.255.255.0 nomodify notrap
3、启动ntp服务
service ntpd start
开机启动服务
chkconfig ntpd on
4、ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。
二、配置时间同步客户机
手工执行 ntpdate <ntp server> 来同步
ntpdate 192.168.xxxx
如果我们不想搭建时间服务器的话,我们可以同步ubuntu的时间服务器 ntp.ubuntu.com