Sharing

2022年9月4日 星期日

Test

 



葉氏盃全國大賽四強下半第一牌,南北方一路氣勢磅礡的叫到大滿貫,在 18 IMP 的領先下實在是不樂見如此大牌。你坐在西家,首攻什麼?

古往今來眾所皆知,對抗大滿貫最好消極首攻,若非單張王一律建議敲王,但在機械化的敲王之前,先來描繪看看南北方的牌情吧。


測試 iframe:




BBO handviewer editor
https://www.bridgebase.com/tools/handviewer.html?editor=y


2014年12月31日 星期三

2014 Study Target

Python

Linux

Design Pattern

重構 (Re-factoring)

    • 重構 - 改善既有程式的設計 (Refactoring: Improving The Design of Existing code) Martin Fowler著,侯捷/熊節 譯
    • Java重構 結城浩 著,江珮齡/王元綱 譯
    • 重構 - 向範式前進 (Refactoring to Pattterns) Joshua Kerievsky 著,侯捷/陳裕城 譯

Storage

Hypervisor

Cloud

演算法

Programming Language

NoSQL



    2014年3月26日 星期三

    MAAS

    Official Site


    http://maas.ubuntu.com/docs/
    https://launchpad.net/maas



    Installation


    Precise 上預設的是 1.2 版, 裝起來後問題不少, 所以決定直接改用 Saucy (13.10) 安裝1.4 版, 安裝過程在文件上寫的滿清楚的, 還附圖, maas-dhcp/maas-dns 則是 optional, 就看環境中是否已經有存在的 dhcp/dns

    http://maas.ubuntu.com/docs/install.html

    每個 node 有一整個 life cycle, 在 /usr/share/pyshared/maasserver/enum.py 裡可以找到
    class NODE_STATUS:
        # A node starts out as READY.
        DEFAULT_STATUS = 0
        #: The node has been created and has a system ID assigned to it.
        DECLARED = 0
        #: Testing and other commissioning steps are taking place.
        COMMISSIONING = 1
        #: Smoke or burn-in testing has a found a problem.
        FAILED_TESTS = 2
        #: The node can't be contacted.
        MISSING = 3
        #: The node is in the general pool ready to be deployed.
        READY = 4
        #: The node is ready for named deployment.
        RESERVED = 5
        #: The node is powering a service from a charm or is ready for use with
        #: a fresh Ubuntu install.                                                                                                          
        ALLOCATED = 6                                                                                                                       
        #: The node has been removed from service manually until an admin
        #: overrides the retirement.
        RETIRED = 7
    


    Configuration

    Proxy Server

    在 MAAS 裡面, 預設是一定有 http proxy, 從 /etc/maas/preseeds/generic 可以看的出來

    {{if http_proxy }}
    d-i     mirror/http/proxy string {{http_proxy}}
    {{else}}
    d-i     mirror/http/proxy string http://{{server_host}}:8000/
    {{endif}}
    

    如果環境中沒有 http proxy, 處理方式可能有兩個, 第一種就是把 proxy 的設定全都拿掉, 以下這些檔案都需要修改

    /etc/maas/templates/commissioning-user-data/user_data_config.template
    /etc/maas/preseeds/enlist_userdata
    /etc/maas/preseeds/curtin_userdata
    /etc/maas/preseeds/generic
    

    第二種則是可以把 MAAS 內建的 squid-deb-proxy 打開來, 其實也會有一些好處, 下載 .deb 檔會快不少

    update-rc.d  squid-deb-proxy defaults
    

    打開 squid-deb-proxy 後, 可能要看一下 /etc/squid-deb-proxy 是否有滿足你的網路環境
    另外如果需要連結額外的 repository server, 則需要在 mirror-dstdomain.acl.d 內加 server
    http://www.garron.me/en/blog/ubuntu-deb-proxy-cache.html

    /etc/maas/import_pxe_files


    設定你需要的 RELEASE 以及 ARCHES, 但 i386 一定要留著, 因為有些地方的預設值是 i386, 沒有的話會出問題, 如果要加自己定義的 RELEASE, 也是加在這裡, 這邊我自己加了一個 precise04, 是要安裝 Ubuntu Precise 12.04 但 kernel 是 3.11.

    RELEASES="precise04 saucy precise"
    #RELEASES="precise quantal raring saucy"
    ARCHES="amd64/generic i386/generic"
    #ARCHES="amd64/generic i386/generic armhf/highbank armhf/generic"
    

    /usr/lib/python2.7/dist-packages/maasserver/enum.py


    如果有加自己定義的 RELEASE, 請加上新的 enum, UI 上就會看到了

    class DISTRO_SERIES:
        precise04 = 'precise04'
        
    DISTRO_SERIES_CHOICES = (
        (DISTRO_SERIES.precise04, 'Ubuntu 12.04 LTS "Precise Pangolin with 3.11 Kernel"')
    )
    

    /usr/sbin/maas-import-pxe-files


    抓 image 的主要程式在這隻檔案內, 配合前面新增的 precise04, 我修改了以下幾個地方

    compose_installer_base_url


    compose_installer_base_url() {
        local arch=$1 release=$2
        case $arch in
            amd64/*|i386/*)
                if [ "$release" = "precise04" ]; then
                    local installer_url="$MAIN_ARCHIVE/dists/precise-updates/main/installer-${arch%%/*}"
                else
                    local installer_url="$MAIN_ARCHIVE/dists/${release}-updates/main/installer-${arch%%/*}"
                fi
                echo "$installer_url/current/images/"
                ;;
        ...
    }
    

    compose_installer_download_url_postfix

    compose_installer_download_url_postfix() {
        local arch=$1
        local release=$2
        case $arch in
            amd64/*|i386/*)
                if [ "$release" = "precise04" ]; then
                    echo "saucy-netboot/ubuntu-installer/${arch%%/*}/"
                else
                    echo "netboot/ubuntu-installer/${arch%%/*}/"
                fi
                ;;
        ...
    }
    

    凡是有用到 compose_installer_download_url_postfix 的地方都加上第二個參數

    compose_installer_download_url_postfix $arch $release
    


    update_install_files

    update_install_files() {
            ...
            filename_in_md5sums_file=./$file_prefix$file
            ...
    }
    


    完成之後就執行 /usr/sbin/maas-import-pxe-files, 就可以看到結果啦~

    root@ops-maas3:/var/lib/maas/tftp# find . | grep initrd.gz
    ./amd64/generic/precise/install/initrd.gz
    ./amd64/generic/saucy/install/initrd.gz
    ./amd64/generic/precise04/install/initrd.gz
    ./i386/generic/precise/install/initrd.gz
    ./i386/generic/saucy/install/initrd.gz
    ./i386/generic/precise04/install/initrd.gz
    



    Preseed Configuration


    其實每個下載下來的 initrd.gz 內, 都有一個 preseed.cfg, 裡面會指明要安裝的 kernel 版本
    d-i     base-installer/kernel/altmeta   string lts-saucy 
    

    /etc/maas/preseeds/preseed_master

    如果按照原本的設定, 反而可能會裝錯 kernel, 把以下兩行改掉
    #d-i     base-installer/kernel/image     string linux-server
    d-i debian-installer/allow_unauthenticated string true
    

    VMWare Issue


    /etc/maas/templates/commissioning-user-data/snippets/maas_ipmi_autodetect_tool.py


    判斷是否是 VMware
    def detect_ipmi():
        # XXX: andreserl 2013-04-09 bug=1064527: Try to detect if node
        # is a Virtual Machine. If it is, do not try to detect IPMI.
        with open('/proc/cpuinfo', 'r') as cpuinfo:
            for line in cpuinfo:
                if line.startswith('model name') and 'QEMU' in line:
                    return (False, None)
        with open('/var/log/dmesg', 'r') as dmesg:
            for line in dmesg:
                if 'Hypervisor detected' in line and 'VMware' in line:
                    return (False, None)
    


    Use E1000 NIC under Curtin Installing


    不知道為什麼如果用 VMXNET3, 在 pxeboot 後 /sys/class/net/eth0/operstate 內的狀態會是 "Unknown".
    這會造成 deploy 的過程中會有誤判, 所以請使用 E1000


    類似的 Issue
    https://www.vmware.com/support/vsphere5/doc/vsp_esxi50_u3_rel_notes.html#resolvedissuesnetworking

    Preseed Order


    /usr/share/pyshared/maasserver/preseed.py

    {prefix}_{node_architecture}_{node_subarchitecture}_{release}_{node_name}
        {prefix}_{node_architecture}_{node_subarchitecture}_{release}
        {prefix}_{node_architecture}_{node_subarchitecture}
        {prefix}_{node_architecture}
        {prefix}
        'generic'
    

    Trouble Shooting


    During Commission Stage

    有個方法可以加入 backdoor 這個帳號, 就可以登入
    https://maas.ubuntu.com/docs/troubleshooting.html

    During Debian Installing

    http://www.informit.com/articles/article.aspx?p=1757616&seqNum=2

    The installer itself runs on virtual console 1. If you switch to console 2 by pressing Alt-F2, you'll be able to activate the console by hitting Enter and land in a minimalistic (busybox) shell. This will let you explore the complete installer environment and take some matters into your own hands if necessary. You can switch back to the installer console by pressing Alt-F1. Console 4 contains a running, noninteractive log file of the installation, which you can inspect by pressing Alt-F4. Finally, it's sometimes useful to be able to connect to another server during installation, perhaps to upload a log file or to gain access to your mailbox or other communication. By default, the shell on console 2 will not provide you with an ssh client, but you can install one by running anna-install openssh-client-udeb after the installer has configured the network. Now you can use the ssh and scp binaries to log in or copy data to the server of your choice.

    Reference


    Compare Razor/Crowbar/MAAS

    http://www.chenshake.com/design-of-the-razor/

    2013年12月31日 星期二

    2013 Study Target

    Python

    Linux

    Design Pattern

    重構 (Re-factoring)

      • 重構 - 改善既有程式的設計 (Refactoring: Improving The Design of Existing code) Martin Fowler著,侯捷/熊節 譯
      • Java重構 結城浩 著,江珮齡/王元綱 譯
      • 重構 - 向範式前進 (Refactoring to Pattterns) Joshua Kerievsky 著,侯捷/陳裕城 譯

    Storage

    Hypervisor

    Cloud

    演算法

    Programming Language

    NoSQL



    2013年11月6日 星期三

    Simple IO Performance Testing


    http://www.slashroot.in/linux-file-system-read-write-performance-test


    Seq Read
    Seq Write
    Rand Read
    Rand Write
    Advanced
    iozone
    V
    V
    V
    V
    V
    fio
    V
    V
    V
    V
    V
    dd
    V
    V



    hdparm
    V




    Bonnie
    V
    V
    V


    ioping

    V

    V


    Bonnie


    直接執行 Bonnie 就可以測試, 但不知道為什麼測試大小空間一定要 RAM * 2 的以上. 所以反而沒法很快的拿到測試結果

    $ bonnie++
    Writing a byte at a time...done
    Writing intelligently...done
    Rewriting...done
    Reading a byte at a time...done
    Reading intelligently...done
    start 'em...done...done...done...done...done...
    Create files in sequential order...done.
    Stat files in sequential order...done.
    Delete files in sequential order...done.
    Create files in random order...done.
    Stat files in random order...done.
    Delete files in random order...done.
    Version  1.96       ------Sequential Output------ --Sequential Input- --Random-
    Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
    Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
    pjack-VirtualBox 8G   575  96 36095   9 24925   7  3157  78 63170  13 101.3   9
    Latency             31959us    2665ms    1823ms     127ms     583ms    1354ms
    Version  1.96       ------Sequential Create------ --------Random Create--------
    pjack-VirtualBox    -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
                  files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                     16 13139  28 +++++ +++ 23059  36 21424  37 +++++ +++ 22344  36
    Latency             63809us    1600us     528us     656us     660us    1080us
    1.96,1.96,pjack-VirtualBox,1,1383799934,8G,,575,96,36095,9,24925,7,3157,78,63170,13,101.3,9,16,,,,,13139,28,+++++,+++,23059,36,21424,37,+++++,+++,22344,36,31959us,2665ms,18
    23ms,127ms,583ms,1354ms,63809us,1600us,528us,656us,660us,1080us
    
    

    iozone

    Iozone 有預設 13 種 pattern , 所以算是測試很齊全又不會太麻煩的工具
    官網:
    http://www.iozone.org/
    使用方式介紹:
    http://www.thegeekstuff.com/2011/05/iozone-examples/

    fio

    fio 則是擁有全功能, 可以自己設計 pattern, 又很多參數可以調整, 是很專業的工具, 但要寫 Script, 如果想要快速的拿到一些 performance report, 可能不是很好用, 之前也有介紹過
    http://pjack1981.blogspot.tw/2012/05/fio-disk-benchmark.html

    ioping

    https://code.google.com/p/ioping/
    很簡易的工具, 支援 seq/random write, 也可以指定 block size, 可以很快速的可以得到大概的狀況.


    2013年11月4日 星期一

    Import VirtualBox VM to ESXi Server


    Transfer VDI to VMDK

    先把 VDI 格式轉成 VMDK, 可以參考這篇, 如果原本的格式就是VMDK, 那可以跳過這一步
    http://www.dedoimedo.com/computers/virtualbox-convert.html

    把原來的 VM disk 換成 VMDK, 按下設定虛擬硬碟的 button, 選擇剛剛轉出來的 .vmdk 檔, 記得開機看看有沒有問題



    Export to OVF


    轉成 VMDK 檔之後, 其實也可以上傳到 ESXi Server 的 datastore 內, 然後生成 VM, 但我試的結果是可以正常開機, 但 snapshot 會有問題, 我猜想 ESXi Server 可能有他自己管理 VMDK 的方式來實作 snapshot, 直接這樣上傳會造成問題, 所以還是透過 OVF 檔較好
    http://tad-do.net/2012/01/30/converting-virtualbox-to-vmware-esxi/

    用 VirtualBox 匯出虛擬機器, 記得要改用 OVF 檔案, 把 XML 檔案獨立出來





    把 XML 獨立出來的原因是, VirtualBox 預設的硬體規格, 有些 Vmware 不支援, 或是要修改, 文字檔才有辦法用文字編輯器改, 主要要修改
    • SATA Controller => SCSI Controller
    • Turn off Sound Card

    如果 Import 還是遇到問題, 建議你可以先用 ESXi Server 做出一個空的機器, 然後 Export OVF, 交叉比對之後再把正確的值入, 像我要 Import 的系統是 Windows 2008 R2, 原來的 ovf:id=77 不支援, 修改成 103 後就可以用了.

    
          The kind of installed guest operating system
          Windows2008_64
          Windows2008_64
        
    


    20131105 Update

    另外還有一招比較慢, 但如果有遇到處理不了的, 都可以靠這個來解決, 大致上就是利用 ESXi Server 自行產生 OVF 檔, 再回覆回去

    1. Transfer VDI to VMDK
    2. import VMDK to ESXi Server
    3. export VM as OVF template
    4. import OVF template