本地NTP服务器与客户端配置
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服务器与客户端配置的更多相关文章
- CentOS7搭建NTP服务器及客户端同步时间
一.服务器配置 1.查看服务器.客户端操作系统版本 [root@hadoop101 ~]# cat /etc/redhat-release CentOS Linux release (Core) 2. ...
- 时间服务器: NTP 服务器及客户端搭建
时间服务器: NTP 服务器及客户端搭建 一. NTP 服务器的安装与设定 1. NTP 服务器的安装与设定前言 2. 所需软件与软件结构 3. 主要配置文件 ntp.conf 的处理 4. NTP ...
- centos6.5环境下svn服务器和客户端配置实用详解
一.服务器端配置 安装 # yum install -y subversion yum安装软件,不清除软件包的方法 # vim /etc/yum.conf keepcache=0 建立svn版本库数据 ...
- [Linux]Linux下rsync服务器和客户端配置
一.rsync简介 Rsync(remote sync)是UNIX及类UNIX平台下一款神奇的数据镜像备份软件,它不像FTP或其他文件传输服务那样需要进行全备份,Rsync可以根据数据的变化进行差异( ...
- 关于windows服务器wsus客户端配置的修改
本文环境如下: 服务器:Windows Server 2012 R2 Standard 由于公司服务器是加了域环境的,又需要将wsus客户端指向另一台wsus服务器,修改本地组策略.可能会被域控给修改 ...
- nfs服务器与客户端配置
服务器端(PC)配置 ubuntu提供两种NFS服务器:一种以内核模块形式提供,nfs-kernel-server:一种以用户空间程序形式提供,nfs-user-server;两种择一即可.1. 安装 ...
- SERVER2012 FTP服务器和客户端配置
SERVER2012 用IIS8 搭建的FTP 默认是主动模式的,导致花了一些时间去研究如何连接,总结了一下配置,希望能帮到需要的同学,以下介绍下步骤 1.服务器--计算机管理-用户-新建用户--默认 ...
- Centos7安装搭建NTP服务器和NTP客户端同步时间
NTP简介: NTP是网络时间协议(Network Time Protocol),它是用来同步网络中各个计算机的时间的协议. 在计算机的世界里,时间非常地重要 例如:对于火箭发射这种科研活动,对时间的 ...
- 日常工作问题解决:配置NTP服务器以及一些常见错误解决
1.配置NTP服务端 环境:redhat 6.5 服务器主机名 ip地址 说明 server 192.168.57.20 NTP服务端 client 192.168.57.21 NTP客户端 搭建说明 ...
随机推荐
- Java多线程(五):死锁
死锁 概念 当线程Thread-0持有锁Lock1,Thread-1持有锁Lock2,此时Thread-0申请Lock2锁的使用权,Thread-1申请Lock1锁的使用权,Thread-0和Thre ...
- Unity3D热更新之LuaFramework篇[06]--Lua中是怎么实现脚本生命周期的
前言 用c#开发的时候,新建的脚本都默认继承自Monobehaviour, 因此脚本才有了自己的生命周期函数,如Awake,Start, Update, OnDestroy等. 在相应的方法中实现游戏 ...
- 超哥的 LINUX 入门大纲
前言 “Linux?听说是一个操作系统,好用吗?” “我也不知道呀,和windows有什么区别?我能在Linux上玩LOL吗” “别提了,我用过Linux,就是黑乎乎一个屏幕,鼠标也不能用,不停地的敲 ...
- Bean property 'transactionManagerBeanName' is not writable or has an invalid set
[2017-02-07 11:38:48,458]-[localhost-startStop-1]-[org.springframework.beans.factory.support.Default ...
- Java SpringBoot 如何使用 IdentityServer4 作为验证学习笔记
这边记录下如何使用IdentityServer4 作为 Java SpringBoot 的 认证服务器和令牌颁发服务器.本人也是新手,所以理解不足的地方请多多指教.另外由于真的很久没有写中文了,用词不 ...
- 网页内嵌html遇到的问题
在项目中遇到个问题 充值功能是点击一个按钮这个按钮会弹出模态框,输入充值金额会执行一段脚本自动提交数据到https://openapi.alipay.com/gateway.do上 结果:本网页跳转到 ...
- UVA1103 古代象形符号 Ancient Messages 题解
题目链接: https://www.luogu.org/problemnew/show/UVA1103 题目分析: 我们可以先进行矩阵的还原 for(int k=1;k<=4;k++) { a[ ...
- Excel催化剂开源第33波-Quick Bible For PPT插件项目全代码开源
很感恩,能够在上帝奇妙地带领下,经过多方的资源整合后,可以从我手中完成一款对教会内部制作PPT过程中,引用圣经的这个小环节能够发挥一些小小的作用的小插件.因制作本插件时,也大量用到VSTO开发的一些技 ...
- springboot4自动配置的原理(浅层)
自动配置的原理(浅层) @Configuration //这是一个配置类 @EnableConfigurationProperties(HttpProperties.class)//启用Configu ...
- vue教程(四)--其他实用用法补充
一.vue生命周期简单介绍 var App={ template:'', data(){ }, beforeCreated:function(){ //不能操作数据,只是初始化了事件等.. }, cr ...