【Linux】部署NTP时间同步服务器
1. 查看机器的Linux版本
查看集群内所有服务器的linux版本,确保相同,不要跨大版本。
[root@bigdata111 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
2.设置时区
集群内所有机器,设置一下时区;
[root@bigdata111 ~]# timedatectl set-timezone Asia/Shanghai
3.查看是否安装NTP服务
集群内所有机器,查看是否安装ntp服务;
[root@bigdata111 ~]# rpm -qa | grep ntp
4.安装NTP服务
集群内所有机器,如果没有安装ntp服务,则执行以下命令安装;
[root@bigdata111 ~]# yum install ntp ntpdate -y
5.查看NTP服务状态
集群内所有机器,执行查看ntp服务状态命令,确定处于服务停止状态;
[root@bigdata111 ~]# systemctl status ntpd
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
6.修改主节点/主服务器的NTP配置文件;
找到集群的主节点配置NTP文件,编辑完毕,保存退出;
[root@bigdata111 ~]# vi /etc/ntp.conf
#找到如下内容注释掉
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
#添加以下内容,同步本地时间,ip写自己的
server 127.127.1.0 iburst
7.主节点同步网络时间
同步网络时间,此处以同步 阿里云的ntp为例;(注意:此操作只有在ntp服务停止的情况下执行,否则报错)
[root@bigdata111 ~]# ntpdate ntp1.aliyun.com
14 Oct 18:01:43 ntpdate[3909]: adjust time server 120.25.115.20 offset -0.020002 sec
8.启动主节点的NTP服务并设置开机启动
[root@bigdata111 ~]# systemctl start ntpd.service
[root@bigdata111 ~]# systemctl enable ntpd.service
9.查看主节点的NTP服务状态
确保主节点的NTP服务状态是 active(running) 状态,才能执行下一步;
[root@bigdata111 ~]# systemctl status ntpd.service
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2019-10-14 18:03:22 CST; 1min 31s ago
Main PID: 3916 (ntpd)
CGroup: /system.slice/ntpd.service
└─3916 /usr/sbin/ntpd -u ntp:ntp -g
10月 14 18:03:22 bigdata111 ntpd[3916]: Listen and drop on 1 v6wildcard :: UDP 123
10月 14 18:03:22 bigdata111 ntpd[3916]: Listen normally on 2 lo 127.0.0.1 UDP 123
10月 14 18:03:22 bigdata111 ntpd[3916]: Listen normally on 3 eno16777736 192.168.1.111 UDP 123
10月 14 18:03:22 bigdata111 ntpd[3916]: Listen normally on 4 lo ::1 UDP 123
10月 14 18:03:22 bigdata111 ntpd[3916]: Listen normally on 5 eno16777736 fe80::20c:29ff:fec9:1f12 UDP 123
10月 14 18:03:22 bigdata111 ntpd[3916]: Listening on routing socket on fd #22 for interface updates
10月 14 18:03:22 bigdata111 ntpd[3916]: 0.0.0.0 c016 06 restart
10月 14 18:03:22 bigdata111 ntpd[3916]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
10月 14 18:03:22 bigdata111 ntpd[3916]: 0.0.0.0 c011 01 freq_not_set
10月 14 18:03:23 bigdata111 ntpd[3916]: 0.0.0.0 c514 04 freq_mode
10.查看主节点是否同步;
如果没有同步,则关闭防火墙或者开放123端口;
[root@bigdata111 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 5 l 16 64 37 0.000 0.000 0.000
11.修改从机的NTP配置文件
修改其他机器的NTP配置文件,确保NTP服务是在停止状态进行该操作;(根据中文注释操作)修改完毕保存退出;
[root@bigdata111 ~]# vi /etc/ntp.conf
# 注释掉如下内容
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
#配置上游时间服务器为本地的ntpd Server服务器(写自己主服务器的IP地址即可)
server 192.168.1.111
#配置允许上游时间服务器主动修改本机的时间(写自己主服务器的IP地址即可)
restrict 192.168.1.111 nomodify notrap noquery
12.从机同步主服务器的时间
从机同步主服务器的时间。(IP就写自己上面配置的主服务器的IP)
[root@bigdata112 ~]# ntpdate -u 192.168.1.111
14 Oct 18:14:23 ntpdate[4608]: adjust time server 192.168.1.111 offset -0.000193 sec
13.启动从机的NTP服务&配置开机启动NTP
从机启动NTP服务和配置开机启动;
[root@bigdata112 ~]# systemctl start ntpd.service
[root@bigdata112 ~]# systemctl enable ntpd.service
13.查看从机的NTP服务状态
[root@bigdata112 ~]# systemctl status ntpd.service
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2019-10-14 21:51:50 CST; 4min 17s ago
Process: 860 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 862 (ntpd)
CGroup: /system.slice/ntpd.service
└─862 /usr/sbin/ntpd -u ntp:ntp -g
10月 14 21:51:49 bigdata112 ntpd[862]: Listen normally on 2 lo 127.0.0.1 UDP 123
10月 14 21:51:49 bigdata112 ntpd[862]: Listen normally on 3 lo ::1 UDP 123
10月 14 21:51:49 bigdata112 ntpd[862]: Listening on routing socket on fd #20 for interface updates
10月 14 21:51:49 bigdata112 ntpd[862]: 0.0.0.0 c016 06 restart
10月 14 21:51:49 bigdata112 ntpd[862]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
10月 14 21:51:49 bigdata112 ntpd[862]: 0.0.0.0 c011 01 freq_not_set
10月 14 21:51:50 bigdata112 systemd[1]: Started Network Time Service.
10月 14 21:51:55 bigdata112 ntpd[862]: Listen normally on 4 eno16777736 192.168.1.112 UDP 123
10月 14 21:51:55 bigdata112 ntpd[862]: Listen normally on 5 eno16777736 fe80::20c:29ff:fe15:e831 UDP 123
10月 14 21:51:55 bigdata112 ntpd[862]: new interface(s) found: waking up resolver
14.查看从机的NTP服务是否同步
[root@bigdata112 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*bigdata111 LOCAL(0) 6 u 17 64 17 0.527 0.035 0.007
至此,所有的NTP操作就全部完毕了。
【Linux】部署NTP时间同步服务器的更多相关文章
- 【转】Linux配置NTP时间同步服务器
分布式程序通常需要运行在一个统一的时间环境里. 转自:http://blog.csdn.net/mengfanzhundsc/article/details/62046562 安装NTP:yum in ...
- Linux集群部署自定义时间同步服务器(ntpd)
Linux集群部署自定义时间同步服务器(ntpd) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 身为一名运维人员,在搭建集群的时候,第一步需要做的就是同步每个机器的时间,尤其是在 ...
- centos7搭建ntp时间同步服务器chrony服务
centos7搭建ntp时间同步服务器chrony服务 前言: 在centos6的时候我们基本使用的是ntp服务用来做时间同步,但是在centos7后推荐是chrony作为时间同步器的服务端使用, ...
- 张高兴的 .NET IoT 入门指南:(八)基于 GPS 的 NTP 时间同步服务器
时间究竟是什么?这既可以是一个哲学问题,也可以是一个物理问题.古人对太阳进行观测,利用太阳的投影发明了日晷,定义了最初的时间.随着科技的发展,天文观测的精度也越来越准确,人们发现地球的自转并不是完全一 ...
- 关于linux下ntp时间同步服务的安装与配置
1.安装ntp服务,要使用时间同步.那么服务端与客户端都需要使用如下命令安装NTP软件包 [root@ ~]# yum install ntp -y 2.如果只是作为客户端的话,配置则可以非常简单,编 ...
- linux搭建ntp时间同步服务
1.NTP简介 NTP(Network Time Protocol,网络时间协议)用来使计算机时间同步的一种协议.它可以使计算机对其服务器或时钟源做同步化,它可以提供高精准度的时间校正(LAN上与标准 ...
- LINUX之ntp时间同步服务配置
本篇将介绍LINUX之ntp服务配置,时钟同步服务器配置.这个在很多地方都会用到,保持各主机之前的时间保持一致,保证主机之间的心跳稳定. 三台主机都是centos7 192.168.1.110 mas ...
- Linux配置NTP时间服务器(date、hwclock、NTP服务器的配置)
目录 date命令 hwclock命令 NTP服务的部署 服务端 客户端 date命令 date 命令的作用是查看和设置Linux中的系统日期时间 date ...
- NTP时间同步服务器设置
一.Window Server设置 [服务器端设置]1) 修改注册表以下键值:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\ ...
随机推荐
- go mod 解决 Go 语言的包依赖问题
转:https://testerhome.com/topics/16980 https://testerhome.com/ -------------------------------------- ...
- Ubuntu安装截图软件shutter
参考链接: Ubuntu 安装和配置shutter截图软件 解决shutter不能编辑的问题:https://itsfoss.com/shutter-edit-button-disabled/ 安装前 ...
- Elasticsearch:运用search_after来进行深度分页
在上一篇文章 "Elasticsearch:运用scroll接口对大量数据实现更好的分页",我们讲述了如何运用scroll接口来对大量数据来进行有效地分页.在那篇文章中,我们讲述了 ...
- c语言1-2019秋作业02
格式: 这个作业属于那个课程 C语言程序设计I 这个作业要求在哪里 http://edu.cnblogs.com/campus/zswxy/SE2019-3/homework/8688 我在这个课程的 ...
- vue初级尝试
为了跟上前端后台化的潮流,本少不得不开始关注vue,下列上机代码是针对App.vue进行的更改 数据渲染----一般键值对,数组,对象和对象数组 <template> <div id ...
- Unity 截图选择框,中间全透明,边缘半透明
效果:点击白色框可拖拽选择区域 代码: using System.Collections; using System.Collections.Generic; using UnityEngine; u ...
- CodeForces 835D - Palindromic characteristics | Codeforces Round #427 (Div. 2)
证明在Tutorial的评论版里 /* CodeForces 835D - Palindromic characteristics [ 分析,DP ] | Codeforces Round #427 ...
- For 循环的嵌套与九九乘法表
㈠通过程序,在页面中输入如下图形 * * * * * * * * * * * * * * * * * * * * * * * * * 代码如下: //向body中输入一个内容 //document. ...
- learning gcc #pragma once
referenc: https://zh.wikipedia.org/wiki/Pragma_once 在C和C++编程语言中,#pragma once是一个非标准但是被广泛支持的前置处理符号, 会让 ...
- vector 与 array
vector STL中的模板数组(在堆中分配内存空间,通过new delete管理内存) 使用包涵头文件#include <vector> vector<ElmentTpye> ...