註釋:linux
安裝服務前,要把防火牆和selinux關閉掉vim
關閉防火牆命令:service iptables stop 或 /etc/init.d/iptables stop
centos
關閉selinux:
服務器
(1) NTP服務是作什麼用的?編輯器
答:ide
<1> NTP是時間服務協議 <2> 保證客戶端和服務端時間一致rest
(2) 軟件的安裝方法server
答:blog
yum install NTP -y進程
(3) 軟件是在服務端安裝,仍是在客戶端安裝
答:
軟件是在服務端安裝
(4) 軟件安裝路徑;配置文件;啓動文件;
答:
查詢軟件安裝路徑: rpm -ql ntp
配置文件: /etc/ntp.conf
啓動文件:/etc/rc.d/init.d/ntpd
(5) 配置文件參數詳解
答:
restrict default kod nomodify notrap nopeer noquery 默認禁止遠程主機訪問NTP服務
restrict 192.168.0.0 mask 255.255.255.0 nomodify 容許某個網段訪問NTP服務,可是不容許修改時間服務器時間
Restrict default nomodify 容許全部的網段訪問ntp服務
restrict default ignore 關閉全部的請求包
restrict 127.0.0.1 開啓本地訪問
server 0.centos.pool.ntp.org iburst 上級時間服務器
driftfile /var/lib/ntp/drift 與上級服務器進行同步時所花費的時間
註釋:
編輯文件建議用vim編輯器,安裝方法是yum install vim -y
(6) 啓動,關閉,重啓NTP服務
啓動NTP服務 /etc/init.d/ntpd start
關閉NTP服務 /etc/init.d/ntpd stop
重啓NTP服務 /etc/init.d/ntpd restart
(7) 查看NTP服務進程是否已經啓動
ps -ef | grep ntp
(8) 查看NTP服務監聽的端口 (NTP監聽的是123端口)
netstat -nul | grep 123
(9) 客戶端安裝ntpdate ip(服務端ip地址)進行校準時間
(10) NTP服務器與上層時間服務器同步(offset查看與上層服務器同步存在的時間差)
(11) crontab計劃任務
<1> 安裝方法: yum install crontab* -y
<2> 打開配置文件: crontab -e 輸入 0 * * * * /usr/sbin/ntpdate 192.168.2.114
<3> 查看配置結果:crontab -l
<4> 重啓crontab服務 /etc/init.d/crond restart