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. 设计模式-外观模式(Facade)

    外观模式又称为门面模式,为一组类似功能的集群,比如类库.子系统等,提供一致的入口供client调用 角色和职责: 1.门面(Facade)-Computer: 外观模式的核心.它被客户角色调用,它熟悉 ...

  2. HDU 5792:World is Exploding(树状数组求逆序对)

    http://acm.hdu.edu.cn/showproblem.php?pid=5792 World is Exploding Problem Description   Given a sequ ...

  3. 基于Django框架 CRM的增删改查

    思路: 创建表------从数据库读出数据展示出来------配置路由-----写视图函数------写对应页面 练习点: 数据库建表 ORM 数据库数据读取 数据 ModelForm  (form组 ...

  4. OCR文字识别笔记总结

    OCR的全称是Optical Character Recognition,光学字符识别技术.目前应用于各个领域方向,甚至这些应用就在我们的身边,比如身份证的识别,交通路牌的识别,车牌的自动识别等等.本 ...

  5. 0x31 prime distance(质数)

    题目描述: 给定两个整数L和U,你需要在闭区间[L,U]内找到距离最接近的两个相邻质数C1和C2(即C2-C1是最小的),如果存在相同距离的其他相邻质数对,则输出第一对. 同时,你还需要找到距离最远的 ...

  6. Stixel_World(single)学习笔记

      1. 算法背景 Q: 如何有效处理数以百万的视差图数据(提供了每个像素的精确深度信息)? 以及如何在大量数据中找到所有相关的障碍物? 提出方法 “ stixel_world ”, It takes ...

  7. WinForm控件之【Button】

    基本介绍 普通按钮大部分情况下用作页面对某系列操作后的提交确认,应用较为广泛,在winfrom控件当中使用设置都相对的简单. 常设置属性.事件 Image:控件上显示的图片: Enabled  :指示 ...

  8. Android 开发感想

    18年从.net转行做安卓开发,现在已经过去一年多了.说一下感想和心得体会! 一.开始 说一下我的经厉,从毕业开始出来工作一直是从事.net方向的开发工作.一开始也是没什么经验,加上也没有其他手艺就找 ...

  9. [leetcode] 905. Sort Array By Parity [easy]

    原题链接 很水的一道题,就是数组内部交换. 水题就想着减少复杂度嘛,于是学到一种交换写法. class Solution { public: vector<int> sortArrayBy ...

  10. NPOI 日期类型的判断

    NPOI目前我用到有两套类,一套是为了读写XLS:一套是读写XLSX 在读取文件时大都会判断单元格类型,方式大同小异,只有日期类型不同. 默认日期类型的单元格在NPOI都认为是数值类型(CellTyp ...