当前位置:网站首页>搭建ntp时间服务器(安装sql2000配置服务器失败)
搭建ntp时间服务器(安装sql2000配置服务器失败)
2022-08-01 14:06:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
简介
时间服务NTP:Network Time Protocol 作用:用来给其他主机提供时间同步服务,在搭建服务器集群的时候,需要保证各个节点的时间是一致的,时间服务器不失为一个好的选择。
准备工作
- 关闭防火墙、关闭selinux
- 系统版本:CentOS7.x,
- NTP服务器IP:10.220.5.111,客户端IP:10.220.5.179
安装配置NTP服务器端
一、安装ntp
[[email protected] ~]# yum install ntp -y二、修改ntp的配置文件
[[email protected] ~]# cp /etc/ntp.conf{,.bak}
[[email protected] ~]# vim /etc/ntp.conf
server 127.127.1.0 #以本机作为时间服务器
fudge 127.127.1.0 startnum 10 #设置服务器层级
restrict 127.0.0.1 # 允许本机使用这个时间服务器
restrict 10.220.5.0 netmask 255.255.255.0 #允许允许10.220.5.0/24网段的所有主机使用该时间服务器进行时间同步
driftfile /var/lib/ntp/ #记录当前时间服务器,与上游服务器的时间差的文件
logfile /var/log/ntp/ntp.log #指定日志文件位置,需要手动创建三、创建日志文件
[email protected] ~]# mkdir /var/lib/ntp/
[[email protected] ~]# touch /var/lib/ntp/ntp.log三、启动服务
[[email protected] ~]# systemctl start ntpd
[[email protected] ~]# systemctl enable ntpd四、查看状态
[[email protected] ~]# ntpstat
synchronised to local net at stratum 6
time correct to within 11 ms
polling server every 64 s
#synchronised:表示时间同步完成(ntp可以正常工作了)
#unsynchronised:表示时间同步尚未完成
# 或者用 ntpq -p查看状态
[[email protected] ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 5 l 13 64 377 0.000 0.000 0.000安装配置NTP客户端
一、安装
[[email protected] ~]# yum install ntp ntpdate -y二、修改配置文件
[[email protected] ~]# cp /etc/ntp.conf{,.bak}
[[email protected] ~]# vim /etc/ntp.conf
server 10.220.5.111 #设置以10.220.5.111做为本机的时间服务器
restrict 127.0.0.1
logfile /var/log/ntp/ntp.log #指定日志文件位置,需要手动创建三、创建日志文件
[[email protected] ~]# mkdir /var/log/ntp
[[email protected] ~]# touch /var/log/ntp/ntp.log四、先执行一次ntpdate时间同步
[[email protected] ~]# ntpdate 10.220.5.111五、启动ntpd
[[email protected] ~]# systemctl start ntpd六、检查状态
[[email protected] ~]# ntpstat
unsynchronised
time server re-starting
polling server every 8 s
# 或者
[[email protected] ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
10.220.5.111 LOCAL(0) 6 u 11 64 1 0.502 0.009 0.000说明:在工作中我们一般都是使用ntpdate+ntp来完成时间同步,因为单独使用ntpdate同步时间虽然简单快捷但是会导致时间不连续,而时间不连续在数据库业务中影响是很大的,单独使用ntp做时间同步时,当服务器与时间服务器相差大的时候则无法启动ntpd来同步时间。由于ntpd做时间同步时是做的顺滑同步(可以简单理解为时间走得快,以便将落后的时间赶过来),所以同步到时间服务器的的时间不是瞬间完成的,开启ntpd之后稍等三五分钟就能完成时间同步。
补充:用ntpq -p查看状态时的各种参数解释
参数 | 释义 |
|---|---|
remote | 上游的时间服务器的ip或者主机名,如果是*表示本机就是做为上游服务器工作 |
refid | “.LOCL.”表示基于当前主机提供时间同步服务,如果是IP地址表示基于一个上游服务器提供时间同步服务。 |
st | 表示remote远程服务器的层级编号 |
t | |
when | 表示几秒之前做过一次时间同步 |
poll | 表示每隔多少秒做一次时间同步 |
reach | 表示向上游服务器成功请求时间同步的次数 |
delay | 从本地机发送同步要求到ntp服务器的时间延迟 |
offset | 主机通过NTP时钟同步与所同步时间源的时间偏移量,单位为毫秒(ms)。offset越接近于0,主机和ntp服务器的时间越接近 |
jitter | 这是一个用来做统计的值. 它统计了在特定个连续的连接数里offset的分布情况. 简单地说这个数值的绝对值越小,主机的时间就越精确 |
——做运维之前很矫情的小年轻—–
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/126413.html原文链接:https://javaforall.cn
边栏推荐
- 我寻找的方向
- Wovent Bio IPO: Annual revenue of 480 million pension fund is a shareholder
- 什么是元编程
- 有限合伙人与普通合伙人的区别
- The role of the final keyword final and basic types, reference types
- Longkou united chemical registration: through 550 million revenue xiu-mei li control 92.5% stake
- 使用open3d可视化3d人脸
- 预防和制止家庭暴力 人身安全保护令司法解释今起施行
- 你真的会测试用户登录吗?
- Qt实战案例(55)——利用QDir删除选定文件目录下的空文件夹
猜你喜欢
随机推荐
什么是元编程
2022图片在线加水印源码
[深入研究4G/5G/6G专题-47]: 5G Link Adaption链路自适应-3-下行链路自适应DLLA-PDSCH信道
VIP的实现原理
PAT 1163 Dijkstra Sequence(30)
PAT 1167 Cartesian Tree(30)
JMP Pro 16.0 software installation package download and installation tutorial
[机缘参悟-57]:《素书》-4-修身养志[本德宗道章第四]
【码蹄集新手村600题】判断一个数字是否为完全平方数
牛客刷SQL--7
性能优化——资源优化笔记
PAT1165 Block Reversing(25)
Multi-threaded cases - blocking queue
免费使用高性能的GPU和TPU—谷歌Colab使用教程
Two Permutations
leetcode.26 删除有序数组中的重复项(set/直接遍历)
lua脚本关键
E - Red and Blue Graph (Combinatorics)
重磅!国内首个开放式在线绘图平台Figdraw突破10万用户!发布《奖学金激励计划》:最高5000元!...
NebulaGraph v3.2.0 Performance Report









