linux ntp 時間同步
linux ntp 時間同步
2016年10月26日 18:43:26 leys123 閱讀數:9219 標籤: ntpntpdate時間同步 更多
個人分類: linux
一:外網同步時間
1.檢視ntpd服務狀態
[[email protected] sbin]# service ntpd status
ntp: unrecognized service
說明 ntpd沒有安裝。
2.檢視是否存在ntp的yum源
[[email protected]
3.如果有顯示出yum源則安裝ntp服務
[[email protected] sbin]# yum -y install ntp;
首先啟動ntp服務:service ntpd start 即可,並設定ntp服務,開機自啟動:chkconfig ntpd on。
4.同步時間:(在每臺伺服器上執行,或者建一個crontab定時)
[[email protected] sbin]# ntpdate asia.pool.ntp.org
二:內網同步時間
1.內網時搭建時間伺服器,,,把cdh做為時間伺服器。修改cdh1中的/etc/ntp.conf
增加
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict default ignore
restrict 172.16.1.0 mask 255.255.255.0 nomodify notrap #172.16.1.0為本叢集的ip段,只允許本ip段同步此ntp伺服器
server 127.127.1.0 #local clock
儲存,退出。
2.service ntpd restart;
3.使用watch ntpq -p命令檢視:
當reach達到7及以上時,就可以去其他節點上執行ntpdate cdh,不然會報如下提示:
.
3.在其他節點機器上也需要檢查ntp服務是否存在(service ntpd status ),無則安裝yum -y install ntp;
假如其他節點都不能連外網,則需要拷貝cdh這個節點機器下的/usr/sbin/ntpdate到其他節點的/usr/sbin/下,並執行chmod u+x ntpdate;
4.然後在每臺機器(除了cdh1之外的)上去同步cdh1上的時間,ntpdate cdh(每個節點機器上都要執行此句)。