CentOS6.x下的ntp服务

广大2年前技术文章966

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





相关文章

某系统被入侵挖矿排查案例

某系统被入侵挖矿排查案例

1、当时的出现的情况是:执行 top、w、netstat命令的时候,会出现卡住的情况,无法正常使用2、我们上传新的top命令之后,只是看到CPU使用率比较高,但是看不到占用CPU的异常进程3、我们通过...

kubebuilder 开发operator初探

1、使用kubebuilder初始化$ mkdir project$ cd project$ kubebuilder init --domain tutorial.kubebuilder.io --r...

CDH-Impala集成ldap认证

CDH-Impala集成ldap认证

1、背景集群版本:cdh6.2.0impala版本:3.2.0+cdh6.2.0用户认证:AD由于用户需要使用数据库工具连接impala,但是集群开启了kerberos,如果使用数据库连接工具连接im...

Go 错误处理与单元测试

1、错误处理1.1 如何定义错误在 Go 语言中,无论是在类型检查还是编译过程中,都是将错误看做值来对待,和 string 或者 integer 这些类型值并不差别。声明一个 string 类型变量和...

Linux_ACL权限、mask值

acl权限在什么情况下使用:当要给一个用户与文件的属主、属组、其他人权限都不同的时候使用。也就是说,这个用户对应于这个文件不属于三个身份中的任何一种,是属于第四种身份,那么我们就需要使用acl权限去给...

shell脚本--sed

sed后面接的动作,务必以 '........'两个单引号包住1.擅长对文件进行操作处理2.对文件信息进行内容的信息修改-i 参数代表直接修改原文件a :往后新增一行, a 的后面可以接字串,而这些字...

发表评论    

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