1. 搭建时间同步服务器
a、修改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
server 127.127.1.0
fudge 127.127.1.0 stratum 10
--与其自身保持同步;
keys /etc/ntp/keys
logfile /var/log/ntp
logconfig all
statistics clockstats cryptostats loopstats peerstats
b、启动ntp服务
service ntpd start
开机启动服务
chkconfig ntpd on
Chkconfig --list ntpd
//可以看到运行级别2、3、4、5上将开机自动启动ntpd服务
C、查看ntpd服务运行状态
Service ntpd status
D、停止ntpd服务
Service ntpd stop
e、ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。
2. 配置NTP客户端
开始-控制面板-日期和时间,Internet选项卡中勾选internet时间设置,输入服务器IP即可同步时间。
3. 设置系统时间date -s 10:18:00