欧美日韩不卡一区二区三区,www.蜜臀.com,高清国产一区二区三区四区五区,欧美日韩三级视频,欧美性综合,精品国产91久久久久久,99a精品视频在线观看

操作系統(tǒng)

Linux系統(tǒng)使用NTP服務器的方法

時間:2025-03-22 20:29:08 操作系統(tǒng) 我要投稿
  • 相關推薦

Linux系統(tǒng)使用NTP服務器的方法

  Linux系統(tǒng)下的NTP服務器指的是網(wǎng)絡時間同步協(xié)議,其作用就是同步網(wǎng)絡時間和Linux系統(tǒng)中的時間,使得Linux時間更加精確。下面就來介紹一下Linux系統(tǒng)下如何使用NTP服務器。

  一、ntp配置文件

  1. /etc/ntp.conf

  NTP服務的主要配置文件,不同的Linux版本文件所在的目錄可能會不同。

  2. /usr/share/zoneinfo

  規(guī)定了各主要時區(qū)的時間設定文件。/usr/share/zoneinfo/Asia/Shanghai 為中國大陸地區(qū)的時區(qū)設定文件。

  3. /etc/sysconfig/clock

  時區(qū)設置文件

  4. /etc/localtime

  本地系統(tǒng)的時間設定文件

 。踨oot@linuxidc1 ~]# 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聯(lián)接所花費的時間

  keys /etc/ntp/keys

  參數(shù):

  ignore :關閉所有的 NTP 聯(lián)機服務

  nomodify:客戶端不能更改服務端的時間參數(shù),但是客戶端可以通過服務端進行網(wǎng)絡校時。

  notrust :客戶端除非通過認證,否則該客戶端來源將被視為不信任子網(wǎng)

  noquery :不提供客戶端的時間查詢

  二、具體配置

 。踨oot@linuxidc1 ~]# 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

 。踨oot@linuxidc1 ~]# /etc/init.d/ntpd restart

  Shutting down ntpd: [ OK ]

  Starting ntpd: [ OK ]

  客戶端測試

  注:客戶端的/etc/hosts里需要加上ntp服務器的ip地址和主機名

 。踨oot@linuxidc2 ~]# 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@linuxidc1 ~]# watch ntpq -p

  注:LOCAL的這個就是與自身同步的ntp server。reach這個值,在啟動ntp server服務后,這個值就從0開始不斷增加,當增加到17的時候,從0到17是5次的變更,每一次是poll的值的秒數(shù),是64秒*5=320秒的時間。

  客戶端測試

 。踨oot@linuxidc2 ~]# ntpdate 192.168.8.70

  2 Mar 00:40:51 ntpdate[11184]: adjust time server 192.168.8.70 offset -0.000031 sec

  [root@linuxidc2 ~]# date

  Sat Mar 2 01:00:13 CST 2013

  服務器端

 。踨oot@linuxidc1 ~]# date

  Sat Mar 2 01:00:15 CST 2013

 。踨oot@linuxidc1 ~]#

  以上就是Linux系統(tǒng)下使用NTP服務器的方法了,使用NTP服務器同步Linux時間,也可以讓服務器下不同計算機的時間達成一致。

【Linux系統(tǒng)使用NTP服務器的方法】相關文章:

Linux系統(tǒng)中sleep的使用方法07-17

linux系統(tǒng)下dd命令的使用方法01-10

linux系統(tǒng)下sudo命令使用方法04-09

Linux系統(tǒng)中smbclient命令的使用方法08-02

linux系統(tǒng)中scp命令的使用方法06-27

Linux系統(tǒng)常用的網(wǎng)絡命令及使用方法02-08

Linux系統(tǒng)top命令的使用方法介紹07-23

Linux系統(tǒng)使用附加權限的方法介紹01-26

Linux系統(tǒng)格式化命令的使用方法06-05