- 論壇徽章:
- 0
|
在solaris9上安裝時間服務器
參考
http://www.ddvip.net/OS/solaris/index3/79.htm
http://www.pool.ntp.org/
http://www.pool.ntp.org/zone/asia
亞洲地區(qū), 將下面幾行加入ntp.conf文件中。
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
由于工作需要把內(nèi)網(wǎng)的機器時間都統(tǒng)一。于是自己搭建一個time server。
利用192.168.1.76(sky76)這臺solaris9機器作為server端,客戶端有win2k,winxp和solairs等。
默認情況下,solaris9已經(jīng)裝好了xntpd(軟件包名為SUNWntpu)
# which ntpdate
/usr/sbin/ntpdate
# which ntpq
/usr/sbin/ntpq
而且已經(jīng)有以下腳本
/etc/init.d/xntpd
啟動xntpd:# /etc/init.d/xntpd start
停止xntpd: # /etc/init.d/xntpd stop
在開機啟動腳本里有 /etc/rc2.d/S74xntpd
相關(guān)配置文件
/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
亞洲區(qū)的服務器
#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
#關(guān)于認證的選項,因為在局域網(wǎng)中用,不做任何的驗證。注釋掉即可
#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
上述表示已經(jīng)啟動。
3、一些命令的用途
# man ntpdate
# ntpdate ntp.fudan.edu.cn 可以和復旦時間服務器同步時間。
# man ntpq 標準網(wǎng)絡時間協(xié)議(ntp)查詢程序。
# ntpq
> as
> pe
4、客戶端機器的設置
對于winxp和win2003
打開“日期和時間”屬性面板,在Internet時間頁中填入時間的服務器(192.168.1.76)就行了
對于solaris機器
可以用ntp的client程序更新,
# ntpdate 192.168.1.76
或者寫入root用戶的cron里自動每天執(zhí)行
# 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分,半分的)執(zhí)行了命令也不會和服務器同步的,ntp是逐步一點一點的來同步時間的,如果想立刻和服務器同步就把client時間改前或改后10分鐘,再同步就可以了
本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u/7635/showart_95112.html |
|