2010年10月14日 星期四

CentOS 5.5 Install ntp 實作


NTP Server 設定
  1. Install NTP ( WebSite http://www.ntp.org/ )
    wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-dev/ntp-dev-4.2.7p61.tar.gz
    tar zxvf ntp-dev-4.2.7p61.tar.gz
    cd ntp*
    ./configure --prefix=/usr/local/ntp
    make && make install

  2. set /etc/ntp.conf
    vim /etc/ntp.conf
    #==================================================================
    # A. Server 時間伺服器
    # 語法:server [ip or hostname] [prefer]
    server ntp.ntu.edu.tw    prefer #優先使用伺服器
    server tick.stdtime.gov.tw
    server tock.stdtime.gov.tw
    server time.stdtime.gov.tw
    server clock.stdtime.gov.tw
    server watch.stdtime.gov.tw

    #B. restrict 權限設定
    #語法:restrict [ip] [parameter]
    restrict 192.168.0.0 mask 255.255.255.0 nomodify

    #C. driftfile 記錄誤差值
    # driftfile [ /path/filename]
    driftfile /var/log/ntp/drift
    #==================================================================

  3. 啟動 ntpd , 檢查是否監聽 123 port
    /usr/local/ntp/bin/ntpd start
    netstat -nal -u | grep 123

  4. 檢查連線狀況
    /usr/local/ntp/bin/ntpq -p


    NTP Client 設定
  5. Install NTP
    同 server 方式

  6. 更新時間的指令
    /usr/local/ntp/bin/ntpdate ntp.ntu.edu.tw


  7. 修改 vim /etc/crontab 加更自動更新時間
    */30 * * * * root /usr/sbin/ntpdate ntp.ntu.edu.tw && /sbin/hwclock -w

後記
備註:
/sbin/hwclock -w 將時間寫入 BIOS

參考:
http://linux.vbird.org/linux_server/0440ntp.php#before
http://www.stdtime.gov.tw/chinese/bulletin/NTP%20promo.txt
http://itgroup.blueshop.com.tw/towns/hc?n=wodvew&i=422
http://wsunccake.spaces.live.com/blog/cns!AB8DB0BB93B43420!208.entry
http://www.weithenn.org/cgi-bin/wiki.pl?NTP-%E6%9E%B6%E8%A8%AD%E7%B6%B2%E8%B7%AF%E5%B0%8D%E6%99%82%E4%BC%BA%E6%9C%8D%E5%99%A8
http://erichuang89.blogspot.com/2010/05/ntp.html


全文完

CentOS 安裝 FluxBox + Vnc + firefox 網頁快拍

第一步:安裝 Yum-Priorities

yum install yum-priorities


 

第二步:修改 /etc/yum.repos.d/CentOS-Base.repo 增加以下紅色字串

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=2

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=2 


 

第三步:下載 RpmForge

32bit :wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm

64bit :wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm 


 

第四步:導入 RPM-GPG-Key

wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt 

rpm  -import ./RPM-GPG-KEY.dag.txt


 

第五步:安裝 RpmForge

32bit :rpm –ivh rpmforge-release-0.5.1-1.el5.rf.i386.rpm

64bit :rpm –ivh rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm


 

第六步:修改 /etc/yum.repos.d/rpmforge.repo 最後加上 priority=11

### Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag
### URL: http://rpmforge.net/
[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
baseurl = http://apt.sw.be/RedHat/el5/en/$basearch/rpmforge
mirrorlist = http://apt.sw.be/RedHat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
priority=11

第七步:安裝 vnc vnc-server fluxbox firefox x11-xorg

yum –y install vnc vnc-server fluxbox firefox x11-xorg


 

第八步:設定 vncserver 密碼

vncserver


 

第九步:設定 vnc 登入即啟動 fluxbox

pkill -9 vnc

rm –rf /tmp/.X1*

vim ~/.vnc/xstartup

修改 twn& 為 exec /usr/bin/fluxbox


 

第十步:啟動 vncserver

vncserver


 

第十一步:使用 realvnc 連入 IP:5901


http://www.realvnc.com/cgi-bin/4.0-download.cgi


 

第十二步:安装firefox插件,Pearl Crescent Page Saver 設定截圖後目錄

地址:http://pearlcrescent.com/products/pagesaver/


 

第十三步:設定環境參數, 使用 firefox 截圖

export DISPLAY=:1.0

firefox -saveimage http://tw.yahoo.com


 

以上環境需開啟 fluxbox 才可使用 firefox 截圖, 透過 xvfb-run.sh 可模擬 x-windows 執行 firefox 截圖

wget http://www.flexthinker.com/wp-content/uploads/2009/11/xvfb-run.sh.txt

mv xvfb-run.sh.txt /usr/bin/xvfb-run.sh

chmod u+x /usr/bin/xvfb-run.sh

/usr/bin/xvfb-run.sh /usr/bin/firefox –saveimage http://tw.yahoo.com

/usr/bin/vfb-run.sh --server-args="-screen 0, 1024x768x24" /usr/bin/firefox -saveimage http://www.591.com.tw


 

1 ~ 6 步驟使用以下取代

install rpmforge

website:http://www.rpmrepo.org/RPMforge/Using

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm

rpm -ivh rpmforge-release-0.5.1-1.el5.rf.i386.rpm


 

7 ~ 8

install fluxbox firefox xorg-x11-xinit vnc-server

yum -y install fluxbox firefox xorg-x11-xinit vnc-server

CentOS 5.5 Install CutyCapt 實作


  1. (x64)
    wget http://dl.atrpms.net/el5-x86_64/atrpms/testing/qt44-4.4.3-10_4.el5.x86_64.rpm
    wget http://dl.atrpms.net/el5-x86_64/atrpms/testing/qt44-x11-4.4.3-10_4.el5.x86_64.rpm
    wget http://dl.atrpms.net/el5-x86_64/atrpms/testing/qt44-devel-4.4.3-10_4.el5.x86_64.rpm


    rpm -ivh qt44-4.4.3-10*
    rpm -ivh qt44-x11-4.4.3-10*
    rpm -e qt-devel --nodeps --allmatches
    rpm -ivh qt44-devel-4.4.3-10*
    rpm -rebuilddb

  2. 加入 QT 目錄到環境參數中
    vim /etc/profile
    #==================================================
    export QTDIR=/usr/lib64/qt44
    export QTLIB=/usr/lib64/qt44/lib
    export QTINC=/usr/lib64/qt44/include
    export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
    export PATH=$QTDIR/bin:$PATH
    #==================================================

  3. 下載 Cutycapt
    svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt
    mv cutycapt/CutyCapt /usr/local/CutyCapt
    cd /usr/local/CutyCapt
    qmake
    make

  4. CutyCapt 截圖指令
    ./CutyCapt --url=http://tw.yahoo.com --out=yahoo.png

  5. 此時如系統無安裝 X-Windows 會出現CutyCapt: cannot connect to X server 需另掛上 xfvb 模擬 X-Windows 環境
    wget http://www.flexthinker.com/wp-content/uploads/2009/11/xvfb-run.sh.txt
    mv ./xvfb-run.sh.txt /usr/local/CutyCapt/xvfb-run.sh
    chmod u+x /usr/local/CutyCapt/xvfb-run.sh

  6. 透過 xfvb-run 模擬 X-Windows 截圖指令
    /usr/local/CutyCapt/xvfb-run.sh /usr/local/CutyCapt/CutyCapt --url=http://tw.yahoo.com --out=yahoo.png


  7. 截圖如出現亂碼或是無字串, 需檢查是否有安裝適當字型
    yum install fonts-chinese

  8. 更改環境語系值為網址語系,再截圖一次即可
    LANG=UFT-8
    /usr/local/CutyCapt/xvfb-run.sh /usr/local/CutyCapt/CutyCapt --url=http://tw.yahoo.com --out=yahoo.png




    後記

    xvfb-run 參數
    xvfb-run –server-args="-screen 0, 1024x768x24〞     模擬 X-Windows 大小色彩
    xvfb-run –wait=10                    模擬 X-Windows 啟動後延遲幾秒後執行指令