`
亦梦亦真
  • 浏览: 226034 次
  • 性别: Icon_minigender_1
  • 来自: 秦皇岛
社区版块
存档分类
最新评论

centos搭建NTP服务器(转)

 
阅读更多

#为了保证应用程序层和数据库层的服务器能够同步时钟,所以要架设一台NTP服务器,让内部所有的服务器来同步NTP服务器的时钟

#检查服务器是否安装ntp
[root@ntp ~]# rpm -qa |grep ntp

#yum安装ntp
[root@ntp ~]# yum install -y ntp

#源码包安装ntp
[root@ntp ~]# wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.6p2.tar.gz
[root@ntp ~]# tar -zxvf ntp-4.2.6p2.tar.gz
[root@ntp ~]# cd ntp-4.2.6p2
[root@ntp ntp-4.2.6p2]# ./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks
[root@ntp ntp-4.2.6p2]# make;make install

#让本服务器时间与time.nist.gov时间同步,使服务器为标准时间
[root@ntp ~]# ntpdate time.nist.gov

#自动同步服务器时钟
[root@ntp ~]# crontab -e
*/5 * * * * /usr/sbin/ntpdate time.nist.gov

[root@ntp ~]# service crond restart

#修改ntp配置文件
[root@ntp ~]# vi /etc/ntp.conf

# 用restrict控管权限
# nomodify - 用户端不能更改ntp服务器的时间参数
# noquery - 用户端不能使用ntpq,ntpc等命令来查询ntp服务器
# notrap - 不提供trap远端登陆

#允许任何IP的客户机都可以进行时间同步
#restrict default nomodify notrap noquery  //注释掉这一行
restrict default modify notrap //允许任何IP的客户端都可以进行同步

#只允许10.8.0.0网段的客户机进行时间同步
restrict default nomodify notrap noquery
restrict 10.8.0.0 mask 255.255.0.0 nomodify     //添加一行

# 以下是两个ntp服务器
restrict time.nist.gov
restrict 164.67.62.194

# 用server设定上层ntp服务器,“prefer”表示优先
server time.nist.gov prefer
server 164.67.62.194
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10

# 系统时间与bios事件的偏差记录
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys

# 日志
logfile /var/log/ntp.log
broadcastdelay 0.008

#BIOS时间同步
SYNC_HWCLOCK=yes


#yum安装启动方式
[root@ntp ~]# service ntpd start

#源码包安装以守护进程启动ntpd
[root@ntp ~]# /usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid

#查看端口
[root@ntp ~]# netstat -unlnp

#iptables开启udp 123端口
[root@ntp ~]# iptables -A INPUT -p udp -m udp --dport 123 -j ACCEPT

#查看ntp服务器有无和上层连通
[root@ntp ~]# ntpstat

#查看ntp服务器与上层间的联系
[root@ntp ~]# ntptrace -n time.nist.gov
time.nist.gov: stratum 1, offset 0.000000, synch distance 0.002650, refid 'ACTS'

查看ntp服务器与上层ntp服务器的状态
[root@ntp ~]# ntpq -p

remote - 本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先
refid - 参考上一层ntp主机地址
st - stratum阶层
when - 多少秒前曾经同步过时间
poll - 下次更新在多少秒后
reach - 已经向上层ntp服务器要求更新的次数
delay - 网络延迟
offset - 时间补偿
jitter - 系统时间与bios时间差

#linux客户端同步NTP服务器时钟
[root@db_1 ~]# crontab -e
*/5 * * * * /usr/sbin/ntpdate 10.8.2.10

 

ntp客户端运行ntpdate serverIP,出现no server suitable for synchronization found的错误。

ntp客户端用ntpdate –d serverIP查看,发现有“Server dropped: strata too high”的错误,并且显示“stratum 16”。而正常情况下stratum这个值得范围是“0~15”。

这是因为NTP server还没有和其自身或者它的server同步上。

以下的定义是让NTP Server和其自身保持同步,如果在/ntp.conf中定义的server都不可用时,将使用local时间作为ntp服务提供给ntp客户端。

server 127.127.1.0
fudge 
127.127.1.0 stratum 8 
分享到:
评论

相关推荐

    CentOS7搭建NTP服务器及客户端同步时间.docx

    CentOS7搭建NTP服务器及客户端同步时间.docx

    搭建ntp服务器

    centos 下搭建ntp时间服务器,centos 下搭建ntp时间服务器,centos 下搭建ntp时间服务器,

    CentOS6.2 NTP时间服务器搭建

    NTP时间服务器可用于需要同步时间的服务器之间,以一台服务器作为标准时间,让其他服务器与这台服务器统一时间。

    CentOS 7 搭建ntp时钟服务器的步骤详解

    前言  NTP 网络时间协议用来同步网络上不同主机的系统时间。你管理的所有主机都可以和...在这篇文章中,我们会介绍在CentOS 7 搭建ntp时钟服务器的步骤,一起来看看吧。 服务器 : 192.168.137.3 客户机: 192.168.1

    搭建NTP服务器所需要的离线安装包

    搭建NTP服务器所需要的离线安装包,使用方式 #安装ntp服务器以及其依赖包 rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm rpm -ivh ntp-4.2.6p5-18.el7.centos.x86_64.rpm rpm -ivh ntpdate-4.2.6p5-18.el7.centos....

    cetos7离线安装时间同步ntp需要的rpm包

    ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm openssl-1.0.2k-19.el7.x86_64.rpm openssl-libs-1.0.2k-19.el7.x86_64.rpm 一键安装命令: rpm -ivh *.rpm --force --nodeps

    Centos7-NTP时钟同步服务配置.docx

    redhat/centos 7 搭建NTP服务器,yum安装 ntp服务,并对外提供时间服务的详细说明

    centos下ntp对时服务设置

    包含libopts25-5.18.12-3.3.1.x86_64.rpm、libopts-devel-5.18.12-3.3.1.x86_64.rpm、ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm官方安装包 适用于centos下ntp服务器搭建。搭建流程参考文章

    在centost7搭建Chrony时间服务器.pdf

    搭建NTP服务器,本人亲自测试,通过centost7.5版本搭建NTP时间服务器

    Ansible-OTRS6:在Centos7.9上安装和配置OTRS6

    ntp_sever_ip:您的NTP服务器IP或域名 ntp_dir:应该是/ etc /或/ etc / ntp mysql_password:这是将为MySQL root用户设置的密码 用法 ansible-playbook -i hosts site.yml --extra-vars "remote_host=YOUR_HOST

    centos7.5分布式平台搭建.docx

    3. HPE服务器Centos7.5安装 16 3.1. 服务器(DL388 Gen10)加载镜像文件 16 3.2. 系统安装、配置 18 3.2.1. 选中【install centos7】 18 3.2.2. 语言 18 3.2.3. 其他配置 18 3.2.4. 时区 18 3.2.5. 软件包安装 19 ...

    Linux下搭建Python开发环境部署.docx

    安装操作系统 系统版本CentOS release 6.5 (Final)mini安装 关闭SELinux 关闭防火墙功能 关闭SSH的UseDNS功能 配置IP地址 配置DNS服务器 配置NTP服务器 配置主机名

    在centos7安装zabbix3.0的超详细步骤记录

    前言 最近公司部分业务迁移机房,为了更方便的监控管理主机资源,决定上线zabbix监控平台。...00 00 * * * /usr/sbin/ntpdate -u x.x.x.x #选择ntp服务器 #systemctl restart crond 1.1 安装依赖包: yum

Global site tag (gtag.js) - Google Analytics