| 您的当前位置:首页 --> CentOS入门 |
| Linux下的ntp服务器配置 |
| 浏览次数:2498 关键词 ( 服务器配置 Linux ntp ) |
|
Linux下的ntp服务器 1.什么是ntp? NTP(Network Time Protocol,网络时间协议)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源做同步化,它可以提供 高精准度的时间校正。 2.对ntp配置文件的相关介绍
1. /etc/ntp.conf [root@tx1 ~]# grep -v "^#" /etc/ntp.conf restrict default kod nomodify notrap nopeer noquery//对于默认的client拒绝所有的操作 restrict -6 default kod nomodify notrap nopeer noquery //针对ipv6的设置 restrict 127.0.0.1 //允许本机地址一切的操作 restrict -6 ::1 server 0.rhel.pool.ntp.org //设置上层服务器做同步ip地址 server 1.rhel.pool.ntp.org server 2.rhel.pool.ntp.org server 127.127.1.0 //local地址 fudge 127.127.1.0 stratum 10 //这行是时间服务器的层次。设为0则为顶级,如果要向别的NTP服务器更新时间,请不要把它设为0 driftfile /var/lib/ntp/drift //记录上次的NTP server与上层NTP server联接所花费的时间 keys /etc/ntp/keys 参数:
ignore :关闭所有的 NTP 联机服务 3.具体配置 [root@tx1 ~]# vim /etc/ntp.conf 3 restrict default kod nomodify notrap nopeer noquery 4 #restrict -6 default kod nomodify notrap nopeer noquery 5 restrict default nomodify 6 restrict 192.168.8.0 mask 255.255.255.0 nomodify 11 restrict 127.0.0.1 18 #server 0.rhel.pool.ntp.org 19 #server 1.rhel.pool.ntp.org 20 #server 2.rhel.pool.ntp.org 21 server 192.168.8.70 31 server 127.127.1.0 # local clock 32 fudge 127.127.1.0 stratum 10
[root@tx1 ~]# /etc/init.d/ntpd restart Shutting down ntpd: [ OK ] Starting ntpd: [ OK ] 客户端测试 注:客户端的/etc/hosts里需要加上ntp服务器的ip地址和主机名 [root@tx2 ~]# ntpdate 192.168.8.70 2 Mar 00:35:44 ntpdate[11181]: no server suitable for synchronization found 注:在ntp server上启动ntp服务后,ntp server自身或者与其server的同步的需要一个时间段,这个过程可能是5分钟,在这个时间之内在客户端运行ntpdate命令进行同步时会产生 no server suitable for synchronization found的错误。 查看同步的过程 [root@tx1 ~]# watch ntpq -p
注:LOCAL的这个就是与自身同步的ntp server。reach这个值,在启动ntp server服务后,这个值就从0开始不断增加,当增加到17的时候,从0到17是5次的变更,每一次是poll的值的秒数,是64秒*5=320秒的时间。 [root@tx2 ~]# ntpdate 192.168.8.70 2 Mar 00:40:51 ntpdate[11184]: adjust time server 192.168.8.70 offset -0.000031 sec [root@tx2 ~]# date Sat Mar 2 01:00:13 CST 2013 服务器端 [root@tx1 ~]# date Sat Mar 2 01:00:15 CST 2013 [root@tx1 ~]# |
| 下载次数:8 |
| 下载地址:点击下载 |
| 本资源为程序自动采集,如有侵权请联系我们移除 admin#80vps.com 来信请将#替换为@ |
| 下一条 centos系统中网络配置相关 上一条 linux系统双网卡绑定单个IP地址 |