Network Time Protocol(NTP,网络时间协议)用于同步它所有客户端时钟的服务。NTP服务器将本地系统的时钟与一个公共的NTP服务器同步然后作为时间主机提供服务,使本地网络的所有客户端能同步时钟。

同步时钟最大的好处就是相关系统上日志文件中的数据,如果网络中使用中央日志主机集中管理日志,得到的日志结果就更能反映真实情况。在同步了时钟的网络中,集中式的性能监控、服务监控系统能实时的反应系统信息,系统管理员可以快速的检测和解决系统错误。

首先要安装一下NTP,一般在CentOS下我还是很热衷用YUM命令安装的.

查看系统是否安装NTP

[root@localhost ~]# rpm -qa | grep ntp

如果没有安装,可以用下面命令安装

[root@localhost ~]# yum -y install ntp.i*

CentOS复习笔记之NTP服务器

修改配置文件

[root@localhost ~]# vi /etc/ntp.conf
# 用restrict控管权限
# nomodify - 用户端不能更改ntp服务器的时间参数
# noquery - 用户端不能使用ntpq,ntpc等命令来查询ntp服务器
# notrap - 不提供trap远端登陆
把这一行的注释(#号)拿掉,并别把IP地址段、子网掩码改成你的IP地址信息
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org

把这里面的地址改成210.72.145.44(中国国家授时中心IP)

#server 127.127.1.0     # local clock
#fudge  127.127.1.0 stratum 10

把这两行的注释拿掉
然后,保存退出!
(时间关系,先写到这里。明天补全)

文章目录