linux建时间服务器,centos6.5 搭建时间服务器

时间服务器

yum install -y ntp ntpdate

修改配置

vim /etc/ntp.conf

driftfile /var/lib/ntp/drift

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict -6 ::1

#允许内部服务器同步

restrict 192.168.3.0 mask 255.255.255.0 nomodify notrap

#从服务器上就行时间同步

server 210.72.145.44 perfer # 中国国家受时中心

server 202.112.10.36 # 1.cn.pool.ntp.org

server 59.124.196.83 # 0.asia.pool.ntp.org

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

#允许上层时间服务器主动修改本机时间

restrict 210.72.145.44 nomodify notrap noquery

restrict 202.112.10.36 nomodify notrap noquery

restrict 59.124.196.83 nomodify notrap noquery

# 外部时间服务器不可用时,以本地时间作为时间服务

server 127.127.1.0 # local clock

fudge 127.127.1.0 stratum 10

启动ntp服务

service ntpd start

chkconfig ntpd on

查看状态

ntpq -p

将同步好的时间写到CMOS里边

vim /etc/sysconfig/ntpd

OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"

SYNC_HWCLOCK=yes

客户端

yum install ntp ntpdate

chkconfig ntpd on

vim /etc/ntp.conf

driftfile /var/lib/ntp/drift

restrict default nomodify

restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict -6 ::1

#上级时间服务器为

server

#允许上级时间服务器更新时间

restrict nomodify notrap noquery

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

启动服务

service ntpd start

手动同步时间

ntpdate -u 

将同步好的时间写到CMOS里边

vim /etc/sysconfig/ntpd

OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"

SYNC_HWCLOCK=yes

写个计划任务每小时同步一次

crontab -e

20 * * * * /usr/sbin/ntpdate

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值