• Centos配置NTP服务器


    NTP服务端:

    1. 安装NTP服务

    rpm -qa|grep ntp      #查看是否安装ntp,以下为已安装

    yum -y install ntp ntpdate   #安装命令

    2. 查找当前地区最适合的时间服务器

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

    注:本章使用aliyun时间服务器

    ntp1.aliyun.com

    ntp2.aliyun.com

    ntp3.aliyun.com

    ntp4.aliyun.com

    3.验证ntp服务是否开启

    yum install -y nmap

    nmap -sU ntp1.aliyun.com -p 123

    4. 编辑/etc/ntp.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 ntp1.aliyun.com iburst

    #server ntp2.aliyun.com iburst
    #server ntp3.aliyun.com iburst
    #server ntp4.aliyun.com iburst

    server 127.127.1.0 iburst      #作为服务端配置这条即可

    5. 启动ntp服务

    systemctl start ntpd.service

    systemctl enable ntpd.service

    6.配置服务器时间

    date       #系统时间

    date -s "2019-12-06 09:59:00"

    hwclock    #硬件时间

    hwclock --set --date "2019-12-06 09:59:30"

    NTP客户端:

    1. 安装ntp服务

    rpm -qa|grep ntp

    yum -y install ntp ntpdate 

    2. 设置ntp.conf

    # Hosts on local network are less restricted.
    #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
    restrict 192.168.0.60 nomodify notrap noquery

    # Use public servers from the pool.ntp.org project.
    # Please consider joining the pool (http://www.pool.ntp.org/join.html).
    #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 192.168.0.60

    3.同步ntp服务时间

    ntpdate -u 192.168.0.60

    ntpdate参数介绍:

    -q  Query only - don’t set the clock.

    -s  Divert logging output from the standard output (default) to the system syslog facility. This is
    designed primarily for convenience of cron scripts.

    -u  Direct ntpdate to use an unprivileged port for outgoing packets. This is most useful when behind a
    firewall that blocks incoming traffic to privileged ports, and you want to synchronize with hosts
    beyond the firewall. Note that the -d option always uses unprivileged ports.

    4. 创建同步时间定时任务

    crontab -e

    0 * * * * /usr/sbin/ntpdate -u 192.168.0.60    #每小时同步

    crontab -l

    5.验证时间服务

    ntpq -p

    6.centos6/7开启ntp服务

    centos6:

      service ntpd start

      chkconfig ntpd on

    centos7:

      systemctl start ntpd.service

      systemctl enable ntpd.service

  • 相关阅读:
    Linux XZ格式的解压
    Linux eject弹出光驱
    什么是错误链接/死链接
    什么是相对地址和绝对地址
    网站被K或者降权后应该如何恢复
    网络营销怎么做才有“钱”途
    如何通过seo技术提高网站对用户的友好度
    如何利用微博客进行seo赚钱营销
    做SEO必须制定超越竞争对手网站的方案
    文章很快收录后又被删除的原因
  • 原文地址:https://www.cnblogs.com/sonnyBag/p/11493766.html
Copyright © 2020-2023  润新知