CentOS7时间设置及ntp同步配置(转)
2024-08-30 02:55:46
出处:http://www.centoscn.com/CentOS/config/2015/1105/6385.html
http://www.centoscn.com/CentOS/config/2015/0723/5901.html
时间设置:
在CentOS7中timectl命令负责时间管理。
查看所有时区:
timedatectl list-timezones
设置时区:
timedatectl set-timezone Asia/Shanghai
设置日期:
timedatectl set-time YYYY-MM-DD
设置时间:
timedatectl set-time HH:MM:SS
ntp开启和关闭:
timedatectl set-ntp yes
timedatectl set-ntp no
ntp时间同步
NTP在linux下有两种时钟同步方式,分别为直接同步和平滑同步:
直接同步
使用ntpdate命令进行同步,直接进行时间变更。如果服务器上存在一个12点运行的任务,当前服务器时间是13点,但标准时间时11点,使用此命令可能会造成任务重复执行。因此使用ntpdate同步可能会引发风险,因此该命令也多用于配置时钟同步服务时第一次同步时间时使用。
平滑同步
使用ntpd进行时钟同步,可以保证一个时间不经历两次,它每次同步时间的偏移量不会太陡,是慢慢来的,这正因为这样,ntpd平滑同步可能耗费的时间比较长。
标准时钟同步服务
http://www.pool.ntp.org/zone/cn网站包含全球的标准时间同步服务,也包括对中国时间的同步,对应的URL为cn.pool.ntp.org。
在其中也描述了ntp配置文件中的建议写法:
server 1.cn.pool.ntp.org
server 3.asia.pool.ntp.org
server 2.asia.pool.ntp.org
检查ntp服务是否安装:
rpm -qa | grep ntp
安装ntp服务:
yum -y install ntp
设置服务开机启动并启动服务:
systemctl enable ntpd
systemctl start ntpd
同步时间:
ntpdate -u cn.pool.ntp.org
配置ntp同步服务器:
vim /etc/ntpd.conf
server .cn.pool.ntp.org
server .asia.pool.ntp.org
server .asia.pool.ntp.org
重启ntp服务:
systemctl restart ntpd
查看时间同步状态:
#ntpstat
unsynchronised
time server re-starting
polling server every s
最新文章
- Mac下手动安装SafariDriver extension
- chkconfig系统服务启动设置
- IOS CoreText.framework --- 行 CTLineRef
- ubuntu下ROS安装时sudo rosdep init和rosdep update的解决方法
- Apache Spark Tachyon的简介
- [IOS开发进阶与实战]第一天:CoreData的运行机制
- [AngularJS] New in Angular 1.5 ng-animate-swap
- 第八届acm省赛 A挑战密室(模拟)
- Keepalived + HAProxy 搭建【第一篇】HAProxy 的安装与配置
- 初识 Javascript.02 -- Date日期、Math对象、数据类型转换、字符串、布尔Boolean、逻辑运算符、if else 、三元表达式、代码调试方法、
- MySQL 事务与锁机制
- 探究PHP底层
- Linux-ftp服务搭建
- springboot 开启事务以及手动提交事务
- python捕获Ctrl+C信号
- 关于<;asp:checkBoxList>;控件的对齐方法
- ElasticSearch入门 第三篇:索引
- 记录EntityValidationErrors的详细信息
- EF大数据批量添加性能问题(续)
- windows中dos命令指南
热门文章
- systemd 开机无法启动privoxy
- Day 30 process&;thread_2
- LeetCode OJ-- Recover Binary Search Tree ***@
- react native windows create bundle folder
- 慎用lodash的cloneDeep函数
- CentOS 7下安装配置FTP
- IOS 暂停和恢复CALayer上的动画(转)
- ios界面笔记(一)
- 安卓Webview缓存网页数据(无网络正常显示)
- xshell登录到CentOS7上时出现“The remote SSH server rejected X11 forwarding request.