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地址  客户机同步服务器时间

注:同步需要一段时间

时间: 2025-01-14 04:13:18

linux中配置NTP基本操作的相关文章

linux中配置DHCP基本操作

rpm -q dhcp #查看dhcp是否安装 yum  install dhcp* -y #安装DHCP(挂载看上文)vim /etc/dhcp/dhcpd.conf 打开配置文件## DHCP Server Configuration file.#DHCP服务配置文件#   see /usr/share/doc/dhcp*/dhcpd.conf.sample#参考/usr/share/doc/dhcp*/dhcpd.conf.sample文件  (#使用命令cp /usr/share/doc

Linux杂记-配置ntp时间同步服务

概念 NTP是网络时间协议(Network Time Protocol),它是用来同步网络中各个计算机的时间的协议. 安装 目标 现集群有三台主机,分别为centos7-1,centos7-2,centos7-3. centos7-1作为master,同步硬件时间. centos7-2,centos7-3同步centos7-1的时间. 安装ntp 三台主机分别安装ntp,并设置一个初始时间. yum -y install ntp date -s '2018-05-04 00:00:00' 修改/

开发电子商城2(linux中配置jdk)

1.下载jdk版本     http://pan.baidu.com/s/1eR16I6e 2:删除centos中自带的jdk    //2.1 先查看linux中是否装过 并且找到安装的路径 rpm -qa |grep jdk       更多rpm 命令:请参照:http://man.linuxde.net/rpm    //2.2 若是装有jdk 卸载       yum remove ****    //2.3  java -version 看是否删除陈功  3 在usr 目录下创建ja

网络安全系列之三十九 在Linux中配置访问控制列表ACL

Linux系统中传统的权限设置方法比较简单,仅有3种身份.3种权限而已,通过配合chmod和chown等命令来对文件的权限或所有者进行设置.如果要进行比较复杂的权限设定,例如某个目录要开放给某个特定的使用者使用时,这些传统的方法就无法满足要求了. 例如对于/home/project目录,该目录的所有者是student用户,所属组是users组,预设权限是770.现在有个名为natasha的用户,属于natasha组,希望能够对/home/project目录具有读写执行权限:还有一个名为instr

讲述一下自己在linux中配置ftp服务的经历

本人大二小白一名,从大一下学期就开始接触到linux,当时看到学校每次让我们下载资源都在一个ftp服务器中,感觉特别的高大上,所以自己就想什么时候自己能够拥有自己的ftp服务器,自己放一点东西进去,让别人访问. 那么,就从那时开始,就有了一系列的艰难旅程.... 要不然先不说经历了,就先直捅技术吧,最后在说经历,要不然有些人就懒得看这篇初级又傻傻的文章了. 小白,那就需要手把手的教,同时还要图文并茂. 第一步: 自己的linux必须是要有的,如果没有,而且你还不会装,那么就可以看一下小弟我以前的

linux中配置yum源

1.配置163或者阿里云yum源: 阿里云yum源地址:https://mirrors.aliyun.com/centos/6.9/os/x86_64/Packages/ 阿里云给出的解决办法:https://mirrors.aliyun.com/centos 点击centos后面的帮助即可看到: 1.备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 2.下载新的CentOS-Base

Linux中配置samba服务器,实现局域网中文件共享。

linux中搭建samba服务,实现局域网中文件共享 Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成.SMB(Server Messages Block,信息服务块)是一种在局域网上共享文件和打印机的一种通信协议,它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务. 实验环境:Linux6.虚拟windows7/10.yum仓库.同一网段. `rpm -q samba` //查看Samba安装与否 `yum install /mnt/Pa

Linux中配置ftp传输

ftp的配置及使用 1.安装ftp:yum install -y vsftpd 出现如图所示,则表示安装成功 2.关闭防火墙:service iptables stop 3.创建一个用户用于ftp传输(或者用已存在的) adduser hxc 4.设置密码 passwd hxcftp  (再输入两遍密码) 5.切换到ftp的配置目录:cd /etc/vsftpd/ 6.编辑该目录下的文件user_list : vim user_list 7.编辑里面的内容,将需要的用户添加进该文件夹中,这里增加

如何在 Linux 中配置基于密钥认证的 SSH

什么是基于 SSH 密钥的认证? 众所周知,Secure Shell,又称 SSH,是允许你通过无安全网络(例如 Internet)和远程系统之间安全访问/通信的加密网络协议.无论何时使用 SSH 在无安全网络上发送数据,它都会在源系统上自动地被加密,并且在目的系统上解密.SSH 提供了四种加密方式,基于密码认证,基于密钥认证,基于主机认证和键盘认证.最常用的认证方式是基于密码认证和基于密钥认证. 在基于密码认证中,你需要的仅仅是远程系统上用户的密码.如果你知道远程用户的密码,你可以使用 ssh