CentOS6.x下的ntp服务

广大2年前技术文章532

CentOS6.x下的ntp服务配置

192.168.1.1(node01) 负责与外网同步时间,同时作为内网的ntp服务

192.168.1.2(node02) 和内网192.168.1.1去同步时间,是ntp的客户端


1、查看ntp是否安装

rpm -qa |grep ntp


2、安装ntp

yum install -y ntp


3、设置开机自启动

chkconfig ntpd on


查看开机自启动状态

chkconfig --list ntpd

ntpd               0:off    1:off    2:on    3:on    4:on    5:on    6:off

在2、3、4、5 处是on表示开机自启


4、配置ntp时间同步

(1)配置内网ntp-server(node01)

vim /etc/ntp.conf


driftfile /var/lib/ntp/drift

#允许远程时间源与我们本地源同步,但不允许远程源查询或修改本本地系统服务

restrict default nomodify notrap nopeer noquery

#允许通过回环地址127.0.0.1的所有访问.也可以被收紧限制,但这样会影响一些本职的功能

restrict 127.0.0.1

restrict ::1

#本地网络主机限制较少。默认被注释了,放开注释,允许内网其他主机同步本机时间

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

#这里换成以下几个ntp服务器

server 0.cn.pool.ntp.org  #China

server 1.asia.pool.ntp.org  #Asia

server 2.centos.pool.ntp.org #centos

server 3.pool.ntp.org  #Worldwide

#允许上层时间服务器主动修改本机时间

restrict 0.cn.pool.ntp.org nomodify notrap noquery

restrict 1.asia.pool.ntp.org nomodify notrap noquery

restrict 2.centos.pool.ntp.org nomodify notrap noquery

restrict 3.pool.ntp.org nomodify notrap noquery

#上边列表中的时间服务器都不可用时,同本地时间同步

server  127.127.1.0     # local clock

fudge   127.127.1.0 stratum 10

 

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

disable monitor


(2)配置内网NTP-Clients

vim /etc/ntp.conf

driftfile /var/lib/ntp/drift

#允许远程时间源与我们本地源同步,但不允许远程源查询或修改本本地系统服务

restrict default nomodify notrap nopeer noquery

#允许通过回环地址127.0.0.1的所有访问.也可以被收紧限制,但这样会影响一些本职的功能

restrict 127.0.0.1

restrict ::1

#本地网络主机限制较少。默认被注释了,放开注释,允许内网其他主机同步本机时间

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

#这里换成以下几个ntp服务器,主要是这步,加上要同步的ntp服务器即可

server 192.168.1.1  #内网ntp-server服务器

#允许上层时间服务器主动修改本机时间

restrict 192.168.1.1 nomodify notrap noquery

#上边列表中的时间服务器都不可用时,同本地时间同步

server  127.127.1.0     # local clock

fudge   127.127.1.0 stratum 10

 

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

disable monitor        




5、启动ntp服务

service ntpd start


6、查看ntp状态 

ntpstat 


7、查看同步网络中的NTP服务器

ntpq -pn





相关文章

数据库性能大揭秘:玩转MySQL监控指标状态变量

前言在本文中,我们将深入探讨MySQL数据库的性能监控世界。通过了解并应用一系列常用的监控指标,我们能够更精准地把握数据库的运行状况。这些指标,通常以状态变量(status variables)的形式...

Linux解锁线程基本概念和线程控制,步入多线程学习的大门(2)

Linux解锁线程基本概念和线程控制,步入多线程学习的大门(2)

2.4.线程等待:为什么需要线程等待?已经退出的线程,其空间没有被释放,仍然在进程的地址空间内。不然也会造成内存泄露问题!创建新的线程不会复用刚才退出线程的地址空间。主线程退出 == 进程退出 ==...

静默安装oracle软件参数文件解析

文件位置在oracle软件解压目录下的database/response/db_install.rsp,主要参数解析如下########################################...

impala故障处理

问题复现:[cdh004:21000] > select count(*) from impala_100yi; Query: select count(*) from impala_100y...

kubernetes调度策略

1、背景在 Kubernetes 中,调度 (scheduling) 指的是确保 Pod 匹配到合适的节点,以便 kubelet 能够运行它们。调度的工作由调度器和控制器协调完成。调度器通过 Kube...

容器引擎Podman常用命令浅析

容器引擎Podman常用命令浅析

Podman简介Podman 是一个开源的无守护进程的容器引擎,用于在Linux系统上开发、管理和运行OCI容器。容器既可以以root身份运行,也可以在无root模式下运行。Podman 提供与 Do...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。