linux集群服务器时间同步

1、NTP的工作模式为典型的C/S模型

2、搭建时间同步服务器

安装NTP Server (root权限)

先对集群中某一个扮演时间同步服务器的机器进行时间校准

所以,先把时间服务器的时间调准了
[root@localhost ~]date -s "2012-11-03 10:25:25"

//以系统时间为基准,修改硬件时间
[root@localhost ~]# hwclock --systohc
[root@localhost ~]# hwclock -w

     ############源码包安装方法如下############

      tar zxf ntp-4.2.6p3.tar.gz
      cd ntp-4.2.6p3

      ./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks
make clean 
make -j
make install

##########配置文件修改####################

 vi /etc/ntp.conf (不存在建一个)    
server 127.127.1.0 
fudge 127.127.1.0 stratum 10
修改配置允许局域网内机器与该服务器进行时间同步。
将下面语句::
restrict default kod nomodify notrap nopeer noquery
修改为::      
restrict default nomodify (没有就加)
   
##########启动ntp服务#####################

mkdir /usr/local/ntp/log
cd /usr/local/ntp/bin
    ./ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid -l /usr/local/ntp/log/ntp.log  (启动ntp server)
    netstat -npl ntpd|grep ntpd(查看起来没)

3、客户机同步时间服务器时间

手动同步时间

要同步的机器
    ntpdate ipaddr 
例如86被设置成ntpserver,需要同步时间的机器:
ntpdate 192.168.99.86 (需要root权限)

自动同步时间

设置定时任务
crontab -e 
如果出现no crontab for root - using an empty one
选择编辑器 vim.tiny
加入 */60 * * * * ntpdate 192.168.99.86 (60分钟执行一次)
  //此处同步周期可自行设置

             重启cron服务,让修改生效 sudo service cron restart

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值