centos5时区、时间设置及ntp服务

上传人:xiao****1972 文档编号:84144965 上传时间:2019-03-02 格式:DOC 页数:6 大小:52.14KB
返回 下载 相关 举报
centos5时区、时间设置及ntp服务_第1页
第1页 / 共6页
centos5时区、时间设置及ntp服务_第2页
第2页 / 共6页
centos5时区、时间设置及ntp服务_第3页
第3页 / 共6页
centos5时区、时间设置及ntp服务_第4页
第4页 / 共6页
centos5时区、时间设置及ntp服务_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《centos5时区、时间设置及ntp服务》由会员分享,可在线阅读,更多相关《centos5时区、时间设置及ntp服务(6页珍藏版)》请在金锄头文库上搜索。

1、设置CentOS的时区和时间http:/be-evil.org/post-132.html首先, 安装ntp时间同步服务yum install -y ntp然后,设置时区为CSTcp /usr/share/zoneinfo/Asia/Shanghai /etc/localtimevi /etc/sysconfig/clock修改时区为ZONE=Asia/Shanghai最后,手动同步一次时间ntpdate us.pool.ntp.orgcentos5 时区、时间设置及NTP服务http:/ 个时区,所以就需要ntp服务器进行同步各地区的时间。计算机上还有个硬件时间,也就是cmos时钟,在win

2、dows系统中,系统启动的时候直接从 coms时钟中读取时间,关闭的时候往cmos中写入,从而保持两者的一致性。linux系统里是通过hwclock命令来读取和设置硬件时钟的,下面就 来看看centos5下的ntp服务吧!rootcentos5 # hwclock 查看硬件时钟2009年07月04日 星期六 19时18分11秒 -0.609827 seconds。rootcentos5 # hwclock -utc 设置硬件时钟为格林威治时间2009年07月05日 星期日 03时19分26秒 -0.561311 secondsrootcentos5 # cat /etc/sysconfig/c

3、lock 查看系统的硬件时钟和时区配置文件ZONE=Asia/ShanghaiUTC=trueARC=false1. #查看时区 2. cat /etc/sysconfig/clock 3. #修改设置时区命令 4. tzselect 5. #也可以复制相应的时区文件,替换系统默认时区 6. cp /usr/share/zoneinfo/$主时区/$次时区 /etc/localtimerootcentos5 # ls -l /usr/share/zoneinfo/Asia/Shanghai-rw-r-r- 2 root root 405 2008-03-11 /usr/share/zonein

4、fo/Asia/Shanghairootcentos5 # date -R 查看系统所在时区Sun, 01 Feb 2009 01:05:53 +0800把系统时间写入硬件时钟rootcentos5 # date -s 2009-07-04 19:04:002009年 07月 04日 星期六 19:04:00 CSTrootcentos5 # date2009年 07月 04日 星期六 19:04:18 CSTrootcentos5 # hwclock2009年07月05日 星期日 19时44分32秒 -0.685570 secondsrootcentos5 # hwclock -systoh

5、crootcentos5 # hwclock2009年07月04日 星期六 19时04分56秒 -0.653825 seconds把硬件时钟写入系统时钟rootcentos5 # hwclock2009年07月03日 星期五 19时04分30秒 -0.298749 secondsrootcentos5 # date -s 2009-07-04 19:04:002009年 07月 04日 星期六 19:04:00 CSTrootcentos5 # hwclock -hctosysrootcentos5 # date2009年 07月 03日 星期五 19:05:02 CST编译方式安装ntp服务

6、http:/www.ntp.org/downloads.html,从该主页上下载源码包,编译并安装rootcentos5 # cd /usr/local/src/rootcentos5 src# tar -zxvf ntp-4.2.4p7.tar.gzrootcentos5 src# cd ntp-4.2.4p7rootcentos5 ntp-4.2.4p7# ./configure -prefix=/usr/local/ntprootcentos5 ntp-4.2.4p7# make & make installrootcentos5 /# cd /usr/local/rootcentos5

7、 local# lsbin etc games include lib libexec ntp sbin share srcrootcentos5 local# ls ntp/bin lib manrootcentos5 ntp# cd ./bin/rootcentos5 bin# lsntpd ntpdc ntpq ntptrace sntpntpdate ntp-keygen ntptime ntp-wait tickadjrootcentos5 bin# ./ntpdate ch.pool.ntp.org 试与ch.pool.ntp.org这台公网ntp服务器同步下时间4 Jul 20:

8、08:47 ntpdate28663: step time server 134.34.3.18 offset 88900.032745 sec ,其中offset是双方的时间差编辑配置文件并启动服务rootcentos5 bin#cd .rootcentos5 ntp# lsbin lib manrootcentos5 ntp# mkdir etcrootcentos5 ntp# lsbin etc lib manrootcentos5 ntp# vi etc/ntpd.confserver ch.pool.ntp.orgrootcentos5 ntp#./bin/netpd -c /usr

9、/local/ntp/ntpd.confrootcentos5 ntp# netstat -nupl |grep 123udp 0 0 192.168.0.200:123 0.0.0.0:* 28697/ntpdudp 0 0 127.0.0.1:123 0.0.0.0:* 28697/ntpdudp 0 0 0.0.0.0:123 0.0.0.0:* 28697/ntpdudp 0 0 fe80:20c:29ff:fefd:123 :* 28697/ntpdudp 0 0 :1:123 :* 28697/ntpdudp 0 0 :123 :* 28697/ntpdrootcentos5 /#

10、 tail -f /var/log/messagesJul 4 20:21:08 centos5 ntpd28696: ntpd 4.2.4p71.1607 Fri Jul 3 11:11:43 UTC 2009 (1)Jul 4 20:21:08 centos5 ntpd28697: precision = 1.000 usecJul 4 20:21:08 centos5 ntpd28697: Listening on interface #0 wildcard, 0.0.0.0#123 DisabledJul 4 20:21:08 centos5 ntpd28697: Listening

11、on interface #1 wildcard, :#123 DisabledJul 4 20:21:08 centos5 ntpd28697: Listening on interface #2 lo, :1#123 EnabledJul 4 20:21:08 centos5 ntpd28697: Listening on interface #3 eth0, fe80:20c:29ff:fefd:caa0#123 EnabledJul 4 20:21:08 centos5 ntpd28697: Listening on interface #4 lo, 127.0.0.1#123 Ena

12、bledJul 4 20:21:08 centos5 ntpd28697: Listening on interface #5 eth0, 192.168.0.200#123 EnabledJul 4 20:21:08 centos5 ntpd28697: kernel time sync status 0040rootcentos5 /# cd /usr/local/ntp/etc/rootcentos5 etc# vi ntpd.confserver ch.pool.ntp.orgserver 127.127.1.0 当网络不可用时,使用本地时间作为参考restrict default i

13、gnore 拒绝所有时间同步请求和其他访问restrict 127.0.0.1 允许本机和192.168.0.0/24位的主机进行时间同步restrict 192.168.0.0 mask 255.255.255.0restrict ch.pool.ntp.org noquery 指定上级ntp服务器可以访问本ntp服务器,但加上noquery参数,即不允许对方查询自己的服务状态rootcentos5 /# ps -ef |grep ntpdroot 28697 1 0 20:21 ? 00:00:00 ./bin/ntpd -c /usr/local/ntp/etc/ntpd.confroot 28731 5928 0 20:36 pts/0 00:00:00 grep ntpdrootcentos5 /# kill -9 28697rootcentos5 /# ps -ef |grep ntpdro

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号