linux时间同步、多台服务器时间同步

时间同步:
1、date -s "2015-06-08 22:08:06"   // 设置系统时间。
2、配置时间服务器,集群的其他机器都跟其中一台机器同步时间。


定时任务执行时间同步的操作

时间同步服务器需要安装ntp服务

例如将node01作为主服务器,其他节点都同步该节点的时间,在node01上执行如下操作:
1、yum list | grep ntp 

2、yum -y install ntp.x86_64

3、修改配置文件:

vi /etc/ntp.conf 

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.149.0 mask 255.255.255.0 nomodify notrap  #加入这一行,表示允许这个网段的ip来同步时间

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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   #先禁用4个自带的服务,添加server 127.127.1.0 

客户端(需要做时间同步的机器)需要安装ntpdate
1、yum list | grep ntp

2、yum -y install ntpdate.x86_64

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值