zoukankan      html  css  js  c++  java
  • linux菜鸟日记(2)

    ntp服务的安装与配置:

    安装ntp服务的过程比较简单首先你需要挂载光盘然后安装ntp服务如果配置了本地yum源可以直接使用光盘中的资源进行本地yum的安装,如果没有就使用rpm包进行安装。

    由于我已经配置好了本地yum源所以我就直接使用本地yum源进行ntp服务的安装。

    第一步使用yum命令安装ntp

    yum install ntp -y

    这里的 -y是一直确定的参数  如果不-y那么在安装的过程中每安装一个包就需要你确定一次那样会出现很繁琐的操作。

    安装完成之后我们对ntp服务进行配置,配置文在:

    /etc/ntp.conf

    使用vi或者vim命令打开ntp.conf

    # For more information about this file, see the man pages
    # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
    
    driftfile /var/lib/ntp/drift
    
    # Permit time synchronization with our time source, but do not
    # permit the source to query or modify the service on this system.
    restrict default kod nomodify notrap nopeer noquery
    restrict -6 default kod nomodify notrap nopeer noquery
    
    # Permit all access over the loopback interface.  This could
    # be tightened as well, but to do so would effect some of
    # the administrative functions.
    restrict 127.0.0.1
    restrict -6 ::1
    
    # Hosts on local network are less restricted.
    #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
    
    # 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
    
    
    
    
    
    #broadcast 192.168.1.255 autokey        # broadcast server
    #broadcastclient                        # broadcast client
    #broadcast 224.0.1.1 autokey            # multicast server
    #multicastclient 224.0.1.1              # multicast client
    #manycastserver 239.255.254.254         # manycast server
    #manycastclient 239.255.254.254 autokey # manycast client
    
    # Enable public key cryptography.
    #crypto
    
    includefile /etc/ntp/crypto/pw
    
    # Key file containing the keys and key identifiers used when operating
    # with symmetric key cryptography. 
    -- 插入 --                                                                                                                                                

    我们需要把这几行使用#全部注释掉

    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 xx.xx.xx.xx iburst
    #server 0.centos.pool.ntp.org iburst
    #erver 1.centos.pool.ntp.org iburst
    #server 2.centos.pool.ntp.org iburst
    #server 3.centos.pool.ntp.org iburst

    使用server IP  iburst 之后你就能从时间同步服务器里同步自己本地的时间了

    如过你要做为服务器的话 你可以在刚才那个位置添加 server 127.127.1.1  然后保存   并且重启ntpd服务就行了。

  • 相关阅读:
    QT窗体程序设置成不可改变大小,并生成在Linux下可双击执行的程序文件
    QT新建一个窗口控制程序,以实现添加按钮点击弹出信息提示框为例
    C# 模拟Http请求、下载
    thingsboard改造使用mysql数据库
    Redis单机版分布式锁实现
    利用jvisualvm使用btrace进行线上调试案例
    Btrace官方教程-中文版
    Powerdesigner16 逆向 postgresql9.2
    Linux java进程无故被kill
    thingsboard填坑之路
  • 原文地址:https://www.cnblogs.com/zhangzhongming/p/5948031.html
Copyright © 2011-2022 走看看