Sharing

2011年10月19日 星期三

Why cannot remove logical volume?


今天想要把兩個 volume 合併起來, 所以計劃把 volume 1 砍掉, 然後 extend volume0, 但想不到竟然無法砍成功

這個是原本的狀態
root@ubuntu1104-64-6:/etc/ceph$ lvscan
  /dev/dm-3: read failed after 0 of 4096 at 0: Input/output error
  ACTIVE            '/dev/ubuntu1104-64-6/root' [45.86 GiB] inherit
  ACTIVE            '/dev/ubuntu1104-64-6/swap_1' [23.99 GiB] inherit
  ACTIVE            '/dev/ubuntu1104-64-6/lvol0' [50.00 GiB] inherit
  ACTIVE            '/dev/ubuntu1104-64-6/lvol1' [50.00 GiB] inherit

先試了一下另一台 Server, 很順利的砍掉, 完全沒有問題
root@ubuntu1104-64-5:/etc/ceph$ lvremove /dev/ubuntu1104-64-5/lvol2
Do you really want to remove active logical volume lvol2? [y/n]: y
  Logical volume "lvol2" successfully removed

試一下網路上的教學, 先把 volume 設成 inactive, 但想不到竟然也失敗!
root@ubuntu1104-64-6:/etc/ceph$ lvchange -an -v /dev/ubuntu1104-64-6/lvol1
    Using logical volume(s) on command line
  /dev/dm-3: read failed after 0 of 4096 at 0: Input/output error
    Deactivating logical volume "lvol1"
    Found volume group "ubuntu1104-64-6"
  LV ubuntu1104-64-6/lvol1 in use: not deactivating

第二招是使用更底層的指令, dmsetup 來砍, 也失敗!
root@ubuntu1104-64-6:/etc/ceph$ dmsetup remove /dev/ubuntu1104-64-6/lvol1
device-mapper: remove ioctl failed: Device or resource busy
Command failed


用 dmsetup 看一下他的狀況, Open = 1 , 想了一下可能是有某個 process 還在用這個 volume
root@ubuntu1104-64-6:/etc/ceph$ dmsetup info -c /dev/ubuntu1104-64-6/lvol1
Name                    Maj Min Stat Open Targ Event  UUID                                          
ubuntu1104--64--6-lvol1 251   3 L--w    1    1      0 LVM-j8BFBw1hbMLXLb4PCFPraeHAaodggpk2S8Wp56e6pUM8peKY22w0V5QMy8hSn3aA

用 lsof 來看一下有沒有 process 在使用, 啥! 也沒有@@
root@ubuntu1104-64-6:/etc/ceph$ lsof /dev/ubuntu1104-64-6/lvol1

突然想到前兩天有玩 iscsi, 該不會我有 export 出去吧.. 咦.. 好像是喔!
root@ubuntu1104-64-6:/etc/iet$ /etc/init.d/open-iscsi stop
 * Disconnecting iSCSI targets
   ...done.
 * Stopping iSCSI initiator service
   ...done.
root@ubuntu1104-64-6:/etc/iet$ /etc/init.d/iscsitarget stop
 * Removing iSCSI enterprise target devices:
   ...done.
 * Removing iSCSI enterprise target modules:
   ...done.

把 iscsi 停下來後, 總算砍成功啦!
root@ubuntu1104-64-6:/etc/iet$ lvremove /dev/ubuntu1104-64-6/lvol1
  /dev/dm-3: read failed after 0 of 4096 at 0: Input/output error
Do you really want to remove active logical volume lvol1? [y/n]: y
  Logical volume "lvol1" successfully removed


把 vol0 extend 成 200G, 任務完成!
root@ubuntu1104-64-6:/etc/iet$ lvresize -L +150G /dev/ubuntu1104-64-6/lvol0
  Extending logical volume lvol0 to 200.00 GiB
  Logical volume lvol0 successfully resized
root@ubuntu1104-64-6:/etc/iet$ lvscan
  ACTIVE            '/dev/ubuntu1104-64-6/root' [45.86 GiB] inherit
  ACTIVE            '/dev/ubuntu1104-64-6/swap_1' [23.99 GiB] inherit
  ACTIVE            '/dev/ubuntu1104-64-6/lvol0' [200.00 GiB] inherit


2011年10月18日 星期二

How to see Python code in Source Insight



資訊是從 http://wiki.python.org/moin/PythonEditors 找到的

1. 下載 Source Insight 的一個CLF文件
http://www.sourceinsight.com/public/languages/Python.CLF

2. 打開 Source Insight, 選擇options->Preferences->Language->Import->將剛剛的clf文件導入進來



3. options->Document options-> Add Type -> 輸入 Python

4. 接下來就會多一個 Python 的 Document Type, 選擇它之後, 要把其它的東西都設定好
    a. Language => Python Language
    b. File filter => *.py
    c. turn on "Include when adding to projects"
    d. turn on some "Editing Options" if need


這樣就大功告成啦!

2011年10月17日 星期一

How to import ssh key from puttygen?


如果在 Window 的系統上我們會用 puttygen 來生成 ssh key, 但如果我們要拿去 ubuntu 使用該怎麼做?

首先因為 ubuntu 上使用的 openSSH 的格式和 puttygen 的不同, 所以要先把 private key 轉換成正確的格式, 轉換成功後記得檔案要存成 id_rsa


接下來把 public key 直接當成純文字存到另一個檔案 id_rsa.pub

我們把這兩個檔案都上傳到 ubuntu 的機器, 然後放在 ~/.ssh/ 底下, 如果原本就有檔案存在, 就把它覆蓋掉

最後一件事是要記得改權限, 不然會被視為有問題!

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/pjack/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /home/pjack/.ssh/id_rsa

chmod 0600 .ssh/id_rsa