2.客戶端配置
[root@fire ~]# yum install -y ntp ntpdate
[root@fire ~]# ntpdate 0.cn.pool.ntp.org
#在啟動時間伺服器前先以時間客戶端的身份去網際網路的時間伺服器進行時間同步,若時間伺服器的時間實際和真正的時間差很遠,網際網路時間伺服器是不肯和它同步時間的。
#預設配置
[root@fire ~]# grep -ev 『^$|#』 /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery #<==對預設的client拒絕所有操作
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 #<==允許本地位址的一切操作
restrict -6 ::1
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
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
#修改配置
[root@fire ~]# cat /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 192.168.1.0 mask 255.255.255.0 noquery
restrict 192.168.2.0 mask 255.255.255.0 noquery #<==允許區域網內所有client連線到這台伺服器
restrict -6 ::1 同步時間.但是拒絕讓他們修改伺服器上的時間
#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 0.cn.pool.ntp.org #<==同步公網的時間
server 127.127.1.0 #<==如果無法連線公網,則使用自己本身的時間作為標準時間。
fudge 127.127.1.0 stratum 10 #<==設定stratum級別
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
ignore :關閉所有的 ntp 聯機服務
nomodify:客戶端不能更改服務端的時間引數,但是客戶端可以通過服務端進行網路校時。
notrust :客戶端除非通過認證,否則該客戶端**將被視為不信任子網
noquery :不提供客戶端的時間查詢
各引數如下:
#使用hwclock –w命令將系統時間同步到機器時間
[root@lb01 ~]# hwclock
mon 24 aug 2020 10:21:42 am cst -0.579479 seconds
NTP時間伺服器簡單配置
ntp network time protocol 網路時間協議,工作在udp的123埠。一種來同步計算機時間,實現高精度時間同步,較小的誤差的協議。ntp伺服器通過向utc的時間源 原子鐘 天文台 衛星或者internet 獲取時間同步。根據與utc源的遠近將所有時間伺服器劃分為不同的層 stra...
ntp時間伺服器
兩台虛擬機器 192.168.30.139 服務端 192.168.30.143 客戶端1 安裝ntp 服務 192.168.30.139 root hadoop1 opt yum install y ntp 192.168.30.143 root hadoop2 opt yum install y...
NTP時間伺服器
ntp network time protocol 網路時間協議,工作在udp的123埠上。是用來使計算機時間同步化的一種協議,它可以使計算機對其伺服器或時鐘源 如石英鐘,gps等等 做同步化,它可以提供高精準度的時間校正 區域網上與標準間差小於1毫秒,網際網路上幾十毫秒 且可介由加密確認的方式來防...