Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ซอฟต์แวร์ >> เครื่องเสมือน

Advanced Xen Troubleshooting Guide: แก้ไขปัญหา Display, Python และ Service Issues ทั่วไป

เรามี tutorial หนึ่งเกี่ยวกับ several common Xen problems ที่อาจเกิดขึ้นเมื่อคุณลองและ test Xen ใน environment ของคุณ First batch ของ tips และ tricks focus บนปัญหา display, Python versions และ modules, changing wrapper scripts และ running explicit commands และ troubleshooting services

วันนี้ เรา dive deeper (ดำน้ำลึก/ลงลึก) และพยายาม understand, fix และ work around several more problems ที่คุณ may or may not have encountered (อาจจะหรืออาจไม่ได้เจอ) ผมต้อง admit (ยอมรับ) ว่า some of the solutions could be a little ad-hoc (แก้ปัญหาเฉพาะจุด/ไม่เป็นระบบ) ดังนั้น don't take my word for it (อย่าเชื่อคำของผมเลย) แต่ผม believe (เชื่อ) ว่ามัน work well overall หวังว่า Xen experience ของคุณจะ more zenny (มากขึ้น/ดีขึ้น - zenny อาจมาจาก zen) หลังจากอ่านนี้

Tip 1: VNC connection to hypervisor host got refused or disconnected

หลังจาก start Virtual Machine Manager (virt-manager) คุณมี option ที่จะ view contents ของ VMs โดยใช้ VNC ซึ่งจะ display contents ของ console ของ relevant domain Now and then (บางครั้ง) console อาจ turn blank (กลายเป็นหน้าจอว่าง) และ thrown error เขียนใน title ด้านบน คำถามคือ ทำไงตอนนี้?

My experience shows (ประสบการณ์ของผมแสดง) ว่านี้จะ happen (เกิดขึ้น) any time (ทุกครั้ง) guest OS restarted หรือ shutdown หนึ่งครั้งคุณ power it on again (เปิดใหม่) คุณจะ have to most inconveniently (อย่างไม่อยู่อย่างสะดวก) reopen console เพื่อ view he contents (เนื้อหา - typo ในต้นฉบับ) same occurs (เกิดขึ้นเหมือนกัน) หากคุณใช้ virt-viewer:

virt-viewer <domain>

Once domain rebooted, reset หรือ powered off คุณจะ lose connection ณ เวลานี้ simple solution คือ reopen console window ไม่ว่าจะผ่าน virt-manager หรือ virt-viewer

Alternatively (ทางเลือก) เพื่อ establish connection:

virsh vncdisplay <domain>
vncviewer <hostname:port returned by virsh command>

Tip 2: vif disappears while guest running, no more networking

อาจเกิดขึ้นที่ while VM ของคุณ running virtual network interface ปกติ labeled vifX.X จะ disappear จาก ifconfig list ทำให้ guest กลายเป็น useless brick (อิฐไร้ประโยชน์)

ปัญหาอาจ manifest ใน relevant network interface MAC address ภายใน VM กลายเป็น all zeros และบน host (dom0) คุณอาจเห็น entries ประเภทนี้ใน /var/log/messages:

kernel: [ 109.743854] br0: port 2(vif1.0) entering learning state
kernel: [ 109.811880] br0: port 3(tap1.0) entering learning state
kernel: [ 117.369189] br0: port 3(tap1.0) entering disabled state
kernel: [ 117.398076] device tap1.0 left promiscuous mode
kernel: [ 117.398083] br0: port 3(tap1.0) entering disabled state
kernel: [ 117.815006] br0: port 2(vif1.0) entering disabled state
kernel: [ 117.850075] br0: port 2(vif1.0) entering disabled state

So how do you go about fixing something like this? (จะแก้อย่างไร?) มี several options หนึ่ง kernel upgrade ที่อาจ mysteriously (ลึกลับ/ไม่รู้สาเหตุ) resolve ปัญหา well not so mysteriously more like fixing race conditions ใน Xen networking stack

Second option คือ try to tweak network settings ใน Xen configuration file อยู่ที่ /etc/xen/xend-config.sxp ไฟล์นี้มี directives ทุกประเภท รวมถึง how to setup bridge และ virtual network interfaces Many claim (หลายคนอ้าง) ว่า networking somewhat buggy และคุณควร manually configure your own scripts

In particular (โดยเฉพาะ) เปลี่ยน directives ต่อไปนี้:

(network-script network-bridge) to (network-script )

อีกทั้ง คุณควร manually configure bridge ของคุณ ระหว่าง testing คุณควรใช้ brctl และ ifconfig commands และ once you're confident (เมื่อคุณมั่นใจ) ว่า changes solid (แน่นอน/มั่นคง) คุณควร permanently commit (ยืนยันถาวร) พวกมันไปที่ network scripts ของคุณ บน RedHat และ SUSE systems นี้หมายถึง creating ifcfg-br<number> และ changing existing network scripts สำหรับ network cards ภายใต้ /etc/sysconfig/network และบน Debian-based systems edit /etc/interfaces configuration file Needless to say (ไม่อาจพูดได้/มובן מאลיו) backups are a must

ตัวอย่าง manual bridge configuration:

brctl addbr br0
brctl setfd br0 0
ifconfig br0 10.0.0.128 up netmask 255.255.255.0
brctl addif br0 eth0
route add -net default gw 10.0.0.254 br0
ifconfig eth0 0.0.0.0 up

Next on the menu (ต่อไปในเมนู) increasing หรือ decreasing number of netloops ซึ่งหมายถึง how many pairs of virtual devices can be created หากคุณ run into upper limit (เจอขีดจำกัดบน) คุณอาจอยาก increase number นี้ ทำได้โดยสร้าง file ชื่อ netloop ภายใต้ /etc/modprobe.d และเขียนข้างใน:

option netloop nloopbacks=<some high number, e.g. 16, 32>

หรือแค่เพิ่ม option นี้ไปที่ /etc/modprobe.conf

Quite a bit more reading on this topic: (อ่านเพิ่มเติมมากกว่านี้เกี่ยวกับหัวข้อนี้:)

Xen networking

Xen network bridges explained with troubleshooting notes

SLES networking under xen, troubleshooting and recommendations

Hassle-free Xen networking

Linux networking sucks. XEN networking sucks.

Creating additional Xen virtual network bridges

หากคุณ happen to encounter (มีโอกาสเจอ) kernel crashes เมื่อสิ่งนี้เกิดขึ้น สอง links นี้อาจ somewhat of interest (น่าสนใจนิดหน่อย) beware the ultra-geekiness (ระวังความเฉพาะทางมาก):

Kernel BUG at mm/vmalloc.c:2165

[PATCH] mm: sync vmalloc address space page tables in alloc_vm_area()

The problem may actually be resolved by reducing the number of netloops to zero (ปัญหาอาจแก้ได้จริงๆโดยการลด netloops เหลือศูนย์)

Tip 3: Enable legacy HTTP access

libvirt makes HTTP redundant (ซ้ำซ้อน/ไม่จำเป็น) เมื่อพูดถึง connecting to dom0 และ managing ทั้ง locally และ remotely อย่างไรก็ตาม some of you might be interesting in this option (อาจสนใจตัวเลือกนี้) โดยเฉพาะหากคุณ intend to use (ตั้งใจใช้) tools like OpenXenManager ซึ่งใช้ HTTP/HTTPS เพื่อ connect เพื่อ make Xen accessible from the Web (ทำให้ Xen เข้าถึงได้จากเว็บ) คุณต้อง edit several directives ใน xend-config.sxp configuration file:

(xend-http-server yes)
(xend-port 8000)
(xend-address '')

Change no เป็น yes สำหรับ xend-http-server และ specify correct port xend-address ระบุ IP address ของ network interface ที่ Xend จะ listen on หากคุณ leave default empty quotation marks (ทิ้งเครื่องหมายคำพูดว่างไว้) มันจะ listen on all available interfaces ต่อไป reload configuration file:

/etc/init.d/xend reload

และจากนั้นคุณสามารถ test Web access:

Tip 4: ERROR: unable to connect to 'localhost:8000': Connection refused

A corollary (สาเหตุ/ผลลัพธ์ที่ตามมา) ของ tip ข้างต้นคือ คุณอาจได้ ugly connection refused error เมื่อพยายาม connect to dom0 ใช้ virt-manager Python notorious for (มีชื่อเสียงในทางร้าย) being verbose (ยาวเหลือ/รวดเร็ว) ดังนั้น be prepared for ugliness (เตรียมพร้อมสำหรับความน่ารังเกียจ)

To resolve this problem (เพื่อแก้ปัญหานี้) คุณอาจต้อง enable HTTP access หรือทางเลือก คุณต้องถามตัวเองว่าทำไมสิ่งนี้ถึงเกิดขึ้นใน first place (ตอนแรก/ต้นเหตุ) Most likely reason (เหตุผลที่น่าจะเป็นไปได้มากที่สุด) คือ one of Xen services not running ซึ่ง forces (บังคับ) virt-manager fall back to legacy access หากคุณไม่ wish to use (ไม่อยากใช้) HTTP protocol คุณอาจอยาก make sure (ให้แน่ใจ) ว่า system boots with all relevant Xen services โดยเฉพาะ libvirtd และ xend

Tip 5: domU startup errors

เมื่อคุณพยายาม power on domains ด้วย xm create <domain> หรือ xm start <domain> คุณอาจเจอ several error messages ที่อาจ anger หรือ confuse คุณ มาลอง dissect (แยกวิเคราะห์) บางอย่างและเข้าใจว่าปัญหาอาจเป็นอะไร

#xm start test1
Error: Domain unable to be unpaused: an integer is required
Usage: xm start <DomainName>

และ graphical equivalent (ค่าเทียบเท่าทางกราฟิก):

นี่ normally means (ปกติหมายถึง) คุณ specified non-existent หรือ unsupported hardware component เช่น network card หรือ sound card โปรด review domain configuration file ปกติ stored under /etc/xen/vm สำหรับ errors คุณอาจอยาก consult /var/log/messages และ Xen error log - /var/log/xen/xend.log

นี่คืออีกอัน:

#xm create test1
Using config file "./test1".
Error: (2, 'Invalid kernel', "elf_xen_note_check: ERROR: Not a Xen-ELF image: No ELF notes or '__xen_guest' section found.\n")

นี่ could happen (อาจเกิดขึ้น) หากคุณพยายาม power on paravirtualized guest ใช้ HVM kernel settings ใน domain configuration file fairly trivial to debug and resolve (ค่อนข้างง่ายที่จะ debug และ resolve)

#xm create test1
Using config file "./test1".
Error: Device 768 (vbd) could not be connected.
File /tmp/disk.raw is loopback-mounted through /dev/loop1,
which is mounted in a guest domain,
and so cannot be mounted now.

คุณอาจเห็นนี้หากพยายาม reuse hard disk file ที่ already in use by another VM หรือทางเลือก คุณอาจ mount มันเป็น loopback device ที่ไหนสักแห่งเพื่อ inspect (ตรวจสอบ) innards (ภายใน)

Speaking of vbd errors นี่คืออีกอัน:

#xm create test1
Using config file "./test1".
Error: Device 5632 (vbd) could not be connected. Device not found.

A variation of this kind of message shown in xend.log:

DEBUG (DevController:139) Waiting for devices vscsi.
DEBUG (DevController:139) Waiting for devices vbd.
DEBUG (DevController:144) Waiting for 768.
WARNING (XendDomain:1076) Failed to setup devices for <domain id=None name=test1 memory=4294967296 state=halted>: Device 768 (vbd) could not be connected. Device not found.

Reasons ที่นี่อาจเป็น badly specified hard disk file หรือ again (อีกครั้ง) bad use of some device น่าจะ due to spelling error (เพราะข้อผิดพลาดการสะกด) นี้ similar to first error listed above

Now (ตอนนี้) one question that may arise (คำถามที่อาจขึ้น) คือ how to know what kind of device vbd is? (รู้ยังไงว่า vbd เป็น device ประเภทไหน?) As the simplest workaround (ในฐานะ workaround ที่ง่ายที่สุด) คุณสามารถ verify this (ตรวจสอบสิ่งนี้) บน any one booted Xen domU All of the devices can be found under /sys/devices/xen/ ตัวอย่าง:

#cat /sys/devices/xen/vbd-768/block/hda/hda1/dev
3:1

ที่นี่เราเห็น vbd-768 เป็น block device with major number 3 ดังนั้น hda1 corresponds to (ตรงกับ) 3:1 ซึ่ง stand to logic (สมเหตุสมผล) More about this nomenclature (การตั้งชื่อ) in a sec (ในหนึ่งวินาที/เร็วๆนี้)

และ complete listing สำหรับ particular VM:

#ll
total 0
drwxr-xr-x 2 root root 0 Dec 18 12:07 power
-rw-r--r-- 1 root root 4096 Dec 18 12:07 uevent
drwxr-xr-x 4 root root 0 Dec 18 12:05 vbd-5632
drwxr-xr-x 4 root root 0 Dec 18 12:05 vbd-768
drwxr-xr-x 3 root root 0 Dec 18 12:05 vfb-0
drwxr-xr-x 4 root root 0 Dec 18 12:05 vif-0

The more complex way (วิธีที่ซับซ้อนกว่า) คือ translate number to hexadecimal (ฐานสิบหก) และใช้ two least significant bits (two bits ที่น้อยที่สุด) สำหรับ minor number และ remaining higher bits (bits สูงกว่าที่เหลือ) เป็น major number จากนั้น refer to (อ้างอิง) devices.txt list either online หรือ under /usr/src/linux/Documentation เพื่อ decipher (ถอดรหัส) exact device type ตัวอย่าง 768 decimal คือ x0300 hexa หมายถึง major number 3, minor number 0 นี้ translate into (แปลงเป็น) first (zero) IDE device หรือ hda Likewise (เช่นเดียวกัน) 5632 translate into x1600 หมายถึง major, minor 16,00 combination ซึ่งสำหรับ block devices คือ CD-ROM Jolly well (ดีมาก/สุขสันต์) no? (ใช่ไหม?) Old Xen mailing list thread นี้อาจ also be of interest (น่าสนใจอีกด้วย)

Tip 6: Advanced settings (การตั้งค่าขั้นสูง)

Finally (สุดท้าย) something lightweight (เบา/ไม่หนัก) เมื่อ boot guests ของคุณ คุณอาจอยาก tweak some of the advanced settings ตัวอย่าง คุณอาจสนใจ PAE หรือ OpenGL คุณควร mark correct options ใน VM wizard หรือทางเลือก หากคุณ well familiar with (คุ้นเคยดี) command line และ VM files แค่ add correct strings ที่นั่น

Last, unlisted tip (เคล็ดลับสุดท้ายที่ไม่ได้ list) คือ setting up multi-boot systems with GRUB2 in charge ไม่มีอะไรใหม่ เราพูดถึงใน introduction article โปรด hop there (กระโดดไปที่นั่น) และ take a look

And we shall end here today (และวันนี้เราจะจบที่นี่)

สรุป

ผม believe (เชื่อ) ว่า any tool written in Python designed with as much error verbosity (ความ冗长ของข้อผิดพลาด) as possible just to spite (ทำให้เสียใจ/ขยี้) administrators และ annoy (รำคาญ) พวกเขา Xen falls within this category (อยู่ในหมวดหมู่นี้) with some fairly profuse (มาก/อุดม) และ inelegant (ไม่สง่างาม) messages เกี่ยวกับปัญหาที่มัน facing (เผชิญ) Not trivial (ไม่ได้ trivial) to say the least (อย่างน้อย)

Still hopefully (ยังหวังว่า) tutorial นี้ of some use to you (มีประโยชน์บ้าง) ผมต้อง admit (ยอมรับ) ว่ามี quite a bit of margin for error (ช่วงที่อาจผิดพลาดได้มาก) ที่นี่ คุณ may very well (อาจจะ) try to apply these suggestions และ fail miserably (ล้มเหลวอย่างน่าสงสาร) feeling anger and disappointment (รู้สึกโกรธและผิดหวัง) This is because (นี่เป็นเพราะ) there are truly hundreds of different scenarios ที่ could inflict (ส่งผลให้บาดเจ็บ/ทำให้เกิดปัญหา) คุณ แต่ละอัน ever so slightly different (ต่างกันนิดหน่อย) Regardless (ไม่ว่า/อย่างไรก็ตาม) some of the tips should be useful How to work around VNC disconnects, how to investigate network problems, various errors และ configuration problems และ more Well that would be all (นั่นคือทั้งหมดแล้ว) see you around (แล้วเจอกันใหม่)

ขอแสดงความนับถือ