Centos6、Centos7下的NTP时间同步

Centos6

  • rpm -q ntp 查看是否安装ntp

  • yum install ntp 安装ntp,已安装则跳过此步骤
  • chkconfig --list ntpd 查看

  • chkconfig ntpd on 设置开机自启动chkconfig --list ntpd 查看

  • vi /etc/ntp.conf 配置同步ntp-server时间,贴出变动内容如下,10.82.71.73为对时服务器
#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

#对时服务器,配置成ntp-server的机器

server 10.82.71.73

restrict 10.82.71.73 nomodify notrap noquery


server  127.127.1.0     # local clock

fudge   127.127.1.0 stratum 10
  • vi /etc/sysconfig/ntpd 设置时钟同步,文件内容如下
# Drop root to id 'ntp:ntp' by default.

SYNC_HWCLOCK=yes

OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
  • service ntpd start 启动ntp服务
  • ntpdate -u 10.82.71.73 手动同步一次时间

Centos7

与Centos6大致相同,执行结果参考上面,如下

  • rpm -qa | grep ntp 查看是否安装ntp
  • yum install ntp ntpdate -y 安装ntp,已安装则跳过此步骤
  • systemctl status ntpd 查看ntp服务器状态
  • vi /etc/ntp.conf 配置同步ntp-server时间,文件内容如下
  • systemctl start ntpd 启动ntp服务
  • systemctl enable ntpd 设置开机启动
  • ntpdate -u 10.82.71.73手动同步一次时间
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值