ntp时钟服务器离线搭建

由于centos6.5 yum不到ntp相关组件,特此记录  

ntp:可以为其配置ntp.conf将其设置为自动同步某服务器时钟。

  ntpd服务只要启动,自动会在后台为这台NTP服务器同步时间(可能需要等几分钟),

  不需要我们手动操作,其它机器只需同步这台NTP服务器即可。

  所以ntp好用些,用ntpdate还得手动写定时麻烦


ntpdate:可以使用 ntpdate -u ip地址 来手动同步某服务器的时钟。

本文主要讨论ntp的使用

1、下载ntp的安装包:

 ntp-4.2.6p5-12.el6.centos.2.x86_64.rpm 试用于 centos6.5  
 链接:https://pan.baidu.com/s/18fOYkkmYNGk2jLBpJt04oQ 
 提取码:mfpy 
 

2、安装命令:

     方式(1) rpm -ivh ntp-4.2.6p5-12.el6.centos.2.x86_64.rpm
      若出现找不到依赖则使用下面的命令:

    方式(2)rpm -ivh ntp-4.2.6p5-12.el6.centos.2.x86_64.rpm --nodeps --force

3、服务器配置:(/etc/ntp.conf)

#然后添加这两行 ,意思是 允许IPV4 IPV6 查询 拒绝修改
restrict -4 default kod notrap nomodify   
restrict -6 default kod notrap nomodify 
#添加修改上层时间服务器,如果能联通外网,则不需要修改,

#定义使用的上游 ntp服务器,将原来的注释。如果联不通外网,则把不要加了
#server ntp1.aliyun.com
#server time1.aliyun.com
#允许上层时间服务器主动修改本机时间
#restrict time1.aliyun.com nomodify notrap noquery
#restrict ntp1.aliyun.com nomodify notrap noquery

#然后添加下面两行,意思是设置成时间服务器是自己

server 127.127.1.0
fudge 127.127.1.0 stratum 8

4、客户端配置:(/etc/ntp.conf)

restrict -4 default kod notrap nomodify   
restrict -6 default kod notrap nomodify
#允许上层进行修改本机时间 ,把原来的注释掉
#restrict 10.4.100.231 nomodify notrap noquery
#配置上层server(要同步的),在这里配置的是实际的物理地址
server 10.4.100.231  
fudge 10.4.100.231 stratum 8

5、测试 

启动: /etc/init.d/ntpd start 

设置开启自启动:chkconfig ntpd on

 (1)服务器:

[root@localhost etc]# ntpq -p
 
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*LOCAL(0)        .LOCL.           8 l   36   64  377    0.000    0.000   0.000
 
 
[root@localhost etc]# ntpstat
 
synchronised to local net at stratum 9 
   time correct to within 12 ms
   polling server every 64 s

(2)客户端:


[root@localhost local]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 10.4.100.231    202.118.1.130    2 u   18   64    1    0.171  -10.820   0.000
+203.107.6.88    100.107.25.114   2 u   16   64    1   15.962   -0.141   0.440
*a.chl.la        131.188.3.222    2 u   14   64    1  182.340   -4.358   0.136
 undefined.hostn 127.67.113.92    2 u   24   64    0    0.000    0.000   0.000

6、日志设置


[root@localhost sysconfig]# pwd
/etc/sysconfig
 
[root@localhost sysconfig]#cat ntpd
 
# Command line options for ntpd
OPTIONS="-g -l /var/log/ntpstats/ntpd.log"
 
[root@localhost ntpstats]# service ntpd stop
 
[root@localhost ntpstats]# service ntpd start 
 
[root@localhost ntpstats]# service ntpd status
 
[root@localhost ntpstats]# tail -200f /var/log/ntpstats/ntpd.log

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值