资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

Linux安装ntp命令的简单介绍

linux ntp是什么服务?

服务器时间同步。NTP是网络时间同步协议,就是用来同步网络中各个计算机的时间的协议。Linux配置NTP时间同步,常用命令有

我们提供的服务有:做网站、成都做网站、微信公众号开发、网站优化、网站认证、贡觉ssl等。为1000多家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的贡觉网站制作公司

启动NTP时间服务器:service ntpd start

设置NTP开机自动启动:chkconfig ntpd on

查看NTP是否正常运行:netstat -tlunp | grep ntp 你试试看吧 看看《Linux就该这么学》 里面有个专栏是 Linux命令大全(手册

Linux 怎么更新 NTP 时间?

1.请确确认各节点的ntp包已经安装 ,我这里是个4.2.2的版本

[oracle@nascds10 ~]$ rpm -qa | grep ntp

ntp-4.2.2p1-9.el5_4.1

2.请编辑各个节点的ntp.conf文件

[oracle@nascds10 ~]$ su - root

Password:

[root@nascds10 ~]# vi /etc/ntp.conf

#New ntp server added by Robinson

server 192.168.1.128 prefer ===========这里是时钟服务器

restrict 192.168.7.0 mask 255.255.255.255 nomodify notrap #基于网段的限制(限制在网段192.168.7.0)

broadcastdelay 0.008

[root@nascds11 ~]# vi /etc/ntp.conf

#New ntp server added by Robinson

server 192.168.7.71 prefer

broadcastdelay 0.008

3、配置ntpd的参数,我们主要强调的是要配置成"微调的模式" 也就是在options中要加入 -x的选项

[root@nascds10 ~]# vi /etc/sysconfig/ntpd

#The following item added by Robinson

#Set to 'yes' to sycn hw clock after successful ntpdate

SYNC_HWCLOCK=yes

OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

[root@nascds11 ~]# vi /etc/sysconfig/ntpd

The following item added by Robinson

SYNC_HWCLOCK=yes

OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

4、自动启动配置

[root@nascds10 ~]# chkconfig ntpd on

[root@nascds11 ~]# chkconfig ntpd on

5、重启一下,使最新配置生效

[root@nascds10 ~]# service ntpd restart

Shutting down ntpd: [ OK ]

ntpd: Synchronizing with time server: [ OK ]

Syncing hardware clock to system time [ OK ]

Starting ntpd: [ OK ]

[root@nascds11 ~]# service ntpd restart

Shutting down ntpd: [ OK ]

ntpd: Synchronizing with time server: [ OK ]

Syncing hardware clock to system time [ OK ]

Starting ntpd: [ OK ]

6、检查ntpd进程的状态

[root@nascds10 ~]# ntpq -p

remote refid st t when poll reach delay offset jitter

==============================================================================

LOCAL(0) .LOCL. 10 l 40 64 1 0.000 0.000 0.001

[root@nascds11 ~]# ntpq -p

remote refid st t when poll reach delay offset jitter

==============================================================================

test.oracle.com .INIT. 16 u 60 64 0 0.000 0.000 0.000

LOCAL(0) .LOCL. 10 l 59 64 1 0.000 0.000 0.001

linux 里 配置NTP服务SERVER为NTP server. 如何配置ntf服务

安装NTP:

yum install ntp

配置时间源

vi /etc/ntp.conf

server 210.72.145.44

server ntp.api.bz

server 2.centos.pool.ntp.org

配置对客户端(172.16.0.0/24的网段机器)提供NTP服务

# vi /etc/ntp.conf

restrict 172.16.0。0 mask 255.255.255.0 nomodify notrap

配置NTP Server的层数提供本地服务

server 127.127.1.0 # local clock

fudge 127.127.1.0 stratum 2

设置开机时自动运行时间服务

chkconfig ntpd on

启动或停止时间服务

# service ntpd start

# service ntpd stop

# service ntpd restart

验证ntp服务已经运行

pgrep ntpd

更新本服务器的时间

ntpdate -u 210.72.145.44

配置iptable规则允许客户端访问本机NTP Sever

vi /etc/sysconfig/iptables

增加一行(NTP Server使用UDP 123端口)

-A INPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT

重启iptables

service iptables restart


分享题目:Linux安装ntp命令的简单介绍
链接URL:http://cdkjz.cn/article/dohccjd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220