2011年2月16日 星期三

在Ubuntu 使用 iSCSI Initiator


在開始之前
請先安裝open-iscsi套件,即Linux Open-iSCSI Initiator。
# sudo apt-get install open-iscsi
請參照以下步驟使用Open-iSCSI Initiator連接iSCSI target (QNAP NAS)。
如有使CHAP登入資訊,您可能需要修改iscsid.conf,如 node.session.auth.username及node.session.auth.password。
# vi /etc/iscsi/iscsid.conf
儲存並關閉檔案,然後重新啟動open-iscsi服務。
# /etc/init.d/open-iscsi restart
尋找iSCSI target (在此例中為QNAP NAS),如IP: 10.8.12.31,連接埠:3260。
# iscsiadm -m discovery -t sendtargets -p 10.8.12.31:3260
選擇要連線的iSCSI node。
# iscsiadm -m node
** 您可以使用以下指令刪除不需要連線的node。
# iscsiadm -m node --op delete --targetname THE_TARGET_IQN
重新啟動open-iscsi並登入要連線的node。
# /etc/init.d/open-iscsi restart
以下訊息將會顯示:
Login session [iface: default, target: iqn.2004-04.com:NAS:iSCSI.ForUbuntu.B9281B,
portal: 10.8.12.31,3260] [ OK ]
使用dmesg檢查裝置狀態。
# dmesg | tail
輸入以下指令建立分割區,裝置名稱為/dev/sdb。
# fdisk /dev/sdb
格式化分割區。
# mkfs.ext3 /dev/sdb1
掛載file system。
# mkdir /mnt/iscsi

# mount /dev/sdb1 /mnt/iscsi/
完成後,您可以使用以下指令測試iSCSI target在Linux上的I/O速度。
# hdparm -tT /dev/sdb1
以下是有關iscsiadm的指令:
尋找主機上的target。
# iscsiadm -m discovery --type sendtargets --portal HOST_IP
登入target。
# iscsiadm –m node --targetname THE_TARGET_IQN --login
登出target。
# iscsiadm –m node --targetname THE_TARGET_IQN --logout
刪除target。
# iscsiadm –m node --op delete --targetname THE_TARGET_IQN

ubuntu無法連線tw.archive.ubuntu.com的問題

這些天來,到 tw.archive.ubuntu.com 更新,一直都無法連線而困惑的人,不妨考慮轉換到別的主機,如 ubuntu.cs.nctu.edu.tw。

以管理者身份編輯設定檔:(sudo gedit 或 vi)
/etc/apt/sources.list

將其內字串 tw.archive.ubuntu.com 全部置換為 ubuntu.cs.nctu.edu.tw。

之後再進行
#sudo apt-get update 
即可

2011年1月21日 星期五

Linux設定 vnc的解析度

1.ubuntu安裝 vnc
#apt-get install vnc4server

2.修改 xstartp
#vi ~/.vnc/xstartup
將x-window-manager &的這一行註解掉,
加入以下這二行
[ -f $HOME/.Xresources ] && xrdb $HOME/.Xresources
gnome-session &
並存檔.

#vncserver
即可啟動.

若要設定vnc的解析度
 vncserver -geometry 1024x768 :1

其中
:1 ,表示vnc port為5900 +1 => 5901
-geometry 1024x768,表示解析度為 1024*768

2011年1月17日 星期一

用dd簡單測Linux的io

read:
# time dd if=/dev/sda of=/dev/zero bs=8k count=1000000
1000000+0 records in
1000000+0 records out
8192000000 bytes (8.2 GB) copied, 73.0053 s, 112 MB/s
real    1m13.025s
user    0m0.230s
sys     0m7.700s





write:
#time dd if=/dev/zero of=/tmp/fake.file bs=8k count=1000000

1000000+0 records in
1000000+0 records out
8192000000 bytes (8.2 GB) copied, 81.6353 s, 100 MB/s

real    1m21.758s
user    0m0.160s
sys     0m8.440s

read and write:
#time dd if=/tmp/fake.file of=/tmp/fake.file.out bs=8k count=1000000
1000000+0 records in
1000000+0 records out
8192000000 bytes (8.2 GB) copied, 207.892 s, 39.4 MB/s

real    3m27.960s
user    0m0.320s
sys     0m17.310s


檢查Linux Block size
# dumpe2fs /dev/sdb1 | grep -i 'Block size'


測試 Ram Disk的速度.(:/tmp採用Ram Disk)
# time dd if=/dev/zero of=/tmp/fake.file bs=8k count=400000
400000+0 records in
400000+0 records out
3276800000 bytes (3.3 GB) copied, 1.33236 s, 2.5 GB/s

2011年1月11日 星期二

Linux 網路校時


ntpdate tock.stdtime.gov.tw 
hwclock -w

vi /etc/crontab
# 加入這一行去!
*/1 * * * * root /usr/sbin/ntpdate tock.stdtime.gov.tw && /sbin/hwclock -w

KVM會有20-30秒的中斷

問題:
當把KVM的Domain強制關機時,網路會有20-30秒的中斷,查詢 /var/log/message時.出現以下訊息.
...
Jan  6 08:59:30 ezkvm-desktop kernel: [862465.409284] br0: port 3(vnet1) entering disabled state
Jan  6 08:59:30 ezkvm-desktop kernel: [862465.487829] device vnet1 left promiscuous mode
Jan  6 08:59:30 ezkvm-desktop kernel: [862465.487835] br0: port 3(vnet1) entering disabled state
....


刪除JBoss的 DeleteWorkDirOnContextDestroy

configurable at the tomcat service level. There is an attribute that can be changed in deploy/jbossweb-tomcat55.sar/META-INF/jboss-service.xml

 <!--Flag to delete the Work Dir on Context Destroy -->
<attribute name="DeleteWorkDirOnContextDestroy">true</attribute>

then reboot jboss.














Reference:
https://issues.jboss.org/browse/JBAS-3358


http://www.contaduria.gov.co:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss.web:service%3DWebServer

2011年1月2日 星期日

Linux SSH 自動登錄

說明:
使用ssh自動登入:

方法:
使用RSA key的方式.

步驟:
假設:要從192.168.1.101(Server1)用ssh自動登入192.168.1.102(Server2)
1.在Server1利用 ssh-keygen產生公鑰:
# ssh-keygen -t rsa -b 1024
操作畫面如下,全部均使用預設值即可.
{{{
root@ezkvm-desktop:~/.ssh# ssh-keygen -t rsa -b 1024
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
ac:04:30:3e:12:60:1c:70:46:d7:5c:ce:45:94:09:40 root@ezkvm-desktop
The key's randomart image is:
+--[ RSA 1024]----+
|B+B .+Eoo++o |
|.* + oo .o |
|. o . o |
| . . . . |
| . S |
| . . |
| . |
| |
| |
+-----------------+
root@ezkvm-desktop:~/.ssh#
}}}
2.把 Server1上的公鑰檔(/root/.ssh/id_rsa.put)的檔案 copy 到 Server 2上的/tmp
3.登入 Server2,把Server1的公鑰 附加 到 Server2的 authorized_keys
{{{
cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys
}}}