免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1190 | 回复: 0
打印 上一主题 下一主题

在solaris9上安装时间服务器 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-04-04 15:56 |只看该作者 |倒序浏览
在solaris9上安装时间服务器

参考
http://www.ddvip.net/OS/solaris/index3/79.htm

http://www.pool.ntp.org/
http://www.pool.ntp.org/zone/asia
亚洲地区, 将下面几行加入ntp.conf文件中。
   server 0.asia.pool.ntp.org
   server 1.asia.pool.ntp.org
   server 2.asia.pool.ntp.org
由于工作需要把内网的机器时间都统一。于是自己搭建一个time server。
利用192.168.1.76(sky76)这台solaris9机器作为server端,客户端有win2k,winxp和solairs等。
默认情况下,solaris9已经装好了xntpd(软件包名为SUNWntpu)
# which ntpdate
/usr/sbin/ntpdate
# which ntpq
/usr/sbin/ntpq
而且已经有以下脚本
/etc/init.d/xntpd
启动xntpd:# /etc/init.d/xntpd start
停止xntpd: # /etc/init.d/xntpd stop
在开机启动脚本里有 /etc/rc2.d/S74xntpd
相关配置文件
/etc/inet/ntp.server
/etc/inet/ntp.client
/var/ntp 目录
1、服务器端的设置(ntp.conf)
ntp.conf这个文件默认安装完是没有的,可以复制一份
(可查看/etc/init.d/xntpd 脚本文件)
# cp /etc/inet/ntp.server /etc/inet/ntp.conf
# touch /var/ntp/ntp.drift
# vi /etc/inet/ntp.conf   编辑配置文件
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/etc/ntp.conf
# @(#)ntp.server 1.5 99/09/21 SMI
#
# /etc/inet/ntp.server
#
# An example file that could be copied over to /etc/inet/ntp.conf and
# edited; it provides a configuration template for a server that
# listens to an external hardware clock, synchronizes the local clock,
# and announces itself on the NTP multicast net.
#
#
# * All TrueTime receivers are now supported by one driver, type 5.
# Types 15 and 25 will be retained only for a limited time and may
# be reassigned in future.
#
# Either a peer or server. Replace "XType" with a value from the
# table above.
#server 127.127.XType.0 prefer
# 定义了两个可用的服务器 在这里也可以直接用域名来代替IP
#setserver ntp.cuhk.edu.hk //这个是internet上的顶级time server
server ntp.cuhk.edu.hk
#setserver ntp.fudan.edu.cn //这个是复旦大学的
server ntp.fudan.edu.cn
# 或者使用
http://www.pool.ntp.org/zone/asia
亚洲区的服务器
#server 0.asia.pool.ntp.org
#server 1.asia.pool.ntp.org
#server 2.asia.pool.ntp.org
#fudge 127.127.XType.0 stratum 0
#broadcast 224.0.1.1 ttl 4
enable auth monitor
driftfile /var/ntp/ntp.drift
statsdir /var/ntp/ntpstats/
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
filegen clockstats file clockstats type day enable
#关于认证的选项,因为在局域网中用,不做任何的验证。注释掉即可
#keys /etc/inet/ntp.keys
#trustedkey 0
#requestkey 0
#controlkey 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2、启动ntpd服务
当配置文件修改完毕后,利用脚本启动ntpd服务
# /etc/init.d/xntpd start
检查是否启动
# ps -ef | grep ntp
root  4258     1  0 14:58:07 ?        0:00 /usr/lib/inet/xntpd
上述表示已经启动。
3、一些命令的用途
# man ntpdate
# ntpdate ntp.fudan.edu.cn 可以和复旦时间服务器同步时间。
# man ntpq 标准网络时间协议(ntp)查询程序。
# ntpq
> as
> pe
4、客户端机器的设置
对于winxp和win2003
打开“日期和时间”属性面板,在Internet时间页中填入时间的服务器(192.168.1.76)就行了
对于solaris机器
可以用ntp的client程序更新,
# ntpdate 192.168.1.76
或者写入root用户的cron里自动每天执行
# export EDITOR=vi
# crontab -e
#synchronization time from 192.168.1.76
05 0 * * * /usr/sbin/ntpdate 192.168.1.76 >> /var/ntp/ntp_client_err.log 2>&1
注意:当ntpd服务器启动以后,client不能马上更新时间,要等一会才能用。
还有一点就是client上的时间和server相差很小的时候(比如只有1分,半分的)执行了命令也不会和服务器同步的,ntp是逐步一点一点的来同步时间的,如果想立刻和服务器同步就把client时间改前或改后10分钟,再同步就可以了


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/7635/showart_95112.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP