| 1 | [[PageOutline]] |
| 2 | {{{ |
| 3 | #!html |
| 4 | <h1 style="text-align: center; color: blue">XCP 安裝</h1> |
| 5 | }}} |
| 6 | ---- |
| 7 | = 【前言】 = |
| 8 | == [0. 設備需求] == |
| 9 | * x86 機器 (單台機器最多 128GB RAM、6 張網卡、32 Cores) (若要使用 windows VM,CPU必須支援 Intel-VTx 或 AMD-V) |
| 10 | == [1. 檔案下載] == |
| 11 | 從 Xen 官方網站下載 ISO 檔 [http://www.xen.org/files/XenCloud/Software/latest/main.iso Base Package],安裝路徑有兩種一是燒成 CD 來安裝,二是用 PXE 安裝。若之後只要開啟 Windows VM 只需安裝一片即可,若要開啟 Linux VM 則必須再安裝第2個 [http://www.xen.org/files/XenCloud/Software/latest/ddk.iso Linux Package]。 |
| 12 | == [2. 安裝程序] == |
| 13 | * 安裝過程中,可以切換到三個 terminal -> Alt+F1:安裝畫面,Alt+F2:事件log檔,Alt+F3:控制console |
| 14 | * 安裝 log 可到 /install/tmp/ 查詢 |
| 15 | * 開機選單也是使用 mboot.c32 |
| 16 | == [3. 儲存機制] == |
| 17 | * XCP 提供三種儲存機制: |
| 18 | 1. local |
| 19 | 2. NFS |
| 20 | 3. iSCSI |
| 21 | == [4. 操作程序] == |
| 22 | ---- |
| 23 | = 【利用 PXE 佈署 XCP】 = |
| 24 | == [1. 前言] == |
| 25 | * 因 XCP 提供 PXE 安裝的方式,此部份可與 DRBL 結合 (透過 DRBL 來方便設置 PXE Installation) |
| 26 | * 官方描述建制 PXE Installation 需要: |
| 27 | 1. TFTP Server |
| 28 | 2. DHCP Server |
| 29 | 3. NFS, FTP, or TFTP Server (放置安裝檔案) |
| 30 | 4. XML answer file (自動執行 unattended installations) |
| 31 | 5. 機器必須有支援 PXE 的網卡 |
| 32 | == [2. 官方設定步驟] == |
| 33 | === __2.1 設定 TFTP 能支援 PXE 開機__ === |
| 34 | 1. 需有 SYSLINUX 3.11 以上的版本,從 /usr/lib/syslinux 複製 mboot.c32 和 pxelinux.o 到 tftp 設定的路徑下(這邊是 /tftpboot) |
| 35 | 2. 從 Base Package 的 /boot 複製 install.img、Vmlinuz 和 xen.gz 到 /tftpboot/xenserver |
| 36 | 3. 建立 /tftpboot/pxelinux.cfg 資料夾,並開啟一個檔案為 /tftpboot/pxelinux.cfg/default |
| 37 | {{{ |
| 38 | $ sudo vim /tftpboot/pxelinux.cfg/default |
| 39 | default xenserver |
| 40 | label xenserver |
| 41 | kernel mboot.c32 |
| 42 | append /tftpboot/xenserver/xen.gz dom0_mem=752M com1=115200,8n1 \ |
| 43 | console=com1,tty --- /tftpboot/xenserver/vmlinuz \ |
| 44 | xencons=hvc console=hvc0 console=tty0 \ |
| 45 | --- /tftpboot/xenserver/install.img |
| 46 | }}} |
| 47 | 4. 上面的安裝程序必須由人來確認每一個步驟,底下可加入 answer file 來做到無人自動安裝 |
| 48 | {{{ |
| 49 | # sudo vim /tftpboot/pxelinux.cfg/default |
| 50 | default xenserver-auto |
| 51 | label xenserver-auto |
| 52 | kernel mboot.c32 |
| 53 | append /tftpboot/xenserver/xen.gz dom0_mem=752M com1=115200,8n1 \ |
| 54 | console=com1,tty --- /tftpboot/xenserver/vmlinuz \ |
| 55 | xencons=hvc console=hvc0 console=tty0 \ |
| 56 | answerfile=http://pxehost.example.com/5.0.0-answerfile \ |
| 57 | install --- /tftpboot/xenserver/install.img |
| 58 | }}} |
| 59 | === __2.2 設定 DHCP__ === |
| 60 | 1. 安裝 DHCP Server |
| 61 | 2. 編輯 dhcpd.conf |
| 62 | {{{ |
| 63 | $ sudo vim /etc/dhcp/dhcpd.conf |
| 64 | allow booting; |
| 65 | allow bootp; |
| 66 | class "pxeclients" { |
| 67 | match if substring(option vendor-class-identifier, 0, 9) = "PXEClient"; |
| 68 | next-server ; |
| 69 | filename "pxelinux.0"; |
| 70 | } |
| 71 | }}} |
| 72 | === __2.3 設定安裝檔案位置__ === |
| 73 | 1. 可用 http, ftp 和 nfs |
| 74 | 2. Base package 的 packages.main 目錄複製出來, |
| 75 | 3. 若要開啟 Linux VM,必須複製 Linux Package 的 packages.linux 目錄出來 |
| 76 | 4. 將路徑寫於 answaer file (XML 檔) 的 source 標籤內(底下有三種寫法) |
| 77 | {{{ |
| 78 | #!sh |
| 79 | # 安裝 Base 和 Linux Packages |
| 80 | <source type="url">http://pxehost.example.com/XenServer_5.0.0</source> |
| 81 | |
| 82 | # 只安裝 Base Package |
| 83 | <source type="url"> |
| 84 | http://pxehost.example.com/XenServer_&PRODUCT_VERSION;/packages.main |
| 85 | </source> |
| 86 | |
| 87 | # 可加上帳密 |
| 88 | <source type="url"> |
| 89 | http://<username>:<password>@pxehost.example.com/XenServer_0.1/packages.main |
| 90 | <source> |
| 91 | }}} |
| 92 | === __2.4 Answer File 編輯__ === |
| 93 | * 範例檔 (一定要有 installation tag) |
| 94 | {{{ |
| 95 | #!sh |
| 96 | <?xml version="1.0"?> |
| 97 | <installation> |
| 98 | <primary-disk>sda</primary-disk> |
| 99 | <guest-disk>sdb</guest-disk> |
| 100 | <guest-disk>sdc</guest-disk> |
| 101 | <keymap>us</keymap> |
| 102 | <root-password>mypassword</root-password> |
| 103 | <source type="url">http://pxehost.example.com</source> |
| 104 | <post-install-script type="url"> |
| 105 | http://pxehost.example.com/myscripts/post-install-script |
| 106 | </post-install-script> |
| 107 | <admin-interface name="eth0" proto="dhcp" /> |
| 108 | <timezone>Europe/London</timezone> |
| 109 | </installation> |
| 110 | }}} |
| 111 | * 範例檔 tag 介紹 |
| 112 | || 標籤 || 說明 || 是否必要|| |
| 113 | || <primary-disk> || 要安裝的 storage device,也可以給予 gueststorage 屬性值(yes/no) [[BR]] <rimary-disk gueststorage="no">sda</primary-disk> [[BR]] 此屬性質預設為 yes,之後在 guest-disk 必須給予值 || Y || |
| 114 | || <guest-disk> || 儲存 guest VM 的印象檔 || N || |
| 115 | || <keymap> || 安裝時使用的 keymap 一般都是使用美國鍵盤 <keymap>us</keymap> || Y || |
| 116 | || <root-password> || 設定 root 密碼 || Y || |
| 117 | || <source> || packages 的安裝路徑,屬性值有 url, nfs 或 local: [[BR]] <source type="url"> [[BR]] !http://server/packages [[BR]] </source> [[BR]] <source type="local" /> [[BR]] <source type="nfs"> [[BR]] server:packages [[BR]] </source> || Y || |
| 118 | || <driver-source> || 安裝設備的 driver 套件路徑,屬性值有 url, nfs 或 local: [[BR]] <driver-source type="url"> [[BR]] !http://server/drivers [[BR]] </driver-source> [[BR]] <driver-source type="local" /> [[BR]] <driver-source type="nfs"> [[BR]] server:drivers [[BR]] </driver-source> || N || |
| 119 | || <post-install-script> || post-install-script 的路徑,屬性值有 url, nfs 或 local: [[BR]] <post-install-script type="url"> [[BR]] !http://server/scripts [[BR]] </post-install-script> [[BR]] <post-install-script type="local" /> [[BR]] <post-install-script type="nfs"> [[BR]] server:scripts [[BR]] </post-install-script>|| Y || |
| 120 | || <admin-interface> || 需要使用的網路設備,屬性值有 proto:dhcp或static, name:eth0,當 proto="static" 時的子屬性值有 [[BR]] <ip> <subnet-mask> <gateway> || N || |
| 121 | || <time_zone> || TZ 變數 ex. Europe/London, or America/Los_Angeles || Y || |
| 122 | || <name_server> || 可設定己組的 name server || N || |
| 123 | || <hostname> || 主機名稱 || N || |
| 124 | || <bootloader> || 可指定要安裝那種 bootloader (目前有兩個有選,預設是 extlinux 和 grub) || N || |
| 125 | * 也可透過 answer file 來做到自動更新 (需設定 reinstall 和 existing-installation) |
| 126 | {{{ |
| 127 | #!sh |
| 128 | <?xml version="1.0"?> |
| 129 | <installation mode="reinstall"> |
| 130 | <existing-installation>sda</existing-installation> |
| 131 | <keymap>us</keymap> |
| 132 | <root-password>mypassword</root-password> |
| 133 | <source type="url">http://pxehost.example.com</source> |
| 134 | <post-install-script type="url"> |
| 135 | http://pxehost.example.com/myscripts/post-install-script |
| 136 | </post-install-script> |
| 137 | <admin-interface name="eth0" proto="dhcp" /> |
| 138 | <timezone>Europe/London</timezone> |
| 139 | </installation> |
| 140 | }}} |
| 141 | ---- |
| 142 | = 【利用 DRBL 佈署 XCP】 = |