• centos7 搭建ntp时钟服务器


    服务器 : 192.168.137.3

    客户机:  192.168.137.6

    1、 服务器端

    centos7下首先确认服务器的防火墙、selinux关闭状态

    # cat /etc/redhat-release 
    CentOS Linux release 7.0.1406 (Core)

    第一步  为服务器和客户机安装ntp   ntpdate   --默认已安装

    # yum install  ntp  ntpdate  -y

    第二步 查找时间同步服务器

    http://www.pool.ntp.org/zone/asia

    第三步  编辑 /etc/ntp.conf

    server time.windows.com

    server s2m.time.edu.cn

    server 0.asia.pool.ntp.org

    server 1.asia.pool.ntp.org

    server 2.asia.pool.ntp.org

    server 3.asia.pool.ntp.org

    server  127.127.1.0  iburst     local  clock  当外部时间不可用时,使用本地时间。

    restrict 192.168.137.1 mask 255.255.255.0 nomodify      允许更新的IP地址段

    第四步  启动ntp服务

    systemctl start  ntpd

    systemctl enable  ntpd.service   设置开机启动服务

    第五步  验证服务

    # ntpq  -p


         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
     211.138.200.209 .INIT.          16 u    -   64    0    0.000    0.000   0.000
     ns.pku.edu.cn   .INIT.          16 u    -   64    0    0.000    0.000   0.000
     211.138.200.208 .INIT.          16 u    -   64    0    0.000    0.000   0.000
     nipper.paina.jp .INIT.          16 u    -   64    0    0.000    0.000   0.000
     send.mx.cdnetwo .INIT.          16 u    -   64    0    0.000    0.000   0.000
    *LOCAL(0)        .LOCL.           5 l   52   64    1    0.000    0.000   0.000

    # date  -R
    Fri, 15 Jul 2016 15:28:34 +0800

    2.客户端

    第六步  远程客户端时间同步测试

    # date 
    Fri Jul 15 15:31:22 CST 2016

    # ntpdate  192.168.137.3
    15 Jul 15:33:04 ntpdate[63912]: step time server 192.168.137.3 offset -4.492463 sec

    第七步 客户端设置计划任务,每天晚上1点同步时间

    crontab -e

    00 01 * * * root  /usr/sbin/ntpdate  192.168.137.3; /sbin/hwclock -w      

             

    格式 00 01 * * *  五个字符表示  分 时 日 月 年

  • 相关阅读:
    sql语句中的通配符
    Q&A 20090922
    Web大文件上传
    作别2010, 迎来2011的第一个工作日
    .Net 中 获取当前应用程序启动目录的几个方法
    asp.net身份验证和使用Silverlight的问题
    常用正则表达式
    最完美的xslt数值函数与字符串函数
    SQL2005的分页存储过程,支持多表多关联,亲测高效绝对可用
    处理大并发下的dropdownlist数据关联
  • 原文地址:https://www.cnblogs.com/felixzh/p/9055165.html
Copyright © 2020-2023  润新知