1. NTP 简介

NTP是网络时间协议(Network Time Protocol),它是用来同步网络中各个计算机的时间的协议。

在集群中,为了保证各节点之间的时间一致,我们通常需要配置本地的 NTP 服务器。

2. 环境准备

os hostname ip
centos6.7 localntpserver 172.16.1.100
centos6.7 ntpclient 172.16.1.101

3. ntpserver配置

3.1   查看是否安装有ntpd

chkconfig --list

3.2 安装ntpd

yum install ntpd ntpdate

3.3 备份 ntpd 配置

mv /etc/ntp.conf /etc/ntp.conf.bak

3.4 修改ntpd 配置

vi/etc/ntp.conf

输入以下内容

#fast ntp server
server 202.108.6.95
server 202.112.29.82
server 110.75.190.198
server cn.ntp.org.cn #store last time
driftfile /etc/ntp/drift #allow upper modify localhost
restrict 0.0.0.0 nomodify notrap noquery #allow any host
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap #level number
fudge 127.127.1.1 stratum 2 #ntp log path
statsdir /var/log/ntp/ #ntp log file
logfile /var/log/ntp/ntp.log

3.5 初始同步时间

ntpdate 202.108.6.95

3.6 定时将日期写入硬件,确保重启时时间异常

    安装定时工具

yum install crontab

添加定时规则:crontab -e

在末尾追加以下内容

# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to be executed #ntp config
0 9 * * 1 hwclock -w

3.7 启动 ntpserver

service ntpd start

3.8 设置 ntpd 服务开机启动

chkconfig ntpd on

4. 配置 ntpd client

客户端配置除了 /etc/ntp.conf 配置文件内容不同外,其他配置都与ntpd server 相同,因此只做简单介绍,相应步骤参考 ntpd server。

4.1   安装 ntpd

yum install ntpd ntpdate

4.2 修改ntpd 配置vi/etc/ntp.conf

输入以下内容(localntpserver为ntp server 的hostname)

#fast ntp server
server 172.16.1.92 prefer #store last time
driftfile /etc/ntp/drift #allow upper modify localhost
restrict 0.0.0.0 nomodify notrap noquery #allow any host
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap #level number
fudge 127.127.1.1 stratum 2 #ntp log path
statsdir /var/log/ntp/ #ntp log file
logfile /var/log/ntp/ntp.log includefile /etc/ntp/crypto/pw keys /etc/ntp/keys

4.3 初始同步时间

ntpdate localntpserver

4.4 定时将日期写入硬件,确保重启时时间异常

添加定时规则: crontab -e

在末尾追加以下内容

# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to be executed #ntp config
0 9 * * 1 hwclock -w

4.5 启动 ntpd

service ntpd start

4.6 设置 ntpd 开机启动

chkconfig ntpd on

4.7 查看ntpd 状态

ntpstat

至此,NTP server 与 client 配置完成

本地NTP服务器与客户端配置的更多相关文章

  1. CentOS7搭建NTP服务器及客户端同步时间

    一.服务器配置 1.查看服务器.客户端操作系统版本 [root@hadoop101 ~]# cat /etc/redhat-release CentOS Linux release (Core) 2. ...

  2. 时间服务器: NTP 服务器及客户端搭建

    时间服务器: NTP 服务器及客户端搭建 一. NTP 服务器的安装与设定 1. NTP 服务器的安装与设定前言 2. 所需软件与软件结构 3. 主要配置文件 ntp.conf 的处理 4. NTP ...

  3. centos6.5环境下svn服务器和客户端配置实用详解

    一.服务器端配置 安装 # yum install -y subversion yum安装软件,不清除软件包的方法 # vim /etc/yum.conf keepcache=0 建立svn版本库数据 ...

  4. [Linux]Linux下rsync服务器和客户端配置

    一.rsync简介 Rsync(remote sync)是UNIX及类UNIX平台下一款神奇的数据镜像备份软件,它不像FTP或其他文件传输服务那样需要进行全备份,Rsync可以根据数据的变化进行差异( ...

  5. 关于windows服务器wsus客户端配置的修改

    本文环境如下: 服务器:Windows Server 2012 R2 Standard 由于公司服务器是加了域环境的,又需要将wsus客户端指向另一台wsus服务器,修改本地组策略.可能会被域控给修改 ...

  6. nfs服务器与客户端配置

    服务器端(PC)配置 ubuntu提供两种NFS服务器:一种以内核模块形式提供,nfs-kernel-server:一种以用户空间程序形式提供,nfs-user-server;两种择一即可.1. 安装 ...

  7. SERVER2012 FTP服务器和客户端配置

    SERVER2012 用IIS8 搭建的FTP 默认是主动模式的,导致花了一些时间去研究如何连接,总结了一下配置,希望能帮到需要的同学,以下介绍下步骤 1.服务器--计算机管理-用户-新建用户--默认 ...

  8. Centos7安装搭建NTP服务器和NTP客户端同步时间

    NTP简介: NTP是网络时间协议(Network Time Protocol),它是用来同步网络中各个计算机的时间的协议. 在计算机的世界里,时间非常地重要 例如:对于火箭发射这种科研活动,对时间的 ...

  9. 日常工作问题解决:配置NTP服务器以及一些常见错误解决

    1.配置NTP服务端 环境:redhat 6.5 服务器主机名 ip地址 说明 server 192.168.57.20 NTP服务端 client 192.168.57.21 NTP客户端 搭建说明 ...

随机推荐

  1. 多语言应用性能监控系统:Elastic APM

    ▶ 概述 Elastic APM 是基于 Elastic Stack 构建的应用性能监控系统.通过 Elastic APM 可以监控应用程序,收集有关请求的响应时间.数据库查询.高速缓存调用.外部 H ...

  2. Codeforces 758D:Ability To Convert(思维+模拟)

    http://codeforces.com/problemset/problem/758/D 题意:给出一个进制数n,还有一个数k表示在n进制下的值,求将这个数转为十进制最小可以是多少. 思路:模拟着 ...

  3. SpringMVC框架的简单理解

    首先,让我们来看下下图 SpringMVC解决了View和Controller的交互问题 其中有几个重要组成部分: (1) DispatcherServlet: 前端控制器 用于接收所有请求,并负责分 ...

  4. 未能加载文件或程序集“Seagull.BarTender.Print, Version=11.0.8.1, Culture=neutral, PublicKeyToken=109ff779a1b4cbc7

    这2天项目上需要使用BarTender打印软件,使用BarTender的库的时候时候发现一个特别的问题: 未能加载文件或程序集“Seagull.BarTender.Print, Version=11. ...

  5. scrapy 发post请求

    可以使用 yield scrapy.FormRequest(url, formdata, callback)方法发送POST请求. 如果希望程序执行一开始就发送POST请求,可以重写Spider类的s ...

  6. IIS配置应用时,请求Header或Cookie过长

    可以在注册表中配置IIS MaxFieldLength MaxRequestBytes 注意配置后需重启http服务于iis服务 net stop http net start http iisres ...

  7. SpringBoot 2.0.3 源码解析

    前言 用SpringBoot也有很长一段时间了,一直是底层使用者,没有研究过其到底是怎么运行的,借此机会今天试着将源码读一下,在此记录...我这里使用的SpringBoot 版本是  2.0.3.RE ...

  8. WinForm控件之【DateTimePicker】

    基本介绍 时间控件应用较为广泛,属性设置项也比较完善是非常好用的控件. 常设置属性.事件 CustomFormat:当Format属性设置为自定义类型时可自定义控件时间的显示格式: Enabled:指 ...

  9. Spring Bean 的装配方式

    Spring Bean 的装配方式 装配 Bean 的三种方式 一个程序中,许多功能模块都是由多个为了实现相同业务而相互协作的组件构成的.而代码之间的相互联系又势必会带来耦合.耦合是个具有两面性的概念 ...

  10. 怎样在自己的网页中调用百度API

    https://blog.csdn.net/u010251278/article/details/52877370 以下内容转自上述网站,为了以后的学习方便,为此才特地将该网站内容转到自己的博客,多谢 ...