linux中配置NTP基本操作
计算机的系统时间是由计算机内的石英晶体震荡电路以固定的震荡频率产生的
date 查看当前时区
vim /etc/sysconfig/clock 修改时区配置文件
ZONE="America/New_York"
#改为
ZONE="Asia/Shanghai"
覆盖 /etc/localtime
cp -a 1114.www.qixoo.qixoo.com/usr/share/zoneinfo/Asia/Shanghai /etc/localtime
cp: overwrite `/etc/localtime‘? y
date 111317402016 修改系统时间
hwclock -w 将系统时间同步到硬件时间
rpm -qa |grep ntp检查 NTP 是否安装
yum install ntp* -y 安装ntp
vim /etc/sysconfig/ntpdate 设置同步更新本地hwclock
在 Linux 下系统时间在开机的时候会和硬件时间同步(synchronization),之后也就各自独立运行了那么既然两个时钟独自运行,那么时间久了必然就会产生误差了,而 NTP 默认又只更新系统时间,因此我们需要设置硬件时钟进行同步调整
[ ~]# vim 1114.www.qixoo.qixoo.com/etc/ntp.conf #ntp配置文件
For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery#禁用全部地址对NTPD各服务的访问
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1#允许本机地址(127.0.0.1)对NTPD各服务的访问
restrict -6 ::1 #ipv6
# Hosts on local network are less restricted.
restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap #允许地址段192.168.100.0对NTPD各服务的访问,但不允许此地址段内客户端修改NTPD服务器时间
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0 # local clock #外部时间服务器不可用时,以本地时间作为时间服务
fudge 127.127.1.0 stratum 10 #设置本地时钟源的层次为10,这样如果NTPD服务从本地时钟源获取时间的话,NTPD对外宣布的时间层次为11
...........................................................
service ntpd restart 重启服务ntp
ps aux | grep ntpd 查看ntp进程
ntpq -p列出目前ntp相关的状态
vim /etc/selinux/config 将防火墙关闭
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
ntpdate server地址 客户机同步服务器时间
注:同步需要一段时间
linux中配置NTP基本操作的更多相关文章
- linux 中配置假域名来测试
1.linux中配置假域名 找到hosts文件进行编辑 命令:vim /etc/hosts 配置: #centos(本机IP)192.168.1.179 www.imooc.com(假域名,自己设置) ...
- 如何在linux 上配置NTP 时间同步?
故障现象: 有些应用场景,对时间同步的要求严格,需要用到NTP同步,如何在linux上配置NTP时间同步? 解决方案: 在linux 上配置NTP 时间同步,具休操作步骤,整理如下: 1.安装软件包( ...
- 讲述一下自己在linux中配置ftp服务的经历
本人大二小白一名,从大一下学期就开始接触到linux,当时看到学校每次让我们下载资源都在一个ftp服务器中,感觉特别的高大上,所以自己就想什么时候自己能够拥有自己的ftp服务器,自己放一点东西进去,让 ...
- Linux中配置别名
Linux中修改配置别名 ####用到的命令: alias是用来查看系统中有什么别名 source 让配置生效 临时取消别名的方法 unalias 临时取消别名 \cp /mnt/test.txt / ...
- linux中配置JDK环境变量
使用的centos版本为 7.5 首先我们要把jdk拷到linux中,这里我们借助XShell工具,我们先来看看Xshell的用法 打开Xshell 后点击文件,“新建“,如下图: 起一个名称,主机填 ...
- linux中配置yum源
1.配置163或者阿里云yum源: 阿里云yum源地址:https://mirrors.aliyun.com/centos/6.9/os/x86_64/Packages/ 阿里云给出的解决办法:htt ...
- 如何在 Linux 中配置基于密钥认证的 SSH
什么是基于 SSH 密钥的认证? 众所周知,Secure Shell,又称 SSH,是允许你通过无安全网络(例如 Internet)和远程系统之间安全访问/通信的加密网络协议.无论何时使用 SSH 在 ...
- 在Linux中配置jdk,Tomcat,MySQL
解压缩: tar 命令 : 使用方式 tar [参数] source [target] source - 压缩文件 target - 解压缩后的目标位置, 默认解压到当前目录 常用写法 : 解压缩 : ...
- Linux中配置ftp传输
.personSunflowerP { background: rgba(51, 153, 0, 0.66); border-bottom: 1px solid rgba(0, 102, 0, 1); ...
随机推荐
- .net程序员转行做手游开发经历(三)
这次就主要讲讲我们开发的过程. 策划是我们团队的一个人成员专门负责,我们几个算是出谋划策.我这边的理解是,策划首先需要对所做的事情一定要有一定的把握,意思是尽可能的想到这件事情的影响范围,类似项目管理 ...
- HTML5+JS 《五子飞》游戏实现(七)游戏试玩
前面第一至第六章我们已经把<五子飞>游戏的基本工作都已经讲得差不多了,这一章主要是把所有的代码分享给大家,然后小伙伴们也可以玩一玩. 至于人机对战的我们放到后面讲进行分析. 试玩地址:ht ...
- 柯尔莫可洛夫-斯米洛夫检验(Kolmogorov–Smirnov test,K-S test)
柯尔莫哥洛夫-斯米尔诺夫检验(Колмогоров-Смирнов检验)基于累计分布函数,用以检验两个经验分布是否不同或一个经验分布与另一个理想分布是否不同. 在进行cumulative probab ...
- MATLAB中的set函数
1.MATLAB给每种对象的每一个属性规定了一个名字,称为属性名,而属性名的取值成为属性值.例如,LineStyle是曲线对象的一个属性名,它的值决定着线型,取值可以是'-' .':'.'-.'.'- ...
- MATLAB中subplot的用法
写成subplot(m,n,p)或者subplot(mnp). subplot是将多个图画到一个平面上的工具.其中,m表示是图排成m行,n表示图排成n列,也就是整个figure中有n个图是排成一行的, ...
- android之拍照与摄像
拍照和摄像的意图很简答,这里直接贴代码 布局文件 <?xml version="1.0" encoding="utf-8"?> <Linear ...
- getopt
头文件 #include<unistd.h> 定义函数 int getopt(int argc,char * const argv[ ],const char * optstring); ...
- [转]html js中name和id的区别和使用分析
js中web页面元素的调用可以有两种识别方法:id和name 自己在用的过程中总结一下id和name的使用区别. 一,使用范围 除 BASE, HEAD, HTML, META, SCRIPT, ST ...
- 【UOJ #150】【NOIP 2015】运输计划
http://uoj.ac/problem/150 用树链剖分求lca,二分答案树上差分判断. 时间复杂度$O(nlogn)$,n,m同阶. #include<cstdio> #inclu ...
- linux命令巧用,随手记
巧用1 一句话修改或者给用户设置密码,并且防止历史命令记住设置的密码 echo "qqxde:ioj123"|passwd --stdin Dicky && his ...