0
点赞
收藏
分享

微信扫一扫

ntp服务器搭建部署

centos-7x 6x

1、安装ntpd服务

yum install ntp -y

启动服务 systemctl start ntpd

设置开机自启 systemctl enable ntpd

2、配置ntp服务器

###############

vim /etc/ntp.conf

driftfile  /var/lib/ntp/drift

pidfile    /var/run/ntpd.pid

logfile    /var/log/ntp.log

restrict default nomodify notrap nopeer noquery          //当前节点IP地址,允许所有机器可以使用

restrict 127.0.0.1

restrict ::1

server  ntp1.aliyun.com prefer#阿里云的时间服务器,可以多加几个时间服务器,但是一定要ping通。

#server  ntp.sjtu.edu.cn iburst#上海交大的时间服务器

# local clock

server 127.127.1.0  #  # local clock#本地的时间服务器,当上面不管事的时候,客户端就同步本地时


fudge  127.127.1.0 stratum 10

includefile /etc/ntp/crypto/pw

########################

测试 :

ntpq -p

添加定时任务

crontab -e

00 01 * * * ntpdate ntp1.aliyun.com

3、客户端配置.

yum install -y ntpdate vim /etc/ntp.conf

#在server 一行,修改为下面信息。

server 192.168.51.174 iburst

## 查看

[root@cicd-server ~]# ntpq -p

    remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

*LOCAL(0)        .LOCL.          10 l   22   64   77    0.000    0.000   0.000

192.168.51.174  LOCAL(0)        11 u   41   64  377    1.225  -559795 634747.


ntpupdate  192.168.51.174   ## 同步客户端时间

注:在客户端配置 定时同步时间

crontab -e

00 01 * * * ntpdate  192.168.51.174

 

举报

相关推荐

0 条评论