【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
相关推荐
浅止菌9 分钟前
嵌入式设备ping不通?tcpdump 5分钟找到凶手,比加printf快10倍
linux
巴啦啦小魔仙变身28 分钟前
SIGINT = Signal Interrupte
linux·服务器·python
RisunJan33 分钟前
Linux命令-route(查看/修改 IP 路由表)
linux·运维
不会C语言的男孩1 小时前
TCP通信可视化工具,含下载地址
服务器·网络·安全
凉、介1 小时前
Linux 设备驱动匹配机制
linux·笔记·单片机·学习·操作系统·嵌入式
卵男(章鱼)1 小时前
第4章:软件架构与SOA
linux·车载系统·汽车
TDengine (老段)2 小时前
TDengine SMA 索引 — 块级/文件级统计索引
android·大数据·服务器·数据库·人工智能·时序数据库·tdengine
玖玥拾2 小时前
C# 语言进阶(十三)网络 DLL 库分层设计
服务器·开发语言·网络·网络协议·c#
是摆烂第一名呀2 小时前
【RK3506】RGB屏幕与背光调试记录
linux·arm开发·驱动开发·嵌入式硬件