【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\ ...
随机推荐
- CentOS7 内核优化 修改参数
一:内核简介 内核是操作系统最基本的部分.它是为众多应用程序提供对计算机硬件的安全访问的一部分软件,这种访问是有限的,并且内核决定一个程序在什么时候对某部分硬件操作多长时间. 内核的分类可分为单内核和 ...
- Ajax fileUpload
在项目开发中用到ajax 的 fileUpload,遇到onchange事件只触发一次 原因是fileUpload调用后将原有的file元素改变了,需要早upload后重新绑定元素 第一次绑定: $( ...
- CodeForces - 1202F You Are Given Some Letters... (整除分块)
题意:一个字符串包含a个A和b个B,求这个字符串所有可能的循环节长度(末尾可能存在不完整的循环节) 好题,但思路不是很好想. 首先由于循环节长度可以任意取,而循环次数最多只有$O(\sqrt n)$个 ...
- 【HDU5521】Meeting
题目大意:给定一张\(N\)个点的图,构成了\(M\)个团,每个团内的边权均相等,求图上有多少个点满足到\(1\)号节点和\(N\)号节点的最大值最小. 题解: 本题的核心是如何优化连边,考虑对于每一 ...
- HDU 6071 - Lazy Running | 2017 Multi-University Training Contest 4
/* HDU 6071 - Lazy Running [ 建模,最短路 ] | 2017 Multi-University Training Contest 4 题意: 四个点的环,给定相邻两点距离, ...
- hover([over,]out)
hover([over,]out) 概述 一个模仿悬停事件(鼠标移动到一个对象上面及移出这个对象)的方法.这是一个自定义的方法,它为频繁使用的任务提供了一种“保持在其中”的状态. 当鼠标移动到一个匹配 ...
- Crash的数字表格 / JZPTAB
https://www.cnblogs.com/peng-ym/p/8666124.html #include<bits/stdc++.h> #define LL long long #d ...
- 一次router拦截器的应用
实现 退出登陆 无法回退到其它页面 当有登陆状态时 可以拿其它页面的地址直接访问 若没有登陆状态 拿其它页面的地址直接访问 会报错 router.beforeEach((to, from, n ...
- Spring Cloud Eureka(四):Eureka 配置参数说明
Eureka Client 配置项(eureka.client.*) org.springframework.cloud.netflix.eureka.EurekaClientConfigBean 参 ...
- 安装mongodb-window10版
第一.下载mongodb 官方地址:https://www.mongodb.com/ 第二步mongodb安装 运行mongodb-win32-x86_64-2008plus-ssl-v3.4-lat ...