1、安裝ntp
查看是否安裝ntp
rpm -q ntp
安裝ntp
yum -y install ntp
systemctl enable ntpd
systemctl start ntpd
時(shí)間服務(wù)器端:標(biāo)準(zhǔn)時(shí)間設(shè)置(手動(dòng)不同時(shí)間)
ntpdate -u cn.pool.ntp.org
2跌宛、服務(wù)器端配置
修改/etc/ntp.conf文件
restrict 192.168.162.0 mask255.255.255.0 nomodify notrap
## 遠(yuǎn)程時(shí)間服務(wù)器配置
server 2.cn.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
restrict 2.cn.pool.ntp.orgnomodify notrap noquery
restrict 1.asia.pool.ntp.orgnomodify notrap noquery
restrict 2.asia.pool.ntp.orgnomodify notrap noquery
## 本地時(shí)間服務(wù)器配置
server 127.127.1.0 # localclock
fudge 127.127.1.0 stratum 10
3、客戶端配置
修改/etc/ntp.conf文件
server 192.168.162.130
restrict 192.168.162.130 nomodify notrap noquery
# 同步本地時(shí)間
server 127.127.1.0 # localclock
fudge 127.127.1.0 stratum 10
4积仗、重啟ntpd服務(wù)
systemctl restart ntpd
修改配置:vim /etc/sysconfig/ntpd
OPTIONS= "-g -x"
SYNC_HWCLOCK=yes
5疆拘、常用命令:
ntpstat:查看服務(wù)器時(shí)間不同狀態(tài)
service ntpd status:查看ntp啟動(dòng)狀態(tài)