linux運維 架構之路 內網NTP時間伺服器

2022-07-13 01:27:12 字數 2180 閱讀 6964

一、環境

[root@m01 tmp]# cat /etc/redhat-release

centos release

6.9(final)

[root@m01 tmp]# hostname -i

10.0.0.61(外網) 172.16.1.61(內網)

二、檢查服務軟體是否安裝

[root@m01 tmp]# rpm -qa ntp

ntp-4.2.6p5-10.el6.centos.2.x86_64

三、修改ntp配置檔案

sed -i '8c restrict default nomodify' /etc/ntp.conf替換配置檔案的第8行內容,也可以使用vim

vim /etc/ntp.conf

# restrict

default

kod nomodify notrap nopeer noquery

restrict

default

nomodify#允許區域網時間同步

#將原有的不可用的源注釋,新增新的時間同步源

server ntp1.aliyun.com

server time.nist.gov

四、啟動ntp服務(這台伺服器是需要外網的)

[root@m01 tmp]# /etc/init.d/ntpd start

starting ntpd: [ ok ]

注:啟動後會自動更新時間

如果原來有同步時間的任務,關閉,否則會報如下的錯誤。

ntpdate[118978]:the ntp socket is inuse,exiting

服務端執行ntpstat結果如下證明時間已同步

[root@m01 ~]# ntpstat 

synchronised to ntp server (

182.92.12.11) at stratum 3

time correct to within

204ms

polling server every

64 s

五、無外網的伺服器同步時間

[root@nfs01 ~]# ntpdate 172.16.1.61

10 oct 14:49:18 ntpdate[21609]: adjust time server 172.16.1.61 offset 0.000652 sec

#時間伺服器啟動後,需要過幾分鐘才能進行同步。

ntpdate[5687]:no server suitable forsynchronization found

六、把同步命令放入定時任務

[root@nfs01 ~]# crontab -l

#time sync by yanxinjiang at

2017-10-10

*/5 * * * * /usr/sbin/ntpdate 172.16.1.61 >/dev/null

2>&1

Linux 運維之路

第一章 linux必備知識 1 linux 系統介紹 2 linux 簡單文字處理 3 linux 組管理 許可權 4 linux vi文件操作 5 linux vim文件操作 6 linux 高階檔案管理 7 linux 檔案許可權 8 linux 檔案系統結構 磁碟的管理 9 linux 磁碟分...

linux運維 架構之路 linux定時任務

1 基礎優化之開機啟動服務優化 使用awk拼接的方式 root cache01 chkconfig egrep v crond network sshd rsyslog sysstat awk bash root cache01 chkconfig grep 3 on 檢查確認是否把不需要的開機服務...

Linux運維提公升之路

目錄 運維的職業現狀 運維的工作 運維的晉公升空間 運維要掌握的必備技能 初級 中級 高階 資深 運維的時間管理 首先,在進做it運維行業前,你一定要做好心理準備,這並不是乙個輕鬆的工作,工作中的事情多而又雜,除了堅持,你需要懂得東西很多。國內人才緊缺,特別是網際網路公司。小公司的運維工作強度大,負...