zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Web安全测试检查点
    "Could not resolve host: mirrorlist.centos.org; Unknown error"解决方法
    VMware vSphere Client中启动虚拟机提示No boot filename received/Operating System not found解决方法
    Android:Mstar Android8.0平台音量控制流程
    Android:系统自定义鼠标样式切换
    Android:系统日历添加默认账户
    Android:状态栏禁用时蓝牙多文件传输弹窗及进度显示
    Android:导入所需的系统jar包到Android studio
    Android:修改连接到AP端显示的设备名
    Android:StateMachine 之 WifiStateMachine
  • 原文地址:https://www.cnblogs.com/sonnyBag/p/11493766.html
Copyright © 2011-2022 走看看