zoukankan      html  css  js  c++  java
  • 【Linux】ntp服务-时间同步

    ntp简易安装与时间同步

    yum -y install ntp ntpdate    //安装ntp服务
    ntpdate cn.pool.ntp.org   //更新时间
    hwclock --systohc     //系统时钟和硬件时钟同步或者 clock --systohc
    
    http://www.pool.ntp.org是NTP的官方网站,在这上面我们可以找到离我们国家的NTP Server cn.pool.ntp.org.它有3个服务器地址:
    服务器一:        1.cn.pool.ntp.org
    服务器二:        2.asia.pool.ntp.org
    服务器三:        3.asia.pool.ntp.org
    (直接用域名有时有问题,可以先Ping出他们的IP,然后用IP地址同步)
    

    老师的方法

    NTP的搭建	
    	yum 库配置,这里配置本地镜像文件作为库,yum库的详细配置还是看看其他博客吧,我没有配置这个
    
    	[mnt]
    	name=mnt
    	baseurl=file:///mnt
    	gpgcheck=0
    	enabled=1
    
    	3.1服务端:
    		vim /etc/ntp.conf
    		把如下四行代码注释掉
    
    			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 iburst  //使本机成为服务器机,其他节点同步时间向本机获取时间,使各节点时间一致
    		
    		启动ntp服务
    		systemctl start ntpd
    		systemctl enable ntpd
    		
    	3.2客户端
    	vim /etc/ntp.conf
    	
    	#注释掉其他上游时间服务器
    	#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
    	#配置上游时间服务器为本地的ntpd Server服务器
    	server 192.168.0.163
    	#配置允许上游时间服务器主动修改本机的时间
    	restrict 192.168.0.163 nomodify notrap noquery
    	
    	与本地ntpd Server同步一下
    	ntpdate -u 192.168.0.163
    	systemctl start ntpd
    	
    	[root@Slave1 yum.repos.d]# date -s '17:30:00'  修改时间
    	[root@Slave1 yum.repos.d]# clock -w  写硬件时钟
    
    
    	
    	
    	计划任务:
    	yum install crontabs (安装 crontabs)
    	systemctl enable crond (设为开机启动)
    	systemctl start crond(启动crond服务)
    	systemctl status crond (查看状态)
    	yum list installed |grep crontab
    	vi /etc/crontab
    	
    	crontab -u 用户名 -l (列出用户的定时任务列表
    	
    	[root@slave1 ~]# crontab /etc/crontab 
    	[root@slave1 ~]# crontab -l
    	tail -10000f /var/log/cron | grep ntpd
    
  • 相关阅读:
    创业日志N,一听到别人说创业我就怕
    《创业维艰分享之五》所有得,有所乐,日事日清,循序渐进。
    创业维艰--分享技术人做产品与做市场的一些经验
    创业维艰--最艰难的时候
    angular js 在ie11 下的get请求缓存问题的解决办法
    《创业维艰-分享创业中遇到的困难之二》----破局
    xwalk_core_library-15.44.384 .13.aar 百度云分享
    linux常用命令
    Merge into 用法
    多线程的并发控制
  • 原文地址:https://www.cnblogs.com/BIG-BOSS-ZC/p/11807301.html
Copyright © 2011-2022 走看看