跳到主要內容

發表文章

目前顯示的是 2012的文章

FreeNAS, ZFS and iSCSI target.

FreeNAS 當 iSCSI target server 的設定概念很有趣,以下是概念上的流程: 1. 先從實體的 disk 建立 ZFS Volume, 三顆以上可以選擇建成 RAIDZ 2. 建立好的 ZFS Volume 可以在上面開 data set, 這時候會有 mount point 3. 有了 data set 以後,在 iSCSI 設定裡面可以建立 extends 4. Extends 有分兩種,一種Device Extends 會把整個 data set 拿來用, 另一種 Extends是可以在data set 的 mount point 上設定一個任意指定大小的檔案。 5. 有了 Extends 後,還要設定 Targets. 基本上就是 ACL 6. 接來就是把把 Target 和 Extends link 起來, 這樣就可以變成一個 iSCSI target 了

GPT, MBR, BIOS and UEFI

Booting from GPT http://www.rodsbooks.com/gdisk/booting.html Windows and GPT FAQ http://msdn.microsoft.com/en-us/library/windows/hardware/gg463525.aspx Summary: 目前到 Windows 2012 為止,GPT disk 如果要當 boot volume 一定要透過 UEFI, 傳統的 BIOS 只能用 MBR 當 boot volume. 而 Linux 和 FreeBSD 則是有可能在傳統的 BIOS 用 MBR 和 GPT 當 boot volume. (應該沒誤解吧? Orz)

iSCSI multipathing on ESXi

之前在ESXi 4/5上裝 Dell equallogic multipath plugin 的時候,還不太曉得確切的用途是甚麼。今天看到了兩篇文章,突然明白了。 簡而言之: 負載平衡與容錯。 VMKernel port 綁兩個IP的用意是,讓不同的IP建立不同的 IP Session 去存取 iSCSI target. 兩張網卡互相設定為 active / un-used 是為了容錯。 因此我們不需要在 Switch 上設定 LACP,在 ESXi OS level 就可以幫你處理掉。 因此可以兼顧效能與可用性。這是一個很簡單卻又漂亮的 practice, 我喜歡 :) REF: http://vlife.pixnet.net/blog/post/26926176 http://www.weithenn.org/cgi-bin/wiki.pl?VMware_MPIO http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=2038869&sliceId=1&docTypeID=DT_KB_1_1&dialogID=501944480&stateId=1%200%20501958830

flash tomato firmware on ASUS RT-N12-C1

Tomato by Shibby For RT-N12-C1 we have to download from: K26RT-N – MIPSR2 – special builds for E4200, RT-N10U, RT-N12B1/C1, RT-N15U, RT-N53, RT-N66U, WNR3500Lv2 and newer Linksys E-series routers Step: 1. Reset AP to factory default 2. Setup staic IP for you desktop or laptop 3. Unplug power 4. Press the reset button in the back of AP the plug power 5. Wait until the pwoer led falsh slowly 6. Open browser and connect http://192.168.1.1 7. You should see a firmware upload page, select the tomato firmware and upload it 8. After upload success wait 5 minutes 9. Connect http://192.168.1.1, if you see the tomato webpage, you have done the job!

the wrong way to create image from sanpshot

If you create a EC2 image from the the sanshot which is a wrong way, you will end up with below error message: EXT3-fs: sda1: couldn't mount because of unsupported optional features (240). EXT2-fs: sda1: couldn't mount because of unsupported optional features (244). Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,1)     The wrong way is: 1. Create sanpshot from the running instance volume 2. Click the created snapshot and create image from the snapshot 3. Launch instance with the created image   The correct way is: 1. Create image from the running instance 2. Launch instance with the created image   That's it!  

enable ssl for squid3 on Ubuntu 12.04

# download source and dependencies cd /usr/src apt-get source squid3 apt-get build-dep squid3 apt-get install libsasl2-dev #  Enable SSL cd squid3-3.1.19 vim debian/rules + --enable-ssl \ # re-configure with enable-ssl ./configure # build package debuild -us -uc -b # Install package under /usr/src dpkg -i squid3-dbg_3.1.19-1ubuntu3.12.04.1_amd64.deb squid-cgi_3.1.19-1ubuntu3.12.04.1_amd64.deb squidclient_3.1.19-1ubuntu3.12.04.1_amd64.deb squid-common_3.1.19-1ubuntu3.12.04.1_all.deb By doing this, you can repackge a new deb package with enable-ssl feature, you can verify by: squid3-v | grep ssl

chrome java plugin on windows 7 64 bit

Chrome and Firefox on windows 7 64 bit OS both are only support 32 bit application. Therefore, if you want to install java plugin in Firefox and Chrome, you need to install java jre 32 bit version instead of 64 bit. Another thing is if after jave jre installation, in java testing page, you still keep asking to install jave plugin, it might caused by some chrome plugins blocks the jave plugin installation. you can use "about:plugins" to disable some plugin or in extension page remove some extenstions.

Communicate with RESTful APIs in Python

It's really cool to use requests to communicate with RESTful API in python! Requests is an elegant and simple HTTP library for Python, built for human beings.   It also support Basic/Digest authentication methods, you can simply pass parameters with it. If you are still using  other low level library such as urllib/urllib2/pycurl, etc... to communicate with RESTful API, you should give it a try! A lightning talk in EuroPython 2012: Communicate with RESTful APIs in Python Ref: Communicating with RESTful APIs in PythonWritten by Balthazar

Mutiple listening squid w/wo authentication

squid 要設定 ncsa_auth 認證其實不難, 有趣的是我們也可以利用 myport 來產生一個 acl squid 的 acl 跟 iptalbes 的 rule 很像, first match first apply. 所以我們可以設定從某些 port 來的 request 不需要密碼驗證, 其他的則必須要密碼驗證。另外也可以加入允許連連線的來源網址,只要注意規則的順序就好囉! # vi /etc/squid/squid.conf  http_port = 3128  # listensing port B http_port = 9999  # listensing port B   # Enable ncsa_auth  (htpasswd -c /etc/squid/passwd username ) auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd auth_param basic children 5 auth_param basic realm Squid proxy-caching web server auth_param basic credentialsttl 2 hours auth_param basic casesensitive off   # Add filter for ncsa auth acl lab_lan src 172.18.0.0/22 172.18.4.0/22 # multiple CIDR network acl ncsa_users proxy_auth REQUIRED acl no_auth myport 9999 http_access allow no_auth lab_lan http_access allow ncsa_users lab_lan # Deny others ...   http_access deny all

Transform putty ppk key to OpenSSH authorized_keys

在登入EC2的機器時,我們常會將 ssh key pair 轉換成 putty 的 ppk 以方便遠端登入。如果有天需要將這把 ppk 轉換成 OpenSSH 可以使用的 public key 要怎麼辦呢? 使用 puttygen 讀取 ppk,  接著點選 Save public key 將 public key 的內容存成遠端機器上的純文字檔 ssh-keygen -i -f {純文字檔} > OpenSSH_authorized_key cat openssh_authorized_key >> ~/.ssh/authorized_keys 這樣就可以用 ppk 來登入遠端的機器囉!

Tips for bundling EC2 RHEL image with ephemeral storage

如果在 EC2 選了一個 ebs block device 是 6G 的 image, 要怎麼重新 bundle 成自己要的  image 呢? 首先是要下載 ec2-ami-tools, 裝完後, 如果你的系統有被 ruby rvm 搞爛了...導致一執行 ec2-bundle-vol 就出現 require error, 那先暫時把 path 設回系統的預設值吧! export PATH=/usr/bin:$PATH, 這時候下 ec2-bundle-vol -c /mnt/cert-XXXX.pem -k /mnt/pk-XXXX.pem -u {userid} -e /mnt -d /mnt 理論上會因為 /mnt 空間太小或者 loop device 在做轉存 image 的過程中耗光了可用空間,導致 bundle 失敗..其實 EC2 所有的 instance 都有 local 的 ephermal storage, 只是有的 instance 預設不會幫你 mount 起來, 而且 EC2 也不保證放在ephermal storage 上資料的安全性。這時候我們可以去手動把這個空間 mount 來, 做成 bundle image 時的暫存空間。以 RHEL 6.0 來說, ephermal storage 的 device id 可能為 /dev/xvd{X}, 可以先用 fdisk 看一下大小, 然後再用 mkfs /dev/xvd{X} 將其格式化在手動 mount 起來! 假設我將 ephermal storage 掛在 /emp 下,那最後用 ec2-bundle-vol 的指令就會變成 ec2-bundle-vol -c /mnt/cert-XXXX.pem -k /mnt/pk-XXXX.pem -u {userid} -e /mnt,/emp -d /emp 有時候倒霉的話還會遇到說 rsync 版本太舊,建議 upgrade後再重新 bundle 一次....不過應該可以不理它, 因為 bundle 還是會繼續....

Setup Dell Equallogic iSCSI storage for ESX/ESXi Host

Dell Equallogic Multiple Path Extension For ESX 4 setup.pl --install --server={HOST} --bundle=c:\dell-eql-mem-esx4-1.1.0.222691.zip setup.pl --server={HOST} --configure --ips={iSCSI Client IP 1},{iSCSI Client IP 1} --nics={iSCSI Client Nic 1},{iSCSI Client Nic 2} --enableswiscsi --netmask={{iSCSI Client IP Netmask}} --mtu=9000 --enableswiscsi 如果 Client iSCSI vSwitch 已經設定過了, 在安裝 Equallogic MEM 的時候,很可能會出現錯誤說請先移除無效的vmknic。這似乎是 ESX 4/5 的一個 bug, vSwitch在被移除後, vmknic IP會被清空但是卻不會移除乾淨。尤其是當iSCSI device 還連線的話,連進ssh下指令也是無法移除vmknic。 ESX5 我的做法是: 1. 用vSphere Client移除 vSwitch 2. 用SSH登入ESX, 利用esxcli中斷該 vSwitch 的 iSCSI session esxcli iscsi session remove -A {iSCSI software adapter} 3. 移除該 vSiwtch 下,被清空但是未移除的 vmnic esxcli iscsi networkportal remove -A {iSCSI software adapter} -n {vmnicX} ESX 4 的話命令有點不一樣,不過原理都是一樣的。移除 vSwitch和其下的網卡,如果無法移除成功那就是還有 iSCSI session 存在,想辦法把他關掉或者重開機後就可以移除乾淨了。這時候就可以順利安裝 Equallogic 的 Plugin. ESX5 Dell Equallogic Plugin 在ESX5透過 vSphere CLI安裝總是會失敗(ESX 4是正常的),我的做法是: