• ntp时间同步


    部署注意事项,时区在安装系统时设置好自己的时区不然同步不了

    安装NTP服务
    yum -y install ntp 

    配置NTP
    vi /etc/ntp.conf

    # line 19: 添加允许接收请求的网络范围
    restrict 192.168.30.0 mask 255.255.255.0 nomodify notrap   

    # line 19  客户端需要同步的ip,有多少个客户端,添加多个
    restrict 192.168.30.5         

    # 同步的更改服务器
    # 中国这边最活跃的时间服务器 : http://www.pool.ntp.org/zone/cn

    server 210.72.145.44 perfer      # 中国国家受时中心

    server 202.112.10.36             # 1.cn.pool.ntp.org

    server 59.124.196.83             # 0.asia.pool.ntp.org


    # allow update time by the upper server 
    # 允许上层时间服务器主动修改本机时间

    restrict 210.72.145.44 nomodify notrap noquery

    restrict 202.112.10.36 nomodify notrap noquery

    restrict 59.124.196.83 nomodify notrap noquery


    # 外部时间服务器不可用时,以本地时间作为时间服务
    server  127.127.1.0     # local clock

    fudge   127.127.1.0 stratum 10


    添加到底部
    includefile /etc/ntp/crypto/pw
    keys /etc/ntp/keys

    防火墙设置
    iptables -I INPUT -p udp -m udp --sport 123 -j ACCEPT    对外开放123端口

    最好的办法是将所有linux系统的防火墙都关闭:

    chkconfig --level 2345 ip6tables off      

    chkconfig --level 2345 iptables off         

    service ip6tables stop

    service iptables stop                       

    查看防火墙是否关闭成功:

    chkconfig --list | grep ip

    ip6tables      0:off1:off2:off3:off4:off5:off6:off

    iptables      0:off1:off2:off3:off4:off5:off6:off


    允许BIOS与系统时间同步,简单命令hwclock -w也可修改配置文件

    vi /etc/sysconfig/ntpd

    SYNC_HWCLOCK=yes


    查看服务连接和监听

    # netstat -tlunp | grep ntp    


    查看本机与上层NTP服务器通信情况

    ntpq -p

    查看123端口
    lsof -i:123

    启动NTP服务
    /etc/rc.d/init.d/ntpd start 或者 service ntpd start

    Starting ntpd:[ OK ]

    开机自启动

    chkconfig ntpd on

    chkconfig --list ntpd

    chkconfig --level 35 ntpd on

     

    NTP-Client 部署-配置 Linux

     It's the time synchronization on CentOS Client.

     ntpdate 192.168.30.3

    如果提示报错no server suitable for synchronization found

    解决方法添加-u参数可以越过防火墙与主机同步

    比如 ntpdate -u 192.168.30.3 

    客户端设置定时同步时间

    [root@dlp ~]# vi /root/ntpupdate.sh       编辑定时脚本

    /usr/sbin/ntpdate 192.168.30.3

    [root@dlp ~]# cat /root/ntpupdate.sh   编辑完之后查看

    /usr/sbin/ntpdate 192.168.30.3

    [root@dlp ~]# crontab -e                       编辑定时任务,每分钟执行一次

    */1 * * * * /root/ntpupdate.sh

    [root@dlp ~]# crontab -l

    */1 * * * * /root/ntpupdate.sh                编辑后查看

     

    NTP-Client-Windows部署-配置

    时间服务器地址

    版权声明:本文为博主原创文章,未经博主允许不得转载。
  • 相关阅读:
    hibernate配置
    关于memset
    Struts2通配符的使用
    Excel表中的数据导入mysql数据库
    蓝桥杯:错误票据
    蓝桥杯:十六进制转八进制
    Android TabHost中切換、修改需要显示的Activity
    Android图片处理(Matrix,ColorMatrix)
    Android gallery滑动惯性问题
    华为手机在开发Android调试时logcat不显示输出信息的解决办法
  • 原文地址:https://www.cnblogs.com/baiquan/p/7764901.html
Copyright © 2020-2023  润新知