centos6.5配置NTP服务器的详细步骤

来源:互联网 发布:编程初学 编辑:程序博客网 时间:2024/06/05 09:58
1.查看是否安装了NTP:
# rpm -q ntp
ntp-4.2.4p8-2.el6.x86_64    // 这表示已安装了,如果没有安装,这是空白。


2.如果没有安装,我们按照下
# yum install ntp


注意:前提是已经配置好了yum源。


3.开启ntp的自启命令:
# chkconfig ntpd on


4.配置NTP的配置文件:
#vi /etc/ntp.conf


需修改内容为:


restrict 127.0.0.1
restrict -6 ::1


添加内容:
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
server 210.72.145.44 perfer   # 中国国家受时中心
server 202.112.10.36             # 1.cn.pool.ntp.org
server 59.124.196.83             # 0.asia.pool.ntp.org
restrict 210.72.145.44 nomodify notrap noquery
restrict 202.112.10.36 nomodify notrap noquery
restrict 59.124.196.83 nomodify notrap noquery


# 外部时间服务器不可用时,以本地时间作为时间服务
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10
 


# Enable public key cryptography.
#crypto


5.保存退出即可。
6.开启ntp服务:
# service ntpd start
7.一般需要5-10分钟左右,查看状态:
# netstat -tlunp | grep ntp 
出现:udp        0      0 172.24.240.160:123           0.0.0.0:*                               23103/ntpd  说明配置成功。
(注意:本机的ip为172.24.240.160)。
到此服务器已经配置完成。




客户机时间同步配置:


1.# yum install ntp
...
# chkconfig ntp on


2.# vim /etc/ntp.conf


配置文件内容为:


driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict -6 ::1
 
# 配置时间服务器为本地的时间服务器
server 172.24.240.160
 
restrict 172.24.240.160 nomodify notrap noquery
 
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10
 
includefile /etc/ntp/crypto/pw
 
keys /etc/ntp/keys


保存退出。


3.手动同步:
ntpdate -u 172.24.240.160


4.查看状态:
# ntpstat
出现:synchronised to NTP server (172.24.240.160) at stratum 12
表示配置成功。


恭喜你配置完成!
原创粉丝点击