| 1 | {{{ |
| 2 | #!html |
| 3 | <div style="text-align: center; color: blue"><big |
| 4 | style="font-weight: bold;"><big><big>Xen + OpenNebula vm cluster study</big></big></big></div> |
| 5 | }}} |
| 6 | [[PageOutline]] |
| 7 | |
| 8 | * 產生完的印象檔會放在 /home/domains 內,而設定檔則會放在 /etc/xen/ |
| 9 | |
| 10 | = 一、 安裝xen = |
| 11 | |
| 12 | {{{ |
| 13 | $ sudo apt-get -y install ubuntu-xen-desktop gcc-4.1 python-xml xen-tools |
| 14 | $ cd |
| 15 | $ mkdir Xen_Kernel && cd Xen_Kernel |
| 16 | $ wget http://trac.nchc.org.tw/grid/export/110/Xen/dom0_Kernel/linux-2.6.26-xen-amd64.tar.bz2 |
| 17 | $ tar jxvf linux-2.6.26-xen-amd64.tar.bz2 |
| 18 | $ sudo dpkg -i ./*.deb |
| 19 | |
| 20 | }}} |
| 21 | |
| 22 | == 1.1 修改設定檔 == |
| 23 | |
| 24 | * 修改設定檔 /etc/xen/xend-config.sxp |
| 25 | |
| 26 | {{{ |
| 27 | #!text |
| 28 | 56 (xend-http-server yes) |
| 29 | 58 (xend-tcp-xmlrpc-server yes) |
| 30 | 61 (xend-relocation-server yes) |
| 31 | 70 (xen-tcp-xmlrpc-server-port 8006) |
| 32 | 80 (xend-port 8000) |
| 33 | 84 (xend-relocation-port 8002) |
| 34 | 121 (xend-relocation-hosts-allow '') |
| 35 | 122 #(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$') |
| 36 | }}} |
| 37 | |
| 38 | == 1.2 更新grub以及重開機選定xen kernel == |
| 39 | |
| 40 | * 更新grub以及重開機選定xen kernel |
| 41 | |
| 42 | {{{ |
| 43 | $ sudo update-grub ; sync ; sudo reboot |
| 44 | }}} |
| 45 | |
| 46 | = 二、使用xen的原生方法新增刪除虛擬機器 = |
| 47 | |
| 48 | == 2.0 檢查xen是否啟動 == |
| 49 | |
| 50 | {{{ |
| 51 | $ ps -aux | grep xend |
| 52 | }}} |
| 53 | |
| 54 | == 2.1 修改 xen-tools.conf == |
| 55 | |
| 56 | * 修改 /etc/xen-tools/xen-tools.conf |
| 57 | |
| 58 | {{{ |
| 59 | #!text |
| 60 | 45 dir = /home |
| 61 | 128 size = 1Gb |
| 62 | 133 dist = lenny |
| 63 | 163 gateway = 192.168.100.254 |
| 64 | 164 netmask = 255.255.255.0 |
| 65 | 165 broadcast = 192.168.100.255 |
| 66 | 193 accounts = 1 |
| 67 | 214 mirror = http://free.nchc.org.tw/debian |
| 68 | 257 serial_device = hvc0 |
| 69 | |
| 70 | }}} |
| 71 | |
| 72 | == 2.2 新增xen的image == |
| 73 | |
| 74 | * 新增xen的image |
| 75 | |
| 76 | {{{ |
| 77 | $ sudo xen-create-image --hostname=vm01 --ip=192.168.100.106 --mac=00:16:01:01:01:01 --force |
| 78 | ...(跑很久是正常的) |
| 79 | }}} |
| 80 | |
| 81 | * 產生完的印象檔會放在 /home/domains 內,而設定檔則會放在 /etc/xen/ |
| 82 | * 檢查 /etc/xen/vm01.cfg 的 ip 與 mac 對應是否如之前所設 (若此檔沒設定正確,則產生的vm無法上網) |
| 83 | |
| 84 | == 2.3 用xm create開啟一個虛擬機器 == |
| 85 | |
| 86 | * 接下來我們使用此 vm01 的設定檔來開啟一個虛擬機器 |
| 87 | * 使用 xm create 指令根據設定檔來開啟虛擬機器 |
| 88 | |
| 89 | {{{ |
| 90 | $ sudo xm create /etc/xen/vm01.cfg |
| 91 | }}} |
| 92 | |
| 93 | * 檢查此 vm01 是否正常開啟 |
| 94 | |
| 95 | {{{ |
| 96 | $ sudo xm list |
| 97 | Name ID Mem VCPUs State Time(s) |
| 98 | Domain-0 0 697 4 r----- 2668.5 |
| 99 | one-8 9 156 1 -b---- 2.2 |
| 100 | }}} |
| 101 | |
| 102 | |
| 103 | == 2.4 用xm console登入此虛擬機器 == |
| 104 | |
| 105 | * 如何登入此虛擬機器呢 (使用 xm console) |
| 106 | |
| 107 | {{{ |
| 108 | $ sudo xm console vm01 |
| 109 | }}} |
| 110 | |
| 111 | == 2.5 用CTRL+] xm console 登出虛擬機器 == |
| 112 | |
| 113 | * 登出跳出鍵 : '''CTRL+]''' |
| 114 | |
| 115 | = 三、使用OpenNebula 管理叢集的vm = |
| 116 | |
| 117 | |
| 118 | * hostname hosts 需要完全正確對應 |
| 119 | * 兩台電腦的免密碼設定完成 (root ) |
| 120 | * 兩台電腦都要作 '''一、安裝xen '''的步驟,並且正確使用xen的kernel開機完成 |
| 121 | * 只需要作'''一'''(不要作二、) |
| 122 | |
| 123 | == 3.0 步驟二的清除方法 == |
| 124 | |
| 125 | * 若已經執行過'''二、使用xen...''',需將之前開啟的虛擬機器給移除 |
| 126 | |
| 127 | {{{ |
| 128 | $ sudo xm destroy {vm_name} |
| 129 | $ sudo xm list |
| 130 | }}} |
| 131 | |
| 132 | == 3.1 安裝opennebula == |
| 133 | |
| 134 | * 安裝opennebula |
| 135 | |
| 136 | {{{ |
| 137 | $ cd ~ |
| 138 | $ sudo aptitude install ruby sqlite3 libsqlite3-0 libsqlite3-dev libsqlite3-ruby libxmlrpc-c3 libxmlrpc-c3-dev scons g++ flex bison |
| 139 | $ wget http://opennebula.org/files/one-1.2.1.tar.gz |
| 140 | $ tar zxvf one-1.2.1.tar.gz |
| 141 | }}} |
| 142 | |
| 143 | == 3.2 修改 XenDriver.cc== |
| 144 | |
| 145 | * 修改 ~/one-1.2.1/src/vmm/XenDriver.cc |
| 146 | |
| 147 | {{{ |
| 148 | #!text |
| 149 | 237 << "'file:" << vm->get_remote_dir() << "/disk." << i << "," |
| 150 | }}} |
| 151 | |
| 152 | == 3.3 執行 scons |
| 153 | |
| 154 | {{{ |
| 155 | $ cd ~/one-1.2.1 |
| 156 | $ sudo scons |
| 157 | $ sudo ./install.sh |
| 158 | }}} |
| 159 | |
| 160 | == 3.4 修改 oned.conf == |
| 161 | |
| 162 | * 修改 /etc/one/oned.conf |
| 163 | |
| 164 | {{{ |
| 165 | #!text |
| 166 | 23 VM_POLLING_INTERVAL = 1 |
| 167 | |
| 168 | 160 # TM_MAD = [ |
| 169 | 161 # name = "tm_ssh", |
| 170 | 162 # executable = "one_tm", |
| 171 | 163 # arguments = "tm_ssh/tm_ssh.conf", |
| 172 | 164 # default = "tm_ssh/tm_ssh.conf" ] |
| 173 | |
| 174 | |
| 175 | 169 TM_MAD = [ |
| 176 | 170 name = "tm_nfs", |
| 177 | 171 executable = "one_tm", |
| 178 | 172 arguments = "tm_ssh/tm_nfs.conf", |
| 179 | 173 default = "tm_ssh/tm_nfs.conf" ] |
| 180 | }}} |
| 181 | |
| 182 | == 3.5 用onehost 增加one的節點資訊 == |
| 183 | |
| 184 | * 用onehost 增加one的節點資訊 |
| 185 | * 注意用 root權限 |
| 186 | |
| 187 | {{{ |
| 188 | $ sudo su - |
| 189 | # one start |
| 190 | # onehost add node01 im_xen vmm_xen tm_nfs |
| 191 | # onehost add node02 im_xen vmm_xen tm_nfs |
| 192 | # onehost list |
| 193 | }}} |
| 194 | |
| 195 | == 3.6 建立設定檔 vm01.one == |
| 196 | |
| 197 | * 建立新檔 /home/domains/vm01.one |
| 198 | * 注意kernel 的資訊需要與grub一樣 |
| 199 | * ip 與 mac 的資訊可與2.2相同 |
| 200 | |
| 201 | {{{ |
| 202 | #!text |
| 203 | NAME = vm01 |
| 204 | CPU = 1 |
| 205 | MEMORY = 156 |
| 206 | OS = [ kernel = /boot/vmlinuz-2.6.26-2-xen-amd64, |
| 207 | initrd = /boot/initrd.img-2.6.26-2-xen-amd64, |
| 208 | root = sda2] |
| 209 | DISK = [ source = /home/domains/vm01/disk.img, |
| 210 | clone = no, |
| 211 | target = sda2, |
| 212 | readonly = no] |
| 213 | DISK = [ type = swap, |
| 214 | size = 128, |
| 215 | target = "sda1", |
| 216 | readonly = "no" ] |
| 217 | NIC=[IP="192.168.100.106", MAC="00:16:01:01:01:01"] |
| 218 | }}} |
| 219 | |
| 220 | == 3.7 用onevm vm01.one == |
| 221 | |
| 222 | * 使用 ONE 來開啟 vm01 |
| 223 | |
| 224 | {{{ |
| 225 | # cd /home/domains/ |
| 226 | # onevm create vm01.one |
| 227 | # onevm list |
| 228 | ID NAME STAT CPU MEM HOSTNAME TIME |
| 229 | 8 vm01 runn 0 159744 node01 00 01:18:59 |
| 230 | }}} |