Linux中集群时间同步问题

Linux中集群时间同步问题

第一种方法

如果集群可以联网的化可以使用定时任务来使每一台机器和外界时间同步服务器保持一致
使用root用户进行配置

前提:安装ntp.x86_64
如果没有安装可以使用 yum list | grep ntp 查找相关的软件
用 yum -y install 软件名 进行安装
安装顺序 先安装ntpdate
有两个文件一个使ntp.x86_64,另一个是ntpdate.x86_64
用service ntpd start 开启服务
其次:保证ntpd 服务运行......
       service ntpd start
然后: 使用root用户,进行定时
        * */2 * * * /usr/sbin/ntpdate -u time.windows.com
       第一个* 是分钟的意思
       第二个*是小时的意思
       第三个*是日的意思
       第四个*是月的意思
       第五个*是周的意思
       /2这里是代表每两个小时

不能联网时

选择一台机器作为时间服务器其他机器和时间服务器同步时间来保证集群内的时间相同
第二种方式: 自定义时间服务器
1. 选择集群中的某一台机器master作为时间服务器
2. 保证这台服务器安装了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.81.0 mask 255.255.255.0 nomodify notrap
	// 添加集群中的网络段位

	# 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     -master作为服务器

 4. 保证服务开启
 5. 其他机器要保证安装ntpdate.x86_64
 6. 其他机器要使用root定义定时器
     * */2 * * * /usr/sbin/ntpdate 服务器的名字或者ip 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值