亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

首頁(yè) 系統(tǒng)教程 操作系統(tǒng) Centos 7安裝配置NTP網(wǎng)絡(luò)時(shí)間同步服務(wù)器

Centos 7安裝配置NTP網(wǎng)絡(luò)時(shí)間同步服務(wù)器

Aug 05, 2024 pm 10:35 PM
linux linux教程 紅帽 linux系統(tǒng) linux命令 linux認(rèn)證 紅帽linux linux視頻

Centos 7安裝配置NTP網(wǎng)絡(luò)時(shí)間同步服務(wù)器

實(shí)驗(yàn)環(huán)境:

OS:Linux Centos 7.4 x86_64

1.查看當(dāng)前服務(wù)器時(shí)區(qū)&列出時(shí)區(qū)并設(shè)置時(shí)區(qū)(如已是正確時(shí)區(qū),請(qǐng)略過(guò)):

# timedatectl
# timedatectl list-timezones
# timedatectl set-timezone Asia/Shanghai

2.時(shí)間時(shí)區(qū)概念理解:

GMT、UTC、CST、DST

UTC:

整個(gè)地球分為二十四時(shí)區(qū),每個(gè)時(shí)區(qū)都有自己的本地時(shí)間,在國(guó)際無(wú)線電通信場(chǎng)合,為了統(tǒng)一起見(jiàn),使用一個(gè)統(tǒng)一的時(shí)間,稱為通用協(xié)調(diào)時(shí)(UTC:Universal Time Coordinated)。

GMT:

格林威治標(biāo)準(zhǔn)時(shí)間 (Greenwich Mean Time)指位于英國(guó)倫敦郊區(qū)的皇家格林尼治天文臺(tái)的標(biāo)準(zhǔn)時(shí)間,因?yàn)楸境踝游缇€被定義在通過(guò)那里的經(jīng)線(UTC與GMT時(shí)間基本相同)。

CST:

中國(guó)標(biāo)準(zhǔn)時(shí)間 (China Standard Time)

GMT + 8 = UTC + 8 = CST

DST:

夏令時(shí)(Daylight Saving Time) 指在夏天太陽(yáng)升起的比較早時(shí),將時(shí)間撥快一小時(shí),以提早日光的使用(中國(guó)不使用)。

2.使用 NTP 公共時(shí)間服務(wù)器池(NTP Public Pool Time Servers)http://www.pool.ntp.org 同步你的服務(wù)器時(shí)間。

查看是否安裝:

# rpm -q ntp
ntp-4.2.6p5-25.el7.centos.2.x86_64

如已安裝請(qǐng)略過(guò)此步,否則請(qǐng)執(zhí)行以下命令安裝:

# yum install ntpdate ntp -y

修改NTP配置:

注:綠色為原有我注釋掉的內(nèi)容,紅色為新增代替之前注釋內(nèi)容,其他默認(rèn)。

# vim /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).

driftfile /var/lib/ntp/drift

#新增:日志目錄.
logfile /var/log/ntpd.log

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery

# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1
#這一行的含義是授權(quán)172.16.128.0網(wǎng)段上的所有機(jī)器可以從這臺(tái)機(jī)器上查詢和同步時(shí)間.
restrict 172.16.128.0 mask 255.255.255.0 nomodify notrap

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# 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

#新增:時(shí)間服務(wù)器列表.
server 0.cn.pool.ntp.org iburst
server 1.cn.pool.ntp.org iburst
server 2.cn.pool.ntp.org iburst
server 3.cn.pool.ntp.org iburst

#新增:當(dāng)外部時(shí)間不可用時(shí),使用本地時(shí)間.
server 172.16.128.171 iburst
fudge 127.0.0.1 stratum 10

#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client

#新增:允許上層時(shí)間服務(wù)器主動(dòng)修改本機(jī)時(shí)間.
restrict 0.cn.pool.ntp.org nomodify notrap noquery
restrict 1.cn.pool.ntp.org nomodify notrap noquery
restrict 2.cn.pool.ntp.org nomodify notrap noquery

# Enable public key cryptography.
#crypto

includefile /etc/ntp/crypto/pw

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8

# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats

# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
disable monitor

3.設(shè)置系統(tǒng)開(kāi)機(jī)自啟動(dòng):

# systemctl enable ntpd
# systemctl enable ntpdate
# systemctl is-enabled ntpd

在ntpd服務(wù)啟動(dòng)時(shí),先使用ntpdate命令同步時(shí)間:

# ntpdate -u 1.cn.pool.ntp.org

原因之一:當(dāng)服務(wù)端與客戶端之間的時(shí)間誤差過(guò)大時(shí),此時(shí)修改時(shí)間可能對(duì)系統(tǒng)或應(yīng)用帶來(lái)不可預(yù)知問(wèn)題,NTP會(huì)停止時(shí)間同步。若檢查NTP啟動(dòng)后時(shí)間未同步時(shí),應(yīng)考慮可能是時(shí)間誤差過(guò)大所致,此時(shí)需要先手動(dòng)進(jìn)行時(shí)間同步。

啟動(dòng)NTP服務(wù)器:

# systemctl start ntpdate
# systemctl start ntpd

4.加入防火墻:

# firewall-cmd --permanent --add-service=ntp
# firewall-cmd --reload

5.查看ntp連接狀態(tài)如果沒(méi)有問(wèn)題,將正確時(shí)間寫入硬件:

# ss -tlunp | grep ntp
# ntpq -p
# hwclock -w

5.1.系統(tǒng)時(shí)間與硬件時(shí)間

硬件時(shí)間:

RTC(Real-Time Clock)或CMOS時(shí)間,一般在主板上靠電池供電,服務(wù)器斷電后也會(huì)繼續(xù)運(yùn)行。僅保存日期時(shí)間數(shù)值,無(wú)法保存時(shí)區(qū)和夏令時(shí)設(shè)置。

系統(tǒng)時(shí)間:

一般在服務(wù)器啟動(dòng)時(shí)復(fù)制RTC時(shí)間,之后獨(dú)立運(yùn)行,保存了時(shí)間、時(shí)區(qū)和夏令時(shí)設(shè)置。

6.客戶端:

以服務(wù)進(jìn)程方式實(shí)時(shí)同步(需安裝NTP):

# vim /etc/ntp.conf
server 172.16.128.171

重要:修改任意節(jié)點(diǎn)服務(wù)器的NTP配置文件都需要重起ntpd服務(wù):

# systemctl restart ntpd

以crontab任務(wù)計(jì)劃同步時(shí)間(需安裝ntpdate,每天24點(diǎn)更新同步時(shí)間):

# crontab -e
0 0 * * * /usr/sbin/sntp -P no -r 172.16.128.171;hwclock -w

已部署完畢。這樣集群會(huì)自動(dòng)定期進(jìn)行服務(wù)的同步,如此以來(lái)集群的時(shí)間就保持一致了。

以上是Centos 7安裝配置NTP網(wǎng)絡(luò)時(shí)間同步服務(wù)器的詳細(xì)內(nèi)容。更多信息請(qǐng)關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

本站聲明
本文內(nèi)容由網(wǎng)友自發(fā)貢獻(xiàn),版權(quán)歸原作者所有,本站不承擔(dān)相應(yīng)法律責(zé)任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請(qǐng)聯(lián)系admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣服圖片

Undresser.AI Undress

Undresser.AI Undress

人工智能驅(qū)動(dòng)的應(yīng)用程序,用于創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用于從照片中去除衣服的在線人工智能工具。

Clothoff.io

Clothoff.io

AI脫衣機(jī)

Video Face Swap

Video Face Swap

使用我們完全免費(fèi)的人工智能換臉工具輕松在任何視頻中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費(fèi)的代碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

功能強(qiáng)大的PHP集成開(kāi)發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺(jué)化網(wǎng)頁(yè)開(kāi)發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級(jí)代碼編輯軟件(SublimeText3)

熱門話題

Laravel 教程
1597
29
PHP教程
1488
72
Linux和Windows的所有權(quán)成本有何不同? Linux和Windows的所有權(quán)成本有何不同? Jun 09, 2025 am 12:17 AM

Linux的擁有成本通常低于Windows。1)Linux無(wú)需許可證費(fèi)用,節(jié)省大量成本,而Windows需購(gòu)買許可證。2)Linux對(duì)硬件要求低,可延長(zhǎng)設(shè)備使用壽命。3)Linux社區(qū)提供免費(fèi)支持,降低維護(hù)成本。4)Linux安全性高,減少生產(chǎn)力損失。5)Linux學(xué)習(xí)曲線較陡,但Windows更易上手。選擇應(yīng)基于具體需求和預(yù)算。

在Linux上安裝Redis的先決條件是什么? 在Linux上安裝Redis的先決條件是什么? Jun 10, 2025 am 12:02 AM

安裝RedisonLinux需要以下幾個(gè)前提條件:1.一個(gè)Linux發(fā)行版,如Ubuntu、CentOS或Debian;2.GCC編譯器,用于從源代碼編譯Redis;3.Make和libc6-dev,用于構(gòu)建Redis;4.Tcl(可選),用于運(yùn)行Redis測(cè)試。這些工具確保了Redis的順利安裝和測(cè)試。

如何與Windows一起安裝Linux(雙啟動(dòng))? 如何與Windows一起安裝Linux(雙啟動(dòng))? Jun 18, 2025 am 12:19 AM

安裝Linux和Windows雙系統(tǒng)的關(guān)鍵是分區(qū)和啟動(dòng)設(shè)置。1.準(zhǔn)備工作包括備份數(shù)據(jù)并壓縮現(xiàn)有分區(qū)騰出空間;2.使用Ventoy或Rufus制作Linux啟動(dòng)U盤,推薦Ubuntu;3.安裝時(shí)選擇“與其他系統(tǒng)并存”或手動(dòng)分區(qū)(/至少20GB,/home剩余空間,swap可選);4.勾選安裝第三方驅(qū)動(dòng)以避免硬件問(wèn)題;5.安裝后若未進(jìn)入Grub引導(dǎo)菜單,可用boot-repair修復(fù)引導(dǎo)或調(diào)整BIOS啟動(dòng)順序。只要步驟清晰、操作得當(dāng),整個(gè)過(guò)程并不復(fù)雜。

在Linux系統(tǒng)上安裝REDIS的步驟是什么? 在Linux系統(tǒng)上安裝REDIS的步驟是什么? Jun 11, 2025 am 12:11 AM

ToinstallRedisonaLinuxsystem,followthesesteps:1)DownloadandextractRedisfromtheofficialGitHubrepository,2)CompileRedisusingthe'make'command,3)InstallRediswith'sudomakeinstall',4)ConfigureRedisbycopyingandeditingtheconfigurationfile,and5)StartRedisusin

如何啟用EPEL(企業(yè)Linux的額外軟件包)存儲(chǔ)庫(kù)? 如何啟用EPEL(企業(yè)Linux的額外軟件包)存儲(chǔ)庫(kù)? Jun 17, 2025 am 09:15 AM

啟用EPEL倉(cāng)庫(kù)的關(guān)鍵在于根據(jù)系統(tǒng)版本選擇正確的安裝方式。首先,確認(rèn)系統(tǒng)類型和版本,使用命令cat/etc/os-release獲取信息;其次,在CentOS/RockyLinux上通過(guò)dnfinstallepel-release啟用EPEL,8和9版本命令相同;第三,在RHEL上需手動(dòng)下載對(duì)應(yīng)版本的.repo文件并安裝;第四,遇到問(wèn)題時(shí)可重新導(dǎo)入GPG密鑰,注意舊版本可能不被支持,也可考慮啟用epel-next獲取測(cè)試包。完成上述步驟后,使用dnfrepolist驗(yàn)證是否成功添加EPEL倉(cāng)庫(kù)。

Linux與Windows的工作負(fù)載相比如何? Linux與Windows的工作負(fù)載相比如何? Jun 08, 2025 am 12:18 AM

Linux在Web服務(wù)器性能方面通常表現(xiàn)得更為出色,主要因?yàn)槠鋬?nèi)核優(yōu)化、資源管理和開(kāi)源生態(tài)的優(yōu)勢(shì)。1)Linux內(nèi)核經(jīng)過(guò)多年優(yōu)化,epoll和kqueue等機(jī)制使其在高并發(fā)請(qǐng)求處理上更高效。2)Linux提供細(xì)粒度的資源管理工具如cgroups。3)開(kāi)源社區(qū)不斷優(yōu)化Linux性能,許多高性能Web服務(wù)器如Nginx在Linux上開(kāi)發(fā)。相比之下,Windows在處理ASP.NET應(yīng)用時(shí)表現(xiàn)出色,并提供更好的開(kāi)發(fā)工具和商業(yè)支持。

如何為初學(xué)者選擇Linux發(fā)行版? 如何為初學(xué)者選擇Linux發(fā)行版? Jun 19, 2025 am 12:09 AM

新手選擇Linux發(fā)行版應(yīng)先明確使用需求。1.日常使用選Ubuntu或LinuxMint;編程開(kāi)發(fā)適合Manjaro或Fedora;老舊設(shè)備用Lubuntu等輕量系統(tǒng);學(xué)習(xí)底層原理推薦CentOSStream或Debian。2.穩(wěn)定性優(yōu)先考慮UbuntuLTS或Debian;追求新功能可選Arch或Manjaro。3.社區(qū)支持方面,Ubuntu和LinuxMint資源豐富,Arch文檔偏技術(shù)向。4.安裝難度上,Ubuntu、LinuxMint較簡(jiǎn)單,Arch適合有基礎(chǔ)者。建議先試用再?zèng)Q定。

如何向Linux添加新磁盤 如何向Linux添加新磁盤 Jun 27, 2025 am 12:15 AM

添加新硬盤到Linux系統(tǒng)步驟如下:1.確認(rèn)硬盤被識(shí)別,使用lsblk或fdisk-l檢查;2.用fdisk或parted分區(qū),如fdisk/dev/sdb創(chuàng)建分區(qū)并保存;3.格式化分區(qū)為文件系統(tǒng),如mkfs.ext4/dev/sdb1;4.臨時(shí)掛載使用mount命令,如mount/dev/sdb1/mnt/data;5.修改/etc/fstab實(shí)現(xiàn)開(kāi)機(jī)自動(dòng)掛載,需先測(cè)試掛載確保無(wú)誤。操作前務(wù)必確認(rèn)數(shù)據(jù)安全,避免硬件連接問(wèn)題。

See all articles