[Linux] CentOS6 client server NTP同步配置

公司局域网,已经配置好了一台NTP服务器,现配置客户机与服务端时间同步。

 

方法一:

crontab定时任务,ntpdate同步客户机与NTP服务器时间

每天7:30同步时间,并写入BIOS

[root@VMServer etc]# crontab -l
30 7 * * * /usr/sbin/ntpdate 10.191.130.130; /sbin/hwclock -w
[root@VMServer etc]#

 

方法二:

ntpd既是服务器端,又是客户端。

1)作为客户端运行时,修改ntp.conf文件增加server 192.168.1.1

vi /etc/ntp.conf

# 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.1.1

2)ntpd设为开机启动并运行:

[root@VMServer etc]# chkconfig ntpd on
[root@VMServer etc]# chkconfig | grep ntpd
ntpd            0:off 1:off 2:on 3:on 4:on 5:on 6:off
ntpdate         0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@VMServer etc]# service ntpd start
Starting ntpd:                                             [  OK  ]
[root@VMServer etc]# service ntpd status
ntpd (pid  9897) is running...
[root@VMServer etc]#

 

两种方法的区别:

ntpd在实际同步时间是一点点的校准过来时间的,最终把时间慢慢的矫正对。

而ntpdate不会考虑其他程序是否会阵痛,直接调整时间。

一个是校准时间,一个是调整时间。

 

备注:

ntpd既是服务器端,也是客户端

作为服务器运行时:
1)修改/etc/ntp.conf增加
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
2)运行:
service ntpd start


作为客户端运行时:
1)修改/etc/ntp.conf增加
server 192.168.1.1
2)运行:
service ntpd start

其他都是默认设置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值