您的位置:首页 > 运维架构 > Linux

Linux-NTP-Server+Client

2015-09-03 20:57 501 查看
GMT/UTC/CST;
/etc/localtime,/usr/share/zoneinfo/*时区文件,/etc/profile加TZ变量;
硬件时间RTC,系统时间;date,hwclock,tzselect;
/usr/share/zoneinfo/Asia

zdump sichuan 查看对于每个time zone当前的时间
# hwclock --set --date="mm/dd/yy hh:mm:ss" 设置硬件时间我们可以开机的时候在BIOS里设定.也可以用hwclock命令
# date -s "dd/mm/yyyy hh:mm:ss" 修改系统时间用date命令就最简单了

1.设置时区
GMT:格林威治时区
UTC:世界协调时区
CST:中国标准时区
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
如果时区不对,删除、/etc/localtime,再配置
tzselect 》5) Asia--9) China--1) Beijing Time

2.Command
# hwclock --set --date="mm/dd/yy hh:mm:ss"
# date -s "dd/mm/yyyy hh:mm:ss"
# hwclock --systohc
# hwclock --hctosys

3.NTP SERVER
rpm -qa | grep ntp
yum -y ntpd install http://www.pool.ntp.org SERVER = cn.pool.ntp.org
ntpdate cn.pool.ntp.org

/etc/ntp.conf

#server cn.pool.ntp.org
#fudge 127.127.1.0 stratum 10 stratum
#driftfile /var/lib/ntp/ntp.drift
#restrict default kod nomodify notrap nopeer noquery 默认的client拒绝所有的操作
#restrict 127.0.0.1 允许本机地址一切
#restrict 192.168.1.0 mask 255.255.255.0 nomodify 允许局域网内所有client连接到这台服务器同步时间.

# /etc/init.d/ntpd start
# chkconfig --level 35 ntpd on

# vi /etc/sysconfig/ntpd
SYNC_HWCLOCK=yes
watch ntpq -p

4.NTP client的设置
/etc/ntp.conf
server 192.168.1.105
LINUX客户端使用
ntpdate 92.168.1.105
# hwclock --systohc

如果同步不成功检查:iptables need disable 或 tcp 123
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: