Linux centerOS 服务器搭建NTP服务

1,安装 NTP软件

bash 复制代码
sudo yum -y install ntp

2,编辑配置文件

bash 复制代码
sudo vim /etc/ntp.conf

3,修改配置

ntp.conf文件中,可以配置服务器从哪些上游时间源同步时间。如果你想让你的服务器对外同步时间,可以去掉restrict default ignore这一行前面的注释符号,并将ignore改为nomodify notrap nopeer noquery

bash 复制代码
restrict default nomodify notrap nopeer noquery

4,将本机设置为NTP服务

bash 复制代码
server 127.127.1.0 将当前主机作为时间服务器

fudge 127.127.1.0 stratum 8   //fudge和server必须一起用 stratum 8代表层数

5,配置时间服务器,如

bash 复制代码
server 192.168.16.44 prefer  //prefer 优先

6,设置开机自动启动

bash 复制代码
systemctl enable ntpd

7,手动同步NTP时间,如下图则表示成功

bash 复制代码
ntpdate 192.168.16.204

8,启动并查看状态

bash 复制代码
systemctl restart ntpd                        //重启ntp服务

systemctl status ntpd                        //查看ntp服务
相关推荐
orion576 小时前
Missing Semester Class1:course overview and introduction of shell
linux
用户1204872216112 小时前
Linux驱动编译与加载
linux·嵌入式
程序员老赵14 小时前
服务器文件不想 SFTP 上传?Docker 跑个 File Browser,浏览器就能管理
服务器·docker·开源
vivo互联网技术18 小时前
从 10 分钟到 1 秒:ES 深度分页任意跳页的三轮优化实战
服务器·数据库·redis·elasticsearch·深度分页
用户8055336980318 小时前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户8055336980318 小时前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
七歌杜金房1 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
tntxia2 天前
linux curl命令详解_curl详解
linux
扛枪的书生2 天前
Linux 网络管理器用法速查
linux