CentOS7系统上配置NTP时钟服务器
来源:互联网 发布:cf调烟头软件 编辑:程序博客网 时间:2024/05/16 11:17
CentOS7系统上配置NTP时钟服务器
1、需要配置的计算机IP
192.168.195.10 ceph-node1
192.168.195.12 ceph-node2
设置IP=192.168.195.10为时钟服务器
IP=192.168.195.12服务器为需要同步机器
2、查看两个机器桑是否安装了ntp包
[root@ceph-node2 ~]# rpm -qa | grep ntp
fontpackages-filesystem-1.44-8.el7.noarch
python-ntplib-0.3.2-1.el7.noarch
ntpdate-4.2.6p5-22.el7.centos.x86_64
ntp-4.2.6p5-22.el7.centos.x86_64
这样的输出证明已经安装好了,其中包就是"ntp-4.2.6p5-22.el7.centos.x86_64"
3、配置ntp.conf文件
配置NTP服务器的关键是需要配置这个文件
[root@ceph-node2 ~]# vi /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
#restrict 192.168.195.0 mask 255.255.0.0 nomodify
server 127.127.1.0
fudge 127.127.1.0 stratum 11
下面的省略了....
这是要改变的地方,server 0-3 注释掉,
加入本地时间服务器,主要是 127.127.1.0,由于是顶层服务,也就是说没有上级时间服务器
了,这里就是使用192.168.195.10的时间为准。
接着,重启或者启动ntpd服务:
[root@ceph-node1 ~]# systemctl restart ntpd.service
此时,ntpd服务器已经配置好了。再执行:
[root@ceph-node1 ~]# systemctl enable ntpd.service
使服务在系统启动后就开启。
4、在客户端机器上进行配置
[root@ceph-node2 ~]# vi /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
#server 127.127.1.0 iburst local clock
#fudge 127.127.1.0 stratum 11
#restrict 192.168.195.0 mask 255.255.0.0 nomodify
server 192.168.195.10
fudge 127.127.1.0 stratum 11
下面省略....
主要是添加下面两行:
server 192.168.195.10
fudge 127.127.1.0 stratum 11#这个是需要11,因为不是顶级的
配置好保存,即可。
查看ntp服务状态:
[root@ceph-node2 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*ceph-node1 LOCAL(0) 11 u 32 64 377 0.168 0.003 0.139
refid为LOCAL(0)为准确。
5、测试
[root@ceph-node2 ~]# date -s "2017-02-14 19:00:00"
而ceph-node1是2017-02-14 11:17:00
最多大概10分钟左右时间,node2会同步node1的时间。
6、ceph-node2执行开机启动ntp服务
[root@ceph-node2 ~]# systemctl enable ntpd.service
7、实时同步时间
[root@ceph-node2 ~]#ntpdate 192.168.195.10
执行这个命令时,可能会出现问题,如:
13 Feb 23:55:58 ntpdate[1788]: the NTP socket is in use, exiting
使用lsof –i:123
[root@ceph-node lsof -i:123
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ntpd 16538 ntp 16u IPv4 10940 UDP *:ntp
ntpd 16538 ntp 17u IPv6 10941 UDP *:ntp
ntpd 16538 ntp 18u IPv6 10942 UDP localhost6.localdomain6:ntp
ntpd 16538 ntp 19u IPv4 10943 UDP localhost:ntp
ntpd 16538 ntp 20u IPv4 10944 UDP 220.181.128.182:ntp
ntpd 16538 ntp 21u IPv4 10945 UDP localhost:ntp
[root@ceph-node kill -9 16538
此后,再使用ntpdate 192.168.195.10就成功了!
1、需要配置的计算机IP
192.168.195.10 ceph-node1
192.168.195.12 ceph-node2
设置IP=192.168.195.10为时钟服务器
IP=192.168.195.12服务器为需要同步机器
2、查看两个机器桑是否安装了ntp包
[root@ceph-node2 ~]# rpm -qa | grep ntp
fontpackages-filesystem-1.44-8.el7.noarch
python-ntplib-0.3.2-1.el7.noarch
ntpdate-4.2.6p5-22.el7.centos.x86_64
ntp-4.2.6p5-22.el7.centos.x86_64
这样的输出证明已经安装好了,其中包就是"ntp-4.2.6p5-22.el7.centos.x86_64"
3、配置ntp.conf文件
配置NTP服务器的关键是需要配置这个文件
[root@ceph-node2 ~]# vi /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
#restrict 192.168.195.0 mask 255.255.0.0 nomodify
server 127.127.1.0
fudge 127.127.1.0 stratum 11
下面的省略了....
这是要改变的地方,server 0-3 注释掉,
加入本地时间服务器,主要是 127.127.1.0,由于是顶层服务,也就是说没有上级时间服务器
了,这里就是使用192.168.195.10的时间为准。
接着,重启或者启动ntpd服务:
[root@ceph-node1 ~]# systemctl restart ntpd.service
此时,ntpd服务器已经配置好了。再执行:
[root@ceph-node1 ~]# systemctl enable ntpd.service
使服务在系统启动后就开启。
4、在客户端机器上进行配置
[root@ceph-node2 ~]# vi /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
#server 127.127.1.0 iburst local clock
#fudge 127.127.1.0 stratum 11
#restrict 192.168.195.0 mask 255.255.0.0 nomodify
server 192.168.195.10
fudge 127.127.1.0 stratum 11
下面省略....
主要是添加下面两行:
server 192.168.195.10
fudge 127.127.1.0 stratum 11#这个是需要11,因为不是顶级的
配置好保存,即可。
查看ntp服务状态:
[root@ceph-node2 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*ceph-node1 LOCAL(0) 11 u 32 64 377 0.168 0.003 0.139
refid为LOCAL(0)为准确。
5、测试
[root@ceph-node2 ~]# date -s "2017-02-14 19:00:00"
而ceph-node1是2017-02-14 11:17:00
最多大概10分钟左右时间,node2会同步node1的时间。
6、ceph-node2执行开机启动ntp服务
[root@ceph-node2 ~]# systemctl enable ntpd.service
7、实时同步时间
[root@ceph-node2 ~]#ntpdate 192.168.195.10
执行这个命令时,可能会出现问题,如:
13 Feb 23:55:58 ntpdate[1788]: the NTP socket is in use, exiting
使用lsof –i:123
[root@ceph-node lsof -i:123
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ntpd 16538 ntp 16u IPv4 10940 UDP *:ntp
ntpd 16538 ntp 17u IPv6 10941 UDP *:ntp
ntpd 16538 ntp 18u IPv6 10942 UDP localhost6.localdomain6:ntp
ntpd 16538 ntp 19u IPv4 10943 UDP localhost:ntp
ntpd 16538 ntp 20u IPv4 10944 UDP 220.181.128.182:ntp
ntpd 16538 ntp 21u IPv4 10945 UDP localhost:ntp
[root@ceph-node kill -9 16538
此后,再使用ntpdate 192.168.195.10就成功了!
0 0
- CentOS7系统上配置NTP时钟服务器
- centos7 搭建ntp时钟服务器
- Centos7 NTP时钟同步配置
- centos7 NTP 服务器配置
- feora12 上配置NTP服务器
- centos7 配置时间同步服务器ntp
- 计算机NTP时钟同步(NTP服务器-NTP时间服务器)的重要性及其配置方法
- CISCO路由器上配置NTP服务器----实验
- AIX 6.1 上 NTP 时钟同步配置详解
- centos7.2上搭建ntp服务器,并实现时间同步
- NTP时钟同步服务器安装
- centos7上配置Samba服务器
- GPS时钟服务器|北斗卫星授时系统|NTP网络时间服务器|时间同步显示系统
- 以本地时钟配置NTP
- NTP服务器的配置
- 配置windows NTP服务器
- ubuntu配置ntp服务器
- NTP服务器配置
- leetcode 315. Count of Smaller Numbers After Self
- 出现Unable to find a pod with name, author, summary, or description matching解决方法
- 运动物体目标检测实现—基于OpenCV
- Shell脚本知识整理
- 网易有道2017内推编程题
- CentOS7系统上配置NTP时钟服务器
- JAVA 图形化界面的格式
- linux 每天自动备份mysql
- Apache Kylin Cube优化
- R语言实现分层抽样(Stratified Sampling)以iris数据集为例
- 推荐!手把手教你使用Git
- 数据结构实验之串一:KMP简单应用
- oracle什么时候需要commit
- django python报错:SNIMissingWarning,InsecurePlatformWarning