日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux/centos/集群安装ntp时间同步,自身实验成功

發(fā)布時間:2025/4/5 linux 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux/centos/集群安装ntp时间同步,自身实验成功 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1. 準備節(jié)點

不管你有多少個節(jié)點,肯定要有一個 server 角色,至于誰是 server 你來決定。
例如下面這樣,我們姑且假設有這樣四個節(jié)點

192.168.11.101(server端 node1) 192.168.11.102(client端 node2) 192.168.11.103(client端 node3)

2. 安裝配置 server 節(jié)點

在192.168.11.101端作為服務端,并在該節(jié)點進行以下步驟

2.1 下載安裝

[root@node1 ~]# yum install ntp ntpdate

并將該服務器同步阿里云服務器網(wǎng)站

[root@node1 ~]# ntpdate ntp1.aliyun.com

2.2 編輯配置文件

[root@node1 ~]# vim /etc/ntp.conf

注釋

#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

在下面再添加一行,代表本機作為服務器,不要懷疑下面的127.127.1.0寫錯了,沒有,就這樣來。

#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 iburst

2.3 啟動服務

[root@node1 ~]# systemctl start ntpd [root@node1 ~]# systemctl enable ntpd.service #設置開機啟動服務

2.4 查看狀態(tài)

[root@node1 ~]# systemctl status ntpd ● ntpd.service - Network Time ServiceLoaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)Active: active (running) since Tue 2020-02-11 19:38:22 CST; 19s agoMain PID: 1491 (ntpd)CGroup: /system.slice/ntpd.service└─1491 /usr/sbin/ntpd -u ntp:ntp -gFeb 11 19:38:22 cdh1 ntpd[1491]: Listen and drop on 1 v6wildcard :: UDP 123 Feb 11 19:38:22 cdh1 ntpd[1491]: Listen normally on 2 lo 127.0.0.1 UDP 123 Feb 11 19:38:22 cdh1 ntpd[1491]: Listen normally on 3 ens33 192.168.0.108 UDP 123 Feb 11 19:38:22 cdh1 ntpd[1491]: Listen normally on 4 lo ::1 UDP 123 Feb 11 19:38:22 cdh1 ntpd[1491]: Listen normally on 5 ens33 fe80::e37b:3e48:9646:7eff UDP 123 Feb 11 19:38:22 cdh1 ntpd[1491]: Listening on routing socket on fd #22 for interface updates Feb 11 19:38:22 cdh1 ntpd[1491]: 0.0.0.0 c016 06 restart Feb 11 19:38:22 cdh1 ntpd[1491]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM Feb 11 19:38:22 cdh1 ntpd[1491]: 0.0.0.0 c011 01 freq_not_set Feb 11 19:38:23 cdh1 ntpd[1491]: 0.0.0.0 c514 04 freq_mode

3. 安裝配置 Client 節(jié)點

下面描述是在node2上進行的,也要在分別在node3或者有其他結點的下面都要執(zhí)行一邊下面操作

3.1 下載安裝

[root@node2 ~]# yum install ntp ntpdate

3.2 編輯配置文件

[root@node2 ~]# vim /etc/ntp.conf

3.3 配置ntp服務器

[root@node2 ~]# vim /etc/ntp.conf

注釋

#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

node2和node3都在下面再添加

#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.11.101 #配置本地ntp服務器為時間同步服務器 restrict 192.168.11.101 nomodify notrap noquery #允許本地時間服務器主動修改本機的時間

3.4 同步時間

[root@node2 ~]# ntpdate -d -b 192.168.11.101

3.5 啟動服務

[root@node2 ~]# systemctl start ntpdate [root@node2 ~]# systemctl enable ntpdate.service #設置開機啟動服務

4. 測試

所有節(jié)點執(zhí)行 date 命令看時間是否一致即可。

總結

以上是生活随笔為你收集整理的linux/centos/集群安装ntp时间同步,自身实验成功的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。