目录

1 ntp时间服务器同步环境准备... 2

1.1 检查系统是否安装ntp服务... 2

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

1.3 重启ntp服务... 3

1.4 检查ntp服务是否运行... 4

1.5 检查ntp服务器与上层授时服务器的连通与状态... 4

1.6 ntp服务重启写入开机启动... 4

2客户端时间同步配置... 5

2.1 修改本地hosts文件... 5

2.2 ~检查命令行内是否能够同步... 5

2.3 写入定时任务中... 5

2.4 验证时间同步定时任务... 5

3故障排错... 6

3.1 防火墙没有关闭... 6(非常重要)

3.2 ntp-serverntp服务没有开启... 6


第1章 ntp时间服务器同步环境准备

1.1 检查系统是否安装ntp服务

[root@schools02 ~]# rpm -qa ntp 没有显示结果,系统没有安装ntp服务

[root@schools02 ~]# yum install ntp �y 安装ntp服务 �y不显示报错

Loaded plugins: fastestmirror

Setting up Install Process

base| 3.7 kB 00:00

base/primary_db| 4.7 MB 00:03

Dependency Installed:

libedit.x86_64 0:2.11-4.20080712cvs.1.el6 ntpdate.x86_640:4.2.6p5-10.el6.centos.1

Complete! 安装完毕

[root@schools02 ~]# rpm -qa ntp

ntp-4.2.6p5-10.el6.centos.1.x86_64 安装成功

1.2 配置ntp服务的配置文件

[root@schools02 ~]# vi /etc/ntp.conf

# For more information about this file,see the manpages

# ntp.conf(5),ntp_acc(5),ntp_auth(5),ntp_clock(5),ntp_misc(5),ntp_mon(5).

driftfile /var/lib/ntp/drift

# Permit time synchronization with our time source,but do not

# permit the source to query or modify the serviceon this system.

restrict default kod nomodify notrap noquery 默认是拒绝所有客户机同步时间在下一行加入:

restrict 172.16.2.0 mask 255.255.255.0 nomodify 仅在此网段的客户机可以同步时间

restrict -6 default kod nomodify notrap nopeernoquery

# Permit all access over the loopbackinterface. This Could

# be tightened as well,but to do so would effectsome of

# the administrative functions.

restrict 127.0.0.1

restrict -6 ::1

# Hosts on local network are less restricted.

#restrict 172.16.2.0 mask 255.255.255.0 nomodifynotrap

# 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 prefer 设置首选的ntp �server同步服务器

server 1.centos.pool.ntp.org iburst

server 2.centos.pool.ntp.org iburst

server 3.centos.pool.ntp.org iburst

#broadcast 192.168.1.255 autokey # broadcast server

#broadcastclient# broadcastclient

#broadcast 224.0.1.1 autokey # multicast server

#multicastclient 224.0.1.1 # multicast client

#manycastserver 239.255.254.254 # manycast server

#manycastclient 239.255.254.254 autokey # manycastclient

# Enable public key cryptography.

#crypto

includefile /etc/ntp/crypto/pw

# Key file containing the keys and key identifiersused when operating

# with symmetric key cryptography.

keys /etc/ntp/keys

# Specify the key identifiers which are trusted.

#trustedkey 4 8 42

#statistics clockstats cryptostats loopstatspeerstats

"/etc/ntp.conf" 53L,1771C written

此配置环境是客户机ntp-server可以访问外网。既有上层的ntp-server

在此文档里边仅需更改限制时间同步的网段即可

1.3 重启ntp服务

[root@schools02 ~]# /etc/init.d/ntpd restart

Shutting down ntpd: [ OK ]

Starting ntpd: [OK ]

1.4 检查ntp服务是否运行

[root@schools02 ~]# netstat -lntup|grep ntp

udp0 0 172.16.2.146:123 0.0.0.0:* 1599/ntpd

udp0 0 127.0.0.1:123 0.0.0.0:* 1599/ntpd

udp0 0 0.0.0.0:123 0.0.0.0:* 1599/ntpd

udp0 0 ::1:123 :::* 1599/ntpd

udp0 0 :::123 :::* 1599/ntpd

1.5 检查ntp服务器与上层授时服务器的连通与状态

[root@schools02 ~]# ntpstat

synchronised to NTP server (202.112.29.82) atstratum 3

timecorrect to within 3995 ms

pollingserver every 64 s

[root@schools02 ~]# ntpq -p

remote refid st t when poll reach delayoffset jitter

==============================================================================

*time6.aliyun.co 10.137.38.86 2 u18 64 121.614 18.914 0.000

202.118.1.130.INIT. 16 u -64 0 0.0000.000 0.000

dns1.synet.edu. 202.118.1.46 2 u6 64 192.939 -2.845 7.267

1.6 ntp服务重启写入开机启动

[root@schools02 ~]# echo "/etc/init.d/ntpdrestart" >>/etc/rc.local 开机后服务可以自动重启,开始服务

[root@schools02 ~]# cat /etc/rc.local

#!/bin/sh

# This script will be executed *after* all theother init scripts.

# You can put your own initialization stuff in hereif you don't

# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

/etc/init.d/ntpd restart

第2章 客户端时间同步配置

2.1 修改本地hosts文件

[root@schools02 ~]# vi /etc/hosts

127.0.0.1localhost localhost.localdomain localhost4 localhost4.localdomain4

::1localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.2.146ntp-server

"/etc/hosts" 3L,183C written

2.2 检查命令行内是否能够同步

[root@schools02 ~]# ntpdate 172.16.2.146

5 Sep01:44:54 ntpdate[1609]: adjust time server 172.16.2.146 offset 0.058518 sec

[root@schools02 ~]# ntpdate ntp-server

5 Sep01:46:47 ntpdate[1611]: adjust time server 172.16.2.146 offset 0.003564 sec

2.3 写入定时任务中

[root@schools02 ~]# echo "* * * * * /usr/sbin/ntpdate ntp-server" >>/var/spool/cron/root

[root@schools02 ~]# crontab -l

* * * * * /usr/sbin/ntpdatentp-server

[root@schools02 ~]# tail -f /var/log/cron

Sep 501:51:02 schools02 CROND[1617]: (root) CMD (/bin/sh /usr/sbin/ntpdatentp-server)

2.4 验证时间同步定时任务

[root@schools02 ~]# date -s 20160302

Wed Mar 200:00:00 CST 2016

[root@schools02 ~]# tail -f /var/log/cron

Sep 502:03:03 schools02 CROND[1774]: (root) CMD (/usr/sbin/ntpdate ntp-server)

[root@schools02 ~]# date

Mon Sep 502:03:06 CST 2016 更新完毕

第3章 故障排错

3.1 防火墙没有关闭

root@schools02 ~]# chkconfig iptables on 打开ntp-server服务器防火墙

[root@schools02 ~]# /etc/init.d/ntpd restart

Shutting down ntpd: [ OK ]

Starting ntpd: [OK ]

[root@schools02 ~]# chkconfig --list|grep ntp

ntpd0:off 1:off 2:off3:off 4:off 5:off6:off

ntpdate0:off 1:off 2:off3:off 4:off 5:off6:off

[root@schools02 ~]# chkconfig --list|grep iptables

iptables0:off 1:off 2:on3:on 4:on 5:on6:off

[root@schools02 ~]# ntpdate ntp-server 客户端无法同步时间

5 Sep02:11:08 ntpdate[1849]: no server suitable for synchronization found

3.2 ntp-serverntp服务没有开启

[root@schools02 ~]# pkill ntpd

[root@schools02 ~]# netstat -lntup|grep ntpd

[root@schools02 ~]# ntpdate ntp-server 客户端失败

5 Sep02:14:39 ntpdate[1868]: no server suitable for synchronization found

[root@schools02 ~]# service ntpd start

Starting ntpd: [OK ] [root@schools02 ~]# netstat-lntup|grep ntpd

udp0 0 172.16.2.146:123 0.0.0.0:* 2056/ntpd

udp0 0 127.0.0.1:123 0.0.0.0:* 2056/ntpd

udp0 0 0.0.0.0:123 0.0.0.0:* 2056/ntpd

root@schools02 ~]# ntpdate ntp-server 客户端成功同步

5 Seadjusttime server 172.16.2.146 offset 0.003626 sec


最后放大招:所有的检查都做了,还不能同步。就重启一下系统。

NTP-server时间同步配置与排错CentOS 6.7 x64的更多相关文章

  1. iOS – 友好的NSDate格式

    我需要在我的应用程序中显示帖子的日期给用户,现在我用这种格式:“5月25日星期五”.如何格式化NSDate以阅读“2小时前”的内容?使其更加用户友好.解决方法NSDateFormatter不能做这样的事情;你将需要建立自己的规则.我想像:所以这是打印’x分钟前’或’x小时前’从日期起24小时,通常是一天.

  2. 记一次云计算测试实验-openstack-icehouse-安装swift

    -----------------------controller:---------------------------------sourceadmin-openrc.shkeystoneuser-create--name=swift--pass=000000--email=swift@localhostkeystoneuser-role-add--user=swift--tenant=ser

  3. android – 模拟器中hosts文件中的Url映射被忽略

    我正在使用genymotion仿真器,并使用它从主机文件中提取adbremountadbpull/system/etc/hostsC:\Users\Rkn09\Desktop\hosts我添加了新的映射192.168.0.115xxx.mydomain.com,我把它推回到模拟器使用adbpushC:\Users\Rkn09\Desktop\hosts/system/etc/hosts但是当我向x

  4. CentOS 8.2服务器上安装最新版Node.js的方法

    这篇文章主要介绍了CentOS 8.2服务器上安装最新版Node.js的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  5. centos+php+coreseek+sphinx+mysql之一coreseek安装篇

    这篇文章主要介绍了centos+php+coreseek+sphinx+mysql之一coreseek安装篇的相关资料,非常不错具有参考借鉴价值,需要的朋友可以参考下

  6. Centos7 中 Node.js安装简单方法

    这篇文章主要介绍了Centos7 中 Node.js安装简单方法,非常不错具有一定的参考借鉴价值,需要的朋友可以参考下

  7. nodejs脚本centos开机启动实操方法

    在本篇文章里小编给大家整理的是关于nodejs脚本centos开机启动实操方法,有兴趣的朋友们参考下。

  8. Centos PHP 扩展Xchche的安装教程

    这篇文章主要介绍了Centos PHP 扩展Xchche的安装教程的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下

  9. Linux CentOS系统下安装node.js与express的方法

    这篇文章主要给大家介绍了在Linux CentOS系统下安装node.js与express的方法,文中介绍的非常详细,相信对大家具有一定的参考价值,需要的朋友们下面来一起看看吧。

  10. CentOS上安装Node.js和mongodb笔记

    这篇文章主要介绍了CentOS上安装Node.js和mongodb笔记,本文讲解了Python安装、Node.js安装、npm安装、mongodb驱动安装、mongodb数据库操作测试代码等内容,需要的朋友可以参考下

随机推荐

  1. 在airgapped(离线)CentOS 6系统上安装yum软件包

    我有一个CentOS6系统,出于安全考虑,它已经被空气泄漏.它可能从未连接到互联网,如果有,它很长时间没有更新.我想将所有.rpm软件包放在一个驱动器上,这样它们就可以脱机安装而无需查询互联网.但是,我在测试VM上遇到的问题是,即使指定了本地路径,yum仍然会挂起并尝试从在线存储库进行更新.另外,有没有办法使用yum-utils/yumdownloader轻松获取该包的所有依赖项和所有依赖项?目前

  2. centos – 命名在日志旋转后停止记录到rsyslog

    CentOS6.2,绑定9.7.3,rsyslog4.6.2我最近设置了一个服务器,我注意到在日志轮换后,named已停止记录到/var/log/messages.我认为这很奇怪,因为所有日志记录都是通过rsyslog进行的,并且named不会直接写入日志文件.这更奇怪,因为我在更新区域文件后命名了HUPed,但它仍然没有记录.在我停止并重新启动命名后,记录恢复.这里发生了什么?

  3. centos – 显示错误的磁盘大小

    对于其中一个磁盘,Df-h在我的服务器上显示错误的空白区域:Cpanel表明它只有34GB免费,但还有更多.几分钟前,我删除了超过80GB的日志文件.所以,我确信它完全错了.fdisk-l/dev/sda2也显示错误:如果没有格式化,我该怎么做才能解决这个问题?并且打开文件描述符就是它需要使用才能做到这一点.所以…使用“lsof”并查找已删除的文件.重新启动写入日志文件的服务,你很可能会看到空间可用.

  4. 如何在centos 6.9上安装docker-ce 17?

    我目前正在尝试在centOS6.9服务器上安装docker-ce17,但是,当运行yuminstalldocker-ce时,我收到以下错误:如果我用跳过的标志运行它我仍然得到相同的消息,有没有人知道这方面的方法?

  5. centos – 闲置工作站的异常负载平均值

    我有一个新的工作站,具有不寻常的高负载平均值.机器规格是:>至强cpu>256GB的RAM>4x512GBSSD连接到LSI2108RAID控制器我从livecd安装了CentOS6.564位,配置了分区,网络,用户/组,并安装了一些软件,如开发工具和MATLAB.在启动几分钟后,工作站负载平均值的值介于0.5到0.9之间.但它没有做任何事情.因此我无法理解为什么负载平均值如此之高.你能帮我诊断一下这个问题吗?

  6. centos – Cryptsetup luks – 检查内核是否支持aes-xts-plain64密码

    我在CentOS5上使用cryptsetupluks加密加密了一堆硬盘.一切都很好,直到我将系统升级到CentOS6.现在我再也无法安装磁盘了.使用我的关键短语装载:我收到此错误:在/var/log/messages中:有关如何装载的任何想法?找到解决方案问题是驱动器使用大约512个字符长的交互式关键短语加密.出于某种原因,CentOS6中的新内核模块在由旧版本创建时无法正确读取512个字符的加密密钥.似乎只会影响内核或cryptsetup的不同版本,因为在同一系统上创建和打开时,512字符的密钥将起作用

  7. centos – 大量ssh登录尝试

    22个我今天登录CentOS盒找到以下内容这是过去3天内的11次登录尝试.WTF?请注意,这是我从我的提供商处获得的全新IP,该盒子是全新的.我还没有发布任何关于此框的内容.为什么我会进行如此大量的登录尝试?是某种IP/端口扫描?基本上有4名匪徒,其中2名来自中国,1名来自香港,1名来自Verizon.这只发生在SSH上.HTTP上没有问题.我应该将罪魁祸首子网路由吗?你们有什么建议?

  8. centos – kswap使用100%的CPU,即使有100GB的RAM也可用

    >Linux内核是否应该足够智能,只需从内存中清除旧缓存页而不是启动kswap?

  9. centos – Azure将VM从A2 / 3调整为DS2 v2

    我正在尝试调整前一段时间创建的几个AzureVM,从基本的A3和标准A3到标准的DS2v2.我似乎没有能力调整到这个大小的VM.必须从头开始重建服务器会有点痛苦.如果它有所不同我在VM中运行CentOS,每个都有一个带有应用程序和操作系统的磁盘.任何人都可以告诉我是否可以在不删除磁盘的情况下删除VM,创建新VM然后将磁盘附加到新VM?

  10. centos – 广泛使用RAM时服务器计算速度减慢

    我在非常具体的情况下遇到服务器速度下降的问题.事实是:>1)我使用计算应用WRF>2)我使用双XeonE5-2620v3和128GBRAM(NUMA架构–可能与问题有关!

返回
顶部