CentOS5 正式版,已經開放下載囉! 什麼是CentOS呢? 就是RHEL的clone版啦!這次是base on RHEL5的版本來發行。
CentOS website
Tuesday, April 17, 2007
Monday, April 16, 2007
架設OpenNMS
今天花了一點時間來架設OpenNMS,想說以後可以用它來monitor Lab network,不料卡在某個環節,上網找到了opennms的官方說明文件,發現到原來是書中漏掉了一個設定,頓時......不知該說些什麼...... 官方的說明文件寫的非常棒!感謝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。
[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
資料沒有遺失,磁區確成功放大了!
-新增三個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真是桌面環境的領導品牌呀!
下載處: http://www.macupdate.com/info.php/id/22275/todos
Mac OS真是桌面環境的領導品牌呀!
Monday, April 09, 2007
Tuesday, April 03, 2007
最近研讀的書籍
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
[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
Monday, March 26, 2007
以SLES10快速架設閘道式防火牆
前言:
以Linux架設Firewall算是一個蠻物美價廉的方案,因為筆者在真實的環境中利用PIII這種老機器架設Firewall ,發覺還挺穩定的,使用到現在還沒發現有任何的問題,因此若您手邊有一些退役的機器,不如將它當成Firewall來用,給它個第二春吧!好了,廢話不多說,您可以參考以下的文件,快速建立一台Linux的Firewall。
概念:
這裡要介紹的是所謂的閘道式防火牆,目的在於隔開內外網路的連線,需求如下:
外部主機 -> 防火牆主機 (不可)
內部主機 -> 防火牆主機 (不可)
外部主機 -> 內部主機 (不可)
內部主機 -> 外部主機 (可, 但應只開放某些對外的連線)
事實上這種設定的方法,還說不上真正的安全!因為對內部的主機我採用的是完全信任的方案,但所謂:內賊難防!最好的方法還是要對內部主機採取安全控管,不過因為筆者是在家中自行架設並測試的,所以我就採用了較鬆散的方法,這一點請原諒。
環境:
eth0 外部網路 (10.6.7.0/24)-----Linux Firewall----- eth1內部網(172.17.2.0/24)
開啟ip_forwarding的功能:
# vi /etc/sysctl.conf
net.ipv4.ip_forward=1
# sysctl –p
# vi /etc/init.d/boot.local
sysctl –p
設定iptables的相關規則:
預設阻擋所有連線之基本原則:
# iptables –P INPUT DROP
# iptables –P FORWARD DROP
允許loopback介面的連線:
#iptables –A INPUT –i lo –j ACCEPT
阻擋非loopback介面但確是127.0.0.0/8的IP
# iptables –A INPUT –i ! lo –s 127.0.0.0/8 –j DROP
# iptables –A OUTPUT –o ! lo –s 127.0.0.0/8 –j DROP
允許後續連線:
# iptables –A INPUT –m state --state RELATED,ESTABLISHED –j ACCEPT
# iptables –A FORWARD –m state --state RELATED,ESTABLISHED –j ACCEPT
阻擋可疑的封包:
# iptables –A INPUT –m state --state INVALID –j DROP
# iptables –A FORWARD –m state --state INVALID –j DROP
阻擋TCP第一個連線非SYN類型的封包:
# iptables –A INPUT –p tcp ! –syn –m state --state NEW –j DROP
# iptables –A FORWARD –p tcp ! –syn –m state --state NEW –j DROP
允許內部主機對外的連線:
# iptables –A FORWARD –i eth1 –o eth0 –j ACCEPT
設定NAT規則:
# iptables –t nat –A POSTROUTING –o eth0 –s 172.17.2.0/24 –j MASQUERADE
以上是iptables的相關設定,第一次接觸的iptables的人可能會罵,到底你是在寫什麼東西呀!有看沒有懂,這點也是非常抱歉,網路上已經有許多先進撰寫過很多很棒的iptables規則說明與基本語法了,請您不妨利用google大神,去尋找吧!這裡講求的是快速架設,所以不會多加論述背後的原理。
辛辛苦苦打了這麼多指令,重開機是否會不見呢?答案是會的!如果您沒有將其存起來,當您重開機時是會叫苦連天的,所以請您依照以下的方法,將它先存成一個文字檔,待開機時再將它載入。
# iptables-save > /etc/sysconfig/iptables.save (將iptables的規則存成一文字檔)
# vi /etc/init.d/boot.local
iptables-restore < /etc/sysconfig/iptables.save (開機時將iptables的規則從檔案讀入)
後記:
以上便是快速架設Linux Firewall的方法,強烈建議您先懂原理再來實作將會讓您對於iptables更加了解,用起來也會順手些,畢竟iptables的語法看起來是有那麼一點小複雜。
以Linux架設Firewall算是一個蠻物美價廉的方案,因為筆者在真實的環境中利用PIII這種老機器架設Firewall ,發覺還挺穩定的,使用到現在還沒發現有任何的問題,因此若您手邊有一些退役的機器,不如將它當成Firewall來用,給它個第二春吧!好了,廢話不多說,您可以參考以下的文件,快速建立一台Linux的Firewall。
概念:
這裡要介紹的是所謂的閘道式防火牆,目的在於隔開內外網路的連線,需求如下:
外部主機 -> 防火牆主機 (不可)
內部主機 -> 防火牆主機 (不可)
外部主機 -> 內部主機 (不可)
內部主機 -> 外部主機 (可, 但應只開放某些對外的連線)
事實上這種設定的方法,還說不上真正的安全!因為對內部的主機我採用的是完全信任的方案,但所謂:內賊難防!最好的方法還是要對內部主機採取安全控管,不過因為筆者是在家中自行架設並測試的,所以我就採用了較鬆散的方法,這一點請原諒。
環境:
eth0 外部網路 (10.6.7.0/24)-----Linux Firewall----- eth1內部網(172.17.2.0/24)
開啟ip_forwarding的功能:
# vi /etc/sysctl.conf
net.ipv4.ip_forward=1
# sysctl –p
# vi /etc/init.d/boot.local
sysctl –p
設定iptables的相關規則:
預設阻擋所有連線之基本原則:
# iptables –P INPUT DROP
# iptables –P FORWARD DROP
允許loopback介面的連線:
#iptables –A INPUT –i lo –j ACCEPT
阻擋非loopback介面但確是127.0.0.0/8的IP
# iptables –A INPUT –i ! lo –s 127.0.0.0/8 –j DROP
# iptables –A OUTPUT –o ! lo –s 127.0.0.0/8 –j DROP
允許後續連線:
# iptables –A INPUT –m state --state RELATED,ESTABLISHED –j ACCEPT
# iptables –A FORWARD –m state --state RELATED,ESTABLISHED –j ACCEPT
阻擋可疑的封包:
# iptables –A INPUT –m state --state INVALID –j DROP
# iptables –A FORWARD –m state --state INVALID –j DROP
阻擋TCP第一個連線非SYN類型的封包:
# iptables –A INPUT –p tcp ! –syn –m state --state NEW –j DROP
# iptables –A FORWARD –p tcp ! –syn –m state --state NEW –j DROP
允許內部主機對外的連線:
# iptables –A FORWARD –i eth1 –o eth0 –j ACCEPT
設定NAT規則:
# iptables –t nat –A POSTROUTING –o eth0 –s 172.17.2.0/24 –j MASQUERADE
以上是iptables的相關設定,第一次接觸的iptables的人可能會罵,到底你是在寫什麼東西呀!有看沒有懂,這點也是非常抱歉,網路上已經有許多先進撰寫過很多很棒的iptables規則說明與基本語法了,請您不妨利用google大神,去尋找吧!這裡講求的是快速架設,所以不會多加論述背後的原理。
辛辛苦苦打了這麼多指令,重開機是否會不見呢?答案是會的!如果您沒有將其存起來,當您重開機時是會叫苦連天的,所以請您依照以下的方法,將它先存成一個文字檔,待開機時再將它載入。
# iptables-save > /etc/sysconfig/iptables.save (將iptables的規則存成一文字檔)
# vi /etc/init.d/boot.local
iptables-restore < /etc/sysconfig/iptables.save (開機時將iptables的規則從檔案讀入)
後記:
以上便是快速架設Linux Firewall的方法,強烈建議您先懂原理再來實作將會讓您對於iptables更加了解,用起來也會順手些,畢竟iptables的語法看起來是有那麼一點小複雜。
Thursday, March 22, 2007
OSX Startup keyboard commands help in troubleshooting
亂逛時不小心看到的,覺得挺實用所以趕緊po上來。
When troubleshooting, performing maintenance, or otherwise starting up your Mac OSX computer in an abnormal fashion, there are a few keyboard shortcuts that you may or may not know about that can help you. Below is a list of them with an explanation of what they do:
When troubleshooting, performing maintenance, or otherwise starting up your Mac OSX computer in an abnormal fashion, there are a few keyboard shortcuts that you may or may not know about that can help you. Below is a list of them with an explanation of what they do:
- X = Force Mac OS X startup
- Option = Brings up a screen with startup volume choices (slow process, may take a while)
- Option+Command+Shift+Delete = Bypass primary startup volume and seek a different startup volume (such as a CD or external disk)
- C = Start up from a CD that has a system folder
- N = Attempt to start up from a compatible network server (NetBoot)
- T = Start up in FireWire Target Disk mode (very handy for plugging your Mac into another as an external hard drive)
- Shift = start up in Safe Boot mode and temporarily disable login items and non-essential kernel extension files (Mac OS X 10.2 and later)
- Command+V = Start up in Verbose mode.
- Command+S = Start up in Single-User mode
- Command+Option+p+r = Zap PRAM. Hold down until second chime.
- Command+Option+n+v = Clear NV RAM. Similar to reset-all in Open Firmware.
- Command+Option+o+f = Boot into open firmware
- Hold mouse button down = Force eject a CD/DVD
調查利用 | (pipe) 連結各指令的執行結果
相信大家在Linux下都使用過|(pipe)來連結過指令, 比如 cat docu.txt | wc -l 可以得知docu.txt有幾行, 但是如果今天串連了許多指令,系統確告知指令不能正確被執行時該怎麼辦呢? 到底是卡在那一個了呢?
此時便可以透過PIPESTATUS這個"陣列變數"來得到每一個指令執行的結果是否正確!
看看以下的例子您便能明白:
[root@localhost ~]# cat docu.txt | wc -l
41
[root@localhost ~]# rm docu.txt
rm: remove regular file `docu.txt'? y
[root@localhost ~]# cat docu.txt | wc -l
cat: docu.txt: No such file or directory
0
[root@localhost ~]# echo ${PIPESTATUS[0]}
1
這樣應該瞭解了吧! 從這可知道各指令執行後的結果由0開始, 所以cat docu.txt的執行結果將存在PIPESTATUS[0]中,而wc -l則存放在PIPESTATUS[1]中,如此方便debug用.
Note: 指令若能正確被執行,則$?變數便會是0,非0則代表指令執行有誤,在這個例子中,您並不能以$?來找出那一段的指令執行錯誤,因為利用|(PIPE)所串連起來的指令,$?將會存放最後一個指令執行後的結果.
Note: PIPESTATUS的值將隨著每次指令的執行而異動!
此時便可以透過PIPESTATUS這個"陣列變數"來得到每一個指令執行的結果是否正確!
看看以下的例子您便能明白:
[root@localhost ~]# cat docu.txt | wc -l
41
[root@localhost ~]# rm docu.txt
rm: remove regular file `docu.txt'? y
[root@localhost ~]# cat docu.txt | wc -l
cat: docu.txt: No such file or directory
0
[root@localhost ~]# echo ${PIPESTATUS[0]}
1
這樣應該瞭解了吧! 從這可知道各指令執行後的結果由0開始, 所以cat docu.txt的執行結果將存在PIPESTATUS[0]中,而wc -l則存放在PIPESTATUS[1]中,如此方便debug用.
Note: 指令若能正確被執行,則$?變數便會是0,非0則代表指令執行有誤,在這個例子中,您並不能以$?來找出那一段的指令執行錯誤,因為利用|(PIPE)所串連起來的指令,$?將會存放最後一個指令執行後的結果.
Note: PIPESTATUS的值將隨著每次指令的執行而異動!
Wednesday, March 21, 2007
建構RHEL5的網路安裝Server
與RHEL4不一樣的是,RHEL5不需要將iso image mount起來,只要將iso image透過NFS Server export出來就可以了,所以說RHEL5變簡單了(笑~)。不過萬一您手上只有安裝光碟的時候,這怎麼辦呢? 請依以下的作法製作iso image吧!
For DVD:
# dd if=/dev/dvd of=/NFS/RHEL5/RHEL5.iso
For CD-ROMs:
# dd if=/dev/cdrom of=/NFS/RHEL5/RHEL5_diskX.iso
Note: X代表第幾片光碟。
設定並啟動NFS Server:
# vi /etc/exports
/NFS/RHEL5 *(ro,sync)
# service nfs start; chkconfig nfs on
For DVD:
# dd if=/dev/dvd of=/NFS/RHEL5/RHEL5.iso
For CD-ROMs:
# dd if=/dev/cdrom of=/NFS/RHEL5/RHEL5_diskX.iso
Note: X代表第幾片光碟。
設定並啟動NFS Server:
# vi /etc/exports
/NFS/RHEL5 *(ro,sync)
# service nfs start; chkconfig nfs on
Saturday, March 17, 2007
紅帽推出企業Linux 5 賽門鐵克來相挺-旗下儲存管理產品將支援RHEL 5
就在 紅帽 ( Red Hat )正式推出最新版旗艦作業系統 - Red Hat Enterprise Linux 5( RHEL 5)之後, 賽門鐵克 也宣布旗下儲存管理產品也將支援RHEL 5。
賽門鐵克表示,他們的Veritas Storage Foundation、Veritas Cluster Server以及Veritas NetBackup產品都將在90內完全支援紅帽最新旗艦Linux作業系統。為了協助紅帽用戶來更佳管理他們的資料中心,賽門鐵克將把開原碼Xen伺服 器虛擬工具列入RHEL 5內一起推出。
此外,賽門鐵克與紅帽也推出共同客戶服務方案,用來提供更快速更周詳的客戶支援。新的共同服務方案乃是藉由給予技術支援來讓工程師可以遠端遙控讀取賽門鐵克與紅帽的測試實驗室環境,結合雙方伺服器及儲存基礎架構來充分傳達客戶支援需求。
出處: CPRO 資傳網 http://cpro.com.tw/channel/news/content/?news_id=54431&cid=A0000
賽門鐵克表示,他們的Veritas Storage Foundation、Veritas Cluster Server以及Veritas NetBackup產品都將在90內完全支援紅帽最新旗艦Linux作業系統。為了協助紅帽用戶來更佳管理他們的資料中心,賽門鐵克將把開原碼Xen伺服 器虛擬工具列入RHEL 5內一起推出。
此外,賽門鐵克與紅帽也推出共同客戶服務方案,用來提供更快速更周詳的客戶支援。新的共同服務方案乃是藉由給予技術支援來讓工程師可以遠端遙控讀取賽門鐵克與紅帽的測試實驗室環境,結合雙方伺服器及儲存基礎架構來充分傳達客戶支援需求。
出處: CPRO 資傳網 http://cpro.com.tw/channel/news/content/?news_id=54431&cid=A0000
Friday, March 16, 2007
定期檢查系統中SUID的檔案
Linux系統中,凡具有SUID權限的檔案,可說是兩面刀呀! 好處是在某些時候可以讓user執行某些只有root可執行的檔案 (如: passwd, ping mount)~但壞處是萬一這個執行檔有"洞",就會讓有心人士有機會侵入到Linux作業系統,所以身為系統管理者的我們,必需要對SUID的檔案特別留意,也因此讓我想到,應該讓系統每天檢查SUID的檔案們是不是有被動過手腳:
-首先,在裝完OS後,先執行以下的命令:
find / -path '/proc' -prune -or -perm -u+s -exec ls -l {} \; > /tmp/suidlist-init
簡單的說就是利用find指令將除了/proc目錄外,所有具有suid權限的檔案找出來,並且存到/tmp/suidlist-init中
-撰寫scripr file:
# vi /root/bin/checksuid.sh
#!/bin/bash
LOGFILE="/tmp/suidlist-`date +%Y-%m-%d`"
RESULTFILE="/tmp/suid_check_result-`date +%Y-%m-%d`"
find / -path '/proc' -prune -or -perm -u+s -exec ls -l {} \; > $LOGFILE
diff /tmp/suidlist-init "$LOGFILE" > $RESULTFILE
mutt -s "SUID CHECK RESULT" root < $RESULTFILE
-定期每天AM 3點檢查,並將結果mail給root
#crontab -e
0 3 * * * /root/bin/checksuid.sh
這麼一來,每天收收信就可以知道目前所有具SUID檔案的狀況了!
-首先,在裝完OS後,先執行以下的命令:
find / -path '/proc' -prune -or -perm -u+s -exec ls -l {} \; > /tmp/suidlist-init
簡單的說就是利用find指令將除了/proc目錄外,所有具有suid權限的檔案找出來,並且存到/tmp/suidlist-init中
-撰寫scripr file:
# vi /root/bin/checksuid.sh
#!/bin/bash
LOGFILE="/tmp/suidlist-`date +%Y-%m-%d`"
RESULTFILE="/tmp/suid_check_result-`date +%Y-%m-%d`"
find / -path '/proc' -prune -or -perm -u+s -exec ls -l {} \; > $LOGFILE
diff /tmp/suidlist-init "$LOGFILE" > $RESULTFILE
mutt -s "SUID CHECK RESULT" root < $RESULTFILE
-定期每天AM 3點檢查,並將結果mail給root
#crontab -e
0 3 * * * /root/bin/checksuid.sh
這麼一來,每天收收信就可以知道目前所有具SUID檔案的狀況了!
Thursday, March 15, 2007
bash下array的幾種使用方法
#!/bin/bash
#一舉將變數設定到陣列中
array=(Redhat Novell MicroSoft Sun IBM HP Dell)
#利用for loop將陣列中的變數印出
for i in 0 1 2 3 4 5 6
do
echo "array[$i]=${array[$i]}"
done
#設定間隔符號為: 搭配$*將陣列的值一口氣輸出
IFS=:
echo "${array[*]}"
#設定間隔符號為換行,搭配$*將陣列的值一口氣輸出
IFS=$'\n'
echo "${array[*]}"
#將陣列中的值利用$@一口氣輸出與$*不同的是,不會將值合併成單一字串
echo "${array[@]}"
#印出陣列中有幾筆資料
echo "${#array[@]}"
執行結果:
array[0]=Redhat
array[1]=Novell
array[2]=MicroSoft
array[3]=Sun
array[4]=IBM
array[5]=HP
array[6]=Dell
Redhat:Novell:MicroSoft:Sun:IBM:HP:Dell
Redhat
Novell
MicroSoft
Sun
IBM
HP
Dell
Redhat Novell MicroSoft Sun IBM HP Dell
7
#一舉將變數設定到陣列中
array=(Redhat Novell MicroSoft Sun IBM HP Dell)
#利用for loop將陣列中的變數印出
for i in 0 1 2 3 4 5 6
do
echo "array[$i]=${array[$i]}"
done
#設定間隔符號為: 搭配$*將陣列的值一口氣輸出
IFS=:
echo "${array[*]}"
#設定間隔符號為換行,搭配$*將陣列的值一口氣輸出
IFS=$'\n'
echo "${array[*]}"
#將陣列中的值利用$@一口氣輸出與$*不同的是,不會將值合併成單一字串
echo "${array[@]}"
#印出陣列中有幾筆資料
echo "${#array[@]}"
執行結果:
array[0]=Redhat
array[1]=Novell
array[2]=MicroSoft
array[3]=Sun
array[4]=IBM
array[5]=HP
array[6]=Dell
Redhat:Novell:MicroSoft:Sun:IBM:HP:Dell
Redhat
Novell
MicroSoft
Sun
IBM
HP
Dell
Redhat Novell MicroSoft Sun IBM HP Dell
7
Wednesday, March 14, 2007
半價網
這個網站挺吸引人的,把供應商跟消費者完完全全結合在一起......
如果真得可以半價買的夢想中的商品,那是多麼地令人興奮呀!! 也因此帽客預約了Apple iMac 2.0Ghz MA590TA/A, 呵~原價42900半價21900, 能成功嗎? 期待中 =)
半價網 http://www.50100.com.tw
如果真得可以半價買的夢想中的商品,那是多麼地令人興奮呀!! 也因此帽客預約了Apple iMac 2.0Ghz MA590TA/A, 呵~原價42900半價21900, 能成功嗎? 期待中 =)
半價網 http://www.50100.com.tw
Monday, March 12, 2007
Redhat Enterprise Linux 5.0 蓄勢待發!
Redhat 計畫在美國時間3月14日推出它的旗艦作業系統最新版本 - Red Hat Enterprise Linux 5。
RHEL 5以連結伺服器虛擬與紅帽的叢集支援來整合Xen架構伺服器與儲存虛擬方案。此外,RHEL 5具有虛擬管理功能,能夠使得安裝及管理Xen虛擬機器變得更容易。新版本RHEL從Linux核心2.6.9版升級至2.6.18版,紅帽更宣稱延伸強 化了作業系統的網路與I/O子系統。
資料來源: CPRO 資傳網 http://cpro.com.tw/channel/news/content/?news_id=54344
RHEL 5以連結伺服器虛擬與紅帽的叢集支援來整合Xen架構伺服器與儲存虛擬方案。此外,RHEL 5具有虛擬管理功能,能夠使得安裝及管理Xen虛擬機器變得更容易。新版本RHEL從Linux核心2.6.9版升級至2.6.18版,紅帽更宣稱延伸強 化了作業系統的網路與I/O子系統。
資料來源: CPRO 資傳網 http://cpro.com.tw/channel/news/content/?news_id=54344
Wednesday, March 07, 2007
利用Kickstart安裝Redhat Linux
我想這不是一個很高深的技術,但確是非常實用且方便的方法,最近買了一堆IBM HP and Dell的Server,要帽客自己一台一台手動安裝Redhat嗎? 實在是沒那個美國時間, 所以就利用kickstart來幫我這麼忙囉! 帽客的作法是: 將kickstart configure file放在NFS Server上, 當然這台NFS Server也同樣是Installation Server, 待用第一片開機片開機時,打入以下的指令: linux ks=nfs:IP address:/Share folder/ks.cfg 這麼一來,人就可以不用待在機房在那邊按來按去囉!
Note: ks.cfg這個檔案是依據手動安裝時所選取的選項與設定,自行產生的範例檔, 原來的檔名與位置是在 /root/anaconda-ks.cfg.
Note: ks.cfg這個檔案是依據手動安裝時所選取的選項與設定,自行產生的範例檔, 原來的檔名與位置是在 /root/anaconda-ks.cfg.
Monday, March 05, 2007
Linux下的備份利器-cpio
說到在Linux下備份檔案,最常用的就是使用tar來備份檔案,不過有的時候在某些特定的需求下,是需要利用到其它的工具來備份,比如: 如果將來要回復*.conf的檔案時,利用tar的話就遇到瓶頸了,不過也不必擔心,還有一個好用的備份壓縮工具cpio可以幫我們達成這個需求!
1.首先,先將/etc完整備份到/tmp下:
# cd /etc;find . -print | cpio -oa > /tmp/etc_backup.cpio
2.將*.conf回復到/tmp下:
# cd /tmp; cpio -im "*.conf" < /tmp/etc_backup.cpio
附帶提一下常見的壓縮工具,它們的壓縮比(優到劣)通常是: tar.bz2 > tgz > tar > cpio > dump
1.首先,先將/etc完整備份到/tmp下:
# cd /etc;find . -print | cpio -oa > /tmp/etc_backup.cpio
2.將*.conf回復到/tmp下:
# cd /tmp; cpio -im "*.conf" < /tmp/etc_backup.cpio
附帶提一下常見的壓縮工具,它們的壓縮比(優到劣)通常是: tar.bz2 > tgz > tar > cpio > dump
Thursday, March 01, 2007
Subscribe to:
Posts (Atom)

