【Linux】NTP服务器配置、时间修改

复制代码
 查看当前系统时间date

修改当前系统时间date -s "2018-2-22 19:10:30"

查看硬件时间hwclock --show

修改硬件时间hwclock --set --date "2018-2-22 19:10:30"

同步系统时间和硬件时间hwclock --hctosys

保存时钟clock --w

1.设置NTP Server服务

检查系统是否安装ntp服务:
rpm -qa | grep ntp

编辑配置文件:
vim /etc/ntp.conf
1)注释
# Use public servers from the pool.ntp.org project.
# 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

2)添加以下配置       
server 127.127.1.0
fudge 127.127.1.0 stratum 10
  

3)启动ntpd服务           
#开启ntp默认端口123(vim /etc/sysconfig/iptables),添加下面配置
-A INPUT -s 10.44.99.84/32 -p udp -m udp --dport 123 -j ACCEPT
 
#启动ntpd服务
systemctl start ntpd
 
#设置开机自启动
chkconfig ntpd on
 
#查看NTP是否正常运行
netstat -tlunp |  grep ntp
 
#查看ntp服务器有无和上层ntp连通
ntpstat
 
#查看ntp服务器与上层ntp的状态
ntpq --p
相关推荐
●VON1 天前
AtomGit Flutter鸿蒙客户端:文件树与代码浏览
android·服务器·安全·flutter·harmonyos·鸿蒙
bush41 天前
嵌入式linux学习记录七,中断
linux·嵌入式
RisunJan1 天前
Linux命令-nologin(用于系统账户或需要禁止交互式登录的场景)
linux·运维
是阿建吖!1 天前
【Linux】信号
android·linux·c语言·c++
城北徐宫1 天前
Linux信号深度解剖:5种产生、3张表、4次切换
linux·c++·学习
倔强的石头1061 天前
【Linux指南】Linux快捷键与系统实用技巧
linux·运维·服务器
番茄地瓜1 天前
Linux 配置静态 IP 步骤
linux·运维·服务器
liulilittle1 天前
论 Linux 内核态全局稳态带宽的卡尔曼估计与工程实现
linux·服务器·网络·c++·计算机网络·tcp·通信
Irissgwe1 天前
五、应用层协议HTTP
linux·网络·网络协议·http·状态码·url
.千余1 天前
【Linux】 传输层协议UDP:从端口号到传输机制
linux·运维·udp