导航:首页 > 配服务器 > linux如何同步ntp服务器地址

linux如何同步ntp服务器地址

发布时间:2025-02-15 21:15:32

linux 时间同步ntp问题,客户端如何同步时间

解决方案:
在linux 上配置NTP 时间同步,具休操作步骤,整理如下:
1. 安装软件包(在服务端和客户端):
yum install ntp
2. 服务器端配置
例如:
首先,服务端设定IP地址为:192.168.146.110
修改ntp配置文件
vim /etc/ntp.conf
server 0.redhat.pool.ntp.org //设定上级服务器
restrict 192.168.146.0 mask 255.255.255.0 nomodify //设定哪些client机器可以和ntp server进行同步
//启动NTP服务前,手动校正一次时间
ntpdate 0.redhat.pool.ntp.org
service ntpd restart
chkconfig ntpd on
//查看ntp服务状态
netstat -ln | grep 123
ntpstat
3.客户端配置:
ntpdate 192.168.146.110 //与NTP server 同步时间
或者定期同步
crontab -e
*/5 * * * * /usr/sbin/ntpdate -u 192.168.146.110 //每五分钟同步一次
重启crond服务/etc/init.d/crond restart
ntpq -p //查看同步状态

❷ linux主机如何同步互联网上的时间服务器

1.将/etc/下的文件ntp.conf修改如下:
server 192.168.0.1(互联网地址) minpoll 4 maxpoll 5
fudge 127.127.1.0 stratum 3
restrict 127.0.0.1
driftfile /var/lib/ntp/drift
logfile /etc/ntp.log
restrict 192.168.0.1 mask 255.255.255.255

2.将/etc/ntp下的文件ntpservers内容置空

3.将/etc/ntp下的文件step-tickers修改如下:
192.168.0.1
4、service ntpd restart
5、如果要查看的话ntpq -p
希望能帮到你

❸ 在各种Linux系统的服务器上设置时间同步的方法

独立主机

rm -rf /etc/localtime

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #修改时区到东8区。

date -R #查看的时区设置。

接下来调整系统时间与时间服务器同步

Debian系统安装NTP校时包:

复制代码代码如下:apt-get install ntpdate #安装ntp

CentOS系统安装NTP校时包:

复制代码代码如下:yum -y install ntpdate ntp #安装ntp

Ubuntu系统安装NTP校时包:

复制代码代码如下:sudo apt-get install -y ntpdate ntp

修改/etc/ntp.conf

vi /etc/ntp.conf 就会看到以下内容:

复制代码代码如下:server 0.centos.ntp.org

server time.windows.com

server time.nist.gov

这是默认的ntp同步服务器,大家可以自己改,全球ntp服务器地址:http://www.pool.ntp.org/

我改成了:

复制代码代码如下:server cn.pool.ntp.org //这中国的ntp服务器
server time-a.nist.gov
server time.windows.com
server time.nist.gov

然 后保存退出(vi退出的方法见:http://www.dabu.info/personal-summary-personally-i- carefully-collected-must-be-familiar-with-vim-shortcut-key-operation.html)

接着输入下面的命令

复制代码代码如下:ntpdate -d cn.pool.ntp.org #调试查看时间差异

ntpdate cn.pool.ntp.org #同步时间

date -R # 检查时间是否同步

修改 ntp 的配置文件

复制代码代码如下:vi /etc/sysconfig/ntpd

SYNC_HWCLOCK=yes #同步独立主机的硬件时钟

#配置开机启动ntp服务,定期同步时间

chkconfig --levels 235 ntpd on #启动ntp同步

/etc/init.d/ntpd start

XEN VPS

最好是安装ntp服务,这样可以解决vps在重启后时间不准的问题。有时候,依靠母鸡的硬件时钟,总是差七八分钟。实在没辙了。而已很多的web服务,如Google Authenticator等,如果时间不同步,会导致无法验证的地步,自然就网站都登陆不上了。

复制代码代码如下:rm -rf /etc/localtime

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #修改时区到东8区。

date -R #查看的时区设置。

接下来调整系统时间与时间服务器同步

Debian系统安装NTP校时包:

复制代码代码如下:apt-get install ntpdate #安装ntp

CentOS系统安装NTP校时包:

复制代码代码如下:yum -y install ntpdate ntp #安装ntp

Ubuntu系统安装NTP校时包:

复制代码代码如下:sudo apt-get install -y ntpdate ntp

修改/etc/ntp.conf

vi /etc/ntp.conf 就会看到以下内容:

复制代码代码如下:server 0.centos.ntp.org

server time.windows.com

server time.nist.gov

这是默认的ntp同步服务器,大家可以自己改,全球ntp服务器地址:http://www.pool.ntp.org/

我改成了:

复制代码代码如下:server cn.pool.ntp.org //这中国的ntp服务器
server time-a.nist.gov
server time.windows.com
server time.nist.gov

然 后保存退出(vi退出的方法见:http://www.dabu.info/personal-summary-personally-i- carefully-collected-must-be-familiar-with-vim-shortcut-key-operation.html)

接着输入下面的命令:

复制代码代码如下:ntpdate -d cn.pool.ntp.org #调试查看时间差异

ntpdate cn.pool.ntp.org #同步时间

date -R # 检查时间是否同步

#配置开机启动ntp服务,定期同步时间

chkconfig --levels 235 ntpd on #启动ntp同步

/etc/init.d/ntpd start

#先设置XEN 的VPS使用和系统无关的时间模式

echo 1 > /proc/sys/xen/independent_wallclock

然后尝试上面独立主机的配置方法即可。通过配置时间正确后,编辑系统配置文件,让配置永久生效。

复制代码代码如下:vi /etc/sysctl.conf

xen.independent_wallclock=1 #在文件中增加并且保存

OpenVZ VPS

(Burst VPS 采用)

OpenVZ的VPS直接从物理机读取时间不允许对主机进行时间修改,你只需修改时区。我还没用过openvz vps,所以,不清楚能否用ntp服务不,可以试试安装ntp service 看。如果可以的话,请告诉我。

复制代码代码如下:rm -rf /etc/localtime

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #修改时区到东8区。

date -R #查看时间和时区

此时如果时间和时区都正确,配置成功,时间如果不对,需要联系主机服务商的技术支持,让他们把母鸡(物理机)时间同步,你的VPS时间就会正常。


阅读全文

与linux如何同步ntp服务器地址相关的资料

热点内容
php获取url中的参数值 浏览:63
dna服务器是什么 浏览:975
pdf图片旋转的 浏览:200
我的世界服务器总断开怎么回事 浏览:406
使用python编写员工信息管理系统 浏览:598
程序员接私活设计费用怎么评估 浏览:154
怎么查询服务器mac地址 浏览:87
什么app看nba直播 浏览:402
ic卡无加密和有加密的区别 浏览:667
51子系列单片机机型 浏览:168
java创建文件代码 浏览:660
天下pdf 浏览:327
产后缓解压力的瑜伽 浏览:241
单片机音乐盒按键系统 浏览:108
魅族最强程序员 浏览:993
java赋值null 浏览:54
数控程序员考试 浏览:260
单片机0x 浏览:451
dhsp服务器是什么 浏览:690
网络监测命令 浏览:206