使用ntp配置内网中集群机器时间同步
集群的时间要同步
找一台集群
时间服务器
所有的机器与这台机器时间进行定时的同步
比如,每日十分钟,同步一次时间
step1: 检查时间服务器有没有装ntp
[xiangkun@hadoop-senior01 hadoop-2.5.0]$ rpm -qa|grep ntp
ntp-4.2.6p5-1.el6.centos.x86_64
fontpackages-filesystem-1.41-1.1.el6.noarch
ntpdate-4.2.6p5-1.el6.centos.x86_64
step2:
ntp.conf 修改三处:
xiangkun@hadoop-senior01 /]$ vi /etc/ntp.conf
#####################第一处:注释打开,修改网段#######
restrict 192.168.111.0 mask 255.255.255.0 nomodify
##################################################
#####################第二处:注释##################
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
##################################################
#####################第三处:打开注释##################
server 127.127.1.0 #local clock
fudge 127.127.1.0 stratum 10y the key identifier to use with the ntpq utility.
#controlkey 8
##################################################
####编辑/etc/sysconfig/ntpd
[xiangkun@hadoop-senior01 ~]$ sudo vi /etc/sysconfig/ntpd
[sudo] password for xiangkun:
#########增加##############
SYNC_HWCLOCK=yes
##########################
# Drop root to id 'ntp:ntp' by default.
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
启动ntpd
[root@hadoop-senior01 xiangkun]# service ntpd status
ntpd 已停
[root@hadoop-senior01 xiangkun]# service ntpd start
正在启动 ntpd:[确定]
[root@hadoop-senior01 xiangkun]# service ntpd status
ntpd (pid 5537) 正在运行...
[root@hadoop-senior01 xiangkun]# chkconfig ntpd on