linux如何给各节点时间同步,Linux 系统配置各个节点的时间一致性
3.1?安裝ntp
示例環(huán)境:主節(jié)點(diǎn) IP-192.168.61.250,子節(jié)點(diǎn) IP-192.168.61.251。集群下各個(gè)節(jié)點(diǎn)均需要進(jìn)行安裝,RedHat&CentOS 的系統(tǒng)可直接使用以下 rpm 包:
下載安裝包后,上傳到服務(wù)器指定目錄,例如上傳到/usr/ntp目錄下,然后執(zhí)行以下安裝命令:cd?/usr/ntp
rpm?-Uvh?*.rpm?--nodeps?--force?#一鍵安裝目錄下所有的?rpm?包
3.2 修改所有節(jié)點(diǎn)的 /etc/ntp.confvi?/etc/ntp.conf
restrict?192.168.6.2?mask?255.255.255.0?nomodify?notrap??#找到?#restrict?192.168.1.0?mask?255.255.255.0?nomodify?notrap?并去掉注釋#修改其IP地址
#?192.168.6.2?為示例,請(qǐng)按照實(shí)際集群所在網(wǎng)段的網(wǎng)關(guān)IP填寫(xiě),255.255.255.0?為子網(wǎng)掩碼,查詢(xún)網(wǎng)段網(wǎng)關(guān)的命令為?IP?route?show,查詢(xún)結(jié)果中default?via?后面的?IP?即是網(wǎng)關(guān)?IP
3.3?配置 ntp 服務(wù)器
選擇一個(gè)節(jié)點(diǎn)作為主節(jié)點(diǎn)即 ntp 服務(wù)器,修改其/etc/ntp.confvi?/etc/ntp.conf
#注釋掉?server?0?~?n,并在?server?部分添加?server?和?fudge行
#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?127.127.1.0?#使用本地時(shí)鐘作為ntp服務(wù)器時(shí)間,這里的?127.127.1.0?在?ntp?中代表本機(jī)
fudge?127.127.1.0?stratum?10?#127.127.1.0?為第10層,ntp?和127.127.1.0同步完后,就變成了?11?層
3.4?配置ntp客戶(hù)端
其他節(jié)點(diǎn)作為子節(jié)點(diǎn),需要配置 ntp 客戶(hù)端,修改其/etc/ntp.confvi?/etc/ntp.conf
注釋掉 server 0 ~ n,并在 server 部分添加 server 行,如下:#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.61.250 #使用主節(jié)點(diǎn) 192.169.61.250 的時(shí)間作為基準(zhǔn)更新時(shí)間
3.5?ntp 啟動(dòng)命令
1)主節(jié)點(diǎn)啟動(dòng)命令service ntpd start #打開(kāi) ntpd 服務(wù)
chkconfig ntpd on #設(shè)置開(kāi)機(jī)啟動(dòng)
2)子節(jié)點(diǎn)啟動(dòng)命令ntpdate 192.168.61.250 #向主節(jié)點(diǎn)發(fā)送請(qǐng)求,同步時(shí)間
service ntpd start #打開(kāi) ntpd 服務(wù)
chkconfig ntpd on #設(shè)置開(kāi)機(jī)啟動(dòng)
3)查看 ntp 服務(wù)器有無(wú)和上層 ntp 連通
使用 ntpstat 行查詢(xún),結(jié)果一般如下:
4)查看 ntp 服務(wù)器與上層 ntp 的狀態(tài)
使用 ntpq -p 進(jìn)行查詢(xún),結(jié)果一般如下:
總結(jié)
以上是生活随笔為你收集整理的linux如何给各节点时间同步,Linux 系统配置各个节点的时间一致性的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 左脸颧骨比右脸突出怎么办
- 下一篇: linux终端xwindow,如何从命令