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. 如何配置selinux

    参考命令:   一.开启/关闭selinux   getenforce:查看selinux运行状态 setenforce 0 :关闭selinux setenforce 1 :开启selinux 系统 ...

  2. HihoCoder 1496:寻找最大值(思维DP)

    http://hihocoder.com/problemset/problem/1496 题意:中文. 思路:一开始做有一种想法,把所有的数都变成二进制后,最优的情况肯定是挑选所有数中最高位的1能同时 ...

  3. scrapy基础知识之 scrapy 三种模拟登录策略:

    注意:模拟登陆时,必须保证settings.py里的 COOKIES_ENABLED (Cookies中间件) 处于开启状态 COOKIES_ENABLED = True或 # COOKIES_ENA ...

  4. ICC中用Tcl脚本给版图中的Port/Terminal加Label的方法

    本文转自:自己的微信公众号<数字集成电路设计及EDA教程> 里面主要讲解数字IC前端.后端.DFT.低功耗设计以及验证等相关知识,并且讲解了其中用到的各种EDA工具的教程. 考虑到微信公众 ...

  5. 数字IC前后端设计中的时序收敛(五)--Max Transition违反的修复方法

    本文转自:自己的微信公众号<数字集成电路设计及EDA教程> 里面主要讲解数字IC前端.后端.DFT.低功耗设计以及验证等相关知识,并且讲解了其中用到的各种EDA工具的教程. 考虑到微信公众 ...

  6. dapper支持DataSet

    在源代码中添加 /// <summary> /// describe:支持 DataSet /// </summary> /// <param name="cn ...

  7. Java - 格式化输出JSON字符串的两种方式

    目录 1 使用阿里的fastjson 1.1 项目的pom.xml依赖 1.2 Java示例代码 2 使用谷歌的gson 2.1 项目的pom.xml依赖 2.2 Java示例代码 1 使用阿里的fa ...

  8. idea中向pom.xml添加依赖时显示”not found dependency“

    总结: 起因:再输入hibernate-core的version时,开始写的是对的,就是 5.0.11.Final(这个也是跟着教程来的),直接就报错了,左等右等没用,也点过maven的reimpor ...

  9. python之pip install

    安装方式1 wget  http://python-distribute.org/distribute_setup.py sudo python distribute_setup.py wget  h ...

  10. Java编程思想:利用内部类实现的工厂模式

    public class Test { public static void main(String[] args) { Factories.test(); } } /* 设计模式之禅中的工厂模式是这 ...