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

红帽5和6的NTP时间同步

2016-04-05 16:06 375 查看
本机ip:12.18.10.33

首先检查是否有ntp包

# rpm -q ntp

如果没有则用yum配置即可

# yum install ntp

############################# rhel 5.x ######################################################

同一网段同步

vi /etc/ntp.conf

修改添加部分

# Hosts on local network are less restricted.

# 允许内网其他机器同步时间

restrict 12.18.10.0 mask 255.255.255.0 nomodify notrap

server 0.cn.pool.ntp.org

server 1.asia.pool.ntp.org

server 2.asia.pool.ntp.org

配置文件修改完成,保存退出,启动服务。

# service ntpd start

配置NTP服务为自启动

# chkconfig ntpd on

等待5分钟左右

手动同步:ntpdate 12.18.10.33

定时任务自动同步: root用户下crontab -e 编辑* * * * * /usr/sbin/ntpdate –u 12.18.10.33

--------------------------------------------------------------------------------------------

任何主机都同步

restrict default kod nomodify

restrict -6 default kod nomodify

server 0.cn.pool.ntp.org

server 1.asia.pool.ntp.org

server 2.asia.pool.ntp.org

####################################### rhel 6.x ###############################################################

同一网段同步

vi /etc/ntp.conf

修改添加部分

# Hosts on local network are less restricted.

# 允许内网其他机器同步时间

restrict 12.18.10.0 mask 255.255.255.0 nomodify notrap

# Please consider joining the pool (http://www.pool.ntp.org/join.html).

# 中国这边最活跃的时间服务器 : http://www.pool.ntp.org/zone/cn
server 210.72.145.44 perfer # 中国国家受时中心

server 202.112.10.36 # 1.cn.pool.ntp.org

server 59.124.196.83 # 0.asia.pool.ntp.org

# Undisciplined Local Clock. This is a fake driver intended for backup

# and when no outside source of synchronized time is available.

# 外部时间服务器不可用时,以本地时间作为时间服务

server 127.127.1.0 # local clock

fudge 127.127.1.0 stratum 10
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: