zoukankan      html  css  js  c++  java
  • CentOS7编译安装ntp

    搭建时间同步服务器

    系统版本:CentOS Linux release 7.4.1708 (Core)

    ntp版本:ntpd 4.2.8p11


    一:服务器端配置
    先创建安装目录:mkdir -p /data/server/ntp


    1、下载、解压安装包,然后编译安装
    # wget https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p11.tar.gz
    # tar -zxvf ntp-4.2.8p11.tar.gz
    # cd ntp-4.2.8p11
    # ./configure --prefix=/data/server/ntp --enable-all-clocks --enable-parse-clocks
    # make && make install


    2、修改配置文件(如果默认没有该文件,则需手动创建)
    # vim /etc/ntp.conf
    interface listen 0.0.0.0
    server 127.127.1.0
    fudge 127.127.1.0 stratum 10
    restrict 192.168.199.0 mask 255.255.255.0 nomodify notrap


    3、把ntp设置为服务
    # cp /data/server/ntp/bin/ntpd /etc/init.d/ntpd


    4、启动ntp并查看进程是否启动
    # service ntpd start
    # netstat -anptu | grep ntp
    # iptable -I INPUT -p tcp --dport 123 -j ACCEPT


    二:客户端配置 

    1、yum安装ntpdate

    # yum -y install ntpdate


    2、设置任务计划自动与时间服务器同步时间(如设置每天凌晨3点连接时间服务器同步时间)
    # crontab -e
    00 03 * * * /usr/sbin/ntpdate 192.168.199.156; /sbin/hwclock -w

    3、重启crond服务
    # systemctl restart crond


    4、测试
    先随意设置一个时间
    # timedatectl set-time 12:00:00 && date
    立即连接ntp服务器同步时间
    # ntpdate 192.168.199.156 && date

    ########完成##########

  • 相关阅读:
    关于标准库中的ptr_fun/binary_function/bind1st/bind2nd
    ptr_fun学习笔记
    stream_iterator、ostream_iterator 使用初探
    C++异常处理
    ext2文件系统
    C语言动态内存管理
    C++中为什么要用虚函数、指针或引用才能实现多态?
    hadoop本地库
    二分图最小点覆盖König定理的简单证明 (加入自己理解)
    Fence Repair POJ
  • 原文地址:https://www.cnblogs.com/relax1949/p/9238712.html
Copyright © 2011-2022 走看看