当前位置:首页 > 电脑常识 > 正文

linux中配置NTP根基操纵 8090安适门户

11-22 电脑常识

date 检察当前时区
vim /etc/sysconfig/clock  改削时区配置文件
ZONE="America/New_York"
#改为
ZONE="Asia/Shanghai"

笼罩 /etc/localtime
cp -a /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 默认又只更新系统时间,因此我们需要设置硬件时钟进行同步调解

[root@mini ~]# vim /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 ().
#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

温馨提示: 本文由杰米博客推荐,转载请保留链接: https://www.jmwww.net/file/pc/13367.html

博客主人杰米WWW
杰米博客,为大家提供seo以及it方面技巧喜欢的朋友收藏哦!
  • 11365文章总数
  • 1378074访问次数
  • 建站天数
  •