Centos7.1 for NTP服务器配置

NTP服务器:network timeprotocol

BIOS内部芯片自身的特性易导致BIOS时间与UTC全球标准时间存在差异。时间同步(synchronize)能够有效地避免主机长时间运行导致的时间偏差。

NTP原理:

  1. 1.    NTP server开启daemon(监听端口号123为UDP的端口)
  2. 2.   client向NTPserver发送校对时间的消息
  3. 3.   NTP server回复当前的标准时间给client()
  4. 4.   client收到来自NTPserver的回复之后,调整自己的时间

client可以自动计算传输过程中的时延;server负载若过重,可采用master/slave架构提供网络校时。

大多数NTP服务器在国外,国内也有一个第二级的NTP服务器(210.72.154.44),直接连国内这台即可。

配置ntp时间同步

1.准备环境:两台主机

172.17.220.145:作为第三级的时间服务器ntpd,用于与二级标准时间服务器210.72.154.44同步时间

172.17.220.224:ntp客户端,用于与172.17.220.145同步时间

2.设置防火墙

vi/etc/sysconfig/iptables

在“-AINPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT”后增加

-AINPUT -p udp -m state --state NEW -m udp --dport 123 -j ACCEPT

3.rpm包检查

若没有安装,可通过yum install ntp安装。

4.设置系统开机自启及启动服务

Centos7默认通过chronyd服务实现时钟同步

我们关闭chronyd服务并使其开机不自启,同时启动ntpd并将其加入开机自启

[15:57:[email protected] ~]# systemctl stop chronyd
[15:59:[email protected] ~]# systemctl disable chronyd 
[15:59:[email protected] ~]# systemctl enable ntpd
[15:59:[email protected] ~]# systemctl start ntpd

5.修改配置文件

vi/etc/ntp.conf
#5.1设置对客户端的限制
restrict172.17.220.0 mask 255.255.255.0 nomodify
:<<’restrict参数

5.2设置自身时间的服务器来源
注释掉系统默认,尽量通过ip设置(减少dns解析时间)’
      #server 0.centos.pool.ntp.org iburst
#server1.centos.pool.ntp.org iburst
#server2.centos.pool.ntp.org iburst
#server3.centos.pool.ntp.org iburst
server110.75.190.198 perfer
server202.108.6.95
server202.112.29.82
#5.3设置自身为3级NTPserver
fudge172.17.220.145 stratum 3

6.重新启动ntpd并查看

systemctlrestart ntpd:重启ntpd

ntpq–p查看ntpd

7.设置ntp客户端

7.1 测试ntpd是否安装成功

ntpdate 172.17.220.145 #从ntpd(172.17.220.145)获取当前时间

date; hwclock –r #获取当前时间,通过hwclock–r写入bios时间

7.2设置自动同步(每隔三个小时更新一次时间)

  crontab –e
0 */1 * * * /usr/sbin/ntpdate192.168.0.240;/sbin/hwclock –w 
crontab –l

修改时区的命令

#cd /usr/share/zoneinfo #进入查找所有时区
# timedatectl set-timezone Asia/Shanghai
# timedatectl status

时间: 2025-01-01 07:07:16

Centos7.1 for NTP服务器配置的相关文章

NTP服务器配置及简单体验heartdeatva1高可用流程

NTP服务器配置及heartbeatV1实现httpd高可用 NTP服务器的搭建和使用 由于在做到高可用集群时,对个各节点的时间要求比较严格.因此我们需要配置一个NTP服务器实现高可用集群的的时间同步器.然后将其他的节点时间指向这个ntp,先来创建一个NTP服务器. [[email protected] ~ ]# rpm -q ntp ntp-4.2.6p5-1.el6.centos.x86_64 由于我们的服务器已经有ntp服务器,那么我们这里边直接使用好了. [[email protecte

Centos 5.5 NTP服务器配置

1.NTP服务器配置 1,ntp(network time protocol,网络时间协议)是一个用于同步计算机时钟的网络协议,它可以使计算机与其他服务器或时钟源进行时间同步.时间信息的传输都使用UDP协议123端口. 2,ntp服务的安装 yum  -y install ntp   // 使用yum 命令从互联网上下载安装包,前提是主机能连接网络. 完成下载并安装! 3,重启NTP服务 重启成功! 4.   Ntp服务其启动,暂停相关命令 service   ntpd start      

centos7中搭建ntp服务器

1.服务端安装ntpd服务 yum install ntp 2.修改配置文件,配置文件在/etc/ntpd.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 127.127.1.0 3.启动ntp system

服务器/客户端方式NTP服务器配置

1.NTP服务介绍 Network Time Protocol(NTP)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的协议攻击.NTP可以利用多个途径和来源的时间服务器来更加精确的校正时间. 现在绝大部分的操作系统都支持NTP,比如在Unix和Windows中都有他们自己的NTP服务.比如在Windows中的SNTP.由于各个系

CentOS7/Red Hat7 NTP服务无法开机自启动

centos7不同于以往linux的操作,对于开机自启动的调整,命令有所不同. chkconfig --list查看非系统内置服务的自启动状态 [[email protected] ~]# chkconfig --list Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by na

centos7.2_x64搭建ntp时间服务器

系统版本centos7.2_x641.安装ntp时间服务程序yum -y install ntp 2.配置ntp服务设置时间源,这里可以使用centos提供的默认时间源,其他都为默认server 0.centos.pool.ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2.centos.pool.ntp.org iburstserver 3.centos.pool.ntp.org iburst 3.更改本地的时区参考我另外一个修改

Linux服务管理之NTP服务器配置

目标环境,3台linuxcentos 6.6,一台作为NTPD服务与外部公共NTP服务同步时间,同时作为内网的NTPD服务器,其他机器与这台服务做时间同步. 1.NTP时间同步方式选择 NTP同步方式在linux下一般两种:使用ntpdate命令直接同步和使用NTPD服务平滑同步.有什么区别呢,简单说下,免得时间长了,概念又模糊. 现有一台设备,系统时间是13:00 , 真实的当前时间(在空中,也许卫星上,这里假设是在准备同步的上级目标NTP服务器)是:12:30  .如果我们使用ntpdate

CentOS7版本安装ntp服务

centos从7.0以后,ntp做成了一个服务,也就是说可以运行一个守护进程来自动同步时间,而不用像5和6的版本一样把命令写入计划任务中,这个在做集群服务的时候非常有帮助. 安装ntp [[email protected] ~]# yum install ntp ntpdate -y 配置文件/etc/ntp.conf [[email protected] ~]# vim /etc/ntp.conf # server 0.asia.pool.ntp.org server 1.asia.pool.

NTP服务器配置

NTPserver配置: server 127.127.1.0 fudge 127.127.1.0 stratum 8 driftfile /var/lib/ntp/drift NTP配置: server 172.16.31.103 driftfile /var/lib/ntp/drift disable auth restrict 127.0.0.1