Tuesday, April 17, 2007

CentOS5 is available to download

CentOS5 正式版,已經開放下載囉! 什麼是CentOS呢? 就是RHEL的clone版啦!這次是base on RHEL5的版本來發行。

CentOS website

Monday, April 16, 2007

架設OpenNMS

今天花了一點時間來架設OpenNMS,想說以後可以用它來monitor Lab network,不料卡在某個環節,上網找到了opennms的官方說明文件,發現到原來是書中漏掉了一個設定,頓時......不知該說些什麼...... 官方的說明文件寫的非常棒!感謝OpenNMS開發團隊!

OpenNMS安裝指南

Thursday, April 12, 2007

在RHEL5安裝NTOP

1.首先請先至rpmfind.net抓取給RHEL5所使用的NTOP,筆者的系統少安裝了glib套件,故自己抓下source rpm 來rebuild。

[root@new-host-6 tmp]# rpm -ivh ntop-3.2-2.el5.rf.i386.rpm
warning: ntop-3.2-2.el5.rf.i386.rpm: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
error: Failed dependencies:
libglib-1.2.so.0 is needed by ntop-3.2-2.el5.rf.i386
[root@new-host-6 tmp]# rpmbuild --rebuild glib-1.2.10-15.src.rpm
Rebuild畫面跳過
[root@new-host-6 tmp]# cd /usr/src/redhat/RPMS/i386/
[root@new-host-6 i386]# ll
total 516
-rw-r--r-- 1 root root 145245 Apr 10 20:08 glib-1.2.10-15.i386.rpm
-rw-r--r-- 1 root root 236817 Apr 10 20:08 glib-debuginfo-1.2.10-15.i386.rpm
-rw-r--r-- 1 root root 129049 Apr 10 20:08 glib-devel-1.2.10-15.i386.rpm
[root@new-host-6 i386]# rpm -ivh *
Preparing... ########################################### [100%]
1:glib ########################################### [ 33%]
2:glib-debuginfo ########################################### [ 67%]
3:glib-devel ########################################### [100%]
[root@new-host-6 tmp]# rpm -ivh ntop-3.2-2.el5.rf.i386.rpm
warning: ntop-3.2-2.el5.rf.i386.rpm: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
1:ntop ########################################### [100%]

2.備份ntop.conf
[root@new-host-6 tmp]# cp /etc/ntop.conf /etc/ntop.conf.bak

3.建立NTOP儲存db的資料夾:
[root@new-host-6 tmp]# mkdir /var/www/html/ntop
[root@new-host-6 tmp]# chown ntop.ntop /var/www/html/ntop

4.啟動NTOP:
啟動NTOP的方法有兩種,一種是依照/etc/ntop.conf的設定並透過/etc/init.d/ntop start來啟動,另一種則是以命令列的方法啟動NTOP,第一種方法筆者有遇過啟動後一點反應也沒有,用status來看,也沒有任何的訊息,用echo $?才知道指令執行的結果是失敗的,但卻不知原因為何?於是乎,我個人偏愛用命令列的方式啟動NTOP。第一次啟動NTOP時會要求輸入帳號與密碼,請用admin/admin輸入即可。

[root@new-host-6 tmp]# ntop -P /var/www/html/ntop/ -u nobody
啟動畫面跳過,跑到一半時會要求輸入密碼
ntop startup - waiting for user response!
Please enter the password for the admin user:
Please enter the password again:

5.瀏覽NTOP website:
預設的port為3000,如果您要自訂port的話,請在啟動NTOP時,加上一個參數,-w 比如說如果我要把它改成6000的話,可以這樣做: ntop –P /var/www/html/ntop –u nobody –w 6000
接下來開啟瀏覽器,輸入 http://IP address:3000,就可以看到NTOP的流量統計的網頁。

後記:
更多有關於NTOP的參數,請參考man page。

Tuesday, April 10, 2007

在RHEL5下實作LVM

需求:
-新增三個LVM的partition,各100M
-新增三個PV
-新增一個VG,size=100M
-新增一個LV,size=50M
-動態放大VG,size+200M
-動態放大LV,size+50M

-新增三個LVM的partition,各100M
root@new-host-6:~^G[root@new-host-6 ~]# fdisk /dev/hda

The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
First cylinder (908-1044, default 908):
Using default value 908
Last cylinder or +size or +sizeM or +sizeK (908-1044, default 1044): +100M

Command (m for help): n
First cylinder (921-1044, default 921):
Using default value 921
Last cylinder or +size or +sizeM or +sizeK (921-1044, default 1044): +100M

Command (m for help): n
First cylinder (934-1044, default 934):
Using default value 934
Last cylinder or +size or +sizeM or +sizeK (934-1044, default 1044): +100M

Command (m for help): p

Disk /dev/hda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 778 6144862+ 83 Linux
/dev/hda3 779 843 522112+ 82 Linux swap / Solaris
/dev/hda4 844 1044 1614532+ 5 Extended
/dev/hda5 844 907 514048+ 83 Linux
/dev/hda6 908 920 104391 83 Linux
/dev/hda7 921 933 104391 83 Linux
/dev/hda8 934 946 104391 83 Linux

Command (m for help): t
Partition number (1-8): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-8): 7
Hex code (type L to list codes): 8e
Changed system type of partition 7 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-8): 8
Hex code (type L to list codes): 8e
Changed system type of partition 8 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/hda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 778 6144862+ 83 Linux
/dev/hda3 779 843 522112+ 82 Linux swap / Solaris
/dev/hda4 844 1044 1614532+ 5 Extended
/dev/hda5 844 907 514048+ 83 Linux
/dev/hda6 908 920 104391 8e Linux LVM
/dev/hda7 921 933 104391 8e Linux LVM
/dev/hda8 934 946 104391 8e Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
重新開機,讓它生效!
[root@new-host-6 ~]# reboot

-新增三個PV
[root@new-host-6 ~]# pvcreate /dev/hda6
Physical volume "/dev/hda6" successfully created
[root@new-host-6 ~]# pvcreate /dev/hda7
Physical volume "/dev/hda7" successfully created
[root@new-host-6 ~]# pvcreate /dev/hda8
Physical volume "/dev/hda8" successfully created
驗證一下
[root@new-host-6 ~]# pvdisplay
--- NEW Physical volume ---
PV Name /dev/hda6
VG Name
PV Size 101.94 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID NPXgcU-Pad8-EsG7-gFtI-hK66-8ua8-H0c78U

--- NEW Physical volume ---
PV Name /dev/hda7
VG Name
PV Size 101.94 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID NeXk3q-RKtl-Ias2-TIO0-0gbq-IdU9-XuL5DC

--- NEW Physical volume ---
PV Name /dev/hda8
VG Name
PV Size 101.94 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID Y9ERKn-oo61-mWj3-IOIZ-ba2p-QJID-UGzi4Q

-新增一個VG,size=100M
[root@new-host-6 ~]# vgcreate rootvg /dev/hda6
Volume group "rootvg" successfully created
驗證一下
[root@new-host-6 ~]# vgdisplay
--- Volume group ---
VG Name rootvg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 100.00 MB
PE Size 4.00 MB
Total PE 25
Alloc PE / Size 0 / 0
Free PE / Size 25 / 100.00 MB
VG UUID 2XpLIi-L1Cp-IbbB-cJ38-id6b-U6Qh-K4j3Gu

-新增一個LV,size=50M
[root@new-host-6 ~]# lvcreate -L +50M -n lv01 rootvg
Rounding up size to full physical extent 52.00 MB
Logical volume "lv01" created
驗證一下
[root@new-host-6 ~]# lvdisplay
--- Logical volume ---
LV Name /dev/rootvg/lv01
VG Name rootvg
LV UUID zWA1PJ-iy4L-PZcG-NgNw-eSue-7xmP-Tw2HNs
LV Write Access read/write
LV Status available
# open 0
LV Size 52.00 MB
Current LE 13
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:0
建立一個mount point: /mnt/lvm,並將其格式化成ext3檔案格式,掛載於/mnt/lvm下
[root@new-host-6 ~]# mkdir /mnt/lvm
[root@new-host-6 ~]# mke2fs -j /dev/rootvg/lv01
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
13328 inodes, 53248 blocks
2662 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=54525952
7 block groups
8192 blocks per group, 8192 fragments per group
1904 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@new-host-6 ~]# mount /dev/rootvg/lv01 /mnt/lvm/
[root@new-host-6 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda2 5.7G 2.9G 2.6G 53% /
/dev/hda1 99M 9.8M 84M 11% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/hda5 487M 11M 451M 3% /home
/dev/mapper/rootvg-lv01
51M 4.9M 43M 11% /mnt/lvm
Copy一些檔案到此目錄下,以供等會驗證動態放大檔案系統時,資料不會消失
[root@new-host-6 ~]# cp -r /boot/ /mnt/lvm/
[root@new-host-6 ~]# cd /mnt/lvm/
[root@new-host-6 lvm]# ll
total 13
drwxr-xr-x 4 root root 1024 Apr 10 20:17 boot
drwx------ 2 root root 12288 Apr 10 20:15 lost+found
[root@new-host-6 lvm]#

-動態放大VG,size+200M
[root@new-host-6 lvm]# vgextend rootvg /dev/hda7 /dev/hda8
Volume group "rootvg" successfully extended
驗證一下
[root@new-host-6 lvm]# vgdisplay
--- Volume group ---
VG Name rootvg
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size 300.00 MB
PE Size 4.00 MB
Total PE 75
Alloc PE / Size 13 / 52.00 MB
Free PE / Size 62 / 248.00 MB
VG UUID 2XpLIi-L1Cp-IbbB-cJ38-id6b-U6Qh-K4j3Gu

-動態放大LV,size+50M
[root@new-host-6 lvm]# lvextend -L +50M /dev/rootvg/lv01
Rounding up size to full physical extent 52.00 MB
Extending logical volume lv01 to 104.00 MB
Logical volume lv01 successfully resized
驗證一下
[root@new-host-6 lvm]# lvdisplay
--- Logical volume ---
LV Name /dev/rootvg/lv01
VG Name rootvg
LV UUID zWA1PJ-iy4L-PZcG-NgNw-eSue-7xmP-Tw2HNs
LV Write Access read/write
LV Status available
# open 1
LV Size 104.00 MB
Current LE 26
Segments 2
Allocation inherit
Read ahead sectors 0
Block device 253:0
[root@new-host-6 lvm]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda2 5.7G 2.9G 2.6G 53% /
/dev/hda1 99M 9.8M 84M 11% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/hda5 487M 11M 451M 3% /home
/dev/mapper/rootvg-lv01
51M 9.1M 39M 20% /mnt/lvm
此時因為還沒執行線上更新大小的動作,所以磁區大小還不會放大喔!
這裡跟RHEL4不同,改用resize2fs 來線上更新
[root@new-host-6 lvm]# resize2fs /dev/rootvg/lv01
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/rootvg/lv01 is mounted on /mnt/lvm; on-line resizing required
Performing an on-line resize of /dev/rootvg/lv01 to 106496 (1k) blocks.
The filesystem on /dev/rootvg/lv01 is now 106496 blocks long.

[root@new-host-6 lvm]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda2 5.7G 2.9G 2.6G 53% /
/dev/hda1 99M 9.8M 84M 11% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/hda5 487M 11M 451M 3% /home
/dev/mapper/rootvg-lv01
101M 9.5M 87M 10% /mnt/lvm
[root@new-host-6 lvm]# cd /mnt/lvm/
[root@new-host-6 lvm]# ll
total 13
drwxr-xr-x 4 root root 1024 Apr 10 20:17 boot
drwx------ 2 root root 12288 Apr 10 20:15 lost+found
資料沒有遺失,磁區確成功放大了!

Todos

Mac用久了,就會安裝一堆應用程式,這時就會覺得Dock放了太多icon會覺得很亂的感覺,如果不放在Dock裡,每次要用到時又必需到應用程式資料夾去翻箱倒櫃的找,非常沒有效率,好在有Todos這套軟體,它會scan您的應用程式資料夾,並可利用快速鍵叫出應用程式選單,非常方便唷!


下載處: http://www.macupdate.com/info.php/id/22275/todos

Mac OS真是桌面環境的領導品牌呀!

Monday, April 09, 2007

利用Flock貼個圖

利用Flock貼個圖看看,嗯~還挺方便的 =) 以下是我女兒,哈哈!可愛吧!

Tuesday, April 03, 2007

最近研讀的書籍


最近想對網路的流量分析與效能監控能更加深入了解,所以在博客來買了這本書,研讀中,希望這個月能把它K完。
實務上我已經有用MRTG與NTOP監控過Lab的流量了,只是我覺得....只懂皮毛是不夠的.....加油!

Monday, April 02, 2007

透過NTP自動更新系統時間與硬體時間

1.首先先設定時區位置為: 亞洲台灣
[root@server1 ~]# cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime
cp: overwrite `/etc/localtime'? y
[root@server1 ~]# vi /etc/sysconfig/clock
ZONE="Asia/Taipei"
UTC=false
ARC=false

2.利用ntpdate更新系統時間:
[root@server1 ~]# date
Mon Apr 2 13:00:05 CST 2007
[root@server1 ~]# ntpdate time.stdtime.gov.tw
2 Apr 16:44:31 ntpdate[2904]: step time server 220.130.158.52 offset 13454.935451 sec
[root@server1 ~]# date
Mon Apr 2 16:44:32 CST 200

3.更新硬體時間:
[root@server1 ~]# hwclock –w

4.利用crontab設定每小時自動更新系統時間與硬體時間:
[root@server1 ~]# crontab –e
01 * * * * /usr/sbin/ntpdate time.stdtime.gov.tw;/sbin/hwclock -w