歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> SUSE Linux時間服務器及客戶端同步配置

SUSE Linux時間服務器及客戶端同步配置

日期:2017/2/28 16:24:59   编辑:Linux教程

一、時區設置
使用utc還是local time.
UTC(Universal Time Coordinated)=GMT(Greenwich Mean Time)
Local time 是你手表上的時間
linux可以處理UTC時間和蹩腳的Windows所使用的local time
如果機器上同時安裝有Linux和Windows,建議使用local time
如果機器上只安裝有Linux,建議使用utc
確定後編輯/etc/sysconfig/clock, UTC=0 是local time; UTC=1 是UTC(GMT)

1)/etc/sysconfig/clock查看當前時區
HWCLOCK="-u" #與下面設置的時區對應
下面2項不用改#jvm/Nginx等程序取的時間才與date命令時間一致
TIMEZONE="America/New_York"
DEFAULT_TIMEZONE="US/Eastern"

2)使用tzselect設置時區(========好像對時間同步沒有用)
#/usr/bin/tzselect
逐步選擇就ok

3)復制相應的時區文件,替換系統默認時區
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
或者 cp /usr/share/zoneinfo/Asia/Beijing /etc/localtime(====這個不能同步時間,不知原因)

4)java時區:java_opts增加 -Duser.timezone=GMT+8

二、時間同步
內網時間服務器:172.22.14.11
1)服務器端配置/etc/ntp.conf
restrict 127.0.0.1
restrict 172.22.12.0 mask 255.255.255.0 #有幾種都配置上
restrict 172.22.13.0 mask 255.255.255.0
restrict 172.22.14.0 mask 255.255.255.0
restrict 172.22.15.0 mask 255.255.255.0

server 218.75.4.130 #218.75.4.130是時鐘服務器

2)服務器端ntp服務啟動 (xntp / ntp)
# /etc/init.d/ntpd start


3)客戶端只做定時同步
#crontab -e
40 4 * * * /usr/sbin/sntp -P no -r 172.22.14.11
#service cron restart

Copyright © Linux教程網 All Rights Reserved