CentOS6.x下的ntp服务

广大2年前技术文章533

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





相关文章

Kafak顺序写入与数据读取详解

Kafak顺序写入与数据读取详解

生产者(producer)是负责向Kafka提交数据的,Kafka会把收到的消息都写入到硬盘中,它绝对不会丢失数据。为了优化写入速度Kafak采用了两个技术,顺序写入和MMFile。1. 顺序写入因为...

HBase 的 BulkLoad 机制

HBase 的 BulkLoad 机制

1.概述在实际生产环境中,有这样一种场景:用户数据位于HDFS中,业务需要定期将这部分海量数据导入 HBase 系统,以执行随机查询更新操作。这种场景如果调用写入 API 进行处理,极有可能会给 Re...

大数据基础之HDFS入门

大数据基础之HDFS入门

一、NameNode是整个文件系统的管理节点。它维护着整个文件系统的文件目录树,文件/目录的元信息和每个文件对应的数据块列表。二、NameNode的工作特点Namenode始终在内存中保存meteda...

开源大数据集群部署(二十一)Spark on yarn 部署

开源大数据集群部署(二十一)Spark on yarn 部署

3.0.1 spark on yarn安装(每个节点) cd /root/bigdata/ tar -xzvf spark-3.3.1-bin-hadoop3.tgz -C /opt/ ln -s...

副本集的管理(二)

五、用户管理MongoDB默认是不开启用户认证模式的,但是为了数据库的安全和管理,我们需要开启用户认证。数据库用户角色:read、readWrite; 数据库管理角色:dbAdmin、dbOwner...

CDH开启kerberos

CDH开启kerberos

1、依赖条件1、安装openldap-clients,krb5-workstations2、准备好kdcserver 或者AD2、操作步骤1、使用admin用户登录cm页面2、启用kerberos填写...

发表评论    

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