1. 程式人生 > 其它 >Linux 配置時間伺服器

Linux 配置時間伺服器

1、叢集時間同步

1、找一臺機器,最好是可以訪問外網,作為管理伺服器。
2、所有的機器與這臺機器時間進行定時的同步,比如:每十分鐘,同步一此時間。

2、時間伺服器配置方法

[rootlocalhost ~]# cat /etc/ntp.conf | grep -v '^#\|^$'
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1 
restrict ::1
restrict 10.22.85.0 mask 255.255.255.0 nomodify notrap
server  127.127.1.0   # local clock
fudge  127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor

3、設定bos系統的時間衝突

[rootlocalhost ~]# cat /etc/sysconfig/ntpd | grep -v '^#\|^$'
SYNC_HWCLOCK=yes
OPTIONS="-g"

4、啟動 ntpd 服務

systemctl start ntpd 

5、配置其他伺服器同步時間伺服器時間

ntpdate -u 時間伺服器IP

6、配置定時任務同步時間

[root@localhost ~]# crontab -l
0 2 * * * /usr/sbin/ntpdate -u 時間伺服器IP或域名

7、常用的時間伺服器地址

# 阿里伺服器地址
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com
# 騰訊
ntp.tencent.com
ntp1.tencent.com
ntp2.tencent.com
ntp3.tencent.com
ntp4.tencent.com
ntp5.tencent.com