CentOS6.5搭建NTP服务器,并为思科交换机提供时间同步

本文主要讲解如何在CentOS6.5上配置NTP服务器,并为思科交换机提供时间同步功能。


服务器安装步骤:

1. Linux上安装NTP软件:

命令:yum install ntp(回车)

输出信息:

[root@localhost ~]# yum install ntp

Loaded plugins: fastestmirror,refresh-packagekit,security

Determining fastest mirrors

* base: mirrors.tuna.tsinghua.edu.cn

* extras: mirrors.tuna.tsinghua.edu.cn

* updates: mirrors.tuna.tsinghua.edu.cn

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package ntp.x86_64 0:4.2.6p5-1.el6.centos will be updated

---> Package ntp.x86_64 0:4.2.6p5-10.el6.centos.1 will be an update

--> Processing Dependency: ntpdate = 4.2.6p5-10.el6.centos.1 for package: ntp-4.2.6p5-10.el6.centos.1.x86_64

--> Running transaction check

---> Package ntpdate.x86_64 0:4.2.6p5-1.el6.centos will be updated

---> Package ntpdate.x86_64 0:4.2.6p5-10.el6.centos.1 will be an update

--> Finished Dependency Resolution

……

2.配置ntp服务器的配置文件

命令:[root@localhost ~]# vim /etc/ntp.conf


driftfile /var/lib/ntp/drift

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict -6 ::1

server ntp.fudan.edu.cn

restric ntp.fudan.edu.cn nomodify notrap noquery

server 127.127.1.0

fudge 127.127.1.0 stratum 8

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

3. 保存退出配置文件,重启ntp服务。

[root@localhost ~]# service ntpd start

如果时间没有立马同步,稍等几分钟。


思科交换机客户端配置步骤:

1. 登录交换机配置如下命令:

ntp server 192.168.4.212 (指定ntp服务器地址)

clock timezone GMT 8 (定义时区)

service timestamps debug datetime localtime (定义debug日志显示时间)

service timestamps log datetime localtime (定义log日志显示时间)

2. 查看命令

sw#show clock

20:56:16.132 GMT Thu Oct 13 2016

sw#show ntp status

Clock is synchronized,stratum 10,reference is 192.168.1.1

nominal freq is 119.2092 Hz,actual freq is 119.2081 Hz,precision is 2**17

reference time is DBAA0318.33909662 (20:56:56.201 GMT Thu Oct 13 2016)

clock offset is 0.2520 msec,root delay is 2.78 msec

root dispersion is 11.99 msec,peer dispersion is 0.41 msec


搭建过程中遇到的问题及解决办法:

搭建完成后发现交换机一直无法同步时间,使用另外一台linux机器配置为客户端一样无法同步时间。

ntp客户端运行ntpdate serverIP,出现no server suitable for synchronization found的错误。

最后发现是没有关闭linux防火墙。。。

使用命令:#serviceiptablesstop 关闭linux防火墙后,服务器运行正常。


参考链接:http://www.blogjava.net/spray/archive/2008/07/10/213964.html

相关文章

linux下开机自启: 在/etc/init.d目录下新建文件elasticsear...
1、因为在centos7中/etc/rc.d/rc.local的权限被降低了,所以...
最简单的查看方法可以使用ls -ll、ls-lh命令进行查看,当使用...
ASP.NET Core应用程序发布linux在shell中运行是正常的。可一...
设置时区(CentOS 7) 先执行命令timedatectl status|grep &...
vim /etc/sysconfig/network-scripts/ifcfg-eth0 B...