返回列表 发帖

NTP服务器

NTP服务器用于网络里设备的时间同步。


NTP服务的安装:
[root@localhost ~]# yum -y install ntp


即时同步别的NTP服务器:
[root@localhost ~]# ntpdate time.windows.com
7 Apr 19:58:34 ntpdate[2208]: step time server 40.81.188.85 offset 55522171.076668 sec


启动ntpd服务:
[root@localhost ~]# service ntpd start
正在启动 ntpd:[确定]

开机自动启动ntpd服务:
[root@localhost ~]# chkconfig --level 35 ntpd on



备注:启动ntpd服务后,要想即时同步别的NTP服务器就不可以了
[root@localhost ~]# ntpdate time.windows.com
7 Apr 20:00:15 ntpdate[2229]: the NTP socket is in use, exiting


要想即时同步别的NTP服务器,必须先关掉自己的ntpd服务
[root@localhost ~]# service ntpd stop
关闭 ntpd:[确定]

[root@localhost ~]# ntpdate time.windows.com
7 Apr 20:02:09 ntpdate[2339]: adjust time server 40.81.188.85 offset -0.004754 sec






修改NTP服务的配置文件:
[root@localhost ~]# vi /etc/ntp.conf
## 仅允许某个网段的服务器进行时间同步
restrict 192.168.168.0 mask 255.255.255.0 nomodify notrap
图片1.png


## 允许任意网段的服务器进行时间同步
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap
图片2.png


修改配置文件后,重启ntpd服务:
[root@localhost ~]# service ntpd restart



防火墙配置:(允许别的服务器进行时间同步)
iptables -I INPUT -p udp --dport 123 -j ACCEPT
iptables-save > /etc/sysconfig/iptables



备注:实验中,NTP服务器IP为 192.168.168.130














###################  Linux客户端配置

[root@client_1 ~]# yum -y install ntp


即时同步NTP时间服务器:
[root@client_1 ~]# ntpdate 192.168.168.130
7 Apr 20:18:18 ntpdate[2378]: step time server 192.168.168.130 offset 55523333.711369 sec


修改自己的NTP配置文件:
[root@client_1 ~]# vi /etc/ntp.conf
图片3.png

修改为:
server 192.168.168.130 iburst minpoll 4 maxpoll 10
图片4.png



同步写入硬件时钟:
[root@client_1 ~]# vi /etc/sysconfig/ntpdate
SYNC_HWCLOCK=no
修改成:
SYNC_HWCLOCK=yes



启动NTP服务:
service ntpd start

设置NTP开机自动启动:
chkconfig --level 35 ntpd on


查看NTP是否正常运行:
netstat -tlunp | grep ntp
图片5.png



笺注:服务器重启后会自动同步NTP服务器的了。














###################  Windows2008R2客户端配置

图片6.png


图片7.png


图片8.png




默认就会同步网络上的时间服务器了
图片9.png


修改为同步自己的NTP服务器:
图片10.png



相关文章:
NTP时间同步
CentOS8使用Chrony进行时间同步

Zabbix使用Agent监控Linux的TCP+UDP端口





#################################
#################################
亲,学习研究也要劳逸结合哦,来我微店逛逛,买点东西好好犒劳犒劳自己和家人吧^_^^_^


苏泊尔电压力锅家用智能5L高压饭煲特价
dianfanbao.png


苏泊尔电磁炉火锅家用智能正品学生电池炉灶特价炒菜
diancilu.png


苏泊尔电蒸锅多功能家用蒸气锅三层大容量电蒸笼蒸锅蒸菜自动断电
dianzhengguo.png

返回列表