码迷,mamicode.com
首页 > 系统相关 > 详细

Linux与云计算——第二阶段 第一章:NTP服务器架设

时间:2016-07-22 19:36:32      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:centos   ntpd   ntp服务器架设   chrony   ntp客户端   

Linux与云计算——第二阶段Linux服务器架设


第一章:NTP服务器架设

技术分享

1.NTP Server(NTPd)安装NTPd并且配置NTP服务器来完成时间调节.


[1] 安装NTPd.

[root@demo ~]# yum -y install ntp

[root@demo ~]# vim /etc/ntp.conf

参考17行,在第18行添加哪个网段内的主机允许访问你的NTP服务器:

restrict 192.168.96.0 mask 255.255.255.0 nomodify notrap

# 修改同步的服务器

#server 0.centos.pool.ntp.org iburst

22 #server 1.centos.pool.ntp.org iburst

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

24 #server 3.centos.pool.ntp.org iburst

25 server asia.pool.ntp.org iburst

[root@demo ~]# systemctl start ntpd

[root@demo ~]# systemctl enable ntpd 


[2] 如果防火墙Firewalld正在运行,注意放行NTP服务,NTP使用UDP的123端口进行通信. 

[root@demo ~]# firewall-cmd --add-service=ntp --permanent

success

[root@demo ~]# firewall-cmd --reload

success


[3] 验证NTP是否在正常工作.

[root@demo ~]# ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter

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

*210-140-66-77.j 133.243.238.163  2 u   33   64    7  209.189   53.766  58.151


2.NTP Server(Chrony)安装Chrony并且配置NTP服务器来完成时间调节.

[1] 安装Chrony.

[root@demo ~]# yum -y install chrony

[root@demo ~]# vim /etc/chrony.conf

# 第三行:修改同步时间的服务器 

#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 asia.pool.ntp.org iburst

# 25: 配置你打算允许接收哪个网段的访问请求

allow 192.168.96.0/24

[root@demo ~]# systemctl start chronyd

[root@demo ~]# systemctl enable chronyd 


[2] 如果防火墙Firewalld正在运行,注意放行NTP服务,NTP使用UDP的123端口进行通信. 

[root@demo ~]# firewall-cmd --add-service=ntp --permanent

success

[root@demo ~]# firewall-cmd --reload

success


 [3] 验证工作状态.

[root@demo ~]# chronyc sources

210 Number of sources = 1

MS Name/IP address         Stratum Poll Reach LastRx Last sample

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

^? 210.23.25.77                  2   7   100    98   -107ms[ -107ms] +/-  193ms

 

3.NTP 客户端

[1] CentOS 客户端同步时间.

[root@demo ~]# ntpdate asia.pool.ntp.org

7 Jul 17:47:40 ntpdate[12683]: adjust time server 110.75.190.198 offset 0.079993 sec


在Windows7上如何配置日期同步:

打开右下角日期和时间

技术分享


选择Internet时间并修改设置

 技术分享

输入刚才配置好的服务器地址,尝试进行同步。


详细视频请点击—→ http://edu.51cto.com/lesson/id-113651.html

本文出自 “11830455” 博客,请务必保留此出处http://11840455.blog.51cto.com/11830455/1828864

Linux与云计算——第二阶段 第一章:NTP服务器架设

标签:centos   ntpd   ntp服务器架设   chrony   ntp客户端   

原文地址:http://11840455.blog.51cto.com/11830455/1828864

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!