centos7-时间同步NTP安装,以及libopts.so.25问题解决

centos7-时间同步NTP安装,以及libopts.so.25问题解决

ntp时间同步服务器同来同步时间

安装

依赖包

ntp服务安装需要三个包:

autogen-libopts-5.18-5.el7.x86_64.rpm

ntpdate-4.2.6p5-25.el7.centos.2.x86_64.rpm

ntp-4.2.6p5-25.el7.centos.2.x86_64.rpm

安装步骤

直接yum安装即可

yum -y install ntp

使用

有两种使用方法

  1. 执行命令来同步

    ntpdate -u 202.120.2.101
    
  2. 设置为守护进程来同步

    1. 修改配置文件

      vi /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 time7.aliyun.com prefer iburst //添加一个同步服务器设置即可
      
    2. 启动守护程序

      systemctl start ntpd //启动
      systemctl stop ntpd //停止
      systemctl status ntpd //查看服务状态
      systemctl enable ntpd //设置开机自启
      

/etc/ntp.conf 配置文件

# 系统时间与BIOS事件的偏差记录
driftfile /var/lib/ntp/drift 

#restrict 控制相关权限。语法为: restrict IP地址 mask 子网掩码 参数
#其中IP地址也可以是default ,default 就是指所有的IP
#参数有以下几个:
#ignore  :关闭所有的 NTP 联机服务
#nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。
#notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网
#noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器
#notrap :不提供trap远端登陆:拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq 控制消息协议的子系统,用于远程事件#日志记录程序。
#nopeer :用于阻止主机尝试与服务器对等,并允许欺诈性服务器控制时钟
#kod : 访问违规时发送 KoD 包。
#restrict -6 表示IPV6地址的权限设置

restrict default nomodify notrap nopeer noquery

#确保localhost(这个常用的IP地址用来指Linux服务器本身)有足够权限.使用没有任何限制关键词的语法
restrict 127.0.0.1
restrict ::1

#
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

#设定NTP主机来源(其中prefer表示优先主机),192.168.7.49是本地的NTP服务器,所以优先指定从该主机同步时间。
server 0.centos.pool.ntp.org prefer
server 0.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
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8

# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats

# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monit
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值