# To create one using the VNC backend and sensible defaults:
#
# vfb = [ 'type=vnc' ]
#
# The backend listens on 127.0.0.1 port 5900+N by default, where N is
# the domain ID. You can override both address and N:
#
# vfb = [ 'type=vnc,vnclisten=127.0.0.1,vncdisplay=1' ]
#
# Or you can bind the first unused port above 5900:
#
# vfb = [ 'type=vnc,vnclisten=0.0.0.0,vncunused=1' ]
#
# You can override the password:
#
# vfb = [ 'type=vnc,vncpasswd=MYPASSWD' ]
#
# Empty password disables authentication. Defaults to the vncpasswd
# configured in xend-config.sxp.
vfb = [ 'type=vnc,vncdisplay=10,vncpasswd=s3cr3t' ]
DomU:
1、根文件系统;
2、kernel及ramdisk;
Dom0:外部
DomU: 内部
xm
create
destroy
shutdown
console
list
network-attach
network-detach
block-attach
block-detach
delete:删除虚拟机
pause: 暂停
unpause: 从暂停中恢复
suspend: 挂起
resume: 从挂起中恢复;
save: 保存状态至文件中
restore: 从保存状态中恢复
top: 资源使用状态监控
info: 查看主机相关信息,如内存等;
批量部署DomU:
准备一个映像模版:
OZ: 辅助创建映像模版;
脚本:
生成一个配置文件/etc/xen
下载一个磁盘映像
16:
disk = ['phy:/dev/sdb,svda,w']
使用了bootloader, pygrup示例:
#ramdisk="/boot/initramfs-2.6.32-358.el6.x86_64.img"
#kernel="/boot/vmlinuz-2.6.32-358.el6.x86_64"
name="linux"
vcpus=1
memory=128
disk=['file:/xen/vm2/dom2.img,xvda,w',]
bootloader="/usr/bin/pygrub"
#root="/dev/xvda2 ro"
#extra="selinux=0 init=/sbin/init"
vif=[ 'bridge=br0' ]
on_crash="destroy"
on_reboot="restart"
使用Dom0中的kernel和ramdisk引导的示例:
ramdisk="/boot/initramfs-2.6.32-358.el6.x86_64.img"
kernel="/boot/vmlinuz-2.6.32-358.el6.x86_64"
name="test"
vcpus=1
memory=128
disk=['file:/xen/vm1/test.img,xvda,w',]
root="/dev/xvda ro"
extra="selinux=0 init=/sbin/init"
自定义安装,并启用了vnc功能:
#ramdisk="/xen/isolinux/initrd.img"
#kernel="/xen/isolinux/vmlinuz"
name="rhel6"
vcpus=2
memory=512
disk=['file:/xen/vm3/rhel6.img,xvda,w',]
bootloader="/usr/bin/pygrub"
#root="/dev/xvda2 ro"
#extra="selinux=0 init=/sbin/init"
#extra="ks=http://172.16.0.1/rhel6.x86_64.cfg"
vif=[ 'bridge=br0' ]
on_crash="destroy"
on_reboot="destroy"
vfb=[ 'vnc=1,vnclisten=0.0.0.0' ]
[root@node1 ~]# xm help(查看xm命令帮助) Usage: xm <subcommand> [args] Control, list, and manipulate Xen guest instances. xm full list of subcommands: console Attach to <Domain>'s console. vncviewer Attach to <Domain>'s VNC server. create Create a domain based on <ConfigFile>. new Adds a domain to Xend domain management delete Remove a domain from Xend domain management.(移除虚拟机) destroy Terminate a domain immediately.(断电虚拟机) domid Convert a domain name to domain id.(将域名转换为id号) domname Convert a domain id to domain name.(将id号转换为域名) dump-core Dump core for a specific domain. list List information about all/some domains. mem-max Set the maximum amount reservation for a domain. mem-set Set the current memory usage for a domain.(设定域当前内存使用状况) migrate Migrate a domain to another machine.(实时迁移) pause Pause execution of a domain.(暂停,停止在内存当中,不在调度到cpu执行) reboot Reboot a domain. rename Rename a domain.(从挂起中恢复) reset Reset a domain. restore Restore a domain from a saved state.(从保存文件从恢复快照) resume Resume a Xend managed domain save Save a domain state to restore later.(把虚拟状态保存到文件中去,可以从这个文件中恢复,类似于快照) shutdown Shutdown a domain. start Start a Xend managed domain suspend Suspend a Xend managed domain(挂起虚拟机) sysrq Send a sysrq to a domain. trigger Send a trigger to a domain. top Monitor a host and the domains in real time. unpause Unpause a paused domain.(从暂停中恢复) uptime Print uptime for all/some domains. usb-add Add the usb device to FV VM. usb-del Delete the usb device to FV VM. domstate get the state of a domain vcpu-list List the VCPUs for all/some domains. vcpu-pin Set which CPUs a VCPU can use. vcpu-set Set the number of active VCPUs for allowed for the domain. debug-keys Send debug keys to Xen. dmesg Read and/or clear Xend's message buffer. info Get information about Xen host. log Print Xend log serve Proxy Xend XMLRPC over stdio. sched-credit2 Get/set credit2 scheduler parameters. sched-credit Get/set credit scheduler parameters. sched-sedf Get/set EDF parameters. block-attach Create a new virtual block device. block-detach Destroy a domain's virtual block device. block-list List virtual block devices for a domain. block-configure Change block device configuration network-attach Create a new virtual network device. network-detach Destroy a domain's virtual network device. network-list List virtual network interfaces for a domain. network2-attach Create a new version 2 virtual network device. network2-detach Destroy a domain's version 2 virtual network device. network2-list List version 2 virtual network interfaces for a domain. vtpm-list List virtual TPM devices. pci-attach Insert a new pass-through pci device. pci-detach Remove a domain's pass-through pci device. pci-list List pass-through pci devices for a domain. pci-list-assignable-devices List all the assignable pci devices scsi-attach Attach a new SCSI device. scsi-detach Detach a specified SCSI device. scsi-list List all SCSI devices currently attached. usb-attach Attach a new USB physical bus to domain's virtual port. usb-detach Detach a USB physical bus from domain's virtual port. usb-list List domain's attachment state of all virtual port . usb-list-assignable-devices List all the assignable usb devices usb-hc-create Create a domain's new virtual USB host controller. usb-hc-destroy Destroy a domain's virtual USB host controller. vnet-list List Vnets. vnet-create Create a vnet from ConfigFile. vnet-delete Delete a Vnet. setpolicy Set the policy of the system. labels List <type> labels for (active) policy. addlabel Add security label to domain. rmlabel Remove a security label from domain. getlabel Show security label for domain or resource. dry-run Test if a domain can access its resources. resources Show info for each labeled resource. dumppolicy Print hypervisor ACM state information. resetpolicy Set the policy of the system to the default policy. getpolicy Get the policy of the system. getenforce Returns the current enforcing mode for the Flask XSM module (Enforcing,Permissive) setenforce Modifies the current enforcing mode for the Flask XSM module tmem-list List tmem pools. tmem-thaw Thaw tmem pools. tmem-freeze Freeze tmem pools. tmem-destroy Destroy tmem pools. tmem-set Change tmem settings. tmem-shared-auth De/authenticate shared tmem pool. cpupool-create Create a CPU pool based an ConfigFile. cpupool-new Adds a CPU pool to Xend CPU pool management cpupool-start Starts a Xend CPU pool cpupool-list List CPU pools on host cpupool-destroy Deactivates a CPU pool cpupool-delete Removes a CPU pool from Xend management cpupool-cpu-add Adds a CPU to a CPU pool cpupool-cpu-remove Removes a CPU from a CPU pool cpupool-migrate Moves a domain into a CPU pool shell Launch an interactive shell. <Domain> can either be the Domain Name or Id. For more help on 'xm' see the xm(1) man page. For more help on 'xm create' see the xmdomain.cfg(5) man page. [root@node1 ~]# xm delete help(查看xm delete命令帮助) Error: <Fault 3: 'help'> Usage: xm delete <DomainName> Remove a domain from Xend domain management. [root@node1 ~]# xm delete --help(查看xm delete命令帮助) Usage: xm delete <DomainName> Remove a domain from Xend domain management. [root@node1 ~]# xm suspend --help(查看xm suspend命令的帮助) Usage: xm suspend <DomainName> Suspend a Xend managed domain [root@node1 ~]# xm create test(创建虚拟机test) Using config file "/etc/xen/test". Started domain test (id=83) [root@node1 ~]# xm list(查看虚拟机) Name ID Mem VCPUs State Time(s) Domain-0 0 1024 2 r----- 622.3 test 83 256 1 -b---- 0.7 [root@node1 ~]# xm pause test(暂停test虚拟机) [root@node1 ~]# xm list(查看域列表) Name ID Mem VCPUs State Time(s) Domain-0 0 1024 2 r----- 623.5 test 83 256 1 --p--- 0.7 提示:test处于暂停状态; [root@node1 ~]# xm console test(通过console连接test域) Initializing cgroup subsys cpuset Initializing cgroup subsys cpu Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014 Command line: root=/dev/xvda ro selinux=0 init=/sbin/init KERNEL supported cpus: Intel GenuineIntel AMD AuthenticAMD Centaur CentaurHauls Disabled fast string operations ACPI in unprivileged domain disabled released 0 pages of unused memory BIOS-provided physical RAM map: Xen: 0000000000000000 - 00000000000a0000 (usable) Xen: 00000000000a0000 - 0000000000100000 (reserved) Xen: 0000000000100000 - 0000000010000000 (usable) DMI not present or invalid. last_pfn = 0x10000 max_arch_pfn = 0x400000000 init_memory_mapping: 0000000000000000-0000000010000000 RAMDISK: 0204b000 - 04ffa000 No NUMA configuration found Faking a node at 0000000000000000-0000000010000000 Bootmem setup node 0 0000000000000000-0000000010000000 NODE_DATA [000000000005a000 - 000000000008dfff] bootmap [000000000008e000 - 000000000008ffff] pages 2 (7 early reservations) ==> bootmem [0000000000 - 0010000000] #0 [0000000000 - 0000001000] BIOS data page ==> [0000000000 - 0000001000] #1 [000507d000 - 00050aa000] XEN PAGETABLES ==> [000507d000 - 00050aa000] #2 [0000006000 - 0000008000] TRAMPOLINE ==> [0000006000 - 0000008000] #3 [0001000000 - 000202abe4] TEXT DATA BSS ==> [0001000000 - 000202abe4] #4 [000204b000 - 0004ffa000] RAMDISK ==> [000204b000 - 0004ffa000] #5 [0004ffa000 - 000507d000] XEN START INFO ==> [0004ffa000 - 000507d000] #6 [0000008000 - 000005a000] PGTABLE ==> [0000008000 - 000005a000] Zone PFN ranges: DMA 0x00000001 -> 0x00001000 DMA32 0x00001000 -> 0x00100000 Normal 0x00100000 -> 0x00100000 Movable zone start PFN for each node early_node_map[2] active PFN ranges 0: 0x00000001 -> 0x000000a0 0: 0x00000100 -> 0x00010000 SFI: Simple Firmware Interface v0.7 http://simplefirmware.org SMP: Allowing 1 CPUs, 0 hotplug CPUs No local APIC present APIC: disable apic facility PM: Registered nosave memory: 00000000000a0000 - 0000000000100000 Allocating PCI resources starting at 10000000 (gap: 10000000:f0000000) Booting paravirtualized kernel on Xen Xen version: 4.1.3 (preserve-AD) NR_CPUS:4096 nr_cpumask_bits:1 nr_cpu_ids:1 nr_node_ids:1 PERCPU: Embedded 31 pages/cpu @ffff8800050e0000 s95064 r8192 d23720 u126976 pcpu-alloc: s95064 r8192 d23720 u126976 alloc=31*4096 pcpu-alloc: [0] 0 Xen: using vcpu_info placement Built 1 zonelists in Node order, mobility grouping on. Total pages: 64458 Policy zone: DMA32 Kernel command line: root=/dev/xvda ro selinux=0 init=/sbin/init PID hash table entries: 1024 (order: 1, 8192 bytes) Checking aperture... No AGP bridge found Memory: 191148k/262144k available (5336k kernel code, 388k absent, 70608k reserved, 7016k data, 1292k init) Hierarchical RCU implementation. NR_IRQS:33024 nr_irqs:256 Console: colour dummy device 80x25 console [tty0] enabled console [hvc0] enabled allocated 1048576 bytes of page_cgroup please try 'cgroup_disable=memory' option if you don't want memory cgroups installing Xen timer for CPU 0 Detected 2493.416 MHz processor. Calibrating delay loop (skipped), value calculated using timer frequency.. 4986.83 BogoMIPS (lpj=2493416) pid_max: default: 32768 minimum: 301 Security Framework initialized SELinux: Disabled at boot. Dentry cache hash table entries: 32768 (order: 6, 262144 bytes) Inode-cache hash table entries: 16384 (order: 5, 131072 bytes) Mount-cache hash table entries: 256 Initializing cgroup subsys ns Initializing cgroup subsys cpuacct Initializing cgroup subsys memory Initializing cgroup subsys devices Initializing cgroup subsys freezer Initializing cgroup subsys net_cls Initializing cgroup subsys blkio Initializing cgroup subsys perf_event Initializing cgroup subsys net_prio Disabled fast string operations alternatives: switching to unfair spinlock SMP alternatives: switching to UP code Freeing SMP alternatives: 36k freed ftrace: converting mcount calls to 0f 1f 44 00 00 ftrace: allocating 21917 entries in 86 pages Performance Events: unsupported p6 CPU model 58 no PMU driver, software events only. NMI watchdog disabled (cpu0): hardware events not enabled Brought up 1 CPUs devtmpfs: initialized Grant table initialized regulator: core version 0.5 NET: Registered protocol family 16 PCI: Fatal: No config space access function found bio: create slab <bio-0> at 0 ACPI: Interpreter disabled. xen_balloon: Initialising balloon driver. last_pfn = 0x10000 max_arch_pfn = 0x400000000 vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default Switching to clocksource xen pnp: PnP ACPI: disabled NET: Registered protocol family 2 IP route cache hash table entries: 2048 (order: 2, 16384 bytes) TCP established hash table entries: 8192 (order: 5, 131072 bytes) TCP bind hash table entries: 8192 (order: 5, 131072 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP reno registered NET: Registered protocol family 1 Trying to unpack rootfs image as initramfs... Freeing initrd memory: 48828k freed platform rtc_cmos: registered platform RTC device (no PNP device found) futex hash table entries: 256 (order: 2, 16384 bytes) audit: initializing netlink socket (disabled) type=2000 audit(1469472819.205:1): initialized HugeTLB registered 2 MB page size, pre-allocated 0 pages VFS: Disk quotas dquot_6.5.2 Dquot-cache hash table entries: 512 (order 0, 4096 bytes) msgmni has been set to 468 alg: No test for stdrng (krng) ksign: Installing public key data Loading keyring - Added public key FEBCF26ABFDA92DD - User ID: CentOS (Kernel Module GPG key) Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 pciehp: PCI Express Hot Plug Controller Driver version: 0.4 acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 Non-volatile memory driver v1.3 Linux agpgart interface v0.103 crash memory driver: version 1.1 Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled brd: module loaded loop: module loaded input: Macintosh mouse button emulation as /devices/virtual/input/input0 Fixed MDIO Bus: probed ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver uhci_hcd: USB Universal Host Controller Interface driver PNP: No PS/2 controller found. Probing ports directly. mice: PS/2 mouse device common for all mice rtc_cmos: probe of rtc_cmos failed with error -16 cpuidle: using governor ladder cpuidle: using governor menu EFI Variables Facility v0.08 2004-May-17 usbcore: registered new interface driver hiddev usbcore: registered new interface driver usbhid usbhid: v2.6:USB HID core driver GRE over IPv4 demultiplexor driver TCP cubic registered Initializing XFRM netlink socket NET: Registered protocol family 17 registered taskstats version 1 XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/console/0 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initalizing network drop monitor service Freeing unused kernel memory: 1292k freed Write protecting the kernel read-only data: 10240k Freeing unused kernel memory: 788k freed Freeing unused kernel memory: 1568k freed dracut: dracut-004-356.el6 device-mapper: uevent: version 1.0.3 device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com udev: starting version 147 dracut: Starting plymouth daemon xlblk_init: register_blkdev major: 202 blkfront: xvda: barriers disabled xvda: unknown partition table EXT4-fs (xvda): mounted filesystem with ordered data mode. Opts: dracut: Mounted root filesystem /dev/xvda dracut: Switching root Welcome to MiniLinux(www.magedu.com) bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell bash-4.1# (敲回车键没有用) bash-4.1# [root@node1 ~]# (ctrl+]退出) [root@node1 ~]# xm list(查看所有域) Name ID Mem VCPUs State Time(s) Domain-0 0 1024 2 r----- 624.9 test 83 256 1 --p--- 0.7 [root@node1 ~]# xm unpause test(恢复暂停虚拟机) [root@node1 ~]# xm console test(通过console连接test虚拟机) Clocksource tsc unstable (delta = -171729951937 ns). Enable clocksource failover by adding clocksource_failover kernel parameter. bash-4.1# bash-4.1# [root@node1 ~]# (使用ctrl+]退出) [root@node1 ~]# xm suspend test(挂起test虚拟机) Error: Domain is not managed by Xend lifecycle support.(当前域没有设定支持xend管理) Usage: xm suspend <DomainName> Suspend a Xend managed domain [root@node1 ~]# xm save --help(查看xm save命令帮助) Usage: xm save [-c] <Domain> <CheckpointFile> Save a domain state to restore later. -c, --checkpoint Leave domain running after creating snapshot [root@node1 ~]# xm save test /root/test(保存test快照到/root目录叫test) [root@node1 ~]# ls /root/(查看/root目录文件及子目录) anaconda-ks.cfg kernel-xen-3.7.4-1.el6xen.x86_64.rpm kernel-xen-release-6-4.noarch.rpm xen-libs-4.1.3-2.el6.x86_64.rpm bincp.sh kernel-xen-devel-3.7.4-1.el6xen.x86_64.rpm test xen-licenses-4.1.3-2.el6.x86_64.rpm install.log kernel-xen-firmware-3.7.4-1.el6xen.x86_64.rpm xen-4.1.3-2.el6.x86_64.rpm xen-runtime-4.1.3-2.el6.x86_64.rpm install.log.syslog kernel-xen-headers-3.14.31-1.el6xen.x86_64.rpm xen-hypervisor-4.1.3-2.el6.x86_64.rpm [root@node1 ~]# ls /root/ -lh(查看root目录文件及子目录详细信息,-h做单位换算) 总用量 296M -rw-------. 1 root root 1010 7月 25 18:56 anaconda-ks.cfg -rw-r--r--. 1 root root 703 7月 25 21:29 bincp.sh -rw-r--r--. 1 root root 13K 7月 25 18:56 install.log -rw-r--r--. 1 root root 3.5K 7月 25 18:54 install.log.syslog -rw-r--r--. 1 root root 19M 7月 25 19:04 kernel-xen-3.7.4-1.el6xen.x86_64.rpm -rw-r--r--. 1 root root 8.2M 7月 25 19:04 kernel-xen-devel-3.7.4-1.el6xen.x86_64.rpm -rw-r--r--. 1 root root 1005K 7月 25 19:04 kernel-xen-firmware-3.7.4-1.el6xen.x86_64.rpm -rw-r--r--. 1 root root 888K 7月 25 19:04 kernel-xen-headers-3.14.31-1.el6xen.x86_64.rpm -rw-r--r--. 1 root root 9.9K 7月 25 19:04 kernel-xen-release-6-4.noarch.rpm -rwxr-xr-x. 1 root root 257M 7月 26 03:02 test -rw-r--r--. 1 root root 1.1M 7月 25 19:04 xen-4.1.3-2.el6.x86_64.rpm -rw-r--r--. 1 root root 4.0M 7月 25 19:04 xen-hypervisor-4.1.3-2.el6.x86_64.rpm -rw-r--r--. 1 root root 314K 7月 25 19:04 xen-libs-4.1.3-2.el6.x86_64.rpm -rw-r--r--. 1 root root 67K 7月 25 19:04 xen-licenses-4.1.3-2.el6.x86_64.rpm -rw-r--r--. 1 root root 4.9M 7月 25 19:04 xen-runtime-4.1.3-2.el6.x86_64.rpm [root@node1 ~]# xm restore --help(查看xm restore命令帮助) Usage: xm restore <CheckpointFile> [-p] Restore a domain from a saved state. -p, --paused Do not unpause domain after restoring it(恢复以后处于暂停状态) [root@node1 ~]# xm list(查看所有域) Name ID Mem VCPUs State Time(s) Domain-0 0 1024 2 r----- 654.4 [root@node1 ~]# xm restore /root/test(从test文件恢复test域虚拟机) [root@node1 ~]# ls /root/(查看/root目录文件及子目录) anaconda-ks.cfg kernel-xen-3.7.4-1.el6xen.x86_64.rpm kernel-xen-release-6-4.noarch.rpm xen-libs-4.1.3-2.el6.x86_64.rpm bincp.sh kernel-xen-devel-3.7.4-1.el6xen.x86_64.rpm test xen-licenses-4.1.3-2.el6.x86_64.rpm install.log kernel-xen-firmware-3.7.4-1.el6xen.x86_64.rpm xen-4.1.3-2.el6.x86_64.rpm xen-runtime-4.1.3-2.el6.x86_64.rpm install.log.syslog kernel-xen-headers-3.14.31-1.el6xen.x86_64.rpm xen-hypervisor-4.1.3-2.el6.x86_64.rpm [root@node1 ~]# xm list(查看所有域虚拟机) Name ID Mem VCPUs State Time(s) Domain-0 0 1024 2 r----- 660.0 test 84 256 1 -b---- 0.0 [root@node1 ~]# xm help(查看xm命令帮助) Usage: xm <subcommand> [args] Control, list, and manipulate Xen guest instances. xm full list of subcommands: console Attach to <Domain>'s console. vncviewer Attach to <Domain>'s VNC server. create Create a domain based on <ConfigFile>. new Adds a domain to Xend domain management delete Remove a domain from Xend domain management.(移除虚拟机) destroy Terminate a domain immediately.(断电虚拟机) domid Convert a domain name to domain id.(将域名转换为id号) domname Convert a domain id to domain name.(将id号转换为域名) dump-core Dump core for a specific domain. list List information about all/some domains. mem-max Set the maximum amount reservation for a domain. mem-set Set the current memory usage for a domain.(设定域当前内存使用状况) migrate Migrate a domain to another machine.(实时迁移) pause Pause execution of a domain.(暂停,停止在内存当中,不在调度到cpu执行) reboot Reboot a domain. rename Rename a domain.(从挂起中恢复) reset Reset a domain.(冷重启) restore Restore a domain from a saved state.(从保存文件从恢复快照) resume Resume a Xend managed domain save Save a domain state to restore later.(把虚拟状态保存到文件中去,可以从这个文件中恢复,类似于快照) shutdown Shutdown a domain.(关闭) start Start a Xend managed domain(启动) suspend Suspend a Xend managed domain(挂起虚拟机) sysrq Send a sysrq to a domain. trigger Send a trigger to a domain. top Monitor a host and the domains in real time.(监控domain host) unpause Unpause a paused domain.(从暂停中恢复) uptime Print uptime for all/some domains. usb-add Add the usb device to FV VM. usb-del Delete the usb device to FV VM. domstate get the state of a domain vcpu-list List the VCPUs for all/some domains. vcpu-pin Set which CPUs a VCPU can use. vcpu-set Set the number of active VCPUs for allowed for the domain. debug-keys Send debug keys to Xen. dmesg Read and/or clear Xend's message buffer. info Get information about Xen host.(查看xen主机info信息) log Print Xend log(查看xend的log) serve Proxy Xend XMLRPC over stdio. sched-credit2 Get/set credit2 scheduler parameters. sched-credit Get/set credit scheduler parameters. sched-sedf Get/set EDF parameters. block-attach Create a new virtual block device.(创建新的虚拟块设备) block-detach Destroy a domain's virtual block device.(销毁域虚拟机块设备) block-list List virtual block devices for a domain.(列出虚拟块设备) block-configure Change block device configuration(改变块设备配置) network-attach Create a new virtual network device. network-detach Destroy a domain's virtual network device. network-list List virtual network interfaces for a domain. network2-attach Create a new version 2 virtual network device. network2-detach Destroy a domain's version 2 virtual network device. network2-list List version 2 virtual network interfaces for a domain. vtpm-list List virtual TPM devices. pci-attach Insert a new pass-through pci device.(向guest插入一个透传技术的pci设备) pci-detach Remove a domain's pass-through pci device. pci-list List pass-through pci devices for a domain. pci-list-assignable-devices List all the assignable pci devices(列出所有可以透传给guest使用的pci设备) scsi-attach Attach a new SCSI device. scsi-detach Detach a specified SCSI device. scsi-list List all SCSI devices currently attached. usb-attach Attach a new USB physical bus to domain's virtual port. usb-detach Detach a USB physical bus from domain's virtual port. usb-list List domain's attachment state of all virtual port . usb-list-assignable-devices List all the assignable usb devices usb-hc-create Create a domain's new virtual USB host controller. usb-hc-destroy Destroy a domain's virtual USB host controller. vnet-list List Vnets.(列出虚拟网络) vnet-create Create a vnet from ConfigFile. vnet-delete Delete a Vnet. setpolicy Set the policy of the system. labels List <type> labels for (active) policy. addlabel Add security label to domain. rmlabel Remove a security label from domain. getlabel Show security label for domain or resource. dry-run Test if a domain can access its resources. resources Show info for each labeled resource. dumppolicy Print hypervisor ACM state information. resetpolicy Set the policy of the system to the default policy. getpolicy Get the policy of the system. getenforce Returns the current enforcing mode for the Flask XSM module (Enforcing,Permissive) setenforce Modifies the current enforcing mode for the Flask XSM module tmem-list List tmem pools. tmem-thaw Thaw tmem pools. tmem-freeze Freeze tmem pools. tmem-destroy Destroy tmem pools. tmem-set Change tmem settings. tmem-shared-auth De/authenticate shared tmem pool. cpupool-create Create a CPU pool based an ConfigFile.(创建cpu池) cpupool-new Adds a CPU pool to Xend CPU pool management cpupool-start Starts a Xend CPU pool cpupool-list List CPU pools on host cpupool-destroy Deactivates a CPU pool cpupool-delete Removes a CPU pool from Xend management cpupool-cpu-add Adds a CPU to a CPU pool cpupool-cpu-remove Removes a CPU from a CPU pool cpupool-migrate Moves a domain into a CPU pool shell Launch an interactive shell. <Domain> can either be the Domain Name or Id. For more help on 'xm' see the xm(1) man page. For more help on 'xm create' see the xmdomain.cfg(5) man page. [root@node1 ~]# xm top --help(查看xm top命令帮助) Usage: xm top Monitor a host and the domains in real time. [root@node1 ~]# xm top(监控domain) [root@node1 ~]# xm top xentop - 03:20:47 Xen 4.1.3 2 domains: 1 running, 1 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown Mem: 2096632k total, 1336056k used, 760576k free CPUs: 1 @ 2493MHz NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) Domain-0 -----r 663 0.7 1048576 50.0 no limit n/a 2 0 0 0 test --b--- 0 0.1 262144 12.5 262144 12.5 1 0 0 0 VBDS VBD_OO VBD_RD VBD_WR VBD_RSECT VBD_WSECT SSID 0 0 0 0 0 0 0 1 0 0 0 0 0 0 Delay Networks vBds Tmem VCPUs Repeat header Sort order Quit [root@node1 ~]# xm info --help(查看xm info命令帮助) Usage: xm info [-c|--config] [-n|--numa] Get information about Xen host. -c, --config List Xend configuration parameters -n, --numa List host NUMA topology information [root@node1 ~]# xm info(查看当前物理机的info信息) host : node1.Smoke.com release : 3.7.4-1.el6xen.x86_64 version : #1 SMP Wed Jan 23 15:52:51 EST 2013 machine : x86_64(架构) nr_cpus : 1(cpu个数) nr_nodes : 1 cores_per_socket : 1 threads_per_core : 1 cpu_mhz : 2493 hw_caps : 0fabfbff:28100800:00000000:00007f40:f3ba2203:00000000:00000001:00000283 virt_caps : total_memory : 2047 free_memory : 742 free_cpus : 0 xen_major : 4 xen_minor : 1 xen_extra : .3 xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p xen_scheduler : credit xen_pagesize : 4096 platform_params : virt_start=0xffff800000000000 xen_changeset : unavailable xen_commandline : dom0_mem=1024M cpufreq=xen dom0_max_vcpus=2 dom0_vcpus_pin cc_compiler : gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) cc_compile_by : mockbuild cc_compile_domain : crc.id.au cc_compile_date : Fri Oct 12 13:39:11 EST 2012 xend_config_format : 4 [root@node1 ~]# xm pci-list-assignable-devices(列出所有可以透传给guest使用的pci设备) [root@node1 ~]# xm vnet-list(列出虚拟网络) Status ErrorDescription [root@node1 ~]# xm vnet-list test(列出test域的虚拟网络) "{'Status': 'Failure', 'ErrorDescription': ['MESSAGE_METHOD_UNKNOWN', 'xend_vnet']}" [root@node1 ~]# xm vnet-list --help(查看xm vnet-list的帮助) Usage: xm vnet-list [-l|--long] List Vnets. -l, --long List Vnets as SXP [root@node1 ~]# xm vnet-list -l(列出u虚拟网络,-l详细信息) "{'Status': 'Failure', 'ErrorDescription': ['MESSAGE_METHOD_UNKNOWN', 'xend_vnet']}" "{'Status': 'Failure', 'ErrorDescription': ['MESSAGE_METHOD_UNKNOWN', 'xend_vnet']}" [root@node1 ~]# cd /etc/xen/(切换到/etc/xen目录) [root@node1 xen]# ls(查看当前目录文件及子目录) auto scripts xend-config.sxp(xend配置文件) xend-pci-quirks.sxp xm-config.xml xmexample2 xmexample.hvm xmexample.nbd xmexample.vti cpupool test xend-pci-permissive.sxp xl.conf xmexample1 xmexample3 xmexample.hvm-stubdom xmexample.pv-grub 提示:xend半虚拟化方式不支持iso映像安装; [root@node1 xen]# vim xend-config.sxp(编辑xend-config.sxp配置文件) # (network-script 'network-bridge netdev=eth1')(桥接网络) #(network-script network-bridge) (network-script /bin/true) #(network-script network-route)(路由模式脚本) #(vif-script vif-route) xend实时迁移: [root@node1 xen]# cat test ramdisk="/boot/initramfs-2.6.32-504.el6.x86_64.img" kernel="/boot/vmlinuz-2.6.32-504.el6.x86_64" name="test" vcpus=1 memory=256 disk=['file:/xen/vm1/test.img,xvda,w',] root="/dev/xvda ro" extra="selinux=0 init=/sbin/init"
环境:开启三台linux虚拟机,分为作为Xen Host 1、Xen Host 2及iSCSI Target服务器;
IP地址:
Xen Host 1:172.16.200.6
Xen Host 2:172.16.200.7
iSCSI Target:172.16.200.8
Xen Host 1:
[root@node1 ~]# ifconfig eth0(查看eth0接口信息) eth0 Link encap:Ethernet HWaddr 00:0C:29:11:21:56 inet addr:172.16.200.6 Bcast:172.16.200.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe11:2156/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:589 errors:0 dropped:0 overruns:0 frame:0 TX packets:609 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:46288 (45.2 KiB) TX bytes:147132 (143.6 KiB)
Xen Host 2:
[root@node2 ~]# ifconfig eth0(查看eth0接口信息) eth0 Link encap:Ethernet HWaddr 00:0C:29:E8:20:12 inet addr:172.16.200.7 Bcast:172.16.200.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fee8:2012/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:556 errors:0 dropped:0 overruns:0 frame:0 TX packets:640 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:43698 (42.6 KiB) TX bytes:152786 (149.2 KiB) iSCSI Target: [root@Smoke ~]# ifconfig eth0(查看eth0接口信息) eth0 Link encap:Ethernet HWaddr 00:0C:29:D9:0D:2A inet addr:172.16.200.8 Bcast:172.16.200.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fed9:d2a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:509 errors:0 dropped:0 overruns:0 frame:0 TX packets:582 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:42178 (41.1 KiB) TX bytes:120418 (117.5 KiB)
Xen Host 1:
[root@node1 ~]# crontab -e(创建任务计划) */3 * * * * /usr/sbin/ntpdate 172.16.200.8 &> /dev/null [root@node1 ~]# ntpdate 172.16.200.8(向ntp服务器同步时间) 8 Aug 22:51:55 ntpdate[2003]: step time server 172.16.200.8 offset 37.549121 sec [root@node1 ~]# date(查看系统时间) 2016年 08月 08日 星期一 22:52:19 CST
Xen Host 2:
[root@node2 ~]# ntpdate 172.16.200.8(向ntp服务器同步时间) 8 Aug 22:53:06 ntpdate[1804]: step time server 172.16.200.8 offset 52.173586 sec [root@node2 ~]# crontab -e(创建任务计划) */3 * * * * /usr/sbin/ntpdate 172.16.200.8 &> /dev/null
iSCSI Target:
[root@Smoke ~]# date(查看系统时间) 2016年 08月 08日 星期一 22:55:20 CST
Xen Host 1:
[root@node1 ~]# ls(查看当前目录文件及子目录) anaconda-ks.cfg install.log install.log.syslog xen [root@node1 ~]# cd xen/(切换到xen目录) [root@node1 xen]# ll(查看当前目录文件及子目录详细信息) 总用量 39816 -rw-r--r--. 1 root root 19565560 8月 8 22:57 kernel-xen-3.7.4-1.el6xen.x86_64.rpm -rw-r--r--. 1 root root 8529216 8月 8 22:57 kernel-xen-devel-3.7.4-1.el6xen.x86_64.rpm -rw-r--r--. 1 root root 1028720 8月 8 22:57 kernel-xen-firmware-3.7.4-1.el6xen.x86_64.rpm -rw-r--r--. 1 root root 908388 8月 8 22:57 kernel-xen-headers-3.14.31-1.el6xen.x86_64.rpm -rw-r--r--. 1 root root 10056 8月 8 22:57 kernel-xen-release-6-4.noarch.rpm -rw-r--r--. 1 root root 1100320 8月 8 22:57 xen-4.1.3-2.el6.x86_64.rpm -rw-r--r--. 1 root root 4101312 8月 8 22:57 xen-hypervisor-4.1.3-2.el6.x86_64.rpm -rw-r--r--. 1 root root 320672 8月 8 22:57 xen-libs-4.1.3-2.el6.x86_64.rpm -rw-r--r--. 1 root root 68112 8月 8 22:57 xen-licenses-4.1.3-2.el6.x86_64.rpm -rw-r--r--. 1 root root 5117316 8月 8 22:57 xen-runtime-4.1.3-2.el6.x86_64.rpm [root@node1 xen]# yum -y localinstall --nogpgcheck *.rpm(通过yum安装本地rpm软件,-y所有询问回答yes,--nogpgcheck不做gpg校验) [root@node1 xen]# yum -y install libvirt(通过yum源安装libvirt)
Xen Host 1:
[root@node2 ~]# cd xen/(切换到xen目录) [root@node2 xen]# yum -y localinstall --nogpgcheck *.rpm(通过yum安装本地rpm软件,-y所有询问回答yes,--nogpgcheck不做gpg校验) [root@node2 xen]# yum -y install libvirt(通过yum源安装libvirt)
iSCSI Target:
[root@Smoke ~]# fdisk /dev/sda(管理/dev/sda磁盘设备,进入交互模式) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): p(查看分区情况) Disk /dev/sda: 53.7 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000da104 Device Boot Start End Blocks Id System /dev/sda1 * 1 13 102400 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 13 2624 20971520 83 Linux /dev/sda3 2624 2885 2097152 82 Linux swap / Solaris Command (m for help): n(创建新分区) Command action e extended p primary partition (1-4) e(扩展分区) Selected partition 4(分区号) First cylinder (2885-6527, default 2885): (起始柱面) Using default value 2885 Last cylinder, +cylinders or +size{K,M,G} (2885-6527, default 6527): (结束柱面) Using default value 6527 Command (m for help): n(新分区) First cylinder (2885-6527, default 2885): Using default value 2885 Last cylinder, +cylinders or +size{K,M,G} (2885-6527, default 6527): +20G(创建20G分区) Command (m for help): w(保存退出) The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: 设备或资源忙. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. [root@Smoke ~]# partprobe /dev/sda(让内核重读/dev/sda分区表) Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (设备或资源忙). As a result, it may not reflect all of your changes until after reboot. [root@Smoke ~]# kpartx -av /dev/sda(让内核重读/dev/sda分区表) device-mapper: reload ioctl on sda1 failed: Invalid argument create/reload failed on sda1 add map sda1 (0:0): 0 204800 linear /dev/sda 2048 device-mapper: reload ioctl on sda2 failed: Invalid argument create/reload failed on sda2 add map sda2 (0:0): 0 41943040 linear /dev/sda 206848 device-mapper: reload ioctl on sda3 failed: Invalid argument create/reload failed on sda3 add map sda3 (0:0): 0 4194304 linear /dev/sda 42149888 device-mapper: reload ioctl on sda4 failed: Invalid argument create/reload failed on sda4 add map sda4 (0:0): 0 2 linear /dev/sda 46344192 device-mapper: reload ioctl on sda5 failed: Invalid argument create/reload failed on sda5 add map sda5 (0:0): 0 41948985 linear /dev/sda 46344255 [root@Smoke ~]# cat /proc/partitions(查看partitions文件内容) major minor #blocks name 8 0 52428800 sda 8 1 102400 sda1 8 2 20971520 sda2 8 3 2097152 sda3 [root@Smoke ~]# service udev-post reload(重新载入udev-post服务) 重新激发失败的 udev 事件 [确定] [root@Smoke ~]# yum -y install scsi-target-utils(通过yum源安装scsi-target-utils)
Xen Host 1:
[root@node1 xen]# vim /etc/grub.conf(编辑grub.conf配置文件) # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/sda2 # initrd /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS (3.7.4-1.el6xen.x86_64) root (hd0,0) kernel /xen.gz dom0_mem=512M cpufreq=xen dom0_max_vcpus=2 dom0_vcpus_pin module /vmlinuz-3.7.4-1.el6xen.x86_64 ro root=UUID=cf43ec31-f59f-423f-aa0b-d091c18b2fa4 rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF module /initramfs-3.7.4-1.el6xen.x86_64.img title CentOS 6 (2.6.32-504.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-504.el6.x86_64 ro root=UUID=cf43ec31-f59f-423f-aa0b-d091c18b2fa4 rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-504.el6.x86_64.img [root@node1 ~]# yum -y install iscsi-initiator-utils(通过yum源安装iscsi-initiator-utils软件包) [root@node1 ~]# rpm -q iscsi-initiator-utils(查看是否安装iscsi-initiator-utils) iscsi-initiator-utils-6.2.0.873-21.el6.x86_64 [root@node1 ~]# shutdown -h now(立即关闭系统)
Xen Host 2:
[root@node2 ~]# rpm -q iscsi-initiator-utils(查看是否安装iscsi-initiator-utils) iscsi-initiator-utils-6.2.0.873-21.el6.x86_64 [root@node2 ~]# vim /etc/grub.conf(编辑grub.conf配置文件) # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/sda2 # initrd /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS (3.7.4-1.el6xen.x86_64) root (hd0,0) kernel /xen.gz dom0_mem=512M cpufreq=xen dom0_max_vcpus=2 dom0_vcpus_pin module /vmlinuz-3.7.4-1.el6xen.x86_64 ro root=UUID=d71a9ca2-6de8-4c96-ae5c-1f9342d875be rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet module /initramfs-3.7.4-1.el6xen.x86_64.img title CentOS 6 (2.6.32-504.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-504.el6.x86_64 ro root=UUID=d71a9ca2-6de8-4c96-ae5c-1f9342d875be rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-504.el6.x86_64.img [root@node2 ~]# shutdown -h now(立即关闭系统) 提示:关闭Xen Host 1和Xen Host 2将内存调整至1G,再启动;
iSCSI Target:
[root@Smoke ~]# shutdown -r now(立即重启系统) [root@Smoke ~]# cd /etc/tgt/(切换到/etc/tgt目录) [root@Smoke tgt]# ls(查看当前目录文件及子目录) targets.conf [root@Smoke tgt]# fdisk -l(查看磁盘分区情况) Disk /dev/sda: 53.7 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000da104 Device Boot Start End Blocks Id System /dev/sda1 * 1 13 102400 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 13 2624 20971520 83 Linux /dev/sda3 2624 2885 2097152 82 Linux swap / Solaris /dev/sda4 2885 6527 29256031+ 5 Extended /dev/sda5 2885 5496 20974492+ 83 Linux [root@Smoke tgt]# pvcreate /dev/sda5(将/dev/sda5创建为物理卷) Physical volume "/dev/sda5" successfully created [root@Smoke tgt]# vgcreate xenvg /dev/sda5(将/dev/sda5物理卷创建为卷组) Volume group "xenvg" successfully created [root@Smoke tgt]# lvcreate -L 10G -n xenlv xenvg(将xenvg创建为10G大小逻辑卷叫xenlv) Logical volume "xenlv" created [root@Smoke tgt]# lvs(查看逻辑卷) LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert xenlv xenvg -wi-a---- 10.00g [root@Smoke tgt]# vim targets.conf(编辑targets.conf配置文件) <target iqn.2016-08.com.magedu:xen.vm1> backing-store /dev/xenvg/xenlv initiator-address 172.16.0.0/16 </target> [root@Smoke tgt]# service tgtd start(启动tgtd服务) 正在启动 SCSI target daemon: [确定] [root@Smoke tgt]# chkconfig tgtd on(让tgtd服务在相应系统级别开机自动启动) [root@Smoke tgt]# netstat -tunlp(查看系统服务,-t代表tcp,-u代表udp,-n以数字显示,-l监听端口,-p显示服务名称) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1203/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1279/master tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 1334/sshd tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 1499/tgtd tcp 0 0 :::22 :::* LISTEN 1203/sshd tcp 0 0 ::1:25 :::* LISTEN 1279/master tcp 0 0 ::1:6010 :::* LISTEN 1334/sshd tcp 0 0 :::3260 :::* LISTEN 1499/tgtd udp 0 0 0.0.0.0:68 0.0.0.0:* 1098/dhclient
Xen Host 1:
[root@node1 ~]# cat /proc/xen/capabilities(查看capabilities文件内容,是否支持xen) control_d [root@node1 ~]# uname -r(查看内核版本) 3.7.4-1.el6xen.x86_64 [root@node1 ~]# service iscsid start(启动iscsid服务) [root@node1 ~]# iscsiadm -m discovery -t st -p 172.16.200.8(发现172.16.200.8服务器是否有target输出,-m指定模式,-t指定类型,-p指定服务器地址) 172.16.200.8:3260,1 iqn.2016-08.com.magedu:xen.vm1 [root@node1 ~]# iscsiadm -m node -T iqn.2016-08.com.magedu:xen.vm1 -p 172.16.200.8 -l(登录172.16.200.8服务器的target,-T指定登录那个target 名称,-p指定服务器地址,-l登录) Logging in to [iface: default, target: iqn.2016-08.com.magedu:xen.vm1, portal: 172.16.200.8,3260] (multiple) Login to [iface: default, target: iqn.2016-08.com.magedu:xen.vm1, portal: 172.16.200.8,3260] successful. [root@node1 ~]# fdisk -l(查看磁盘分区情况) Disk /dev/sda: 53.7 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000d5d5d Device Boot Start End Blocks Id System /dev/sda1 * 1 13 102400 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 13 2624 20971520 83 Linux /dev/sda3 2624 2755 1048576 82 Linux swap / Solaris Disk /dev/sdb: 10.7 GB, 10737418240 bytes 64 heads, 32 sectors/track, 10240 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
Xen Host 2:
[root@node2 ~]# iscsiadm -m discovery -t st -p 172.16.200.8(发现172.16.200.8服务器是否有target输出,-m指定模式,-t指定类型,st=send target, -p指定服务器地址,) 正在启动 iscsid: [确定] 172.16.200.8:3260,1 iqn.2016-08.com.magedu:xen.vm1 [root@node2 ~]# iscsiadm -m node -T iqn.2016-08.com.magedu:xen.vm1 -p 172.16.200.8 -l(登录172.16.200.8服务器的target,-T指定登录那个target 名称,-p指定服务器地址,-l登录) Logging in to [iface: default, target: iqn.2016-08.com.magedu:xen.vm1, portal: 172.16.200.8,3260] (multiple) Login to [iface: default, target: iqn.2016-08.com.magedu:xen.vm1, portal: 172.16.200.8,3260] successful. [root@node2 ~]# fdisk -l(查看磁盘分区情况) Disk /dev/sda: 53.7 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0003ee34 Device Boot Start End Blocks Id System /dev/sda1 * 1 13 102400 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 13 2624 20971520 83 Linux /dev/sda3 2624 2755 1048576 82 Linux swap / Solaris Disk /dev/sdb: 10.7 GB, 10737418240 bytes 64 heads, 32 sectors/track, 10240 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 [root@node2 ~]# chkconfig iscsid on(让iscsid在相应系统级别开机自动启动)
Xen Host 1:
[root@node1 ~]# chkconfig iscsid on(让iscsid在相应系统级别开机自动启动) [root@node1 ~]# fdisk /dev/sdb(管理/dev/sdb磁盘设备,进入交互式模式) Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x8662d268. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): p(查看磁盘分区情况) Disk /dev/sdb: 10.7 GB, 10737418240 bytes 64 heads, 32 sectors/track, 10240 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x8662d268 Device Boot Start End Blocks Id System Command (m for help): n(新建分区) Command action e extended p primary partition (1-4) p(主分区) Partition number (1-4): 1(分区号) First cylinder (1-10240, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-10240, default 10240): +500M(创建500M分区) Command (m for help): p(查看分区情况) Disk /dev/sdb: 10.7 GB, 10737418240 bytes 64 heads, 32 sectors/track, 10240 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x8662d268 Device Boot Start End Blocks Id System /dev/sdb1 1 501 513008 83 Linux Command (m for help): n(新建分区) Command action e extended p primary partition (1-4) p(主分区) Partition number (1-4): 2(分区号) First cylinder (502-10240, default 502): Using default value 502 Last cylinder, +cylinders or +size{K,M,G} (502-10240, default 10240): +2G(创建2G分区) Command (m for help): n(新建分区) Command action e extended p primary partition (1-4) p(主分区) Partition number (1-4): 3(分区号) First cylinder (2551-10240, default 2551): Using default value 2551 Last cylinder, +cylinders or +size{K,M,G} (2551-10240, default 10240): +512M(创建512M分区) Command (m for help): t(修改分区类型) Partition number (1-4): 3(第三个分区) Hex code (type L to list codes): L(查看支持的分区类型) 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx 5 Extended 42 SFS 86 NTFS volume set da Non-FS data 6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility 8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt 9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary 16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS 17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto 1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT 1e Hidden W95 FAT1 Hex code (type L to list codes): 82(修改类型为swap) Changed system type of partition 3 to 82 (Linux swap / Solaris) Command (m for help): p(查看分区情况) Disk /dev/sdb: 10.7 GB, 10737418240 bytes 64 heads, 32 sectors/track, 10240 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x8662d268 Device Boot Start End Blocks Id System /dev/sdb1 1 501 513008 83 Linux /dev/sdb2 502 2550 2098176 83 Linux /dev/sdb3 2551 3063 525312 82 Linux swap / Solaris Command (m for help): w(保存退出) The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@node1 ~]# partprobe /dev/sdb(让内核重新加载/dev/sdb分区表) [root@node1 ~]# cat /proc/partitions(查看内核加载的分区) major minor #blocks name 11 0 4524032 sr0 8 0 52428800 sda 8 1 102400 sda1 8 2 20971520 sda2 8 3 1048576 sda3 8 16 10485760 sdb 8 17 513008 sdb1 8 18 2098176 sdb2 8 19 525312 sdb3 [root@node1 ~]# mkdir -pv /mnt/{boot,sysroot}(创建/mnt/boot和/mnt/sysroot目录,-p递归创建,-v显示创建过程) mkdir: 已创建目录 "/mnt/boot" mkdir: 已创建目录 "/mnt/sysroot" [root@node1 ~]# mkfs.ext4 /dev/sdb1(将/dev/sdb1格式化为ext4文件系统) mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=1024 (log=0) 分块大小=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 128520 inodes, 513008 blocks 25650 blocks (5.00%) reserved for the super user 第一个数据块=1 Maximum filesystem blocks=67633152 63 block groups 8192 blocks per group, 8192 fragments per group 2040 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 正在写入inode表: 完成 Creating journal (8192 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 28 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@node1 ~]# mkfs.ext4 /dev/sdb2(将/dev/sdb2格式化为ext4文件系统) mke2fs 1.41.12 (17-May-2010) 警告: 256 块未使用. 文件系统标签= 操作系统:Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131328 inodes, 524288 blocks 26227 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=536870912 16 block groups 32768 blocks per group, 32768 fragments per group 8208 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 正在写入inode表: 完成 Creating journal (16384 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 25 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@node1 ~]# mkswap /dev/sdb3(将/dev/sdb3格式化为swap分区) Setting up swapspace version 1, size = 525308 KiB no label, UUID=a0d40eea-7b65-4894-a732-cbc297211200 [root@node1 ~]# mount /dev/sdb1 /mnt/boot/(挂载/dev/sdb1到/mnt/boot目录) [root@node1 ~]# mount /dev/sdb2 /mnt/sysroot/(挂载/dev/sdb2到/mnt/sysroot目录) [root@node1 ~]# lftp 172.16.0.1(连接ftp服务器) cd ok, cwd=/pub/Sources lftp 172.16.0.1:/pub/Sources> cd ../Files/scripts/(切换到/scripts目录) lftp 172.16.0.1:/pub/Files/scripts> get bincp.sh(下载bincp.sh脚本) 710 bytes transferred lftp 172.16.0.1:/pub/Files/scripts> bye(退出) [root@node1 ~]# bash bincp.sh Your command: init /sbin/init copy lib /lib64/libnih.so.1 finished. copy lib /lib64/libnih-dbus.so.1 finished. copy lib /lib64/libdbus-1.so.3 finished. copy lib /lib64/libpthread.so.0 finished. copy lib /lib64/librt.so.1 finished. copy lib /lib64/libgcc_s.so.1 finished. copy lib /lib64/libc.so.6 finished. copy lib /lib64/ld-linux-x86-64.so.2 finished. copy /sbin/init finished. Continue: bash /bin/bash copy lib /lib64/libtinfo.so.5 finished. copy lib /lib64/libdl.so.2 finished. copy /bin/bash finished. Continue: ls /bin/ls copy lib /lib64/libselinux.so.1 finished. copy lib /lib64/libcap.so.2 finished. copy lib /lib64/libacl.so.1 finished. copy lib /lib64/libattr.so.1 finished. copy /bin/ls finished. Continue: cat /bin/cat copy /bin/cat finished. Continue: ifconfig /sbin/ifconfig copy /sbin/ifconfig finished. Continue: mkdir /bin/mkdir copy /bin/mkdir finished. Continue: ping /bin/ping copy lib /lib64/libidn.so.11 finished. copy /bin/ping finished. Continue: shutdown /sbin/shutdown copy lib /lib64/libaudit.so.1 finished. copy /sbin/shutdown finished. Continue: halt /sbin/halt copy /sbin/halt finished. Continue: reboot /sbin/reboot copy /sbin/reboot finished. Continue: mount /bin/mount copy lib /lib64/libblkid.so.1 finished. copy lib /lib64/libuuid.so.1 finished. copy lib /lib64/libsepol.so.1 finished. copy /bin/mount finished. Continue: umount /bin/umount copy /bin/umount finished. Continue: vi /bin/vi copy lib /lib64/libm.so.6 finished. copy lib /lib64/libncurses.so.5 finished. copy /bin/vi finished. Continue: netstat /bin/netstat copy /bin/netstat finished. Continue: chmod /bin/chmod copy /bin/chmod finished. Continue: chown /bin/chown copy /bin/chown finished. Continue: rmdir /bin/rmdir copy /bin/rmdir finished. Continue: rm /bin/rm copy /bin/rm finished. Continue: insmod /sbin/insmod copy /sbin/insmod finished. Continue: lsmod /sbin/lsmod copy /sbin/lsmod finished. Continue: modinfo /sbin/modinfo copy /sbin/modinfo finished. Continue: q(退出) [root@node1 ~]# cd /mnt/sysroot/(切换到/mnt/sysroot目录) [root@node1 sysroot]# ls(查看当前目录文件及子目录) bin lib64 lost+found sbin [root@node1 sysroot]# mkdir -pv etc/{init,rc.d} var/{log,run} sys proc dev tmp lib/modules usr/{bin,sbin,lib,lib64}(创建目录,-p递归创建, -v显示创建过程) mkdir: 已创建目录 "etc" mkdir: 已创建目录 "etc/init" mkdir: 已创建目录 "etc/rc.d" mkdir: 已创建目录 "var" mkdir: 已创建目录 "var/log" mkdir: 已创建目录 "var/run" mkdir: 已创建目录 "sys" mkdir: 已创建目录 "proc" mkdir: 已创建目录 "dev" mkdir: 已创建目录 "tmp" mkdir: 已创建目录 "lib" mkdir: 已创建目录 "lib/modules" mkdir: 已创建目录 "usr" mkdir: 已创建目录 "usr/bin" mkdir: 已创建目录 "usr/sbin" mkdir: 已创建目录 "usr/lib" mkdir: 已创建目录 "usr/lib64" [root@node1 sysroot]# ll(查看当前目录文件及子目录) 总用量 60 drwxr-xr-x. 2 root root 4096 8月 9 01:02 bin drwxr-xr-x. 2 root root 4096 8月 9 01:09 dev drwxr-xr-x. 4 root root 4096 8月 9 01:09 etc drwxr-xr-x. 3 root root 4096 8月 9 01:09 lib drwxr-xr-x. 2 root root 4096 8月 9 01:01 lib64 drwx------. 2 root root 16384 8月 9 00:44 lost+found drwxr-xr-x. 2 root root 4096 8月 9 01:09 proc drwxr-xr-x. 2 root root 4096 8月 9 01:02 sbin drwxr-xr-x. 2 root root 4096 8月 9 01:09 sys drwxr-xr-x. 2 root root 4096 8月 9 01:09 tmp drwxr-xr-x. 6 root root 4096 8月 9 01:09 usr drwxr-xr-x. 4 root root 4096 8月 9 01:09 var [root@node1 sysroot]# modinfo xen-netfront(查看xen-netfront模块信息) filename: /lib/modules/3.7.4-1.el6xen.x86_64/kernel/drivers/net/xen-netfront.ko alias: xennet alias: xen:vif license: GPL description: Xen virtual network device frontend srcversion: 746EC04CBED591C2D0F65D1 depends: intree: Y vermagic: 3.7.4-1.el6xen.x86_64 SMP mod_unload modversions [root@node1 sysroot]# cp /lib/modules/3.7.4-1.el6xen.x86_64/kernel/drivers/net/xen-netfront.ko /mnt/sysroot/lib/modules/(复制xen-netf ront.ko到/mnt/sysroot/lib/modules目录) [root@node1 sysroot]# sync(同步磁盘写入) [root@node1 sysroot]# cp /etc/init/rcS.conf /mnt/sysroot/etc/init/(复制rcS.conf配置文件到/mnt/sysroot/etc/init目录) [root@node1 sysroot]# vim /mnt/sysroot/etc/init/rcS.conf(编辑rcS.conf配置文件) # rcS - runlevel compatibility # # This task runs the old sysv-rc startup scripts. # # Do not edit this file directly. If you want to change the behaviour, # please create a file rcS.override and put your changes there. start on startup stop on runlevel task # Note: there can be no previous runlevel here, if we have one it's bad # information (we enter rc1 not rcS for maintenance). Run /etc/rc.d/rc # without information so that it defaults to previous=N runlevel=S. console output exec /etc/rc.d/rc.sysinit [root@node1 sysroot]# vim /mnt/sysroot/etc/rc.d/rc.sysinit(编辑rc.sysinit文件) #!/bin/bash # echo -e "\tWelcome to our linux." insmod /lib/modules/xen-netfront.ko ifconfig lo 127.0.01/8 up ifconfig eth0 172.16.200.12/16 up #mount -n -o remount,rw / /bin/bash [root@node1 sysroot]# chmod +x /mnt/sysroot/etc/rc.d/rc.sysinit(给rc.sysinit执行权限) [root@node1 sysroot]# chroot /mnt/sysroot/(切换根到/mnt/sysroot目录) bash-4.1# ls(查看当前目录文件及子目录) bin dev etc lib lib64 lost+found proc sbin sys tmp usr var bash-4.1# exit(退出) exit [root@node1 sysroot]# cd(切换到用户家目录) [root@node1 ~]# cd /etc/xen/(切换到/etc/xen目录) [root@node1 xen]# service xend start(启动xend服务) 启动 xend 守护进程: [确定] [root@node1 xen]# vim test(编辑test文件) ramdisk="/boot/initramfs-2.6.32-504.el6.x86_64.img" kernel="/boot/vmlinuz-2.6.32-504.el6.x86_64" name="test" vcpus=1 memory=256 disk=['phy:/dev/sdb,xvda,w',] root="/dev/xvda2 ro" extra="selinux=0 init=/sbin/init" vif=[ 'bridge=br0' ] on_crash="destroy" on_reboot="restart" [root@node1 xen]# service libvirtd start(启动libvirtd服务) 启动 libvirtd 守护进程: [root@node1 xen]# service libvirtd restart(重启libvirtd服务) 正在关闭 libvirtd 守护进程: [确定] 启动 libvirtd 守护进程: [确定] [root@node1 xen]# virsh help iface-bridge(查看virsh iface-bridge命令帮助) NAME iface-bridge - create a bridge device and attach an existing network device to it SYNOPSIS iface-bridge <interface> <bridge> [--no-stp] [--delay <number>] [--no-start](指定那个网络接口桥接到那个网络设备上) DESCRIPTION bridge an existing network device OPTIONS [--interface] <string> existing interface name [--bridge] <string> new bridge device name --no-stp do not enable STP for this bridge --delay <number> number of seconds to squelch traffic on newly connected ports --no-start don't start the bridge immediately [root@node1 xen]# virsh iface-bridge eth0 br0(创建br0桥接口,将eth0桥接到br0) Created bridge br0 with attached device eth0 Bridge interface br0 started [root@node1 xen]# ifconfig(查看网卡接口信息) br0 Link encap:Ethernet HWaddr 00:0C:29:11:21:56 inet addr:172.16.200.6 Bcast:172.16.200.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe11:2156/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:30 errors:0 dropped:0 overruns:0 frame:0 TX packets:50 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2674 (2.6 KiB) TX bytes:4496 (4.3 KiB) eth0 Link encap:Ethernet HWaddr 00:0C:29:11:21:56 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:60095 errors:0 dropped:0 overruns:0 frame:0 TX packets:121810 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:13004861 (12.4 MiB) TX bytes:146152639 (139.3 MiB) eth1 Link encap:Ethernet HWaddr 00:0C:29:11:21:60 inet addr:192.168.111.137 Bcast:192.168.111.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe11:2160/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:102 errors:0 dropped:0 overruns:0 frame:0 TX packets:48 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:10161 (9.9 KiB) TX bytes:5657 (5.5 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) virbr0 Link encap:Ethernet HWaddr 52:54:00:1D:4C:EE inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) [root@node1 xen]# brctl show(查看桥接接口) bridge name bridge id STP enabled interfaces br0 8000.000c29112156 yes eth0 virbr0 8000.5254001d4cee yes virbr0-nic [root@node1 xen]# xm create -c test(创建test域,-c连接控制台) Using config file "./test". Started domain test (id=3) Initializing cgroup subsys cpuset Initializing cgroup subsys cpu Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014 Command line: root=/dev/xvda2 ro selinux=0 init=/sbin/init KERNEL supported cpus: Intel GenuineIntel AMD AuthenticAMD Centaur CentaurHauls Disabled fast string operations ACPI in unprivileged domain disabled released 0 pages of unused memory BIOS-provided physical RAM map: Xen: 0000000000000000 - 00000000000a0000 (usable) Xen: 00000000000a0000 - 0000000000100000 (reserved) Xen: 0000000000100000 - 0000000010000000 (usable) DMI not present or invalid. last_pfn = 0x10000 max_arch_pfn = 0x400000000 init_memory_mapping: 0000000000000000-0000000010000000 RAMDISK: 0204b000 - 04ffa000 No NUMA configuration found Faking a node at 0000000000000000-0000000010000000 Bootmem setup node 0 0000000000000000-0000000010000000 NODE_DATA [000000000005a000 - 000000000008dfff] bootmap [000000000008e000 - 000000000008ffff] pages 2 (7 early reservations) ==> bootmem [0000000000 - 0010000000] #0 [0000000000 - 0000001000] BIOS data page ==> [0000000000 - 0000001000] #1 [000507d000 - 00050aa000] XEN PAGETABLES ==> [000507d000 - 00050aa000] #2 [0000006000 - 0000008000] TRAMPOLINE ==> [0000006000 - 0000008000] #3 [0001000000 - 000202abe4] TEXT DATA BSS ==> [0001000000 - 000202abe4] #4 [000204b000 - 0004ffa000] RAMDISK ==> [000204b000 - 0004ffa000] #5 [0004ffa000 - 000507d000] XEN START INFO ==> [0004ffa000 - 000507d000] #6 [0000008000 - 000005a000] PGTABLE ==> [0000008000 - 000005a000] Zone PFN ranges: DMA 0x00000001 -> 0x00001000 DMA32 0x00001000 -> 0x00100000 Normal 0x00100000 -> 0x00100000 Movable zone start PFN for each node early_node_map[2] active PFN ranges 0: 0x00000001 -> 0x000000a0 0: 0x00000100 -> 0x00010000 SFI: Simple Firmware Interface v0.7 http://simplefirmware.org SMP: Allowing 1 CPUs, 0 hotplug CPUs No local APIC present APIC: disable apic facility PM: Registered nosave memory: 00000000000a0000 - 0000000000100000 Allocating PCI resources starting at 10000000 (gap: 10000000:f0000000) Booting paravirtualized kernel on Xen Xen version: 4.1.3 (preserve-AD) NR_CPUS:4096 nr_cpumask_bits:1 nr_cpu_ids:1 nr_node_ids:1 PERCPU: Embedded 31 pages/cpu @ffff8800050e0000 s95064 r8192 d23720 u126976 pcpu-alloc: s95064 r8192 d23720 u126976 alloc=31*4096 pcpu-alloc: [0] 0 Xen: using vcpu_info placement Built 1 zonelists in Node order, mobility grouping on. Total pages: 64458 Policy zone: DMA32 Kernel command line: root=/dev/xvda2 ro selinux=0 init=/sbin/init PID hash table entries: 1024 (order: 1, 8192 bytes) Checking aperture... No AGP bridge found Memory: 191148k/262144k available (5336k kernel code, 388k absent, 70608k reserved, 7016k data, 1292k init) Hierarchical RCU implementation. NR_IRQS:33024 nr_irqs:256 Console: colour dummy device 80x25 console [tty0] enabled console [hvc0] enabled allocated 1048576 bytes of page_cgroup please try 'cgroup_disable=memory' option if you don't want memory cgroups installing Xen timer for CPU 0 Detected 2493.318 MHz processor. Calibrating delay loop (skipped), value calculated using timer frequency.. 4986.63 BogoMIPS (lpj=2493318) pid_max: default: 32768 minimum: 301 Security Framework initialized SELinux: Disabled at boot. Dentry cache hash table entries: 32768 (order: 6, 262144 bytes) Inode-cache hash table entries: 16384 (order: 5, 131072 bytes) Mount-cache hash table entries: 256 Initializing cgroup subsys ns Initializing cgroup subsys cpuacct Initializing cgroup subsys memory Initializing cgroup subsys devices Initializing cgroup subsys freezer Initializing cgroup subsys net_cls Initializing cgroup subsys blkio Initializing cgroup subsys perf_event Initializing cgroup subsys net_prio Disabled fast string operations alternatives: switching to unfair spinlock SMP alternatives: switching to UP code Freeing SMP alternatives: 36k freed ftrace: converting mcount calls to 0f 1f 44 00 00 ftrace: allocating 21917 entries in 86 pages Performance Events: unsupported p6 CPU model 58 no PMU driver, software events only. NMI watchdog disabled (cpu0): hardware events not enabled Brought up 1 CPUs devtmpfs: initialized Grant table initialized regulator: core version 0.5 NET: Registered protocol family 16 PCI: Fatal: No config space access function found bio: create slab <bio-0> at 0 ACPI: Interpreter disabled. xen_balloon: Initialising balloon driver. last_pfn = 0x10000 max_arch_pfn = 0x400000000 vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default Switching to clocksource xen pnp: PnP ACPI: disabled NET: Registered protocol family 2 IP route cache hash table entries: 2048 (order: 2, 16384 bytes) TCP established hash table entries: 8192 (order: 5, 131072 bytes) TCP bind hash table entries: 8192 (order: 5, 131072 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP reno registered NET: Registered protocol family 1 Trying to unpack rootfs image as initramfs... Freeing initrd memory: 48828k freed platform rtc_cmos: registered platform RTC device (no PNP device found) futex hash table entries: 256 (order: 2, 16384 bytes) audit: initializing netlink socket (disabled) type=2000 audit(1470678499.078:1): initialized HugeTLB registered 2 MB page size, pre-allocated 0 pages VFS: Disk quotas dquot_6.5.2 Dquot-cache hash table entries: 512 (order 0, 4096 bytes) msgmni has been set to 468 alg: No test for stdrng (krng) ksign: Installing public key data Loading keyring - Added public key FEBCF26ABFDA92DD - User ID: CentOS (Kernel Module GPG key) Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 pciehp: PCI Express Hot Plug Controller Driver version: 0.4 acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 Non-volatile memory driver v1.3 Linux agpgart interface v0.103 crash memory driver: version 1.1 Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled brd: module loaded loop: module loaded input: Macintosh mouse button emulation as /devices/virtual/input/input0 Fixed MDIO Bus: probed ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver uhci_hcd: USB Universal Host Controller Interface driver PNP: No PS/2 controller found. Probing ports directly. mice: PS/2 mouse device common for all mice rtc_cmos: probe of rtc_cmos failed with error -16 cpuidle: using governor ladder cpuidle: using governor menu EFI Variables Facility v0.08 2004-May-17 usbcore: registered new interface driver hiddev usbcore: registered new interface driver usbhid usbhid: v2.6:USB HID core driver GRE over IPv4 demultiplexor driver TCP cubic registered Initializing XFRM netlink socket NET: Registered protocol family 17 registered taskstats version 1 XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/console/0 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initalizing network drop monitor service Freeing unused kernel memory: 1292k freed Write protecting the kernel read-only data: 10240k Freeing unused kernel memory: 788k freed Freeing unused kernel memory: 1568k freed dracut: dracut-004-356.el6 device-mapper: uevent: version 1.0.3 device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com udev: starting version 147 dracut: Starting plymouth daemon xlblk_init: register_blkdev major: 202 blkfront: xvda: barriers disabled xvda: xvda1 xvda2 xvda3 EXT4-fs (xvda2): INFO: recovery required on readonly filesystem EXT4-fs (xvda2): write access will be enabled during recovery EXT4-fs (xvda2): recovery complete EXT4-fs (xvda2): mounted filesystem with ordered data mode. Opts: dracut: Mounted root filesystem /dev/xvda2 dracut: Switching root Welcome to our linux. xen_netfront: disagrees about version of symbol module_layout insmod: error inserting '/lib/modules/xen-netfront.ko': -1 Invalid module format(无效格式模块,复制的是新内核模块,不是老内核模块) SIOCSIFADDR: No such device(没有网卡设备) SIOCSIFNETMASK: No such device SIOCGIFADDR: No such device SIOCSIFBROADCAST: No such device eth0: unknown interface: No such device eth0: unknown interface: No such device bash: no job control in this shell bash-4.1# ifconfig -a(查看所有接口信息) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) bash-4.1# [root@node1 xen]#(使用ctrl+]退出) [root@node1 xen]# xm destroy test(销毁test域) [root@node1 xen]# modinfo xen-netfront(查看xen-netfront模块信息) filename: /lib/modules/3.7.4-1.el6xen.x86_64/kernel/drivers/net/xen-netfront.ko alias: xennet alias: xen:vif license: GPL description: Xen virtual network device frontend srcversion: 746EC04CBED591C2D0F65D1 depends: intree: Y vermagic: 3.7.4-1.el6xen.x86_64 SMP mod_unload modversions [root@node1 xen]# cp /lib/modules/2.6.32-504.el6.x86_64/kernel/drivers/net/xen-netfront.ko /mnt/sysroot/lib/modules/xen-netfront.ko (复制xen-netfront.ko到/mnt/sysroot/lib/modules目录) cp:是否覆盖"/mnt/sysroot/lib/modules/xen-netfront.ko"? y(覆盖) [root@node1 xen]# sync(同步磁盘写入) [root@node1 xen]# sync(同步磁盘写入) [root@node1 xen]# xm create -c test(创建test域并启动,-c连接控制台) Using config file "./test". Started domain test (id=4) Initializing cgroup subsys cpuset Initializing cgroup subsys cpu Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014 Command line: root=/dev/xvda2 ro selinux=0 init=/sbin/init KERNEL supported cpus: Intel GenuineIntel AMD AuthenticAMD Centaur CentaurHauls Disabled fast string operations ACPI in unprivileged domain disabled released 0 pages of unused memory BIOS-provided physical RAM map: Xen: 0000000000000000 - 00000000000a0000 (usable) Xen: 00000000000a0000 - 0000000000100000 (reserved) Xen: 0000000000100000 - 0000000010000000 (usable) DMI not present or invalid. last_pfn = 0x10000 max_arch_pfn = 0x400000000 init_memory_mapping: 0000000000000000-0000000010000000 RAMDISK: 0204b000 - 04ffa000 No NUMA configuration found Faking a node at 0000000000000000-0000000010000000 Bootmem setup node 0 0000000000000000-0000000010000000 NODE_DATA [000000000005a000 - 000000000008dfff] bootmap [000000000008e000 - 000000000008ffff] pages 2 (7 early reservations) ==> bootmem [0000000000 - 0010000000] #0 [0000000000 - 0000001000] BIOS data page ==> [0000000000 - 0000001000] #1 [000507d000 - 00050aa000] XEN PAGETABLES ==> [000507d000 - 00050aa000] #2 [0000006000 - 0000008000] TRAMPOLINE ==> [0000006000 - 0000008000] #3 [0001000000 - 000202abe4] TEXT DATA BSS ==> [0001000000 - 000202abe4] #4 [000204b000 - 0004ffa000] RAMDISK ==> [000204b000 - 0004ffa000] #5 [0004ffa000 - 000507d000] XEN START INFO ==> [0004ffa000 - 000507d000] #6 [0000008000 - 000005a000] PGTABLE ==> [0000008000 - 000005a000] Zone PFN ranges: DMA 0x00000001 -> 0x00001000 DMA32 0x00001000 -> 0x00100000 Normal 0x00100000 -> 0x00100000 Movable zone start PFN for each node early_node_map[2] active PFN ranges 0: 0x00000001 -> 0x000000a0 0: 0x00000100 -> 0x00010000 SFI: Simple Firmware Interface v0.7 http://simplefirmware.org SMP: Allowing 1 CPUs, 0 hotplug CPUs No local APIC present APIC: disable apic facility PM: Registered nosave memory: 00000000000a0000 - 0000000000100000 Allocating PCI resources starting at 10000000 (gap: 10000000:f0000000) Booting paravirtualized kernel on Xen Xen version: 4.1.3 (preserve-AD) NR_CPUS:4096 nr_cpumask_bits:1 nr_cpu_ids:1 nr_node_ids:1 PERCPU: Embedded 31 pages/cpu @ffff8800050e0000 s95064 r8192 d23720 u126976 pcpu-alloc: s95064 r8192 d23720 u126976 alloc=31*4096 pcpu-alloc: [0] 0 Xen: using vcpu_info placement Built 1 zonelists in Node order, mobility grouping on. Total pages: 64458 Policy zone: DMA32 Kernel command line: root=/dev/xvda2 ro selinux=0 init=/sbin/init PID hash table entries: 1024 (order: 1, 8192 bytes) Checking aperture... No AGP bridge found Memory: 191148k/262144k available (5336k kernel code, 388k absent, 70608k reserved, 7016k data, 1292k init) Hierarchical RCU implementation. NR_IRQS:33024 nr_irqs:256 Console: colour dummy device 80x25 console [tty0] enabled console [hvc0] enabled allocated 1048576 bytes of page_cgroup please try 'cgroup_disable=memory' option if you don't want memory cgroups installing Xen timer for CPU 0 Detected 2493.318 MHz processor. Calibrating delay loop (skipped), value calculated using timer frequency.. 4986.63 BogoMIPS (lpj=2493318) pid_max: default: 32768 minimum: 301 Security Framework initialized SELinux: Disabled at boot. Dentry cache hash table entries: 32768 (order: 6, 262144 bytes) Inode-cache hash table entries: 16384 (order: 5, 131072 bytes) Mount-cache hash table entries: 256 Initializing cgroup subsys ns Initializing cgroup subsys cpuacct Initializing cgroup subsys memory Initializing cgroup subsys devices Initializing cgroup subsys freezer Initializing cgroup subsys net_cls Initializing cgroup subsys blkio Initializing cgroup subsys perf_event Initializing cgroup subsys net_prio Disabled fast string operations alternatives: switching to unfair spinlock SMP alternatives: switching to UP code Freeing SMP alternatives: 36k freed ftrace: converting mcount calls to 0f 1f 44 00 00 ftrace: allocating 21917 entries in 86 pages Performance Events: unsupported p6 CPU model 58 no PMU driver, software events only. NMI watchdog disabled (cpu0): hardware events not enabled Brought up 1 CPUs devtmpfs: initialized Grant table initialized regulator: core version 0.5 NET: Registered protocol family 16 PCI: Fatal: No config space access function found bio: create slab <bio-0> at 0 ACPI: Interpreter disabled. xen_balloon: Initialising balloon driver. last_pfn = 0x10000 max_arch_pfn = 0x400000000 vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default Switching to clocksource xen pnp: PnP ACPI: disabled NET: Registered protocol family 2 IP route cache hash table entries: 2048 (order: 2, 16384 bytes) TCP established hash table entries: 8192 (order: 5, 131072 bytes) TCP bind hash table entries: 8192 (order: 5, 131072 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP reno registered NET: Registered protocol family 1 Trying to unpack rootfs image as initramfs... Freeing initrd memory: 48828k freed platform rtc_cmos: registered platform RTC device (no PNP device found) futex hash table entries: 256 (order: 2, 16384 bytes) audit: initializing netlink socket (disabled) type=2000 audit(1470678832.703:1): initialized HugeTLB registered 2 MB page size, pre-allocated 0 pages VFS: Disk quotas dquot_6.5.2 Dquot-cache hash table entries: 512 (order 0, 4096 bytes) msgmni has been set to 468 alg: No test for stdrng (krng) ksign: Installing public key data Loading keyring - Added public key FEBCF26ABFDA92DD - User ID: CentOS (Kernel Module GPG key) Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 pciehp: PCI Express Hot Plug Controller Driver version: 0.4 acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 Non-volatile memory driver v1.3 Linux agpgart interface v0.103 crash memory driver: version 1.1 Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled brd: module loaded loop: module loaded input: Macintosh mouse button emulation as /devices/virtual/input/input0 Fixed MDIO Bus: probed ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver uhci_hcd: USB Universal Host Controller Interface driver PNP: No PS/2 controller found. Probing ports directly. mice: PS/2 mouse device common for all mice rtc_cmos: probe of rtc_cmos failed with error -16 cpuidle: using governor ladder cpuidle: using governor menu EFI Variables Facility v0.08 2004-May-17 usbcore: registered new interface driver hiddev usbcore: registered new interface driver usbhid usbhid: v2.6:USB HID core driver GRE over IPv4 demultiplexor driver TCP cubic registered Initializing XFRM netlink socket NET: Registered protocol family 17 registered taskstats version 1 XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/console/0 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initalizing network drop monitor service Freeing unused kernel memory: 1292k freed Write protecting the kernel read-only data: 10240k Freeing unused kernel memory: 788k freed Freeing unused kernel memory: 1568k freed dracut: dracut-004-356.el6 device-mapper: uevent: version 1.0.3 device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com udev: starting version 147 dracut: Starting plymouth daemon xlblk_init: register_blkdev major: 202 blkfront: xvda: barriers disabled xvda: xvda1 xvda2 xvda3 EXT4-fs (xvda2): INFO: recovery required on readonly filesystem EXT4-fs (xvda2): write access will be enabled during recovery EXT4-fs (xvda2): recovery complete EXT4-fs (xvda2): mounted filesystem with ordered data mode. Opts: dracut: Mounted root filesystem /dev/xvda2 dracut: Switching root Welcome to our linux. Initialising Xen virtual ethernet driver. bash: no job control in this shell bash-4.1# ifconfig(查看网卡接口信息) eth0 Link encap:Ethernet HWaddr 00:16:3E:45:80:E5 inet addr:172.16.200.12 Bcast:172.16.255.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:96 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:5848 (5.7 KiB) TX bytes:0 (0.0 b) Interrupt:247 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) bash-4.1# ping -c 5 172.16.200.6(ping测试到达172.16.200.6,-c指定个数) PING 172.16.200.6 (172.16.200.6) 56(84) bytes of data. 64 bytes from 172.16.200.6: icmp_seq=1 ttl=64 time=3.54 ms 64 bytes from 172.16.200.6: icmp_seq=2 ttl=64 time=0.324 ms 64 bytes from 172.16.200.6: icmp_seq=3 ttl=64 time=1.83 ms 64 bytes from 172.16.200.6: icmp_seq=4 ttl=64 time=0.305 ms 64 bytes from 172.16.200.6: icmp_seq=5 ttl=64 time=0.443 ms --- 172.16.200.6 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 0.305/1.290/3.546/1.265 ms bash-4.1# [root@node1 xen]#(使用ctrl+]退出) [root@node1 xen]# xm destroy test(销毁test域) [root@node1 xen]# grub-install --root-directory=/mnt /dev/sdb(安装grub,--root-directory安装grub映像到根目录,) Probing devices to guess BIOS drives. This may take a long time. Installation finished. No error reported. This is the contents of the device map /mnt/boot/grub/device.map. Check if this is correct or not. If any of the lines is incorrect, fix it and re-run the script `grub-install'. (fd0) /dev/fd0 (hd0) /dev/sda (hd1) /dev/sdb [root@node1 xen]# ls /mnt/boot/grub/(查看/mnt/boot/grub目录文件及子目录) device.map fat_stage1_5 iso9660_stage1_5 minix_stage1_5 stage1 ufs2_stage1_5 xfs_stage1_5 e2fs_stage1_5 ffs_stage1_5 jfs_stage1_5 reiserfs_stage1_5 stage2 vstafs_stage1_5 [root@node1 xen]# vim /mnt/boot/grub/grub.conf(编辑grub.conf配置文件) timeout 5 default 0 title MageEdu.com Linux root (hd0,0) kernel /vmlinuz initrd /initramfs.img [root@node1 xen]# cp /boot/vmlinuz-2.6.32-504.el6.x86_64 /mnt/boot/vmlinuz [root@node1 xen]# cp /boot/initramfs-2.6.32-504.el6.x86_64.img /mnt/boot/initramfs.img [root@node1 xen]# sync(同步磁盘写入) [root@node1 xen]# sync(同步磁盘写入) [root@node1 xen]# vim test(编辑test文件) #ramdisk="/boot/initramfs-2.6.32-504.el6.x86_64.img" #kernel="/boot/vmlinuz-2.6.32-504.el6.x86_64" name="test" vcpus=1 memory=256 disk=['phy:/dev/sdb,xvda,w',] #root="/dev/xvda2 ro" bootloader="/usr/bin/pygrub" #extra="selinux=0 init=/sbin/init" vif=[ 'bridge=br0' ] on_crash="destroy" on_reboot="restart" [root@node1 xen]# vim /mnt/boot/grub/grub.conf(编辑grub.conf配置文件) timeout 5 default 0 title MageEdu.com Linux root (hd0,0) kernel /vmlinuz ro root=/dev/xvda2 selinux=0 initrd /initramfs.img [root@node1 xen]# sync(同步磁盘写入) [root@node1 xen]# sync(同步磁盘写入) [root@node1 xen]# vim test(编辑test文件) #ramdisk="/boot/initramfs-2.6.32-504.el6.x86_64.img" #kernel="/boot/vmlinuz-2.6.32-504.el6.x86_64" name="test" vcpus=2 memory=256 disk=['phy:/dev/sdb,xvda,w',] #root="/dev/xvda2 ro" bootloader="/usr/bin/pygrub" #extra="selinux=0 init=/sbin/init" vif=[ 'bridge=br0' ] on_crash="destroy" on_reboot="restart" [root@node1 xen]# xm list(列出所有域) Name ID Mem VCPUs State Time(s) Domain-0 0 512 2 r----- 150.5 [root@node1 xen]# xm create -c test(创建test域并启动,-c连接控制台) Using config file "./test". Using <class 'grub.GrubConf.GrubConfigFile'> to parse /grub/grub.conf pyGRUB version 0.6 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x MageEdu.com Linux x x x x x x x x x x x x x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj Use the ^ and v keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting, 'a' to modify the kernel arguments before booting, or 'c' for a command line. Will boot selected entry in 1 seconds Use the ^ and v keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting, 'a' to modify the kernel arguments before booting, or 'c' for a command line. Started domain test (id=5)try in 1 seconds Initializing cgroup subsys cpuset Initializing cgroup subsys cpu Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014 Command line: ro root=/dev/xvda2 selinux=0 KERNEL supported cpus: Intel GenuineIntel AMD AuthenticAMD Centaur CentaurHauls Disabled fast string operations ACPI in unprivileged domain disabled released 0 pages of unused memory BIOS-provided physical RAM map: Xen: 0000000000000000 - 00000000000a0000 (usable) Xen: 00000000000a0000 - 0000000000100000 (reserved) Xen: 0000000000100000 - 0000000010000000 (usable) DMI not present or invalid. last_pfn = 0x10000 max_arch_pfn = 0x400000000 init_memory_mapping: 0000000000000000-0000000010000000 RAMDISK: 0204b000 - 04ffa000 No NUMA configuration found Faking a node at 0000000000000000-0000000010000000 Bootmem setup node 0 0000000000000000-0000000010000000 NODE_DATA [000000000005a000 - 000000000008dfff] bootmap [000000000008e000 - 000000000008ffff] pages 2 (7 early reservations) ==> bootmem [0000000000 - 0010000000] #0 [0000000000 - 0000001000] BIOS data page ==> [0000000000 - 0000001000] #1 [000507d000 - 00050aa000] XEN PAGETABLES ==> [000507d000 - 00050aa000] #2 [0000006000 - 0000008000] TRAMPOLINE ==> [0000006000 - 0000008000] #3 [0001000000 - 000202abe4] TEXT DATA BSS ==> [0001000000 - 000202abe4] #4 [000204b000 - 0004ffa000] RAMDISK ==> [000204b000 - 0004ffa000] #5 [0004ffa000 - 000507d000] XEN START INFO ==> [0004ffa000 - 000507d000] #6 [0000008000 - 000005a000] PGTABLE ==> [0000008000 - 000005a000] Zone PFN ranges: DMA 0x00000001 -> 0x00001000 DMA32 0x00001000 -> 0x00100000 Normal 0x00100000 -> 0x00100000 Movable zone start PFN for each node early_node_map[2] active PFN ranges 0: 0x00000001 -> 0x000000a0 0: 0x00000100 -> 0x00010000 SFI: Simple Firmware Interface v0.7 http://simplefirmware.org SMP: Allowing 2 CPUs, 0 hotplug CPUs No local APIC present APIC: disable apic facility PM: Registered nosave memory: 00000000000a0000 - 0000000000100000 Allocating PCI resources starting at 10000000 (gap: 10000000:f0000000) Booting paravirtualized kernel on Xen Xen version: 4.1.3 (preserve-AD) NR_CPUS:4096 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1 PERCPU: Embedded 31 pages/cpu @ffff8800050e0000 s95064 r8192 d23720 u126976 pcpu-alloc: s95064 r8192 d23720 u126976 alloc=31*4096 pcpu-alloc: [0] 0 [0] 1 Xen: using vcpu_info placement Built 1 zonelists in Node order, mobility grouping on. Total pages: 64458 Policy zone: DMA32 Kernel command line: ro root=/dev/xvda2 selinux=0 PID hash table entries: 1024 (order: 1, 8192 bytes) Checking aperture... No AGP bridge found Memory: 191024k/262144k available (5336k kernel code, 388k absent, 70732k reserved, 7016k data, 1292k init) Hierarchical RCU implementation. NR_IRQS:33024 nr_irqs:288 Console: colour dummy device 80x25 console [tty0] enabled console [hvc0] enabled allocated 1048576 bytes of page_cgroup please try 'cgroup_disable=memory' option if you don't want memory cgroups installing Xen timer for CPU 0 Detected 2493.318 MHz processor. Calibrating delay loop (skipped), value calculated using timer frequency.. 4986.63 BogoMIPS (lpj=2493318) pid_max: default: 32768 minimum: 301 Security Framework initialized SELinux: Disabled at boot. Dentry cache hash table entries: 32768 (order: 6, 262144 bytes) Inode-cache hash table entries: 16384 (order: 5, 131072 bytes) Mount-cache hash table entries: 256 Initializing cgroup subsys ns Initializing cgroup subsys cpuacct Initializing cgroup subsys memory Initializing cgroup subsys devices Initializing cgroup subsys freezer Initializing cgroup subsys net_cls Initializing cgroup subsys blkio Initializing cgroup subsys perf_event Initializing cgroup subsys net_prio Disabled fast string operations alternatives: switching to unfair spinlock SMP alternatives: switching to UP code ftrace: converting mcount calls to 0f 1f 44 00 00 ftrace: allocating 21917 entries in 86 pages Performance Events: unsupported p6 CPU model 58 no PMU driver, software events only. NMI watchdog disabled (cpu0): hardware events not enabled installing Xen timer for CPU 1 SMP alternatives: switching to SMP code Disabled fast string operations Brought up 2 CPUs devtmpfs: initialized Grant table initialized regulator: core version 0.5 NET: Registered protocol family 16 PCI: Fatal: No config space access function found bio: create slab <bio-0> at 0 ACPI: Interpreter disabled. xen_balloon: Initialising balloon driver. last_pfn = 0x10000 max_arch_pfn = 0x400000000 vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default Switching to clocksource xen pnp: PnP ACPI: disabled NET: Registered protocol family 2 IP route cache hash table entries: 2048 (order: 2, 16384 bytes) TCP established hash table entries: 8192 (order: 5, 131072 bytes) TCP bind hash table entries: 8192 (order: 5, 131072 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP reno registered NET: Registered protocol family 1 Trying to unpack rootfs image as initramfs... Freeing initrd memory: 48828k freed platform rtc_cmos: registered platform RTC device (no PNP device found) futex hash table entries: 512 (order: 3, 32768 bytes) audit: initializing netlink socket (disabled) type=2000 audit(1470679787.391:1): initialized HugeTLB registered 2 MB page size, pre-allocated 0 pages VFS: Disk quotas dquot_6.5.2 Dquot-cache hash table entries: 512 (order 0, 4096 bytes) msgmni has been set to 468 alg: No test for stdrng (krng) ksign: Installing public key data Loading keyring - Added public key FEBCF26ABFDA92DD - User ID: CentOS (Kernel Module GPG key) Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 pciehp: PCI Express Hot Plug Controller Driver version: 0.4 acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 Non-volatile memory driver v1.3 Linux agpgart interface v0.103 crash memory driver: version 1.1 Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled brd: module loaded loop: module loaded input: Macintosh mouse button emulation as /devices/virtual/input/input0 Fixed MDIO Bus: probed ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver uhci_hcd: USB Universal Host Controller Interface driver PNP: No PS/2 controller found. Probing ports directly. mice: PS/2 mouse device common for all mice rtc_cmos: probe of rtc_cmos failed with error -16 cpuidle: using governor ladder cpuidle: using governor menu EFI Variables Facility v0.08 2004-May-17 usbcore: registered new interface driver hiddev usbcore: registered new interface driver usbhid usbhid: v2.6:USB HID core driver GRE over IPv4 demultiplexor driver TCP cubic registered Initializing XFRM netlink socket NET: Registered protocol family 17 registered taskstats version 1 XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/console/0 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initalizing network drop monitor service Freeing unused kernel memory: 1292k freed Write protecting the kernel read-only data: 10240k Freeing unused kernel memory: 788k freed Freeing unused kernel memory: 1568k freed dracut: dracut-004-356.el6 device-mapper: uevent: version 1.0.3 device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com udev: starting version 147 dracut: Starting plymouth daemon xlblk_init: register_blkdev major: 202 blkfront: xvda: barriers disabled xvda: xvda1 xvda2 xvda3 EXT4-fs (xvda2): mounted filesystem with ordered data mode. Opts: dracut: Mounted root filesystem /dev/xvda2 dracut: Switching root Initialising Xen virtual ethernet driver.(virtual ethernet设备初始化不成功,使用ctrl+]退出) [root@node1 xen]# xm destroy test(销毁test域) [root@node1 xen]# vim /mnt/sysroot/etc/rc.d/rc.sysinit(编辑rc.sysinit文件) #!/bin/bash # echo -e "\tWelcome to our linux." insmod /lib/modules/xen-netfront.ko sleep 2 ifconfig lo 127.0.01/8 up ifconfig eth0 172.16.200.12/16 up #mount -n -o remount,rw / /bin/bash [root@node1 xen]# cd(切换到用户家目录) [root@node1 ~]# bash bincp.sh(执行bincp.sh脚本) Your command: sleep /bin/sleep copy /bin/sleep finished. Continue: q [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# xm create -c test(创建test域并启动,-c连接控制台) Using config file "/etc/xen/test". Using <class 'grub.GrubConf.GrubConfigFile'> to parse /grub/grub.conf pyGRUB version 0.6 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x MageEdu.com Linux x x x x x x x x x x x x x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj Use the ^ and v keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting, 'a' to modify the kernel arguments before booting, or 'c' for a command line. Started domain test (id=6)try in 1 seconds Initializing cgroup subsys cpuset Initializing cgroup subsys cpu Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014 Command line: ro root=/dev/xvda2 selinux=0 KERNEL supported cpus: Intel GenuineIntel AMD AuthenticAMD Centaur CentaurHauls Disabled fast string operations ACPI in unprivileged domain disabled released 0 pages of unused memory BIOS-provided physical RAM map: Xen: 0000000000000000 - 00000000000a0000 (usable) Xen: 00000000000a0000 - 0000000000100000 (reserved) Xen: 0000000000100000 - 0000000010000000 (usable) DMI not present or invalid. last_pfn = 0x10000 max_arch_pfn = 0x400000000 init_memory_mapping: 0000000000000000-0000000010000000 RAMDISK: 0204b000 - 04ffa000 No NUMA configuration found Faking a node at 0000000000000000-0000000010000000 Bootmem setup node 0 0000000000000000-0000000010000000 NODE_DATA [000000000005a000 - 000000000008dfff] bootmap [000000000008e000 - 000000000008ffff] pages 2 (7 early reservations) ==> bootmem [0000000000 - 0010000000] #0 [0000000000 - 0000001000] BIOS data page ==> [0000000000 - 0000001000] #1 [000507d000 - 00050aa000] XEN PAGETABLES ==> [000507d000 - 00050aa000] #2 [0000006000 - 0000008000] TRAMPOLINE ==> [0000006000 - 0000008000] #3 [0001000000 - 000202abe4] TEXT DATA BSS ==> [0001000000 - 000202abe4] #4 [000204b000 - 0004ffa000] RAMDISK ==> [000204b000 - 0004ffa000] #5 [0004ffa000 - 000507d000] XEN START INFO ==> [0004ffa000 - 000507d000] #6 [0000008000 - 000005a000] PGTABLE ==> [0000008000 - 000005a000] Zone PFN ranges: DMA 0x00000001 -> 0x00001000 DMA32 0x00001000 -> 0x00100000 Normal 0x00100000 -> 0x00100000 Movable zone start PFN for each node early_node_map[2] active PFN ranges 0: 0x00000001 -> 0x000000a0 0: 0x00000100 -> 0x00010000 SFI: Simple Firmware Interface v0.7 http://simplefirmware.org SMP: Allowing 2 CPUs, 0 hotplug CPUs No local APIC present APIC: disable apic facility PM: Registered nosave memory: 00000000000a0000 - 0000000000100000 Allocating PCI resources starting at 10000000 (gap: 10000000:f0000000) Booting paravirtualized kernel on Xen Xen version: 4.1.3 (preserve-AD) NR_CPUS:4096 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1 PERCPU: Embedded 31 pages/cpu @ffff8800050e0000 s95064 r8192 d23720 u126976 pcpu-alloc: s95064 r8192 d23720 u126976 alloc=31*4096 pcpu-alloc: [0] 0 [0] 1 Xen: using vcpu_info placement Built 1 zonelists in Node order, mobility grouping on. Total pages: 64458 Policy zone: DMA32 Kernel command line: ro root=/dev/xvda2 selinux=0 PID hash table entries: 1024 (order: 1, 8192 bytes) Checking aperture... No AGP bridge found Memory: 191024k/262144k available (5336k kernel code, 388k absent, 70732k reserved, 7016k data, 1292k init) Hierarchical RCU implementation. NR_IRQS:33024 nr_irqs:288 Console: colour dummy device 80x25 console [tty0] enabled console [hvc0] enabled allocated 1048576 bytes of page_cgroup please try 'cgroup_disable=memory' option if you don't want memory cgroups installing Xen timer for CPU 0 Detected 2493.318 MHz processor. Calibrating delay loop (skipped), value calculated using timer frequency.. 4986.63 BogoMIPS (lpj=2493318) pid_max: default: 32768 minimum: 301 Security Framework initialized SELinux: Disabled at boot. Dentry cache hash table entries: 32768 (order: 6, 262144 bytes) Inode-cache hash table entries: 16384 (order: 5, 131072 bytes) Mount-cache hash table entries: 256 Initializing cgroup subsys ns Initializing cgroup subsys cpuacct Initializing cgroup subsys memory Initializing cgroup subsys devices Initializing cgroup subsys freezer Initializing cgroup subsys net_cls Initializing cgroup subsys blkio Initializing cgroup subsys perf_event Initializing cgroup subsys net_prio Disabled fast string operations alternatives: switching to unfair spinlock SMP alternatives: switching to UP code ftrace: converting mcount calls to 0f 1f 44 00 00 ftrace: allocating 21917 entries in 86 pages Performance Events: unsupported p6 CPU model 58 no PMU driver, software events only. NMI watchdog disabled (cpu0): hardware events not enabled installing Xen timer for CPU 1 SMP alternatives: switching to SMP code Disabled fast string operations Brought up 2 CPUs devtmpfs: initialized Grant table initialized regulator: core version 0.5 NET: Registered protocol family 16 PCI: Fatal: No config space access function found bio: create slab <bio-0> at 0 ACPI: Interpreter disabled. xen_balloon: Initialising balloon driver. last_pfn = 0x10000 max_arch_pfn = 0x400000000 vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default Switching to clocksource xen pnp: PnP ACPI: disabled NET: Registered protocol family 2 IP route cache hash table entries: 2048 (order: 2, 16384 bytes) TCP established hash table entries: 8192 (order: 5, 131072 bytes) TCP bind hash table entries: 8192 (order: 5, 131072 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP reno registered NET: Registered protocol family 1 Trying to unpack rootfs image as initramfs... Freeing initrd memory: 48828k freed platform rtc_cmos: registered platform RTC device (no PNP device found) futex hash table entries: 512 (order: 3, 32768 bytes) audit: initializing netlink socket (disabled) type=2000 audit(1470680102.486:1): initialized HugeTLB registered 2 MB page size, pre-allocated 0 pages VFS: Disk quotas dquot_6.5.2 Dquot-cache hash table entries: 512 (order 0, 4096 bytes) msgmni has been set to 468 alg: No test for stdrng (krng) ksign: Installing public key data Loading keyring - Added public key FEBCF26ABFDA92DD - User ID: CentOS (Kernel Module GPG key) Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 pciehp: PCI Express Hot Plug Controller Driver version: 0.4 acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 Non-volatile memory driver v1.3 Linux agpgart interface v0.103 crash memory driver: version 1.1 Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled brd: module loaded loop: module loaded input: Macintosh mouse button emulation as /devices/virtual/input/input0 Fixed MDIO Bus: probed ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver uhci_hcd: USB Universal Host Controller Interface driver PNP: No PS/2 controller found. Probing ports directly. mice: PS/2 mouse device common for all mice rtc_cmos: probe of rtc_cmos failed with error -16 cpuidle: using governor ladder cpuidle: using governor menu EFI Variables Facility v0.08 2004-May-17 usbcore: registered new interface driver hiddev usbcore: registered new interface driver usbhid usbhid: v2.6:USB HID core driver GRE over IPv4 demultiplexor driver TCP cubic registered Initializing XFRM netlink socket NET: Registered protocol family 17 registered taskstats version 1 XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/console/0 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initalizing network drop monitor service Freeing unused kernel memory: 1292k freed Write protecting the kernel read-only data: 10240k Freeing unused kernel memory: 788k freed Freeing unused kernel memory: 1568k freed dracut: dracut-004-356.el6 device-mapper: uevent: version 1.0.3 device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com udev: starting version 147 dracut: Starting plymouth daemon xlblk_init: register_blkdev major: 202 blkfront: xvda: barriers disabled xvda: xvda1 xvda2 xvda3 EXT4-fs (xvda2): INFO: recovery required on readonly filesystem EXT4-fs (xvda2): write access will be enabled during recovery EXT4-fs (xvda2): recovery complete EXT4-fs (xvda2): mounted filesystem with ordered data mode. Opts: dracut: Mounted root filesystem /dev/xvda2 dracut: Switching root Initialising Xen virtual ethernet driver.(xen virtual ethernet设备还是无法初始化,使用ctrl+]退出) [root@node1 ~]# xm destroy test(销毁test域) [root@node1 ~]# vim /mnt/sysroot/etc/rc.d/rc.sysinit(编辑rc.sysinit文件) #!/bin/bash # echo -e "\tWelcome to our linux." #insmod /lib/modules/xen-netfront.ko #ifconfig lo 127.0.01/8 up #ifconfig eth0 172.16.200.12/16 up #mount -n -o remount,rw / /bin/bash [root@node1 ~]# xm create -c test(创建test虚拟机并启动,-c连接控制台) Using config file "/etc/xen/test". Using <class 'grub.GrubConf.GrubConfigFile'> to parse /grub/grub.conf pyGRUB version 0.6 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x MageEdu.com Linux x x x x x x x x x x x x x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj Use the ^ and v keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting, 'a' to modify the kernel arguments before booting, or 'c' for a command line. Started domain test (id=7)try in 1 seconds Initializing cgroup subsys cpuset Initializing cgroup subsys cpu Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014 Command line: ro root=/dev/xvda2 selinux=0 KERNEL supported cpus: Intel GenuineIntel AMD AuthenticAMD Centaur CentaurHauls Disabled fast string operations ACPI in unprivileged domain disabled released 0 pages of unused memory BIOS-provided physical RAM map: Xen: 0000000000000000 - 00000000000a0000 (usable) Xen: 00000000000a0000 - 0000000000100000 (reserved) Xen: 0000000000100000 - 0000000010000000 (usable) DMI not present or invalid. last_pfn = 0x10000 max_arch_pfn = 0x400000000 init_memory_mapping: 0000000000000000-0000000010000000 RAMDISK: 0204b000 - 04ffa000 No NUMA configuration found Faking a node at 0000000000000000-0000000010000000 Bootmem setup node 0 0000000000000000-0000000010000000 NODE_DATA [000000000005a000 - 000000000008dfff] bootmap [000000000008e000 - 000000000008ffff] pages 2 (7 early reservations) ==> bootmem [0000000000 - 0010000000] #0 [0000000000 - 0000001000] BIOS data page ==> [0000000000 - 0000001000] #1 [000507d000 - 00050aa000] XEN PAGETABLES ==> [000507d000 - 00050aa000] #2 [0000006000 - 0000008000] TRAMPOLINE ==> [0000006000 - 0000008000] #3 [0001000000 - 000202abe4] TEXT DATA BSS ==> [0001000000 - 000202abe4] #4 [000204b000 - 0004ffa000] RAMDISK ==> [000204b000 - 0004ffa000] #5 [0004ffa000 - 000507d000] XEN START INFO ==> [0004ffa000 - 000507d000] #6 [0000008000 - 000005a000] PGTABLE ==> [0000008000 - 000005a000] Zone PFN ranges: DMA 0x00000001 -> 0x00001000 DMA32 0x00001000 -> 0x00100000 Normal 0x00100000 -> 0x00100000 Movable zone start PFN for each node early_node_map[2] active PFN ranges 0: 0x00000001 -> 0x000000a0 0: 0x00000100 -> 0x00010000 SFI: Simple Firmware Interface v0.7 http://simplefirmware.org SMP: Allowing 2 CPUs, 0 hotplug CPUs No local APIC present APIC: disable apic facility PM: Registered nosave memory: 00000000000a0000 - 0000000000100000 Allocating PCI resources starting at 10000000 (gap: 10000000:f0000000) Booting paravirtualized kernel on Xen Xen version: 4.1.3 (preserve-AD) NR_CPUS:4096 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1 PERCPU: Embedded 31 pages/cpu @ffff8800050e0000 s95064 r8192 d23720 u126976 pcpu-alloc: s95064 r8192 d23720 u126976 alloc=31*4096 pcpu-alloc: [0] 0 [0] 1 Xen: using vcpu_info placement Built 1 zonelists in Node order, mobility grouping on. Total pages: 64458 Policy zone: DMA32 Kernel command line: ro root=/dev/xvda2 selinux=0 PID hash table entries: 1024 (order: 1, 8192 bytes) Checking aperture... No AGP bridge found Memory: 191024k/262144k available (5336k kernel code, 388k absent, 70732k reserved, 7016k data, 1292k init) Hierarchical RCU implementation. NR_IRQS:33024 nr_irqs:288 Console: colour dummy device 80x25 console [tty0] enabled console [hvc0] enabled allocated 1048576 bytes of page_cgroup please try 'cgroup_disable=memory' option if you don't want memory cgroups installing Xen timer for CPU 0 Detected 2493.318 MHz processor. Calibrating delay loop (skipped), value calculated using timer frequency.. 4986.63 BogoMIPS (lpj=2493318) pid_max: default: 32768 minimum: 301 Security Framework initialized SELinux: Disabled at boot. Dentry cache hash table entries: 32768 (order: 6, 262144 bytes) Inode-cache hash table entries: 16384 (order: 5, 131072 bytes) Mount-cache hash table entries: 256 Initializing cgroup subsys ns Initializing cgroup subsys cpuacct Initializing cgroup subsys memory Initializing cgroup subsys devices Initializing cgroup subsys freezer Initializing cgroup subsys net_cls Initializing cgroup subsys blkio Initializing cgroup subsys perf_event Initializing cgroup subsys net_prio Disabled fast string operations alternatives: switching to unfair spinlock SMP alternatives: switching to UP code ftrace: converting mcount calls to 0f 1f 44 00 00 ftrace: allocating 21917 entries in 86 pages Performance Events: unsupported p6 CPU model 58 no PMU driver, software events only. NMI watchdog disabled (cpu0): hardware events not enabled installing Xen timer for CPU 1 SMP alternatives: switching to SMP code Disabled fast string operations Brought up 2 CPUs devtmpfs: initialized Grant table initialized regulator: core version 0.5 NET: Registered protocol family 16 PCI: Fatal: No config space access function found bio: create slab <bio-0> at 0 ACPI: Interpreter disabled. xen_balloon: Initialising balloon driver. last_pfn = 0x10000 max_arch_pfn = 0x400000000 vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default Switching to clocksource xen pnp: PnP ACPI: disabled NET: Registered protocol family 2 IP route cache hash table entries: 2048 (order: 2, 16384 bytes) TCP established hash table entries: 8192 (order: 5, 131072 bytes) TCP bind hash table entries: 8192 (order: 5, 131072 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP reno registered NET: Registered protocol family 1 Trying to unpack rootfs image as initramfs... Freeing initrd memory: 48828k freed platform rtc_cmos: registered platform RTC device (no PNP device found) futex hash table entries: 512 (order: 3, 32768 bytes) audit: initializing netlink socket (disabled) type=2000 audit(1470680409.193:1): initialized HugeTLB registered 2 MB page size, pre-allocated 0 pages VFS: Disk quotas dquot_6.5.2 Dquot-cache hash table entries: 512 (order 0, 4096 bytes) msgmni has been set to 468 alg: No test for stdrng (krng) ksign: Installing public key data Loading keyring - Added public key FEBCF26ABFDA92DD - User ID: CentOS (Kernel Module GPG key) Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 pciehp: PCI Express Hot Plug Controller Driver version: 0.4 acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 Non-volatile memory driver v1.3 Linux agpgart interface v0.103 crash memory driver: version 1.1 Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled brd: module loaded loop: module loaded input: Macintosh mouse button emulation as /devices/virtual/input/input0 Fixed MDIO Bus: probed ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver uhci_hcd: USB Universal Host Controller Interface driver PNP: No PS/2 controller found. Probing ports directly. mice: PS/2 mouse device common for all mice rtc_cmos: probe of rtc_cmos failed with error -16 cpuidle: using governor ladder cpuidle: using governor menu EFI Variables Facility v0.08 2004-May-17 usbcore: registered new interface driver hiddev usbcore: registered new interface driver usbhid usbhid: v2.6:USB HID core driver GRE over IPv4 demultiplexor driver TCP cubic registered Initializing XFRM netlink socket NET: Registered protocol family 17 registered taskstats version 1 XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/console/0 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initalizing network drop monitor service Freeing unused kernel memory: 1292k freed Write protecting the kernel read-only data: 10240k Freeing unused kernel memory: 788k freed Freeing unused kernel memory: 1568k freed dracut: dracut-004-356.el6 device-mapper: uevent: version 1.0.3 device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com udev: starting version 147 dracut: Starting plymouth daemon xlblk_init: register_blkdev major: 202 blkfront: xvda: barriers disabled xvda: xvda1 xvda2 xvda3 EXT4-fs (xvda2): INFO: recovery required on readonly filesystem EXT4-fs (xvda2): write access will be enabled during recovery EXT4-fs (xvda2): recovery complete EXT4-fs (xvda2): mounted filesystem with ordered data mode. Opts: dracut: Mounted root filesystem /dev/xvda2 dracut: Switching root(卡住了,使用ctrl+]退出) [root@node1 ~]# xm destroy test(销毁test域) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# vim /mnt/sysroot/etc/rc.d/rc.sysinit(编辑rc.sysinit文件) #!/bin/bash # echo -e "\tWelcome to our linux." #insmod /lib/modules/xen-netfront.ko #ifconfig lo 127.0.01/8 up #ifconfig eth0 172.16.200.12/16 up #mount -n -o remount,rw / /bin/bash [root@node1 ~]# cd /etc/xen/(切换到/etc/xen目录) [root@node1 xen]# vim test(编辑test文件) [root@node1 xen]# vim /mnt/boot/grub/grub.conf(编辑grub.conf配置文件) timeout 5 default 0 title MageEdu.com Linux root (hd0,0) kernel /vmlinuz ro root=/dev/xvda2 selinux=0 init=/sbin/init initrd /initramfs.img [root@node1 xen]# sync(同步磁盘写入) [root@node1 xen]# sync(同步磁盘写入) [root@node1 xen]# sync(同步磁盘写入) [root@node1 xen]# xm create -c test(创建test域并启动,-c连接控制台) Using config file "./test". Using <class 'grub.GrubConf.GrubConfigFile'> to parse /grub/grub.conf pyGRUB version 0.6 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x MageEdu.com Linux x x x x x x x x x x x x x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj Use the ^ and v keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting, 'a' to modify the kernel arguments before booting, or 'c' for a command line. Started domain test (id=8)try in 1 seconds Initializing cgroup subsys cpuset Initializing cgroup subsys cpu Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014 Command line: ro root=/dev/xvda2 selinux=0 init=/sbin/init KERNEL supported cpus: Intel GenuineIntel AMD AuthenticAMD Centaur CentaurHauls Disabled fast string operations ACPI in unprivileged domain disabled released 0 pages of unused memory BIOS-provided physical RAM map: Xen: 0000000000000000 - 00000000000a0000 (usable) Xen: 00000000000a0000 - 0000000000100000 (reserved) Xen: 0000000000100000 - 0000000010000000 (usable) DMI not present or invalid. last_pfn = 0x10000 max_arch_pfn = 0x400000000 init_memory_mapping: 0000000000000000-0000000010000000 RAMDISK: 0204b000 - 04ffa000 No NUMA configuration found Faking a node at 0000000000000000-0000000010000000 Bootmem setup node 0 0000000000000000-0000000010000000 NODE_DATA [000000000005a000 - 000000000008dfff] bootmap [000000000008e000 - 000000000008ffff] pages 2 (7 early reservations) ==> bootmem [0000000000 - 0010000000] #0 [0000000000 - 0000001000] BIOS data page ==> [0000000000 - 0000001000] #1 [000507d000 - 00050aa000] XEN PAGETABLES ==> [000507d000 - 00050aa000] #2 [0000006000 - 0000008000] TRAMPOLINE ==> [0000006000 - 0000008000] #3 [0001000000 - 000202abe4] TEXT DATA BSS ==> [0001000000 - 000202abe4] #4 [000204b000 - 0004ffa000] RAMDISK ==> [000204b000 - 0004ffa000] #5 [0004ffa000 - 000507d000] XEN START INFO ==> [0004ffa000 - 000507d000] #6 [0000008000 - 000005a000] PGTABLE ==> [0000008000 - 000005a000] Zone PFN ranges: DMA 0x00000001 -> 0x00001000 DMA32 0x00001000 -> 0x00100000 Normal 0x00100000 -> 0x00100000 Movable zone start PFN for each node early_node_map[2] active PFN ranges 0: 0x00000001 -> 0x000000a0 0: 0x00000100 -> 0x00010000 SFI: Simple Firmware Interface v0.7 http://simplefirmware.org SMP: Allowing 2 CPUs, 0 hotplug CPUs No local APIC present APIC: disable apic facility PM: Registered nosave memory: 00000000000a0000 - 0000000000100000 Allocating PCI resources starting at 10000000 (gap: 10000000:f0000000) Booting paravirtualized kernel on Xen Xen version: 4.1.3 (preserve-AD) NR_CPUS:4096 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1 PERCPU: Embedded 31 pages/cpu @ffff8800050e0000 s95064 r8192 d23720 u126976 pcpu-alloc: s95064 r8192 d23720 u126976 alloc=31*4096 pcpu-alloc: [0] 0 [0] 1 Xen: using vcpu_info placement Built 1 zonelists in Node order, mobility grouping on. Total pages: 64458 Policy zone: DMA32 Kernel command line: ro root=/dev/xvda2 selinux=0 init=/sbin/init PID hash table entries: 1024 (order: 1, 8192 bytes) Checking aperture... No AGP bridge found Memory: 191024k/262144k available (5336k kernel code, 388k absent, 70732k reserved, 7016k data, 1292k init) Hierarchical RCU implementation. NR_IRQS:33024 nr_irqs:288 Console: colour dummy device 80x25 console [tty0] enabled console [hvc0] enabled allocated 1048576 bytes of page_cgroup please try 'cgroup_disable=memory' option if you don't want memory cgroups installing Xen timer for CPU 0 Detected 2493.318 MHz processor. Calibrating delay loop (skipped), value calculated using timer frequency.. 4986.63 BogoMIPS (lpj=2493318) pid_max: default: 32768 minimum: 301 Security Framework initialized SELinux: Disabled at boot. Dentry cache hash table entries: 32768 (order: 6, 262144 bytes) Inode-cache hash table entries: 16384 (order: 5, 131072 bytes) Mount-cache hash table entries: 256 Initializing cgroup subsys ns Initializing cgroup subsys cpuacct Initializing cgroup subsys memory Initializing cgroup subsys devices Initializing cgroup subsys freezer Initializing cgroup subsys net_cls Initializing cgroup subsys blkio Initializing cgroup subsys perf_event Initializing cgroup subsys net_prio Disabled fast string operations alternatives: switching to unfair spinlock SMP alternatives: switching to UP code ftrace: converting mcount calls to 0f 1f 44 00 00 ftrace: allocating 21917 entries in 86 pages Performance Events: unsupported p6 CPU model 58 no PMU driver, software events only. NMI watchdog disabled (cpu0): hardware events not enabled installing Xen timer for CPU 1 SMP alternatives: switching to SMP code Disabled fast string operations Brought up 2 CPUs devtmpfs: initialized Grant table initialized regulator: core version 0.5 NET: Registered protocol family 16 PCI: Fatal: No config space access function found bio: create slab <bio-0> at 0 ACPI: Interpreter disabled. xen_balloon: Initialising balloon driver. last_pfn = 0x10000 max_arch_pfn = 0x400000000 vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default Switching to clocksource xen pnp: PnP ACPI: disabled NET: Registered protocol family 2 IP route cache hash table entries: 2048 (order: 2, 16384 bytes) TCP established hash table entries: 8192 (order: 5, 131072 bytes) TCP bind hash table entries: 8192 (order: 5, 131072 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP reno registered NET: Registered protocol family 1 Trying to unpack rootfs image as initramfs... Freeing initrd memory: 48828k freed platform rtc_cmos: registered platform RTC device (no PNP device found) futex hash table entries: 512 (order: 3, 32768 bytes) audit: initializing netlink socket (disabled) type=2000 audit(1470680955.057:1): initialized HugeTLB registered 2 MB page size, pre-allocated 0 pages VFS: Disk quotas dquot_6.5.2 Dquot-cache hash table entries: 512 (order 0, 4096 bytes) msgmni has been set to 468 alg: No test for stdrng (krng) ksign: Installing public key data Loading keyring - Added public key FEBCF26ABFDA92DD - User ID: CentOS (Kernel Module GPG key) Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 pciehp: PCI Express Hot Plug Controller Driver version: 0.4 acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 Non-volatile memory driver v1.3 Linux agpgart interface v0.103 crash memory driver: version 1.1 Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled brd: module loaded loop: module loaded input: Macintosh mouse button emulation as /devices/virtual/input/input0 Fixed MDIO Bus: probed ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver uhci_hcd: USB Universal Host Controller Interface driver PNP: No PS/2 controller found. Probing ports directly. mice: PS/2 mouse device common for all mice rtc_cmos: probe of rtc_cmos failed with error -16 cpuidle: using governor ladder cpuidle: using governor menu EFI Variables Facility v0.08 2004-May-17 usbcore: registered new interface driver hiddev usbcore: registered new interface driver usbhid usbhid: v2.6:USB HID core driver GRE over IPv4 demultiplexor driver TCP cubic registered Initializing XFRM netlink socket NET: Registered protocol family 17 registered taskstats version 1 XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/console/0 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initalizing network drop monitor service Freeing unused kernel memory: 1292k freed Write protecting the kernel read-only data: 10240k Freeing unused kernel memory: 788k freed Freeing unused kernel memory: 1568k freed dracut: dracut-004-356.el6 device-mapper: uevent: version 1.0.3 device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com udev: starting version 147 dracut: Starting plymouth daemon xlblk_init: register_blkdev major: 202 blkfront: xvda: barriers disabled xvda: xvda1 xvda2 xvda3 EXT4-fs (xvda2): INFO: recovery required on readonly filesystem EXT4-fs (xvda2): write access will be enabled during recovery EXT4-fs (xvda2): recovery complete EXT4-fs (xvda2): mounted filesystem with ordered data mode. Opts: dracut: Mounted root filesystem /dev/xvda2 dracut: Switching root Welcome to our linux. bash: no job control in this shell bash-4.1# [root@node1 xen]# (使用ctrl+]退出) [root@node1 xen]# xm destroy test(销毁test域) [root@node1 xen]# vim /mnt/sysroot/etc/rc.d/rc.sysinit(编辑rc.sysinit文件) #!/bin/bash # echo -e "\tWelcome to our linux." insmod /lib/modules/xen-netfront.ko ifconfig lo 127.0.01/8 up ifconfig eth0 172.16.200.12/16 up #mount -n -o remount,rw / /bin/bash [root@node1 xen]# xm create -c test(创建test域并启动,-c连接到控制台) Using config file "./test". Using <class 'grub.GrubConf.GrubConfigFile'> to parse /grub/grub.conf pyGRUB version 0.6 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x MageEdu.com Linux x x x x x x x x x x x x x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj Use the ^ and v keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting, 'a' to modify the kernel arguments before booting, or 'c' for a command line. Will boot selected entry in 1 seconds Started domain test (id=9) Initializing cgroup subsys cpuset Initializing cgroup subsys cpu Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014 Command line: ro root=/dev/xvda2 selinux=0 init=/sbin/init KERNEL supported cpus: Intel GenuineIntel AMD AuthenticAMD Centaur CentaurHauls Disabled fast string operations ACPI in unprivileged domain disabled released 0 pages of unused memory BIOS-provided physical RAM map: Xen: 0000000000000000 - 00000000000a0000 (usable) Xen: 00000000000a0000 - 0000000000100000 (reserved) Xen: 0000000000100000 - 0000000010000000 (usable) DMI not present or invalid. last_pfn = 0x10000 max_arch_pfn = 0x400000000 init_memory_mapping: 0000000000000000-0000000010000000 RAMDISK: 0204b000 - 04ffa000 No NUMA configuration found Faking a node at 0000000000000000-0000000010000000 Bootmem setup node 0 0000000000000000-0000000010000000 NODE_DATA [000000000005a000 - 000000000008dfff] bootmap [000000000008e000 - 000000000008ffff] pages 2 (7 early reservations) ==> bootmem [0000000000 - 0010000000] #0 [0000000000 - 0000001000] BIOS data page ==> [0000000000 - 0000001000] #1 [000507d000 - 00050aa000] XEN PAGETABLES ==> [000507d000 - 00050aa000] #2 [0000006000 - 0000008000] TRAMPOLINE ==> [0000006000 - 0000008000] #3 [0001000000 - 000202abe4] TEXT DATA BSS ==> [0001000000 - 000202abe4] #4 [000204b000 - 0004ffa000] RAMDISK ==> [000204b000 - 0004ffa000] #5 [0004ffa000 - 000507d000] XEN START INFO ==> [0004ffa000 - 000507d000] #6 [0000008000 - 000005a000] PGTABLE ==> [0000008000 - 000005a000] Zone PFN ranges: DMA 0x00000001 -> 0x00001000 DMA32 0x00001000 -> 0x00100000 Normal 0x00100000 -> 0x00100000 Movable zone start PFN for each node early_node_map[2] active PFN ranges 0: 0x00000001 -> 0x000000a0 0: 0x00000100 -> 0x00010000 SFI: Simple Firmware Interface v0.7 http://simplefirmware.org SMP: Allowing 2 CPUs, 0 hotplug CPUs No local APIC present APIC: disable apic facility PM: Registered nosave memory: 00000000000a0000 - 0000000000100000 Allocating PCI resources starting at 10000000 (gap: 10000000:f0000000) Booting paravirtualized kernel on Xen Xen version: 4.1.3 (preserve-AD) NR_CPUS:4096 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1 PERCPU: Embedded 31 pages/cpu @ffff8800050e0000 s95064 r8192 d23720 u126976 pcpu-alloc: s95064 r8192 d23720 u126976 alloc=31*4096 pcpu-alloc: [0] 0 [0] 1 Xen: using vcpu_info placement Built 1 zonelists in Node order, mobility grouping on. Total pages: 64458 Policy zone: DMA32 Kernel command line: ro root=/dev/xvda2 selinux=0 init=/sbin/init PID hash table entries: 1024 (order: 1, 8192 bytes) Checking aperture... No AGP bridge found Memory: 191024k/262144k available (5336k kernel code, 388k absent, 70732k reserved, 7016k data, 1292k init) Hierarchical RCU implementation. NR_IRQS:33024 nr_irqs:288 Console: colour dummy device 80x25 console [tty0] enabled console [hvc0] enabled allocated 1048576 bytes of page_cgroup please try 'cgroup_disable=memory' option if you don't want memory cgroups installing Xen timer for CPU 0 Detected 2493.318 MHz processor. Calibrating delay loop (skipped), value calculated using timer frequency.. 4986.63 BogoMIPS (lpj=2493318) pid_max: default: 32768 minimum: 301 Security Framework initialized SELinux: Disabled at boot. Dentry cache hash table entries: 32768 (order: 6, 262144 bytes) Inode-cache hash table entries: 16384 (order: 5, 131072 bytes) Mount-cache hash table entries: 256 Initializing cgroup subsys ns Initializing cgroup subsys cpuacct Initializing cgroup subsys memory Initializing cgroup subsys devices Initializing cgroup subsys freezer Initializing cgroup subsys net_cls Initializing cgroup subsys blkio Initializing cgroup subsys perf_event Initializing cgroup subsys net_prio Disabled fast string operations alternatives: switching to unfair spinlock SMP alternatives: switching to UP code ftrace: converting mcount calls to 0f 1f 44 00 00 ftrace: allocating 21917 entries in 86 pages Performance Events: unsupported p6 CPU model 58 no PMU driver, software events only. NMI watchdog disabled (cpu0): hardware events not enabled installing Xen timer for CPU 1 SMP alternatives: switching to SMP code Disabled fast string operations Brought up 2 CPUs devtmpfs: initialized Grant table initialized regulator: core version 0.5 NET: Registered protocol family 16 PCI: Fatal: No config space access function found bio: create slab <bio-0> at 0 ACPI: Interpreter disabled. xen_balloon: Initialising balloon driver. last_pfn = 0x10000 max_arch_pfn = 0x400000000 vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default Switching to clocksource xen pnp: PnP ACPI: disabled NET: Registered protocol family 2 IP route cache hash table entries: 2048 (order: 2, 16384 bytes) TCP established hash table entries: 8192 (order: 5, 131072 bytes) TCP bind hash table entries: 8192 (order: 5, 131072 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP reno registered NET: Registered protocol family 1 Trying to unpack rootfs image as initramfs... Freeing initrd memory: 48828k freed platform rtc_cmos: registered platform RTC device (no PNP device found) futex hash table entries: 512 (order: 3, 32768 bytes) audit: initializing netlink socket (disabled) type=2000 audit(1470681302.151:1): initialized HugeTLB registered 2 MB page size, pre-allocated 0 pages VFS: Disk quotas dquot_6.5.2 Dquot-cache hash table entries: 512 (order 0, 4096 bytes) msgmni has been set to 468 alg: No test for stdrng (krng) ksign: Installing public key data Loading keyring - Added public key FEBCF26ABFDA92DD - User ID: CentOS (Kernel Module GPG key) Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 pciehp: PCI Express Hot Plug Controller Driver version: 0.4 acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 Non-volatile memory driver v1.3 Linux agpgart interface v0.103 crash memory driver: version 1.1 Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled brd: module loaded loop: module loaded input: Macintosh mouse button emulation as /devices/virtual/input/input0 Fixed MDIO Bus: probed ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver uhci_hcd: USB Universal Host Controller Interface driver PNP: No PS/2 controller found. Probing ports directly. mice: PS/2 mouse device common for all mice rtc_cmos: probe of rtc_cmos failed with error -16 cpuidle: using governor ladder cpuidle: using governor menu EFI Variables Facility v0.08 2004-May-17 usbcore: registered new interface driver hiddev usbcore: registered new interface driver usbhid usbhid: v2.6:USB HID core driver GRE over IPv4 demultiplexor driver TCP cubic registered Initializing XFRM netlink socket NET: Registered protocol family 17 registered taskstats version 1 XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/console/0 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initalizing network drop monitor service Freeing unused kernel memory: 1292k freed Write protecting the kernel read-only data: 10240k Freeing unused kernel memory: 788k freed Freeing unused kernel memory: 1568k freed dracut: dracut-004-356.el6 device-mapper: uevent: version 1.0.3 device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com udev: starting version 147 dracut: Starting plymouth daemon xlblk_init: register_blkdev major: 202 blkfront: xvda: barriers disabled xvda: xvda1 xvda2 xvda3 EXT4-fs (xvda2): INFO: recovery required on readonly filesystem EXT4-fs (xvda2): write access will be enabled during recovery EXT4-fs (xvda2): recovery complete EXT4-fs (xvda2): mounted filesystem with ordered data mode. Opts: dracut: Mounted root filesystem /dev/xvda2 dracut: Switching root Welcome to our linux. Initialising Xen virtual ethernet driver. bash: no job control in this shell bash-4.1# ifconfig -a(查看所有网卡接口信息) eth0 Link encap:Ethernet HWaddr 00:16:3E:4E:D2:CE inet addr:172.16.200.12 Bcast:172.16.255.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:82 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:5092 (4.9 KiB) TX bytes:0 (0.0 b) Interrupt:18 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) bash-4.1# ping -c 5 172.16.200.6(测试到达172.16.200.6,-c指定个数) PING 172.16.200.6 (172.16.200.6) 56(84) bytes of data. 64 bytes from 172.16.200.6: icmp_seq=1 ttl=64 time=2.54 ms 64 bytes from 172.16.200.6: icmp_seq=2 ttl=64 time=2.17 ms 64 bytes from 172.16.200.6: icmp_seq=3 ttl=64 time=0.350 ms 64 bytes from 172.16.200.6: icmp_seq=4 ttl=64 time=0.395 ms 64 bytes from 172.16.200.6: icmp_seq=5 ttl=64 time=0.467 ms --- 172.16.200.6 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4007ms rtt min/avg/max/mdev = 0.350/1.186/2.542/0.965 ms bash-4.1# [root@node1 xen]# (使用ctrl+]退出) [root@node1 xen]# vim xend-config.sxp(编辑xend-config.sxp文件) #(xend-http-server no) (xend-unix-server yes) #(xend-tcp-xmlrpc-server no) #(xend-unix-xmlrpc-server yes) #(xend-relocation-server no) (xend-relocation-server yes)(启动迁移) #(xend-relocation-ssl-server no) #(xend-udev-event-server no) (xend-relocation-port 8002)(监听端口) (xend-address '0.0.0.0')(监听地址) (xend-relocation-address '0.0.0.0')(允许迁移出去的地址) (xend-relocation-hosts-allow '')(允许那些主机向本机迁移,不写所有主机) #(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$') [root@node1 xen]# service xend restart(重启xend服务) 正在关闭 xend 守护进程: [确定] 启动 xend 守护进程: [确定] [root@node1 xen]# netstat -tunlp(查看系统服务,-t代表tcp,-u代表udp,-n以数字显示,-l监听端口,-p显示服务名称) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:8002 0.0.0.0:* LISTEN 7382/python tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2596/rpcbind tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 3011/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2770/sshd tcp 0 0 0.0.0.0:37432 0.0.0.0:* LISTEN 2616/rpc.statd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2847/master tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 3596/sshd tcp 0 0 :::33647 :::* LISTEN 2616/rpc.statd tcp 0 0 :::111 :::* LISTEN 2596/rpcbind tcp 0 0 :::22 :::* LISTEN 2770/sshd tcp 0 0 ::1:25 :::* LISTEN 2847/master tcp 0 0 ::1:6010 :::* LISTEN 3596/sshd udp 0 0 127.0.0.1:703 0.0.0.0:* 2616/rpc.statd udp 0 0 0.0.0.0:51069 0.0.0.0:* 2616/rpc.statd udp 0 0 192.168.122.1:53 0.0.0.0:* 3011/dnsmasq udp 0 0 0.0.0.0:67 0.0.0.0:* 3011/dnsmasq udp 0 0 0.0.0.0:68 0.0.0.0:* 2505/dhclient udp 0 0 0.0.0.0:111 0.0.0.0:* 2596/rpcbind udp 0 0 0.0.0.0:651 0.0.0.0:* 2596/rpcbind udp 0 0 :::33616 :::* 2616/rpc.statd udp 0 0 :::111 :::* 2596/rpcbind udp 0 0 :::651 :::* 2596/rpcbind 提示:8002端口已经监听了; [root@node1 xen]# scp xend-config.sxp 172.16.200.7:/etc/xen(复制xend-config.sxp到172.16.200.7主机的/etc/xen目录) root@172.16.200.7's password: xend-config.sxp 100% 11KB 11.1KB/s 00:00
Xen Host 2:
[root@node2 ~]# service xend restart(重启xend服务) 正在关闭 xend 守护进程: [确定] 启动 xend 守护进程: [确定] [root@node2 ~]# ifconfig(查看网卡接口信息) eth0 Link encap:Ethernet HWaddr 00:0C:29:E8:20:12 inet addr:172.16.200.7 Bcast:172.16.200.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fee8:2012/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3659 errors:0 dropped:0 overruns:0 frame:0 TX packets:4960 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1147867 (1.0 MiB) TX bytes:479065 (467.8 KiB) eth1 Link encap:Ethernet HWaddr 00:0C:29:E8:20:1C inet addr:192.168.111.138 Bcast:192.168.111.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fee8:201c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1224 errors:0 dropped:0 overruns:0 frame:0 TX packets:444 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1223982 (1.1 MiB) TX bytes:31883 (31.1 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) virbr0 Link encap:Ethernet HWaddr 52:54:00:E3:30:C6 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) [root@node2 ~]# netstat -tnlp(查看系统服务,-t代表tcp,-n以数字显示,-l监听端口,-p显示服务名称) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:8002 0.0.0.0:* LISTEN 3863/python tcp 0 0 0.0.0.0:53602 0.0.0.0:* LISTEN 2625/rpc.statd tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2605/rpcbind tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 3022/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3838/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2854/master tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 3428/sshd tcp 0 0 :::50400 :::* LISTEN 2625/rpc.statd tcp 0 0 :::111 :::* LISTEN 2605/rpcbind tcp 0 0 :::22 :::* LISTEN 3838/sshd tcp 0 0 ::1:25 :::* LISTEN 2854/master tcp 0 0 ::1:6010 :::* LISTEN 3428/sshd [root@node2 ~]# virsh iface-bridge eth0 br0(创建br0接口,并将eth0添加到br0) Created bridge br0 with attached device eth0 Bridge interface br0 started [root@node2 ~]# ifconfig(查看网卡接口信息) br0 Link encap:Ethernet HWaddr 00:0C:29:E8:20:12 inet addr:172.16.200.7 Bcast:172.16.200.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fee8:2012/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:30 errors:0 dropped:0 overruns:0 frame:0 TX packets:52 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2470 (2.4 KiB) TX bytes:4996 (4.8 KiB) eth0 Link encap:Ethernet HWaddr 00:0C:29:E8:20:12 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3861 errors:0 dropped:0 overruns:0 frame:0 TX packets:5122 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1166119 (1.1 MiB) TX bytes:499697 (487.9 KiB) eth1 Link encap:Ethernet HWaddr 00:0C:29:E8:20:1C inet addr:192.168.111.138 Bcast:192.168.111.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fee8:201c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1224 errors:0 dropped:0 overruns:0 frame:0 TX packets:444 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1223982 (1.1 MiB) TX bytes:31883 (31.1 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) virbr0 Link encap:Ethernet HWaddr 52:54:00:E3:30:C6 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) [root@node2 ~]# brctl show(显示桥接信息) bridge name bridge id STP enabled interfaces br0 8000.000c29e82012 yes eth0 virbr0 8000.525400e330c6 yes virbr0-nic
Xen Host 1:
[root@node1 xen]# xm migrate test 172.16.200.7(将test域迁移到172.16.200.7主机)
Xen Host 2:
[root@node2 ~]# xm list(查看所有域) Name ID Mem VCPUs State Time(s) Domain-0 0 512 2 r----- 176.8 test 1 256 2 -b---- 0.2 [root@node2 ~]# xm console test(通过console连接test域) Using NULL legacy PIC Changing capacity of (202, 0) to 20971520 sectors Changing capacity of (202, 0) to 20971520 sectors bash-4.1# ping -c 50 172.16.200.8(ping测试到达172.16.200.8,-c指定个数) PING 172.16.200.8 (172.16.200.8) 56(84) bytes of data. 64 bytes from 172.16.200.8: icmp_seq=1 ttl=64 time=2.16 ms 64 bytes from 172.16.200.8: icmp_seq=2 ttl=64 time=0.824 ms 64 bytes from 172.16.200.8: icmp_seq=3 ttl=64 time=1.04 ms [root@node2 ~]# xm migrate test 172.16.200.6(将test域迁移到172.16.200.6) [root@node2 ~]# xm list(列出所有域) Name ID Mem VCPUs State Time(s) Domain-0 0 512 2 r----- 188.4
Xen Host 1:
[root@node1 xen]# xm list(列出所有域) Name ID Mem VCPUs State Time(s) Domain-0 0 512 2 r----- 306.9 test 10 256 2 ------ 0.1 [root@node1 xen]# xm console test(通过console连接到test域) Using NULL legacy PIC Changing capacity of (202, 0) to 20971520 sectors 64 bytes from 172.16.200.8: icmp_seq=7 ttl=64 time=0.561 ms 64 bytes from 172.16.200.8: icmp_seq=8 ttl=64 time=1.06 ms 64 bytes from 172.16.200.8: icmp_seq=9 ttl=64 time=0.898 ms 64 bytes from 172.16.200.8: icmp_seq=10 ttl=64 time=1.62 ms 64 bytes from 172.16.200.8: icmp_seq=11 ttl=64 time=0.761 ms 提示:ping包没有中断,实时迁移; [root@node1 xen]# cd(切换到用户家目录) [root@node1 ~]# yum -y groupinstall "Development Tools" "server Platform Development"(通过yum源安装开发工具和服务器开发平台组件) [root@node1 ~]# yum -y install pcre-devel [root@node1 ~]# lftp 172.16.0.1(连接ftp服务器) cd ok, cwd=/pub/Sources lftp 172.16.0.1:/pub/Sources> cd nginx/(切换到nginx目录) lftp 172.16.0.1:/pub/Sources/nginx> get nginx-1.4.1.tar.gz(下载nginx-1.4.1.tar.gz目录) 767107 bytes transferred lftp 172.16.0.1:/pub/Sources/nginx> bye(退出) [root@node1 ~]# ls(查看当前目录文件及子目录) anaconda-ks.cfg bincp.sh install.log install.log.syslog nginx-1.4.1.tar.gz xen [root@node1 ~]# tar zvxf nginx-1.4.1.tar.gz(解压nginx) [root@node1 ~]# cd nginx-1.4.1(切换到nginx-1.4.1目录) [root@node1 nginx-1.4.1]# useradd -r nginx(添加系统用户nginx) [root@node1 nginx-1.4.1]# ./configure \(配置nginx) > --prefix=/usr \ > --sbin-path=/usr/sbin/nginx \ > --conf-path=/etc/nginx/nginx.conf \ > --error-log-path=/var/log/nginx/error.log \ > --http-log-path=/var/log/nginx/access.log \ > --pid-path=/var/run/nginx/nginx.pid \ > --lock-path=/var/lock/nginx.lock \ > --user=nginx \ > --group=nginx \ > --with-http_ssl_module \ > --with-http_flv_module \ > --with-http_stub_status_module \ > --with-http_gzip_static_module \ > --http-client-body-temp-path=/var/tmp/nginx/client/ \ > --http-proxy-temp-path=/var/tmp/nginx/proxy/ \ > --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \ > --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ > --http-scgi-temp-path=/var/tmp/nginx/scgi \ > --with-pcre [root@node1 nginx-1.4.1]# make && make install(编译并安装) [root@node1 nginx-1.4.1]# strace nginx((追踪nginx启动过程) execve("/usr/sbin/nginx", ["nginx"], [/* 26 vars */]) = 0 brk(0) = 0x8c3000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef28000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=37212, ...}) = 0 mmap(NULL, 37212, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f03aef1e000 close(3) = 0 open("/lib64/libpthread.so.0", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000^\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=142688, ...}) = 0 mmap(NULL, 2212848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03aeaed000 mprotect(0x7f03aeb04000, 2097152, PROT_NONE) = 0 mmap(0x7f03aed04000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x7f03aed04000 mmap(0x7f03aed06000, 13296, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f03aed06000 close(3) = 0 open("/lib64/libcrypt.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\f\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=40400, ...}) = 0 mmap(NULL, 2318816, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ae8b6000 mprotect(0x7f03ae8bd000, 2097152, PROT_NONE) = 0 mmap(0x7f03aeabd000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7000) = 0x7f03aeabd000 mmap(0x7f03aeabf000, 184800, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f03aeabf000 close(3) = 0 open("/lib64/libpcre.so.0", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\25\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=183080, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef1d000 mmap(NULL, 2278264, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ae689000 mprotect(0x7f03ae6b5000, 2097152, PROT_NONE) = 0 mmap(0x7f03ae8b5000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2c000) = 0x7f03ae8b5000 close(3) = 0 open("/usr/lib64/libssl.so.10", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\202\1\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=441256, ...}) = 0 mmap(NULL, 2536648, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ae41d000 mprotect(0x7f03ae47f000, 2093056, PROT_NONE) = 0 mmap(0x7f03ae67e000, 45056, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x61000) = 0x7f03ae67e000 close(3) = 0 open("/usr/lib64/libcrypto.so.10", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\234\6\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=1967392, ...}) = 0 mmap(NULL, 4079480, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ae039000 mprotect(0x7f03ae1f3000, 2093056, PROT_NONE) = 0 mmap(0x7f03ae3f2000, 159744, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b9000) = 0x7f03ae3f2000 mmap(0x7f03ae419000, 16248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f03ae419000 close(3) = 0 open("/lib64/libdl.so.2", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\r\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=19536, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef1c000 mmap(NULL, 2109696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ade35000 mprotect(0x7f03ade37000, 2097152, PROT_NONE) = 0 mmap(0x7f03ae037000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f03ae037000 close(3) = 0 open("/lib64/libz.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 !\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=88600, ...}) = 0 mmap(NULL, 2183696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03adc1f000 mprotect(0x7f03adc34000, 2093056, PROT_NONE) = 0 mmap(0x7f03ade33000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0x7f03ade33000 close(3) = 0 open("/lib64/libc.so.6", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000\356\1\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=1923352, ...}) = 0 mmap(NULL, 3750184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ad88b000 mprotect(0x7f03ada15000, 2097152, PROT_NONE) = 0 mmap(0x7f03adc15000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18a000) = 0x7f03adc15000 mmap(0x7f03adc1b000, 14632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f03adc1b000 close(3) = 0 open("/lib64/libfreebl3.so", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\n\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=10312, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef1b000 mmap(NULL, 2105520, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ad688000 mprotect(0x7f03ad68a000, 2093056, PROT_NONE) = 0 mmap(0x7f03ad889000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x7f03ad889000 close(3) = 0 open("/lib64/libgssapi_krb5.so.2", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\254\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=277704, ...}) = 0 mmap(NULL, 2373600, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ad444000 mprotect(0x7f03ad485000, 2097152, PROT_NONE) = 0 mmap(0x7f03ad685000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x41000) = 0x7f03ad685000 close(3) = 0 open("/lib64/libkrb5.so.3", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\265\1\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=946048, ...}) = 0 mmap(NULL, 3041984, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ad15d000 mprotect(0x7f03ad238000, 2097152, PROT_NONE) = 0 mmap(0x7f03ad438000, 49152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xdb000) = 0x7f03ad438000 close(3) = 0 open("/lib64/libcom_err.so.2", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\23\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=14664, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef1a000 mmap(NULL, 2109872, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03acf59000 mprotect(0x7f03acf5c000, 2093056, PROT_NONE) = 0 mmap(0x7f03ad15b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f03ad15b000 close(3) = 0 open("/lib64/libk5crypto.so.3", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320C\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=174840, ...}) = 0 mmap(NULL, 2273704, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03acd2d000 mprotect(0x7f03acd56000, 2097152, PROT_NONE) = 0 mmap(0x7f03acf56000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x29000) = 0x7f03acf56000 mmap(0x7f03acf58000, 424, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f03acf58000 close(3) = 0 open("/lib64/libkrb5support.so.0", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@*\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=43728, ...}) = 0 mmap(NULL, 2139216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03acb22000 mprotect(0x7f03acb2c000, 2093056, PROT_NONE) = 0 mmap(0x7f03acd2b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9000) = 0x7f03acd2b000 close(3) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef19000 open("/lib64/libkeyutils.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\v\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=10192, ...}) = 0 mmap(NULL, 2105424, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ac91f000 mprotect(0x7f03ac921000, 2093056, PROT_NONE) = 0 mmap(0x7f03acb20000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x7f03acb20000 close(3) = 0 open("/lib64/libresolv.so.2", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\00009\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=110960, ...}) = 0 mmap(NULL, 2202248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ac705000 mprotect(0x7f03ac71b000, 2097152, PROT_NONE) = 0 mmap(0x7f03ac91b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f03ac91b000 mmap(0x7f03ac91d000, 6792, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f03ac91d000 close(3) = 0 open("/lib64/libselinux.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0PY\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=122056, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef18000 mmap(NULL, 2221912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f03ac4e6000 mprotect(0x7f03ac503000, 2093056, PROT_NONE) = 0 mmap(0x7f03ac702000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c000) = 0x7f03ac702000 mmap(0x7f03ac704000, 1880, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f03ac704000 close(3) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef17000 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef15000 arch_prctl(ARCH_SET_FS, 0x7f03aef157c0) = 0 mprotect(0x7f03ac702000, 4096, PROT_READ) = 0 mprotect(0x7f03ac91b000, 4096, PROT_READ) = 0 mprotect(0x7f03acb20000, 4096, PROT_READ) = 0 mprotect(0x7f03acd2b000, 4096, PROT_READ) = 0 mprotect(0x7f03acf56000, 4096, PROT_READ) = 0 mprotect(0x7f03ad15b000, 4096, PROT_READ) = 0 mprotect(0x7f03ad438000, 40960, PROT_READ) = 0 mprotect(0x7f03ad685000, 4096, PROT_READ) = 0 mprotect(0x7f03ad889000, 4096, PROT_READ) = 0 mprotect(0x7f03adc15000, 16384, PROT_READ) = 0 mprotect(0x7f03ade33000, 4096, PROT_READ) = 0 mprotect(0x7f03ae037000, 4096, PROT_READ) = 0 mprotect(0x7f03ae3f2000, 110592, PROT_READ) = 0 mprotect(0x7f03ae67e000, 16384, PROT_READ) = 0 mprotect(0x7f03aeabd000, 4096, PROT_READ) = 0 mprotect(0x7f03aed04000, 4096, PROT_READ) = 0 mprotect(0x7f03aef29000, 4096, PROT_READ) = 0 munmap(0x7f03aef1e000, 37212) = 0 set_tid_address(0x7f03aef15a90) = 11083 set_robust_list(0x7f03aef15aa0, 24) = 0 futex(0x7fff8b2865cc, FUTEX_WAKE_PRIVATE, 1) = 0 futex(0x7fff8b2865cc, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, 7f03aef157c0) = -1 EAGAIN (Resource temporarily unavail able) rt_sigaction(SIGRTMIN, {0x7f03aeaf2cb0, [], SA_RESTORER|SA_SIGINFO, 0x7f03aeafc7e0}, NULL, 8) = 0 rt_sigaction(SIGRT_1, {0x7f03aeaf2d40, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7f03aeafc7e0}, NULL, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0 getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0 statfs("/selinux", {f_type=0xf97cff8c, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen =255, f_frsize=4096}) = 0 statfs("/selinux", {f_type=0xf97cff8c, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen =255, f_frsize=4096}) = 0 stat("/selinux", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 brk(0) = 0x8c3000 brk(0x8e4000) = 0x8e4000 access("/usr/share/dracut/modules.d/01fips", F_OK) = -1 ENOENT (No such file or directory) gettimeofday({1470685936, 847603}, NULL) = 0 open("/etc/localtime", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=388, ...}) = 0 fstat(3, {st_mode=S_IFREG|0644, st_size=388, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef27000 read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0\2\0\0\0\0"..., 4096) = 388 lseek(3, -240, SEEK_CUR) = 148 read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0\0\3\0\0\0\0"..., 4096) = 240 close(3) = 0 munmap(0x7f03aef27000, 4096) = 0 open("/var/log/nginx/error.log", O_WRONLY|O_CREAT|O_APPEND, 0644) = 3 open("/etc/pki/tls/openssl.cnf", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=10906, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef27000 read(4, "#\n# OpenSSL example configuratio"..., 4096) = 4096 read(4, ": ancient versions of Netscape c"..., 4096) = 4096 read(4, "against PKIX guidelines but some"..., 4096) = 2714 read(4, "", 4096) = 0 close(4) = 0 munmap(0x7f03aef27000, 4096) = 0 brk(0x905000) = 0x905000 uname({sys="Linux", node="node1.Smoke.com", ...}) = 0 open("/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = 4 read(4, "0-1\n", 8192) = 4 close(4) = 0 getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=4*1024}) = 0 stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=388, ...}) = 0 gettimeofday({1470685936, 871279}, NULL) = 0 uname({sys="Linux", node="node1.Smoke.com", ...}) = 0 open("/etc/nginx/nginx.conf", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=2685, ...}) = 0 pread(4, "\n#user nobody;\nworker_processes"..., 2685, 0) = 2685 epoll_create(100) = 5 close(5) = 0 open("/etc/nginx/mime.types", O_RDONLY) = 5 fstat(5, {st_mode=S_IFREG|0644, st_size=3463, ...}) = 0 pread(5, "\ntypes {\n text/html "..., 3463, 0) = 3463 close(5) = 0 close(4) = 0 geteuid() = 0 socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4 connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(4) = 0 socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4 connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(4) = 0 open("/etc/nsswitch.conf", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=1688, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef27000 read(4, "#\n# /etc/nsswitch.conf\n#\n# An ex"..., 4096) = 1688 read(4, "", 4096) = 0 close(4) = 0 munmap(0x7f03aef27000, 4096) = 0 open("/etc/ld.so.cache", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=37212, ...}) = 0 mmap(NULL, 37212, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7f03aef1e000 close(4) = 0 open("/lib64/libnss_files.so.2", O_RDONLY) = 4 read(4, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360!\0\0\0\0\0\0"..., 832) = 832 fstat(4, {st_mode=S_IFREG|0755, st_size=65960, ...}) = 0 mmap(NULL, 2151824, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 4, 0) = 0x7f03ac2d8000 mprotect(0x7f03ac2e5000, 2093056, PROT_NONE) = 0 mmap(0x7f03ac4e4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 4, 0xc000) = 0x7f03ac4e4000 close(4) = 0 mprotect(0x7f03ac4e4000, 4096, PROT_READ) = 0 munmap(0x7f03aef1e000, 37212) = 0 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 4 fcntl(4, F_GETFD) = 0x1 (flags FD_CLOEXEC) fstat(4, {st_mode=S_IFREG|0644, st_size=1294, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef27000 read(4, "root:x:0:0:root:/root:/bin/bash\n"..., 4096) = 1294 close(4) = 0 munmap(0x7f03aef27000, 4096) = 0 socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4 connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(4) = 0 socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4 connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(4) = 0 open("/etc/group", O_RDONLY|O_CLOEXEC) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=640, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f03aef27000 read(4, "root:x:0:\nbin:x:1:bin,daemon\ndae"..., 4096) = 640 close(4) = 0 munmap(0x7f03aef27000, 4096) = 0 mkdir("/var/tmp/nginx/client/", 0700) = -1 ENOENT (No such file or directory) write(3, "2016/08/09 03:52:16 [emerg] 1108"..., 108) = 108 write(2, "nginx: [emerg] mkdir() \"/var/tmp"..., 86nginx: [emerg] mkdir() "/var/tmp/nginx/client/" failed (2: No such file or direc tory)(没有var/tmp/nginx/client目录) ) = 86 exit_group(1) = ? +++ exited with 1 +++ [root@node1 nginx-1.4.1]# mkdir -pv /var/tmp/nginx/client(创建/var/tmp/nginx/client目录,-p递归创建,-v显示创建过程) mkdir: 已创建目录 "/var/tmp/nginx" mkdir: 已创建目录 "/var/tmp/nginx/client" [root@node1 nginx-1.4.1]# nginx(启动nginx服务) [root@node1 nginx-1.4.1]# netstat -tnlp(查看系统服务,-t代表tcp,-n以数字显示,-l监听端口,-p显示服务名称) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:8002 0.0.0.0:* LISTEN 7382/python tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2596/rpcbind tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11091/nginx tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 3011/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 8494/sshd tcp 0 0 0.0.0.0:37432 0.0.0.0:* LISTEN 2616/rpc.statd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2847/master tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 8687/sshd tcp 0 0 :::33647 :::* LISTEN 2616/rpc.statd tcp 0 0 :::111 :::* LISTEN 2596/rpcbind tcp 0 0 :::22 :::* LISTEN 8494/sshd tcp 0 0 ::1:25 :::* LISTEN 2847/master tcp 0 0 ::1:6010 :::* LISTEN 8687/sshd [root@node1 nginx-1.4.1]# killall nginx(杀死nginx进程) [root@node1 nginx-1.4.1]# strace nginx(追踪nginx启动过程) execve("/usr/sbin/nginx", ["nginx"], [/* 26 vars */]) = 0 brk(0) = 0x2521000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f149202f000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=37212, ...}) = 0 mmap(NULL, 37212, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1492025000 close(3) = 0 open("/lib64/libpthread.so.0", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000^\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=142688, ...}) = 0 mmap(NULL, 2212848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1491bf4000 mprotect(0x7f1491c0b000, 2097152, PROT_NONE) = 0 mmap(0x7f1491e0b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x7f1491e0b000 mmap(0x7f1491e0d000, 13296, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f1491e0d000 close(3) = 0 open("/lib64/libcrypt.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\f\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=40400, ...}) = 0 mmap(NULL, 2318816, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f14919bd000 mprotect(0x7f14919c4000, 2097152, PROT_NONE) = 0 mmap(0x7f1491bc4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7000) = 0x7f1491bc4000 mmap(0x7f1491bc6000, 184800, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f1491bc6000 close(3) = 0 open("/lib64/libpcre.so.0", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\25\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=183080, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1492024000 mmap(NULL, 2278264, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1491790000 mprotect(0x7f14917bc000, 2097152, PROT_NONE) = 0 mmap(0x7f14919bc000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2c000) = 0x7f14919bc000 close(3) = 0 open("/usr/lib64/libssl.so.10", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\202\1\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=441256, ...}) = 0 mmap(NULL, 2536648, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1491524000 mprotect(0x7f1491586000, 2093056, PROT_NONE) = 0 mmap(0x7f1491785000, 45056, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x61000) = 0x7f1491785000 close(3) = 0 open("/usr/lib64/libcrypto.so.10", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\234\6\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=1967392, ...}) = 0 mmap(NULL, 4079480, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1491140000 mprotect(0x7f14912fa000, 2093056, PROT_NONE) = 0 mmap(0x7f14914f9000, 159744, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b9000) = 0x7f14914f9000 mmap(0x7f1491520000, 16248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f1491520000 close(3) = 0 open("/lib64/libdl.so.2", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\r\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=19536, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1492023000 mmap(NULL, 2109696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1490f3c000 mprotect(0x7f1490f3e000, 2097152, PROT_NONE) = 0 mmap(0x7f149113e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f149113e000 close(3) = 0 open("/lib64/libz.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 !\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=88600, ...}) = 0 mmap(NULL, 2183696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1490d26000 mprotect(0x7f1490d3b000, 2093056, PROT_NONE) = 0 mmap(0x7f1490f3a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0x7f1490f3a000 close(3) = 0 open("/lib64/libc.so.6", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000\356\1\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=1923352, ...}) = 0 mmap(NULL, 3750184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1490992000 mprotect(0x7f1490b1c000, 2097152, PROT_NONE) = 0 mmap(0x7f1490d1c000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18a000) = 0x7f1490d1c000 mmap(0x7f1490d22000, 14632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f1490d22000 close(3) = 0 open("/lib64/libfreebl3.so", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\n\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=10312, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1492022000 mmap(NULL, 2105520, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f149078f000 mprotect(0x7f1490791000, 2093056, PROT_NONE) = 0 mmap(0x7f1490990000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x7f1490990000 close(3) = 0 open("/lib64/libgssapi_krb5.so.2", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\254\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=277704, ...}) = 0 mmap(NULL, 2373600, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f149054b000 mprotect(0x7f149058c000, 2097152, PROT_NONE) = 0 mmap(0x7f149078c000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x41000) = 0x7f149078c000 close(3) = 0 open("/lib64/libkrb5.so.3", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\265\1\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=946048, ...}) = 0 mmap(NULL, 3041984, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1490264000 mprotect(0x7f149033f000, 2097152, PROT_NONE) = 0 mmap(0x7f149053f000, 49152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xdb000) = 0x7f149053f000 close(3) = 0 open("/lib64/libcom_err.so.2", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\23\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=14664, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1492021000 mmap(NULL, 2109872, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1490060000 mprotect(0x7f1490063000, 2093056, PROT_NONE) = 0 mmap(0x7f1490262000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f1490262000 close(3) = 0 open("/lib64/libk5crypto.so.3", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320C\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=174840, ...}) = 0 mmap(NULL, 2273704, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f148fe34000 mprotect(0x7f148fe5d000, 2097152, PROT_NONE) = 0 mmap(0x7f149005d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x29000) = 0x7f149005d000 mmap(0x7f149005f000, 424, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f149005f000 close(3) = 0 open("/lib64/libkrb5support.so.0", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@*\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=43728, ...}) = 0 mmap(NULL, 2139216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f148fc29000 mprotect(0x7f148fc33000, 2093056, PROT_NONE) = 0 mmap(0x7f148fe32000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9000) = 0x7f148fe32000 close(3) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1492020000 open("/lib64/libkeyutils.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\v\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=10192, ...}) = 0 mmap(NULL, 2105424, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f148fa26000 mprotect(0x7f148fa28000, 2093056, PROT_NONE) = 0 mmap(0x7f148fc27000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x7f148fc27000 close(3) = 0 open("/lib64/libresolv.so.2", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\00009\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=110960, ...}) = 0 mmap(NULL, 2202248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f148f80c000 mprotect(0x7f148f822000, 2097152, PROT_NONE) = 0 mmap(0x7f148fa22000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f148fa22000 mmap(0x7f148fa24000, 6792, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f148fa24000 close(3) = 0 open("/lib64/libselinux.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0PY\0\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=122056, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f149201f000 mmap(NULL, 2221912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f148f5ed000 mprotect(0x7f148f60a000, 2093056, PROT_NONE) = 0 mmap(0x7f148f809000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c000) = 0x7f148f809000 mmap(0x7f148f80b000, 1880, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f148f80b000 close(3) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f149201e000 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f149201c000 arch_prctl(ARCH_SET_FS, 0x7f149201c7c0) = 0 mprotect(0x7f148f809000, 4096, PROT_READ) = 0 mprotect(0x7f148fa22000, 4096, PROT_READ) = 0 mprotect(0x7f148fc27000, 4096, PROT_READ) = 0 mprotect(0x7f148fe32000, 4096, PROT_READ) = 0 mprotect(0x7f149005d000, 4096, PROT_READ) = 0 mprotect(0x7f1490262000, 4096, PROT_READ) = 0 mprotect(0x7f149053f000, 40960, PROT_READ) = 0 mprotect(0x7f149078c000, 4096, PROT_READ) = 0 mprotect(0x7f1490990000, 4096, PROT_READ) = 0 mprotect(0x7f1490d1c000, 16384, PROT_READ) = 0 mprotect(0x7f1490f3a000, 4096, PROT_READ) = 0 mprotect(0x7f149113e000, 4096, PROT_READ) = 0 mprotect(0x7f14914f9000, 110592, PROT_READ) = 0 mprotect(0x7f1491785000, 16384, PROT_READ) = 0 mprotect(0x7f1491bc4000, 4096, PROT_READ) = 0 mprotect(0x7f1491e0b000, 4096, PROT_READ) = 0 mprotect(0x7f1492030000, 4096, PROT_READ) = 0 munmap(0x7f1492025000, 37212) = 0 set_tid_address(0x7f149201ca90) = 11106 set_robust_list(0x7f149201caa0, 24) = 0 futex(0x7fff235677ec, FUTEX_WAKE_PRIVATE, 1) = 0 futex(0x7fff235677ec, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, 7f149201c7c0) = -1 EAGAIN (Resource temporarily unavail able) rt_sigaction(SIGRTMIN, {0x7f1491bf9cb0, [], SA_RESTORER|SA_SIGINFO, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGRT_1, {0x7f1491bf9d40, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0 getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0 statfs("/selinux", {f_type=0xf97cff8c, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen =255, f_frsize=4096}) = 0 statfs("/selinux", {f_type=0xf97cff8c, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen =255, f_frsize=4096}) = 0 stat("/selinux", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 brk(0) = 0x2521000 brk(0x2542000) = 0x2542000 access("/usr/share/dracut/modules.d/01fips", F_OK) = -1 ENOENT (No such file or directory) gettimeofday({1470686168, 69261}, NULL) = 0 open("/etc/localtime", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=388, ...}) = 0 fstat(3, {st_mode=S_IFREG|0644, st_size=388, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f149202e000 read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0\2\0\0\0\0"..., 4096) = 388 lseek(3, -240, SEEK_CUR) = 148 read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0\0\3\0\0\0\0"..., 4096) = 240 close(3) = 0 munmap(0x7f149202e000, 4096) = 0 open("/var/log/nginx/error.log", O_WRONLY|O_CREAT|O_APPEND, 0644) = 3 open("/etc/pki/tls/openssl.cnf", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=10906, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f149202e000 read(4, "#\n# OpenSSL example configuratio"..., 4096) = 4096 read(4, ": ancient versions of Netscape c"..., 4096) = 4096 read(4, "against PKIX guidelines but some"..., 4096) = 2714 read(4, "", 4096) = 0 close(4) = 0 munmap(0x7f149202e000, 4096) = 0 brk(0x2563000) = 0x2563000 uname({sys="Linux", node="node1.Smoke.com", ...}) = 0 open("/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = 4 read(4, "0-1\n", 8192) = 4 close(4) = 0 getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=4*1024}) = 0 stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=388, ...}) = 0 gettimeofday({1470686168, 832259}, NULL) = 0 uname({sys="Linux", node="node1.Smoke.com", ...}) = 0 open("/etc/nginx/nginx.conf", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=2685, ...}) = 0 pread(4, "\n#user nobody;\nworker_processes"..., 2685, 0) = 2685 epoll_create(100) = 5 close(5) = 0 open("/etc/nginx/mime.types", O_RDONLY) = 5 fstat(5, {st_mode=S_IFREG|0644, st_size=3463, ...}) = 0 pread(5, "\ntypes {\n text/html "..., 3463, 0) = 3463 close(5) = 0 close(4) = 0 geteuid() = 0 socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4 connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(4) = 0 socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4 connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(4) = 0 open("/etc/nsswitch.conf", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=1688, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f149202e000 read(4, "#\n# /etc/nsswitch.conf\n#\n# An ex"..., 4096) = 1688 read(4, "", 4096) = 0 close(4) = 0 munmap(0x7f149202e000, 4096) = 0 open("/etc/ld.so.cache", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=37212, ...}) = 0 mmap(NULL, 37212, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7f1492025000 close(4) = 0 open("/lib64/libnss_files.so.2", O_RDONLY) = 4 read(4, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360!\0\0\0\0\0\0"..., 832) = 832 fstat(4, {st_mode=S_IFREG|0755, st_size=65960, ...}) = 0 mmap(NULL, 2151824, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 4, 0) = 0x7f148f3df000 mprotect(0x7f148f3ec000, 2093056, PROT_NONE) = 0 mmap(0x7f148f5eb000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 4, 0xc000) = 0x7f148f5eb000 close(4) = 0 mprotect(0x7f148f5eb000, 4096, PROT_READ) = 0 munmap(0x7f1492025000, 37212) = 0 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 4 fcntl(4, F_GETFD) = 0x1 (flags FD_CLOEXEC) fstat(4, {st_mode=S_IFREG|0644, st_size=1294, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f149202e000 read(4, "root:x:0:0:root:/root:/bin/bash\n"..., 4096) = 1294 close(4) = 0 munmap(0x7f149202e000, 4096) = 0 socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4 connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(4) = 0 socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4 connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(4) = 0 open("/etc/group", O_RDONLY|O_CLOEXEC) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=640, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f149202e000 read(4, "root:x:0:\nbin:x:1:bin,daemon\ndae"..., 4096) = 640 close(4) = 0 munmap(0x7f149202e000, 4096) = 0 mkdir("/var/tmp/nginx/client/", 0700) = -1 EEXIST (File exists) stat("/var/tmp/nginx/client/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 mkdir("/var/tmp/nginx/proxy/", 0700) = -1 EEXIST (File exists) stat("/var/tmp/nginx/proxy/", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0 mkdir("/var/tmp/nginx/fcgi/", 0700) = -1 EEXIST (File exists) stat("/var/tmp/nginx/fcgi/", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0 mkdir("/var/tmp/nginx/uwsgi", 0700) = -1 EEXIST (File exists) stat("/var/tmp/nginx/uwsgi", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0 mkdir("/var/tmp/nginx/scgi", 0700) = -1 EEXIST (File exists) stat("/var/tmp/nginx/scgi", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0 open("/var/log/nginx/access.log", O_WRONLY|O_CREAT|O_APPEND, 0644) = 4 fcntl(4, F_SETFD, FD_CLOEXEC) = 0 open("/var/log/nginx/error.log", O_WRONLY|O_CREAT|O_APPEND, 0644) = 5 fcntl(5, F_SETFD, FD_CLOEXEC) = 0 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 6 setsockopt(6, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 ioctl(6, FIONBIO, [1]) = 0 bind(6, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("0.0.0.0")}, 16) = 0 listen(6, 511) = 0 listen(6, 511) = 0 getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=4*1024}) = 0 mmap(NULL, 1280, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0) = 0x7f149202e000 rt_sigaction(SIGHUP, {0x41f0a0, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGUSR1, {0x41f0a0, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGWINCH, {0x41f0a0, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGTERM, {0x41f0a0, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGQUIT, {0x41f0a0, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGUSR2, {0x41f0a0, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGALRM, {0x41f0a0, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGINT, {0x41f0a0, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGIO, {0x41f0a0, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGCHLD, {0x41f0a0, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGSYS, {SIG_IGN, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 rt_sigaction(SIGPIPE, {SIG_IGN, [], SA_RESTORER, 0x7f1491c037e0}, NULL, 8) = 0 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f149201ca90) = 11107 exit_group(0) = ? +++ exited with 0 +++ [root@node1 nginx-1.4.1]# mkdir /mnt/sysroot/var/log/nginx/(创建nginx目录) [root@node1 nginx-1.4.1]# mkdir -pv /mnt/sysroot/var/tmp/nginx/client(创建/mng/sysroot/var/tmp/nginx/client目录,-p递归创建,-v显示创建过程) mkdir: 已创建目录 "/mnt/sysroot/var/tmp" mkdir: 已创建目录 "/mnt/sysroot/var/tmp/nginx" mkdir: 已创建目录 "/mnt/sysroot/var/tmp/nginx/client" [root@node1 nginx-1.4.1]# cp /etc/nsswitch.conf /mnt/sysroot/etc/(复制nsswitch.conf配置文件到/mnt/sysroot/etc目录) [root@node1 nginx-1.4.1]# cp /etc/{passwd,group,shadow} /mnt/sysroot/etc/(复制passwd、group、shadow文件到/mnt/sysroot/etc目录) [root@node1 nginx-1.4.1]# cp /lib64/libnss_files.so.2 /mnt/sysroot/lib64/(复制libnss_files.so.2文件到/mnt/sysroot/lib64目录) [root@node1 nginx-1.4.1]# cd(切换到用户家目录) [root@node1 ~]# bash bincp.sh(执行bincp.sh脚本) Your command: nginx /usr/sbin/nginx copy lib /lib64/libcrypt.so.1 finished. copy lib /lib64/libpcre.so.0 finished. copy lib /usr/lib64/libssl.so.10 finished. copy lib /usr/lib64/libcrypto.so.10 finished. copy lib /lib64/libz.so.1 finished. copy lib /lib64/libfreebl3.so finished. copy lib /lib64/libgssapi_krb5.so.2 finished. copy lib /lib64/libkrb5.so.3 finished. copy lib /lib64/libcom_err.so.2 finished. copy lib /lib64/libk5crypto.so.3 finished. copy lib /lib64/libkrb5support.so.0 finished. copy lib /lib64/libkeyutils.so.1 finished. copy lib /lib64/libresolv.so.2 finished. copy /usr/sbin/nginx finished. Continue: q [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# mkdir /mnt/sysroot/etc/nginx/(创建nginx目录) [root@node1 ~]# cp /etc/nginx/nginx.conf /mnt/sysroot/etc/nginx/(复制nginx.conf到/mnt/sysroot/etc/nginx目录) [root@node1 ~]# cp /etc/nginx/mime.types /mnt/sysroot/etc/nginx/(复制mime.types到/etc/sysroot/etc/nginx目录) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# mkdir /mnt/sysroot/usr/html/(创建html目录) [root@node1 ~]# vim /mnt/sysroot/usr/html/index.html(编辑index.html文件) <h1>From Our Linux. www.magedu.com</h1> [root@node1 ~]# bash bincp.sh(执行bincp.sh脚本) Your command: ps /bin/ps copy lib /lib64/libproc-3.2.8.so finished. copy /bin/ps finished. Continue: kill /bin/kill copy /bin/kill finished. Continue: killall /usr/bin/killall copy /usr/bin/killall finished. Continue: q [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# xm list(列出所有域) Name ID Mem VCPUs State Time(s) Domain-0 0 512 2 r----- 1370.1 test 11 256 2 -b---- 4.2 [root@node1 ~]# xm destroy test(销毁test域) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# xm create -c test(创建test域并启动,-c连接控制台) Using config file "/etc/xen/test". Using <class 'grub.GrubConf.GrubConfigFile'> to parse /grub/grub.conf pyGRUB version 0.6 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x MageEdu.com Linux x x x x x x x x x x x x x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj Use the ^ and v keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting, 'a' to modify the kernel arguments before booting, or 'c' for a command line. Will boot selected entry in 1 seconds Started domain test (id=12) Initializing cgroup subsys cpuset Initializing cgroup subsys cpu Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014 Command line: ro root=/dev/xvda2 selinux=0 init=/sbin/init KERNEL supported cpus: Intel GenuineIntel AMD AuthenticAMD Centaur CentaurHauls Disabled fast string operations ACPI in unprivileged domain disabled released 0 pages of unused memory BIOS-provided physical RAM map: Xen: 0000000000000000 - 00000000000a0000 (usable) Xen: 00000000000a0000 - 0000000000100000 (reserved) Xen: 0000000000100000 - 0000000010000000 (usable) DMI not present or invalid. last_pfn = 0x10000 max_arch_pfn = 0x400000000 init_memory_mapping: 0000000000000000-0000000010000000 RAMDISK: 0204b000 - 04ffa000 No NUMA configuration found Faking a node at 0000000000000000-0000000010000000 Bootmem setup node 0 0000000000000000-0000000010000000 NODE_DATA [000000000005a000 - 000000000008dfff] bootmap [000000000008e000 - 000000000008ffff] pages 2 (7 early reservations) ==> bootmem [0000000000 - 0010000000] #0 [0000000000 - 0000001000] BIOS data page ==> [0000000000 - 0000001000] #1 [000507d000 - 00050aa000] XEN PAGETABLES ==> [000507d000 - 00050aa000] #2 [0000006000 - 0000008000] TRAMPOLINE ==> [0000006000 - 0000008000] #3 [0001000000 - 000202abe4] TEXT DATA BSS ==> [0001000000 - 000202abe4] #4 [000204b000 - 0004ffa000] RAMDISK ==> [000204b000 - 0004ffa000] #5 [0004ffa000 - 000507d000] XEN START INFO ==> [0004ffa000 - 000507d000] #6 [0000008000 - 000005a000] PGTABLE ==> [0000008000 - 000005a000] Zone PFN ranges: DMA 0x00000001 -> 0x00001000 DMA32 0x00001000 -> 0x00100000 Normal 0x00100000 -> 0x00100000 Movable zone start PFN for each node early_node_map[2] active PFN ranges 0: 0x00000001 -> 0x000000a0 0: 0x00000100 -> 0x00010000 SFI: Simple Firmware Interface v0.7 http://simplefirmware.org SMP: Allowing 2 CPUs, 0 hotplug CPUs No local APIC present APIC: disable apic facility PM: Registered nosave memory: 00000000000a0000 - 0000000000100000 Allocating PCI resources starting at 10000000 (gap: 10000000:f0000000) Booting paravirtualized kernel on Xen Xen version: 4.1.3 (preserve-AD) NR_CPUS:4096 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1 PERCPU: Embedded 31 pages/cpu @ffff8800050e0000 s95064 r8192 d23720 u126976 pcpu-alloc: s95064 r8192 d23720 u126976 alloc=31*4096 pcpu-alloc: [0] 0 [0] 1 Xen: using vcpu_info placement Built 1 zonelists in Node order, mobility grouping on. Total pages: 64458 Policy zone: DMA32 Kernel command line: ro root=/dev/xvda2 selinux=0 init=/sbin/init PID hash table entries: 1024 (order: 1, 8192 bytes) Checking aperture... No AGP bridge found Memory: 191024k/262144k available (5336k kernel code, 388k absent, 70732k reserved, 7016k data, 1292k init) Hierarchical RCU implementation. NR_IRQS:33024 nr_irqs:288 Console: colour dummy device 80x25 console [tty0] enabled console [hvc0] enabled allocated 1048576 bytes of page_cgroup please try 'cgroup_disable=memory' option if you don't want memory cgroups installing Xen timer for CPU 0 Detected 2493.318 MHz processor. Calibrating delay loop (skipped), value calculated using timer frequency.. 4986.63 BogoMIPS (lpj=2493318) pid_max: default: 32768 minimum: 301 Security Framework initialized SELinux: Disabled at boot. Dentry cache hash table entries: 32768 (order: 6, 262144 bytes) Inode-cache hash table entries: 16384 (order: 5, 131072 bytes) Mount-cache hash table entries: 256 Initializing cgroup subsys ns Initializing cgroup subsys cpuacct Initializing cgroup subsys memory Initializing cgroup subsys devices Initializing cgroup subsys freezer Initializing cgroup subsys net_cls Initializing cgroup subsys blkio Initializing cgroup subsys perf_event Initializing cgroup subsys net_prio Disabled fast string operations alternatives: switching to unfair spinlock SMP alternatives: switching to UP code ftrace: converting mcount calls to 0f 1f 44 00 00 ftrace: allocating 21917 entries in 86 pages Performance Events: unsupported p6 CPU model 58 no PMU driver, software events only. NMI watchdog disabled (cpu0): hardware events not enabled installing Xen timer for CPU 1 SMP alternatives: switching to SMP code Disabled fast string operations Brought up 2 CPUs devtmpfs: initialized Grant table initialized regulator: core version 0.5 NET: Registered protocol family 16 PCI: Fatal: No config space access function found bio: create slab <bio-0> at 0 ACPI: Interpreter disabled. xen_balloon: Initialising balloon driver. last_pfn = 0x10000 max_arch_pfn = 0x400000000 vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default Switching to clocksource xen pnp: PnP ACPI: disabled NET: Registered protocol family 2 IP route cache hash table entries: 2048 (order: 2, 16384 bytes) TCP established hash table entries: 8192 (order: 5, 131072 bytes) TCP bind hash table entries: 8192 (order: 5, 131072 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP reno registered NET: Registered protocol family 1 Trying to unpack rootfs image as initramfs... Freeing initrd memory: 48828k freed platform rtc_cmos: registered platform RTC device (no PNP device found) futex hash table entries: 512 (order: 3, 32768 bytes) audit: initializing netlink socket (disabled) type=2000 audit(1470687319.923:1): initialized HugeTLB registered 2 MB page size, pre-allocated 0 pages VFS: Disk quotas dquot_6.5.2 Dquot-cache hash table entries: 512 (order 0, 4096 bytes) msgmni has been set to 468 alg: No test for stdrng (krng) ksign: Installing public key data Loading keyring - Added public key FEBCF26ABFDA92DD - User ID: CentOS (Kernel Module GPG key) Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 pciehp: PCI Express Hot Plug Controller Driver version: 0.4 acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 Non-volatile memory driver v1.3 Linux agpgart interface v0.103 crash memory driver: version 1.1 Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled brd: module loaded loop: module loaded input: Macintosh mouse button emulation as /devices/virtual/input/input0 Fixed MDIO Bus: probed ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver uhci_hcd: USB Universal Host Controller Interface driver PNP: No PS/2 controller found. Probing ports directly. mice: PS/2 mouse device common for all mice rtc_cmos: probe of rtc_cmos failed with error -16 cpuidle: using governor ladder cpuidle: using governor menu EFI Variables Facility v0.08 2004-May-17 usbcore: registered new interface driver hiddev usbcore: registered new interface driver usbhid usbhid: v2.6:USB HID core driver GRE over IPv4 demultiplexor driver TCP cubic registered Initializing XFRM netlink socket NET: Registered protocol family 17 registered taskstats version 1 XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/console/0 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initalizing network drop monitor service Freeing unused kernel memory: 1292k freed Write protecting the kernel read-only data: 10240k Freeing unused kernel memory: 788k freed Freeing unused kernel memory: 1568k freed dracut: dracut-004-356.el6 device-mapper: uevent: version 1.0.3 device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com udev: starting version 147 dracut: Starting plymouth daemon xlblk_init: register_blkdev major: 202 blkfront: xvda: barriers disabled xvda: xvda1 xvda2 xvda3 EXT4-fs (xvda2): INFO: recovery required on readonly filesystem EXT4-fs (xvda2): write access will be enabled during recovery EXT4-fs (xvda2): recovery complete EXT4-fs (xvda2): mounted filesystem with ordered data mode. Opts: dracut: Mounted root filesystem /dev/xvda2 dracut: Switching root Welcome to our linux. Initialising Xen virtual ethernet driver. bash: no job control in this shell bash-4.1# ifconfig(查看网卡接口信息) eth0 Link encap:Ethernet HWaddr 00:16:3E:6B:EB:5C inet addr:172.16.200.12 Bcast:172.16.255.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:84 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:5220 (5.0 KiB) TX bytes:0 (0.0 b) Interrupt:18 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) bash-4.1# nginx(启动nginx) nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (30: Read-only file system)(只读文件系统无法创建 error.log文件) 2016/08/08 20:16:28 [emerg] 212#0: chown("/var/tmp/nginx/client/", 498) failed (30: Read-only file system) bash-4.1# [root@node1 ~]#(使用ctrl+]退出) [root@node1 ~]# xm destroy test(销毁test域) [root@node1 ~]# cat /etc/fstab(查看fstab文件内容) # # /etc/fstab # Created by anaconda on Mon Jul 25 18:51:23 2016 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=cf43ec31-f59f-423f-aa0b-d091c18b2fa4 / ext4 defaults 1 1 UUID=8d02aaa8-1714-4377-9925-a3d6e4cdca1e /boot ext4 defaults 1 2 UUID=2273581c-907e-423b-95f3-cc95e035dfda swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 [root@node1 ~]# vim /mnt/sysroot/etc/fstab(编辑fstab文件) tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /dev/xvda2 / ext4 defaults 0 0 /dev/xvda1 /boot ext4 defaults 0 0 /dev/xvda3 swap swap defaults 0 0 [root@node1 ~]# mkdir /mnt/sysroot/boot(创建boot目录) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# vim /mnt/sysroot/etc/rc.d/rc.sysinit(编辑rc.sysinit文件) #!/bin/bash # echo -e "\tWelcome to our linux." insmod /lib/modules/xen-netfront.ko ifconfig lo 127.0.01/8 up ifconfig eth0 172.16.200.12/16 up mount -n -o remount,rw / /bin/bash [root@node1 ~]# umount /mnt/sysroot/(卸载/mnt/sysroot目录) [root@node1 ~]# umount /mnt/boot/(卸载/mnt/boot目录) [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# xm create -c test(创建test域并启动,-c连接到控制台) Using config file "/etc/xen/test". Using <class 'grub.GrubConf.GrubConfigFile'> to parse /grub/grub.conf pyGRUB version 0.6 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x MageEdu.com Linux x x x x x x x x x x x x x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj Use the ^ and v keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting, 'a' to modify the kernel arguments before booting, or 'c' for a command line. Started domain test (id=13)ry in 1 seconds Initializing cgroup subsys cpuset Initializing cgroup subsys cpu Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014 Command line: ro root=/dev/xvda2 selinux=0 init=/sbin/init KERNEL supported cpus: Intel GenuineIntel AMD AuthenticAMD Centaur CentaurHauls Disabled fast string operations ACPI in unprivileged domain disabled released 0 pages of unused memory BIOS-provided physical RAM map: Xen: 0000000000000000 - 00000000000a0000 (usable) Xen: 00000000000a0000 - 0000000000100000 (reserved) Xen: 0000000000100000 - 0000000010000000 (usable) DMI not present or invalid. last_pfn = 0x10000 max_arch_pfn = 0x400000000 init_memory_mapping: 0000000000000000-0000000010000000 RAMDISK: 0204b000 - 04ffa000 No NUMA configuration found Faking a node at 0000000000000000-0000000010000000 Bootmem setup node 0 0000000000000000-0000000010000000 NODE_DATA [000000000005a000 - 000000000008dfff] bootmap [000000000008e000 - 000000000008ffff] pages 2 (7 early reservations) ==> bootmem [0000000000 - 0010000000] #0 [0000000000 - 0000001000] BIOS data page ==> [0000000000 - 0000001000] #1 [000507d000 - 00050aa000] XEN PAGETABLES ==> [000507d000 - 00050aa000] #2 [0000006000 - 0000008000] TRAMPOLINE ==> [0000006000 - 0000008000] #3 [0001000000 - 000202abe4] TEXT DATA BSS ==> [0001000000 - 000202abe4] #4 [000204b000 - 0004ffa000] RAMDISK ==> [000204b000 - 0004ffa000] #5 [0004ffa000 - 000507d000] XEN START INFO ==> [0004ffa000 - 000507d000] #6 [0000008000 - 000005a000] PGTABLE ==> [0000008000 - 000005a000] Zone PFN ranges: DMA 0x00000001 -> 0x00001000 DMA32 0x00001000 -> 0x00100000 Normal 0x00100000 -> 0x00100000 Movable zone start PFN for each node early_node_map[2] active PFN ranges 0: 0x00000001 -> 0x000000a0 0: 0x00000100 -> 0x00010000 SFI: Simple Firmware Interface v0.7 http://simplefirmware.org SMP: Allowing 2 CPUs, 0 hotplug CPUs No local APIC present APIC: disable apic facility PM: Registered nosave memory: 00000000000a0000 - 0000000000100000 Allocating PCI resources starting at 10000000 (gap: 10000000:f0000000) Booting paravirtualized kernel on Xen Xen version: 4.1.3 (preserve-AD) NR_CPUS:4096 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1 PERCPU: Embedded 31 pages/cpu @ffff8800050e0000 s95064 r8192 d23720 u126976 pcpu-alloc: s95064 r8192 d23720 u126976 alloc=31*4096 pcpu-alloc: [0] 0 [0] 1 Xen: using vcpu_info placement Built 1 zonelists in Node order, mobility grouping on. Total pages: 64458 Policy zone: DMA32 Kernel command line: ro root=/dev/xvda2 selinux=0 init=/sbin/init PID hash table entries: 1024 (order: 1, 8192 bytes) Checking aperture... No AGP bridge found Memory: 191024k/262144k available (5336k kernel code, 388k absent, 70732k reserved, 7016k data, 1292k init) Hierarchical RCU implementation. NR_IRQS:33024 nr_irqs:288 Console: colour dummy device 80x25 console [tty0] enabled console [hvc0] enabled allocated 1048576 bytes of page_cgroup please try 'cgroup_disable=memory' option if you don't want memory cgroups installing Xen timer for CPU 0 Detected 2493.318 MHz processor. Calibrating delay loop (skipped), value calculated using timer frequency.. 4986.63 BogoMIPS (lpj=2493318) pid_max: default: 32768 minimum: 301 Security Framework initialized SELinux: Disabled at boot. Dentry cache hash table entries: 32768 (order: 6, 262144 bytes) Inode-cache hash table entries: 16384 (order: 5, 131072 bytes) Mount-cache hash table entries: 256 Initializing cgroup subsys ns Initializing cgroup subsys cpuacct Initializing cgroup subsys memory Initializing cgroup subsys devices Initializing cgroup subsys freezer Initializing cgroup subsys net_cls Initializing cgroup subsys blkio Initializing cgroup subsys perf_event Initializing cgroup subsys net_prio Disabled fast string operations alternatives: switching to unfair spinlock SMP alternatives: switching to UP code ftrace: converting mcount calls to 0f 1f 44 00 00 ftrace: allocating 21917 entries in 86 pages Performance Events: unsupported p6 CPU model 58 no PMU driver, software events only. NMI watchdog disabled (cpu0): hardware events not enabled installing Xen timer for CPU 1 SMP alternatives: switching to SMP code Disabled fast string operations Brought up 2 CPUs devtmpfs: initialized Grant table initialized regulator: core version 0.5 NET: Registered protocol family 16 PCI: Fatal: No config space access function found bio: create slab <bio-0> at 0 ACPI: Interpreter disabled. xen_balloon: Initialising balloon driver. last_pfn = 0x10000 max_arch_pfn = 0x400000000 vgaarb: loaded SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb PCI: System does not support PCI PCI: System does not support PCI NetLabel: Initializing NetLabel: domain hash size = 128 NetLabel: protocols = UNLABELED CIPSOv4 NetLabel: unlabeled traffic allowed by default Switching to clocksource xen pnp: PnP ACPI: disabled NET: Registered protocol family 2 IP route cache hash table entries: 2048 (order: 2, 16384 bytes) TCP established hash table entries: 8192 (order: 5, 131072 bytes) TCP bind hash table entries: 8192 (order: 5, 131072 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP reno registered NET: Registered protocol family 1 Trying to unpack rootfs image as initramfs... Freeing initrd memory: 48828k freed platform rtc_cmos: registered platform RTC device (no PNP device found) futex hash table entries: 512 (order: 3, 32768 bytes) audit: initializing netlink socket (disabled) type=2000 audit(1470687909.346:1): initialized HugeTLB registered 2 MB page size, pre-allocated 0 pages VFS: Disk quotas dquot_6.5.2 Dquot-cache hash table entries: 512 (order 0, 4096 bytes) msgmni has been set to 468 alg: No test for stdrng (krng) ksign: Installing public key data Loading keyring - Added public key FEBCF26ABFDA92DD - User ID: CentOS (Kernel Module GPG key) Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) pci_hotplug: PCI Hot Plug PCI Core version: 0.5 pciehp: PCI Express Hot Plug Controller Driver version: 0.4 acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 Non-volatile memory driver v1.3 Linux agpgart interface v0.103 crash memory driver: version 1.1 Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled brd: module loaded loop: module loaded input: Macintosh mouse button emulation as /devices/virtual/input/input0 Fixed MDIO Bus: probed ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver uhci_hcd: USB Universal Host Controller Interface driver PNP: No PS/2 controller found. Probing ports directly. mice: PS/2 mouse device common for all mice rtc_cmos: probe of rtc_cmos failed with error -16 cpuidle: using governor ladder cpuidle: using governor menu EFI Variables Facility v0.08 2004-May-17 usbcore: registered new interface driver hiddev usbcore: registered new interface driver usbhid usbhid: v2.6:USB HID core driver GRE over IPv4 demultiplexor driver TCP cubic registered Initializing XFRM netlink socket NET: Registered protocol family 17 registered taskstats version 1 XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/console/0 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initalizing network drop monitor service Freeing unused kernel memory: 1292k freed Write protecting the kernel read-only data: 10240k Freeing unused kernel memory: 788k freed Freeing unused kernel memory: 1568k freed dracut: dracut-004-356.el6 device-mapper: uevent: version 1.0.3 device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com udev: starting version 147 dracut: Starting plymouth daemon xlblk_init: register_blkdev major: 202 blkfront: xvda: barriers disabled xvda: xvda1 xvda2 xvda3 EXT4-fs (xvda2): mounted filesystem with ordered data mode. Opts: dracut: Mounted root filesystem /dev/xvda2 dracut: Switching root Welcome to our linux. Initialising Xen virtual ethernet driver. net eth0: rx->offset: 0, size: 4294967295 bash: no job control in this shell bash-4.1# net eth0: rx->offset: 0, size: 4294967295 net eth0: rx->offset: 0, size: 4294967295 net eth0: rx->offset: 0, size: 4294967295 net eth0: rx->offset: 0, size: 4294967295 net eth0: rx->offset: 0, size: 4294967295 net eth0: rx->offset: 0, size: 4294967295 bash-4.1# mount(查看系统挂载的文件系统) rootfs on / type rootfs (rw) proc on /proc type proc (rw,relatime) sysfs on /sys type sysfs (rw,relatime) devtmpfs on /dev type devtmpfs (rw,relatime,size=95512k,nr_inodes=23878,mode=755) devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000) tmpfs on /dev/shm type tmpfs (rw,relatime) /dev/xvda2 on / type ext4 (rw,relatime,barrier=1,data=ordered) bash-4.1# cat /etc/fstab(查看/etc/fstab文件内容) tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /dev/xvda2 / ext4 defaults 0 0 /dev/xvda1 /boot ext4 defaults 0 0 /dev/xvda3 swap swap defaults 0 0 bash-4.1# cat /etc/rc.d/rc.sysinit(查看rc.sysinit文件内容) #!/bin/bash # echo -e "\tWelcome to our linux." insmod /lib/modules/xen-netfront.ko ifconfig lo 127.0.01/8 up ifconfig eth0 172.16.200.12/16 up mount -n -o remount,rw / /bin/bash bash-4.1# nginx(启动nginx服务) bash-4.1# nginx: [emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory)(/var/run/nginx/目录不存在) bash-4.1# mkdir /var/run/nginx/(创建nginx目录) bash-4.1# nginx(启动nginx服务) bash-4.1# netstat -tnlp(查看系统服务,-t代表tcp,-n以数字显示,-l监听端口,-p显示服务名称) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 220/nginx
测试:通过Windows的ie浏览器访问172.16.200.12网页,可以正常访问;
bash-4.1# [root@node1 ~]# (使用crtl+]退出) [root@node1 ~]# xm migrate test 172.16.200.7(迁移test域到172.16.200.7)
测试:通过Windows的ie浏览器访问172.16.200.12网页,可以正常访问;
KVM:(64bits)
rhel5.9
rhel6.4
CPU: HVM
grep -o -E 'svm|vm' /proc/cpuinfo(查看cpu是否支持虚拟化)
modprobe
kvm_inter,kvm_amd
kvm
modprobe kvm
安装:
KVM架构
KVM管理工具
virtio
KVM: virtio,半虚拟化,不支持cpu半虚拟化;
KVM: Full 完全虚拟化;
Xen: PV 半虚拟化,Full(HVM+qemu) 完全虚拟化,PV on HVM;
2.5.3.2 使用virt-install创建虚拟机并安装GuestOS
virt-install是一个命令行工具,它能够为KVM、Xen或其它支持libvrit API的hypervisor创建虚拟机并完成GuestOS安装;此外,它能够基于串行控制台、VNC或SDL支持文本或图形安装界面。安装过程可以使用本地的安装介质如CDROM,也可以通过网络方式如NFS、HTTP或FTP服务实现。对于通过网络安装的方式,virt-install可以自动加载必要的文件以启动安装过程而无须额外提供引导工具。当然,virt-install也支持PXE方式的安装过程,也能够直接使用现有的磁盘映像直接启动安装过程。
virt-install命令有许多选项,这些选项大体可分为下面几大类,同时对每类中的常用选项也做出简单说明。
◇ 一般选项:指定虚拟机的名称、内存大小、VCPU个数及特性等;
-n NAME, --name=NAME:虚拟机名称,需全局惟一;
-r MEMORY, --ram=MEMORY:虚拟机内在大小,单位为MB;
--vcpus=VCPUS[,maxvcpus=MAX][,sockets=#][,cores=#][,threads=#]:VCPU个数及相关配置;
--cpu=CPU:CPU模式及特性,如coreduo等;可以使用qemu-kvm -cpu ?来获取支持的CPU模式;
◇ 安装方法:指定安装方法、GuestOS类型等;
-c CDROM, --cdrom=CDROM:光盘安装介质;
-l LOCATION, --location=LOCATION:安装源URL,支持FTP、HTTP及NFS等,如ftp://172.16.0.1/pub;
--pxe:基于PXE完成安装;
--livecd: 把光盘当作LiveCD;
--os-type=DISTRO_TYPE:操作系统类型,如linux、unix或windows等;
--os-variant=DISTRO_VARIANT:某类型操作系统的变体,如rhel5、fedora8等;
-x EXTRA, --extra-args=EXTRA:根据--location指定的方式安装GuestOS时,用于传递给内核的额外选项,例如指定kickstart文件的位置,--extra-args "ks=http://172.16.0.1/class.cfg"
--boot=BOOTOPTS:指定安装过程完成后的配置选项,如指定引导设备次序、使用指定的而非安装的kernel/initrd来引导系统启动等 ;例如:
--boot cdrom,hd,network:指定引导次序;
--boot kernel=KERNEL,initrd=INITRD,kernel_args=”console=/dev/ttyS0”:指定启动系统的内核及initrd文件;
◇ 存储配置:指定存储类型、位置及属性等;
--disk=DISKOPTS:指定存储设备及其属性;格式为--disk /some/storage/path,opt1=val1,opt2=val2等;常用的选项有:
device:设备类型,如cdrom、disk或floppy等,默认为disk;
bus:磁盘总结类型,其值可以为ide、scsi、usb、virtio或xen;
perms:访问权限,如rw、ro或sh(共享的可读写),默认为rw;
size:新建磁盘映像的大小,单位为GB;
cache:缓存模型,其值有none、writethrouth(缓存读)及writeback(缓存读写);
format:磁盘映像格式,如raw、qcow2、vmdk等;
sparse:磁盘映像使用稀疏格式,即不立即分配指定大小的空间;
--nodisks:不使用本地磁盘,在LiveCD模式中常用;
◇ 网络配置:指定网络接口的网络类型及接口属性如MAC地址、驱动模式等;
-w NETWORK, --network=NETWORK,opt1=val1,opt2=val2:将虚拟机连入宿主机的网络中,其中NETWORK可以为:
bridge=BRIDGE:连接至名为“BRIDEG”的桥设备;
network=NAME:连接至名为“NAME”的网络;
其它常用的选项还有:
model:GuestOS中看到的网络设备型号,如e1000、rtl8139或virtio等;
mac:固定的MAC地址;省略此选项时将使用随机地址,但无论何种方式,对于KVM来说,其前三段必须为52:54:00;
--nonetworks:虚拟机不使用网络功能;
◇ 图形配置:定义虚拟机显示功能相关的配置,如VNC相关配置;
--graphics TYPE,opt1=val1,opt2=val2:指定图形显示相关的配置,此选项不会配置任何显示硬件(如显卡),而是仅指定虚拟机启动后对其进行访问的接口;
TYPE:指定显示类型,可以为vnc、sdl、spice或none等,默认为vnc;
port:TYPE为vnc或spice时其监听的端口;
listen:TYPE为vnc或spice时所监听的IP地址,默认为127.0.0.1,可以通过修改/etc/libvirt/qemu.conf定义新的默认值;
password:TYPE为vnc或spice时,为远程访问监听的服务进指定认证密码;
--noautoconsole:禁止自动连接至虚拟机的控制台;
◇ 设备选项:指定文本控制台、声音设备、串行接口、并行接口、显示接口等;
--serial=CHAROPTS:附加一个串行设备至当前虚拟机,根据设备类型的不同,可以使用不同的选项,格式为“--serial type,opt1=val1,opt2=val2,...”,例如:
--serial pty:创建伪终端;
--serial dev,path=HOSTPATH:附加主机设备至此虚拟机;
--video=VIDEO:指定显卡设备模型,可用取值为cirrus、vga、qxl或vmvga;
◇ 虚拟化平台:虚拟化模型(hvm或paravirt)、模拟的CPU平台类型、模拟的主机类型、hypervisor类型(如kvm、xen或qemu等)以及当前虚拟机的UUID等;
-v, --hvm:当物理机同时支持完全虚拟化和半虚拟化时,指定使用完全虚拟化;
-p, --paravirt:指定使用半虚拟化;
--virt-type:使用的hypervisor,如kvm、qemu、xen等;所有可用值可以使用’virsh capabilities’命令获取;
◇ 其它:
--autostart:指定虚拟机是否在物理启动后自动启动;
--print-xml:如果虚拟机不需要安装过程(--import、--boot),则显示生成的XML而不是创建此虚拟机;默认情况下,此选项仍会创建磁盘映像;
--force:禁止命令进入交互式模式,如果有需要回答yes或no选项,则自动回答为yes;
--dry-run:执行创建虚拟机的整个过程,但不真正创建虚拟机、改变主机上的设备配置信息及将其创建的需求通知给libvirt;
-d, --debug:显示debug信息;
尽管virt-install命令有着类似上述的众多选项,但实际使用中,其必须提供的选项仅包括--name、--ram、--disk(也可是--nodisks)及安装过程相关的选项。此外,有时还需要使用括--connect=CONNCT选项来指定连接至一个非默认的hypervisor。
下面这个示例创建一个名为rhel5的虚拟机,其hypervisor为KVM,内存大小为512MB,磁盘为8G的映像文件/var/lib/libvirt/images/rhel5.8.img,通过boot.iso光盘镜像来引导启动安装过程。
# virt-install \
--connect qemu:///system \
--virt-type kvm \(虚拟类型)
--name rhel5 \(虚拟机名字)
--ram 512 \(内存大小)
--disk path=/var/lib/libvirt/images/rhel5.img,size=8 \(磁盘大小)
--graphics vnc \(自动打开vnc界面)
--cdrom /tmp/boot.iso \(光盘引导启动安装过程)
--os-variant rhel5
下面的示例将创建一个名为rhel6的虚拟机,其有两个虚拟CPU,安装方法为FTP,并指定了ks文件的位置,磁盘映像文件为稀疏格式,连接至物理主机上的名为brnet0的桥接网络:
# virt-install \
--connect qemu:///system \
--virt-type kvm \
--name rhel6 \
--ram 1024 \
--vcpus 2 \
--network bridge=brnet0 \
--disk path=/VMs/images/rhel6.img,size=120,sparse \
--location ftp://172.16.0.1/rhel6/dvd \(指定安装的ftp路径)
--extra_args “ks=http://172.16.0.1/rhel6.cfg” \(指定ks安装文件)
--os-variant rhel6 \
--force
下面的示例将创建一个名为rhel5.8的虚拟机,磁盘映像文件为稀疏模式的格式为qcow2且总线类型为virtio,安装过程不启动图形界面(--nographics),但会启动一个串行终端将安装过程以字符形式显示在当前文本模式下,虚拟机显卡类型为cirrus:
# virt-install \
--connect qemu:///system \
--virt-type kvm \
--name rhel5.8 \
--vcpus 2,maxvcpus=4 \
--ram 512 \
--disk path=/VMs/images/rhel5.8.img,size=120,format=qcow2,bus=virtio,sparse \
--network bridge=brnet0,model=virtio
--nographics \
--location ftp://172.16.0.1/pub \
--extra-args "ks=http://172.16.0.1/class.cfg console=ttyS0 serial" \
--os-variant rhel5 \
--force \
--video=cirrus
下面的示例则利用已经存在的磁盘映像文件(已经有安装好的系统)创建一个名为rhel5.8的虚拟机:
# virt-install \
--name rhel5.8
--ram 512
--disk /VMs/rhel5.8.img
--import
每个虚拟机创建后,其配置信息保存在/etc/libvirt/qemu目录中,文件名与虚拟机相同,格式为XML。
virsh uri:查看主机上hypervisor的连接路径;
virsh connect: 手动连接;
virsh define: 创建虚拟机,根据事先定义的xml格式的配置文件,创建以后不会自动启动;
virsh create: 创建虚拟机,创建完成后会自动启动;
virsh undefine: 删除虚拟机;
--initrd-inject=/path/to/my.ks --extra-args "ks=file:/my.ks"
--boot kernel=KERNEL,initrd=INITRD,kernel_args="console=/dev/ttyS0"
[root@node1 ~]# modprobe kvm(加载kvm模块) [root@node1 ~]# lsmod(显示已经装载的内核模块) Module Size Used by kvm 316506 0 nls_utf8 1455 1 ipt_REJECT 2351 2 nf_conntrack_ipv4 9506 2 nf_defrag_ipv4 1483 1 nf_conntrack_ipv4 iptable_filter 2793 1 ip_tables 17831 1 iptable_filter ip6t_REJECT 4628 2 nf_conntrack_ipv6 8748 2 nf_defrag_ipv6 11182 1 nf_conntrack_ipv6 xt_state 1492 4 nf_conntrack 79357 3 nf_conntrack_ipv4,nf_conntrack_ipv6,xt_state ip6table_filter 2889 1 ip6_tables 19458 1 ip6table_filter ipv6 321422 271 ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6 dm_mod 82839 0 btusb 16851 0 bluetooth 99239 1 btusb rfkill 19255 1 bluetooth snd_ens1371 21587 0 snd_rawmidi 22825 1 snd_ens1371 snd_ac97_codec 124967 1 snd_ens1371 ac97_bus 1452 1 snd_ac97_codec snd_seq 55759 0 snd_seq_device 6500 2 snd_rawmidi,snd_seq snd_pcm 86635 2 snd_ens1371,snd_ac97_codec snd_timer 22411 2 snd_seq,snd_pcm snd 69907 7 snd_ens1371,snd_rawmidi,snd_ac97_codec,snd_seq,snd_seq_device,snd_pcm,snd_timer soundcore 7958 1 snd snd_page_alloc 8470 1 snd_pcm e1000 170646 0 vmware_balloon 7199 0 sg 29350 0 i2c_piix4 12608 0 i2c_core 31084 1 i2c_piix4 shpchp 32778 0 ext4 363408 2 mbcache 8193 1 ext4 jbd2 90230 1 ext4 sr_mod 15177 1 cdrom 39085 1 sr_mod ahci 41127 1 sd_mod 38976 4 crc_t10dif 1541 1 sd_mod mptspi 16603 3 mptscsih 36700 1 mptspi mptbase 93615 2 mptspi,mptscsih scsi_transport_spi 25863 1 mptspi pata_acpi 3701 0 ata_generic 3837 0 ata_piix 24121 0 提示:kvm模块可以装载进来但是没办法使用; [root@node1 ~]# qemu-kvm -cpu ?(查看qemu-kvm支持cpu类型) -bash: qemu-kvm: command not found 提示:当前软件包还没有装; [root@node1 ~]# uname -r(查看内核版本) 2.6.32-358.el6.x86_64 [root@node1 ~]# yum grouplist(查看yum源软件包组) Loaded plugins: product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Setting up Group Process Installed Groups: E-mail server Fonts General Purpose Desktop Graphical Administration Tools Input Methods Legacy X Window System compatibility Installed Language Groups: Chinese Support [zh] Available Groups: Additional Development Backup Client Backup Server Base CIFS file server Client management tools Compatibility libraries Console internet tools Debugging Tools Desktop Desktop Debugging and Performance Tools Desktop Platform Desktop Platform Development Development tools Dial-up Networking Support Directory Client Directory Server Eclipse Emacs FCoE Storage Client FTP server Graphics Creation Tools Hardware monitoring utilities Identity Management Server Infiniband Support Internet Browser Java Platform KDE Desktop Large Systems Performance Legacy UNIX compatibility Mainframe Access Messaging Client Support MySQL Database client MySQL Database server NFS file server Network Infrastructure Server Network Storage Server Network file system client Networking Tools PHP Support Performance Tools Perl Support PostgreSQL Database client PostgreSQL Database server Print Server Printing client Remote Desktop Clients Ruby Support SNMP Support Scientific support Security Tools Server Platform Server Platform Development Smart card support Storage Availability Tools System Management System administration tools Systems Management Messaging Server support TeX support Technical Writing TurboGears application framework Virtualization Virtualization Client Virtualization Platform Virtualization Tools(libguestfs) Web Server Web Servlet Engine Web-Based Enterprise Management X Window System iSCSI Storage Client Available Language Groups: Afrikaans Support [af] Albanian Support [sq] Amazigh Support [ber] Arabic Support [ar] Armenian Support [hy] Assamese Support [as] Azerbaijani Support [az] Basque Support [eu] Belarusian Support [be] Bengali Support [bn] Bhutanese Support [dz] Brazilian Portuguese Support [pt_BR] Breton Support [br] Bulgarian Support [bg] Catalan Support [ca] Chhattisgarhi Support [hne] Chichewa Support [ny] Coptic Support [cop] Croatian Support [hr] Czech Support [cs] Danish Support [da] Dutch Support [nl] English (UK) Support [en_GB] Esperanto Support [eo] Estonian Support [et] Ethiopic Support [am] Faroese Support [fo] Fijian Support [fj] Filipino Support [fil] Finnish Support [fi] French Support [fr] Frisian Support [fy] Friulian Support [fur] Gaelic Support [gd] Galician Support [gl] Georgian Support [ka] German Support [de] Greek Support [el] Gujarati Support [gu] Hebrew Support [he] Hiligaynon Support [hil] Hindi Support [hi] Hungarian Support [hu] Icelandic Support [is] Indonesian Support [id] Interlingua Support [ia] Inuktitut Support [iu] Irish Support [ga] Italian Support [it] Japanese Support [ja] Kannada Support [kn] Kashmiri Support [ks] Kashubian Support [csb] Kazakh Support [kk] Khmer Support [km] Kinyarwanda Support [rw] Konkani Support [kok] Korean Support [ko] Kurdish Support [ku] Lao Support [lo] Latin Support [la] Latvian Support [lv] Lithuanian Support [lt] Low Saxon Support [nds] Luxembourgish Support [lb] Macedonian Support [mk] Maithili Support [mai] Malagasy Support [mg] Malay Support [ms] Malayalam Support [ml] Maltese Support [mt] Manx Support [gv] Maori Support [mi] Marathi Support [mr] Mongolian Support [mn] Myanmar (Burmese) Support [my] Nepali Support [ne] Northern Sotho Support [nso] Norwegian Support [nb] Occitan Support [oc] Oriya Support [or] Persian Support [fa] Polish Support [pl] Portuguese Support [pt] Punjabi Support [pa] Romanian Support [ro] Russian Support [ru] Sanskrit Support [sa] Sardinian Support [sc] Serbian Support [sr] Sindhi Support [sd] Sinhala Support [si] Slovak Support [sk] Slovenian Support [sl] Somali Support [so] Southern Ndebele Support [nr] Southern Sotho Support [st] Spanish Support [es] Swahili Support [sw] Swati Support [ss] Swedish Support [sv] Tagalog Support [tl] Tajik Support [tg] Tamil Support [ta] Telugu Support [te] Tetum Support [tet] Thai Support [th] Tibetan Support [bo] Tsonga Support [ts] Tswana Support [tn] Turkish Support [tr] Turkmen Support [tk] Ukrainian Support [uk] Upper Sorbian Support [hsb] Urdu Support [ur] Uzbek Support [uz] Venda Support [ve] Vietnamese Support [vi] Walloon Support [wa] Welsh Support [cy] Xhosa Support [xh] Zulu Support [zu] Done [root@node1 ~]# yum -y groupinstall "Virtualization" "Virtualization Client" "Virtualization Platform"(通过yum源安装虚拟化包组工具等) 提示:红帽装上这些包组以后,默认必须要使用KVM来实现虚拟化,它不支持qemu的,虽然说qemu不依赖KVM也能工作,只不过红帽通过精巧的方式将qemu功能隐藏起来了,必须要 使用KVM,必须要打破原来的设计,因为现在没办法使用KVM,所以让它能够支持qemu,模拟方式来实现,然后才能演示接下来的过程; [root@node1 ~]# qemu-i(查看qemu开头相关的命令) qemu-img qemu-io 提示:根本没有qemu-kvm命令,需要使用全路径,在/usr/libexec/qemu-kvm,所以它不再环境变量里面; [root@node1 ~]# /usr/libexec/qemu-kvm --help(查看qemu-kvm的命令帮助) QEMU PC emulator version 0.12.1 (qemu-kvm-0.12.1.2), Copyright (c) 2003-2008 Fabrice Bellard WARNING: Direct use of qemu-kvm from the command line is not recommended by Red Hat. WARNING: Some command line options listed here may not be available in future releases. WARNING: Red Hat recommends the use of libvirt as the stable management interface. usage: qemu [options] [disk_image] 'disk_image' is a raw hard image image for IDE hard disk 0 Standard options: -h or -help display this help and exit -version display version information and exit -M machine select emulated machine (-M ? for list) -cpu cpu select CPU (-cpu ? for list) -smp n[,maxcpus=cpus][,cores=cores][,threads=threads][,sockets=sockets] set the number of CPUs to 'n' [default=1] maxcpus= maximum number of total cpus, including offline CPUs for hotplug etc. cores= number of CPU cores on one socket threads= number of threads on one CPU core sockets= number of discrete sockets in the system -numa node[,mem=size][,cpus=cpu[-cpu]][,nodeid=node] -fda/-fdb file use 'file' as floppy disk 0/1 image -hda/-hdb file use 'file' as IDE hard disk 0/1 image -hdc/-hdd file use 'file' as IDE hard disk 2/3 image -cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master) -drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i] [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off] [,cache=writethrough|writeback|none|unsafe][,format=f] [,serial=s][,addr=A][,id=name][,aio=threads|native] [,readonly=on|off][,copy-on-read=on|off] use 'file' as a drive image -set group.id.arg=value set <arg> parameter for item <id> of type <group> i.e. -set drive.$id.file=/path/to/image -global driver.prop=value set a global default for a driver property -mtdblock file use 'file' as on-board Flash memory image -sd file use 'file' as SecureDigital card image -pflash file use 'file' as a parallel flash image -boot [order=drives][,once=drives][,menu=on|off] [,reboot-timeout=rb_time] 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n) 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms -snapshot write to temporary files instead of disk image files -m megs set virtual RAM size to megs MB [default=128] -redhat-disable-KSM disable KSM on guest physical memory -k language use keyboard layout (for example 'fr' for French) -audio-help print list of audio drivers and their options -soundhw c1,... enable audio support and only specified sound cards (comma separated list) use -soundhw ? to get the list of supported cards use -soundhw all to enable all of them -usb enable the USB driver (will be the default soon) -usbdevice name add the host or guest USB device 'name' -device driver[,prop[=value][,...]] add device (based on driver) prop=value,... sets driver properties use -device ? to print all possible drivers use -device driver,? to print all possible properties -name string1[,process=string2] set the name of the guest string1 sets the window title and string2 the process name (on Linux) -uuid %08x-%04x-%04x-%04x-%012x specify machine UUID Display options: -nographic disable graphical output and redirect serial I/Os to console -spice [port=port][,tls-port=secured-port][,x509-dir=<dir>] [,x509-key-file=<file>][,x509-key-password=<file>] [,x509-cert-file=<file>][,x509-cacert-file=<file>] [,x509-dh-key-file=<file>][,addr=addr][,ipv4|ipv6] [,tls-ciphers=<list>] [,tls-channel=[main|display|cursor|inputs|record|playback]] [,plaintext-channel=[main|display|cursor|inputs|record|playback]] [,sasl][,password=<secret>][,disable-ticketing] [,image-compression=[auto_glz|auto_lz|quic|glz|lz|off]] [,jpeg-wan-compression=[auto|never|always]] [,zlib-glz-wan-compression=[auto|never|always]] [,streaming-video=[off|all|filter]][,disable-copy-paste] [,agent-mouse=[on|off]][,playback-compression=[on|off]] [,seamless-migration=[on|off]] enable spice at least one of {port, tls-port} is mandatory -portrait rotate graphical output 90 deg left (only PXA LCD) -vga [std|cirrus|vmware|qxl|xenfb|none] select video card type -full-screen start in full screen -vnc display start a VNC server on display i386 target only: -win2k-hack use it when installing Windows 2000 to avoid a disk full bug -no-fd-bootchk disable boot signature checking for floppy disks -no-acpi disable ACPI -balloon none disable balloon device -balloon virtio[,addr=str] enable virtio balloon device (default) -acpitable [sig=str][,rev=n][,oem_id=str][,oem_table_id=str][,oem_rev=n][,asl_compiler_id=str][,asl_compiler_rev=n][,data=file1[: file2]...] ACPI table description -smbios file=binary Load SMBIOS entry from binary file -smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d] Specify SMBIOS type 0 fields -smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str] [,uuid=uuid][,sku=str][,family=str] Specify SMBIOS type 1 fields Network options: -net nic[,vlan=n][,macaddr=mac][,model=type][,name=str][,addr=str][,vectors=v] create a new Network Interface Card and connect it to VLAN 'n' -net user[,vlan=n][,name=str][,net=addr[/mask]][,host=addr][,restrict=y|n] [,hostname=host][,dhcpstart=addr][,dns=addr][,tftp=dir][,bootfile=f] [,hostfwd=rule][,guestfwd=rule][,smb=dir[,smbserver=addr]] connect the user mode network stack to VLAN 'n', configure its DHCP server and enabled optional services -net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off] [,vhostfd=h][,vhostforce=on|off] connect the host TAP network interface to VLAN 'n' and use the network scripts 'file' (default=/etc/qemu-ifup) and 'dfile' (default=/etc/qemu-ifdown); use '[down]script=no' to disable script execution; use 'fd=h' to connect to an already opened TAP interface use 'sndbuf=nbytes' to limit the size of the send buffer (the default is disabled 'sndbuf=0' to enable flow control set 'sndbuf=1048576') use vnet_hdr=off to avoid enabling the IFF_VNET_HDR tap flag; use vnet_hdr=on to make the lack of IFF_VNET_HDR support an error condition use vhost=on to enable experimental in kernel accelerator (only has effect for virtio guests which use MSIX) use vhostforce=on to force vhost on for non-MSIX virtio guests use 'vhostfd=h' to connect to an already opened vhost net device -net socket[,vlan=n][,name=str][,fd=h][,listen=[host]:port][,connect=host:port] connect the vlan 'n' to another VLAN using a socket connection -net socket[,vlan=n][,name=str][,fd=h][,mcast=maddr:port] connect the vlan 'n' to multicast maddr and port -net dump[,vlan=n][,file=f][,len=n] dump traffic on vlan 'n' to file 'f' (max n bytes per packet) -net none use it alone to have zero network devices; if no -net option is provided, the default is '-net nic -net user' -netdev [user|tap|socket],id=str[,option][,option][,...] Character device options: -chardev null,id=id -chardev socket,id=id[,host=host],port=host[,to=to][,ipv4][,ipv6][,nodelay] [,server][,nowait][,telnet] (tcp) -chardev socket,id=id,path=path[,server][,nowait][,telnet] (unix) -chardev udp,id=id[,host=host],port=port[,localaddr=localaddr] [,localport=localport][,ipv4][,ipv6] -chardev msmouse,id=id -chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]] -chardev file,id=id,path=path -chardev pipe,id=id,path=path -chardev pty,id=id -chardev stdio,id=id -chardev tty,id=id,path=path -chardev parport,id=id,path=path -chardev spicevmc,id=id,debug=debug,name=name Bluetooth(R) options: -bt hci,null dumb bluetooth HCI - doesn't respond to commands -bt hci,host[:id] use host's HCI with the given name -bt hci[,vlan=n] emulate a standard HCI in virtual scatternet 'n' -bt vhci[,vlan=n] add host computer to virtual scatternet 'n' using VHCI -bt device:dev[,vlan=n] emulate a bluetooth device 'dev' in scatternet 'n' Linux/Multiboot boot specific: -kernel bzImage use 'bzImage' as kernel image -append cmdline use 'cmdline' as kernel command line -initrd file use 'file' as initial ram disk Debug/Expert options: -serial dev redirect the serial port to char device 'dev' -parallel dev redirect the parallel port to char device 'dev' -monitor dev redirect the monitor to char device 'dev' -qmp dev like -monitor but opens in 'control' mode. -mon chardev=[name][,mode=readline|control][,default] -debugcon dev redirect the debug console to char device 'dev' -pidfile file write PID to 'file' -singlestep always run in singlestep mode -S freeze CPU at startup (use 'c' to start execution) -gdb dev wait for gdb connection on 'dev' -s shorthand for -gdb tcp::1234 -d item1,... output log to /tmp/qemu.log (use -d ? for a list of log items) -hdachs c,h,s[,t] force hard disk 0 physical geometry and the optional BIOS translation (t=none or lba) (usually qemu can guess them) -L path set the directory for the BIOS, VGA BIOS and keymaps -bios file set the filename for the BIOS -enable-kvm enable KVM full virtualization support -machine [type=]name[,prop[=value][,...]] selects emulated machine (-machine ? for list) property accel=accel1[:accel2[:...]] selects accelerator supported accelerators are kvm, tcg (default: kvm:tcg) dump-guest-core=on|off include guest memory in a core dump (default=on) -no-reboot exit instead of rebooting -no-shutdown stop before shutdown -loadvm [tag|id] start right away with a saved state (loadvm in monitor) -daemonize daemonize QEMU after initializing -option-rom rom load a file, rom, into the option ROM space -clock force the use of the given methods for timer alarm. To see what timers are available use -clock ? -rtc [base=utc|localtime|date][,clock=host|vm][,driftfix=none|slew] set the RTC base and clock, enable drift fix for clock ticks -icount [N|auto] enable virtual instruction counter with 2^N clock ticks per instruction -watchdog i6300esb|ib700 enable virtual hardware watchdog [default=none] -watchdog-action reset|shutdown|poweroff|pause|debug|none action when watchdog fires [default=reset] -echr chr set terminal escape character instead of ctrl-a -virtioconsole c set virtio console -show-cursor show cursor -tb-size n set TB size -incoming p prepare for incoming migration, listen on port p -nodefaults don't create default devices. -chroot dir Chroot to dir just before starting the VM. -runas user Change to user id user just before starting the VM. -nodefconfig do not load default config files at startup -readconfig <file> -writeconfig <file> read/write config file -no-kvm disable KVM hardware virtualization -no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC -no-kvm-pit disable KVM kernel mode PIT -no-kvm-pit-reinjection disable KVM kernel mode PIT interrupt reinjection -pcidevice host=bus:dev.func[,dma=none][,name=string] expose a PCI device to the guest OS. dma=none: don't perform any dma translations (default is to use an iommu) 'string' is used in log output. -nvram FILE provide ia64 nvram contents -tdf enable guest time drift compensation -kvm-shadow-memory MEGABYTES allocate MEGABYTES for kvm mmu shadowing -mem-path FILE provide backing storage for guest RAM -mem-prealloc preallocate guest memory (use with -mempath) During emulation, the following keys are useful: ctrl-alt-f toggle full screen ctrl-alt-n switch to virtual console 'n' ctrl-alt toggle mouse and keyboard grab When using -nographic, press 'ctrl-a h' to get some help. WARNING: Direct use of qemu-kvm from the command line is not recommended by Red Hat. WARNING: Some command line options listed here may not be available in future releases. WARNING: Red Hat recommends the use of libvirt as the stable management interface. [root@node1 ~]# /usr/libexec/qemu-kvm -cpu ?(查看quemu-kvm支持的cpu类型) x86 Opteron_G5 AMD Opteron 63xx class CPU x86 Opteron_G4 AMD Opteron 62xx class CPU x86 Opteron_G3 AMD Opteron 23xx (Gen 3 Class Opteron) x86 Opteron_G2 AMD Opteron 22xx (Gen 2 Class Opteron) x86 Opteron_G1 AMD Opteron 240 (Gen 1 Class Opteron) x86 Haswell Intel Core Processor (Haswell) x86 SandyBridge Intel Xeon E312xx (Sandy Bridge) x86 Westmere Westmere E56xx/L56xx/X56xx (Nehalem-C) x86 Nehalem Intel Core i7 9xx (Nehalem Class Core i7) x86 Penryn Intel Core 2 Duo P9xxx (Penryn Class Core 2) x86 Conroe Intel Celeron_4x0 (Conroe/Merom Class Core 2) x86 cpu64-rhel5 QEMU Virtual CPU version (cpu64-rhel5) x86 cpu64-rhel6 QEMU Virtual CPU version (cpu64-rhel6) x86 n270 Intel(R) Atom(TM) CPU N270 @ 1.60GHz x86 athlon QEMU Virtual CPU version 0.12.1 x86 pentium3 x86 pentium2 x86 pentium x86 486 x86 coreduo Genuine Intel(R) CPU T2600 @ 2.16GHz x86 qemu32 QEMU Virtual CPU version 0.12.1 x86 kvm64 Common KVM processor x86 core2duo Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz x86 phenom AMD Phenom(tm) 9550 Quad-Core Processor x86 qemu64 QEMU Virtual CPU version 0.12.1(模拟cpu) Recognized CPUID flags: f_edx: pbe ia64 tm ht ss sse2 sse fxsr mmx acpi ds clflush pn pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de vme fpu f_ecx: hypervisor rdrand f16c avx osxsave xsave aes tsc-deadline popcnt movbe x2apic sse4.2|sse4_2 sse4.1|sse4_1 dca pcid pdcm xtpr cx16 fma cid ssse3 tm2 est smx vmx ds_cpl monitor dtes64 pclmulqdq|pclmuldq pni|sse3 extf_edx: 3dnow 3dnowext lm|i64 rdtscp pdpe1gb fxsr_opt|ffxsr fxsr mmx mmxext nx|xd pse36 pat cmov mca pge mtrr syscall apic cx8 mce pae msr tsc pse de vme fpu extf_ecx: perfctr_nb perfctr_core topoext tbm nodeid_msr tce fma4 lwp wdt skinit xop ibs osvw 3dnowprefetch misalignsse sse4a abm cr8legacy extapic svm cmp_legacy lahf_lm [root@node1 ~]# service libvirtd start(启动libvirtd服务) 启动 libvirtd 守护进程: [确定] [root@node1 ~]# chkconfig libvirtd on(将libvirtd添加到系统服务) 提示:只要启动了libvirtd,他会自动创建一个桥接设备; [root@node1 ~]# ifconfig(查看网卡信息) eth0 Link encap:Ethernet HWaddr 00:0C:29:D9:0D:2A inet addr:172.16.200.6 Bcast:172.16.200.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fed9:d2a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:11676 errors:0 dropped:0 overruns:0 frame:0 TX packets:5807 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1022435 (998.4 KiB) TX bytes:1439279 (1.3 MiB) eth1 Link encap:Ethernet HWaddr 00:0C:29:D9:0D:34 inet addr:192.168.111.140 Bcast:192.168.111.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fed9:d34/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6475 errors:0 dropped:0 overruns:0 frame:0 TX packets:180 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:627162 (612.4 KiB) TX bytes:16103 (15.7 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) virbr0 Link encap:Ethernet HWaddr 52:54:00:AA:22:1F inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) 提示:virbr0虚拟的网桥设备,这个设备没有额外的功能,就是个nat模型的桥,默认启动的,我们应该使用物理桥; [root@node1 ~]# yum -y install bridge-utils(安装桥工具软件) 提示:如果没有安装会创建桥失败; [root@node1 ~]# virsh iface-bridge eth0 br0(创建物理桥br0) Created bridge br0 with attached device eth0 Bridge interface br0 started [root@node1 ~]# ifconfig(查看网卡接口信息) br0 Link encap:Ethernet HWaddr 00:0C:29:D9:0D:2A inet addr:172.16.200.1 Bcast:172.16.200.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fed9:d2a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:12 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:720 (720.0 b) eth0 Link encap:Ethernet HWaddr 00:0C:29:D9:0D:2A UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:19 errors:0 dropped:0 overruns:0 frame:0 TX packets:68 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1716 (1.6 KiB) TX bytes:3976 (3.8 KiB) eth1 Link encap:Ethernet HWaddr 00:0C:29:D9:0D:34 inet addr:192.168.111.140 Bcast:192.168.111.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fed9:d34/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1535 errors:0 dropped:0 overruns:0 frame:0 TX packets:1616 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:131989 (128.8 KiB) TX bytes:765786 (747.8 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) virbr0 Link encap:Ethernet HWaddr 52:54:00:AA:22:1F inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) [root@node1 ~]# virsh capabilities(查看支持的虚拟化类型) <capabilities> <host> <uuid>564dd7f5-d4e9-554f-9890-f316e3d90d2a</uuid> <cpu> <arch>x86_64</arch> <model>SandyBridge</model> <vendor>Intel</vendor> <topology sockets='1' cores='1' threads='1'/> <feature name='erms'/>(平台类型) <feature name='smep'/> <feature name='fsgsbase'/> <feature name='hypervisor'/> <feature name='rdrand'/> <feature name='f16c'/> <feature name='osxsave'/> <feature name='pcid'/> <feature name='vmx'/> <feature name='ss'/> <feature name='ds'/> <feature name='vme'/> </cpu> <power_management> <suspend_disk/>(磁盘类型) </power_management> <migration_features> <live/> <uri_transports> <uri_transport>tcp</uri_transport> </uri_transports> </migration_features> <topology> <cells num='1'> <cell id='0'> <cpus num='1'>(cpu类型) <cpu id='0'/> </cpus> </cell> </cells> </topology> <secmodel> <model>selinux</model> <doi>0</doi> </secmodel> <secmodel> <model>dac</model> <doi>0</doi> </secmodel> </host> <guest> <os_type>hvm</os_type>(完全虚拟化类型) <arch name='i686'> <wordsize>32</wordsize> <emulator>/usr/libexec/qemu-kvm</emulator> <machine>rhel6.4.0</machine> <machine canonical='rhel6.4.0'>pc</machine> <machine>rhel6.3.0</machine> <machine>rhel6.2.0</machine> <machine>rhel6.1.0</machine> <machine>rhel6.0.0</machine> <machine>rhel5.5.0</machine> <machine>rhel5.4.4</machine> <machine>rhel5.4.0</machine> <domain type='qemu'> </domain> <domain type='kvm'> <emulator>/usr/libexec/qemu-kvm</emulator> </domain> </arch> <features> <cpuselection/> <deviceboot/> <acpi default='on' toggle='yes'/> <apic default='on' toggle='no'/> <pae/> <nonpae/> </features> </guest> <guest> <os_type>hvm</os_type> <arch name='x86_64'> <wordsize>64</wordsize> <emulator>/usr/libexec/qemu-kvm</emulator> <machine>rhel6.4.0</machine> <machine canonical='rhel6.4.0'>pc</machine> <machine>rhel6.3.0</machine> <machine>rhel6.2.0</machine> <machine>rhel6.1.0</machine> <machine>rhel6.0.0</machine> <machine>rhel5.5.0</machine> <machine>rhel5.4.4</machine> <machine>rhel5.4.0</machine> <domain type='qemu'> </domain> <domain type='kvm'> <emulator>/usr/libexec/qemu-kvm</emulator> </domain> </arch> <features> <cpuselection/> <deviceboot/> <acpi default='on' toggle='yes'/> <apic default='on' toggle='no'/> </features> </guest> </capabilities> [root@node1 ~]# virsh --help(查看virsh命令帮助) virsh [options]... [<command_string>] virsh [options]... <command> [args...] options: -c | --connect=URI hypervisor connection URI -r | --readonly connect readonly -d | --debug=NUM debug level [0-4] -h | --help this help -q | --quiet quiet mode -t | --timing print timing information -l | --log=FILE output logging to file -v short version -V long version --version[=TYPE] version, TYPE is short or long (default short) -e | --escape <char> set escape sequence for console commands (non interactive mode): Domain Management (help keyword 'domain') attach-device 从一个XML文件附加装置 attach-disk 附加磁盘设备 attach-interface 获得网络界面 autostart 自动开始一个域 blkdeviotune Set or query a block device I/O tuning parameters. blkiotune Get or set blkio parameters blockcommit Start a block commit operation. blockcopy Start a block copy operation. blockjob Manage active block operations blockpull Populate a disk from its backing image. blockresize Resize block device of domain. change-media Change media of CD or floppy drive console 连接到客户会话 cpu-baseline compute baseline CPU cpu-compare compare host CPU with a CPU described by an XML file cpu-stats show domain cpu statistics create 从一个 XML 文件创建一个域 define 从一个 XML 文件定义(但不开始)一个域 desc show or set domain's description or title destroy destroy (stop) a domain detach-device 从一个 XML 文件分离设备 detach-disk 分离磁盘设备 detach-interface 分离网络界面 domdisplay domain display connection URI domhostname print the domain's hostname domid 把一个域名或 UUID 转换为域 id domif-setlink set link state of a virtual interface domiftune get/set parameters of a virtual interface domjobabort abort active domain job domjobinfo domain job information domname 将域 id 或 UUID 转换为域名 dompmsuspend suspend a domain gracefully using power management functions dompmwakeup wakeup a domain from pmsuspended state domuuid 把一个域名或 id 转换为域 UUID domxml-from-native Convert native config to domain XML domxml-to-native Convert domain XML to native config dump 把一个域的内核 dump 到一个文件中以方便分析 dumpxml XML 中的域信息 edit 编辑某个域的 XML 配置 inject-nmi Inject NMI to the guest send-key Send keycodes to the guest managedsave managed save of a domain state managedsave-remove Remove managed save of a domain maxvcpus connection vcpu maximum memtune Get or set memory parameters migrate 将域迁移到另一个主机中 migrate-setmaxdowntime set maximum tolerable downtime migrate-setspeed Set the maximum migration bandwidth migrate-getspeed Get the maximum migration bandwidth numatune Get or set numa parameters reboot 重新启动一个域 reset reset a domain restore 从一个存在一个文件中的状态恢复一个域 resume 重新恢复一个域 save 把一个域的状态保存到一个文件 save-image-define redefine the XML for a domain's saved state file save-image-dumpxml saved state domain information in XML save-image-edit edit XML for a domain's saved state file schedinfo 显示/设置日程安排变量 screenshot take a screenshot of a current domain console and store it into a file setmaxmem 改变最大内存限制值 setmem 改变内存的分配 setvcpus 改变虚拟 CPU 的号 shutdown 关闭一个域 start 开始一个(以前定义的)非活跃的域 suspend 挂起一个域 ttyconsole tty 控制台 undefine undefine a domain update-device update device from an XML file vcpucount domain vcpu counts vcpuinfo detailed domain vcpu information vcpupin control or query domain vcpu affinity emulatorpin control or query domain emulator affinity vncdisplay vnc 显示 Domain Monitoring (help keyword 'monitor') domblkerror Show errors on block devices domblkinfo domain block device size information domblklist list all domain blocks domblkstat 获得域设备块状态 domcontrol domain control interface state domif-getlink get link state of a virtual interface domiflist list all domain virtual interfaces domifstat 获得域网络接口状态 dominfo 域信息 dommemstat get memory statistics for a domain domstate 域状态 list 列出域 Host and Hypervisor (help keyword 'host') capabilities 性能 connect 连接(重新连接)到 hypervisor freecell NUMA可用内存 hostname 打印管理程序主机名 node-memory-tune Get or set node memory parameters nodecpustats Prints cpu stats of the node. nodeinfo 节点信息 nodememstats Prints memory stats of the node. nodesuspend suspend the host node for a given time duration qemu-attach QEMU Attach qemu-monitor-command QEMU Monitor Command qemu-agent-command QEMU Guest Agent Command sysinfo print the hypervisor sysinfo uri 打印管理程序典型的URI version 显示版本 Interface (help keyword 'interface') iface-begin create a snapshot of current interfaces settings, which can be later committed (iface-commit) or restored (iface-rollback) iface-bridge create a bridge device and attach an existing network device to it iface-commit commit changes made since iface-begin and free restore point iface-define define (but don't start) a physical host interface from an XML file iface-destroy destroy a physical host interface (disable it / "if-down") iface-dumpxml interface information in XML iface-edit edit XML configuration for a physical host interface iface-list list physical host interfaces iface-mac convert an interface name to interface MAC address iface-name convert an interface MAC address to interface name iface-rollback rollback to previous saved configuration created via iface-begin iface-start start a physical host interface (enable it / "if-up") iface-unbridge undefine a bridge device after detaching its slave device iface-undefine undefine a physical host interface (remove it from configuration) Network Filter (help keyword 'filter') nwfilter-define define or update a network filter from an XML file nwfilter-dumpxml network filter information in XML nwfilter-edit edit XML configuration for a network filter nwfilter-list list network filters nwfilter-undefine undefine a network filter Networking (help keyword 'network') net-autostart 自动开始网络 net-create 从一个 XML 文件创建一个网络 net-define 从一个 XML 文件定义(但不开始)一个网络 net-destroy destroy (stop) a network net-dumpxml XML 中的网络信息 net-edit 为网络编辑 XML 配置 net-info network information net-list 列出网络 net-name 把一个网络UUID 转换为网络名 net-start 开始一个(以前定义的)不活跃的网络 net-undefine 取消定义一个非活跃的网络 net-update update parts of an existing network's configuration net-uuid 把一个网络名转换为网络UUID Node Device (help keyword 'nodedev') nodedev-create create a device defined by an XML file on the node nodedev-destroy destroy (stop) a device on the node nodedev-detach detach node device from its device driver nodedev-dumpxml XML 中的节点设备详情 nodedev-list 这台主机中中的枚举设备 nodedev-reattach reattach node device to its device driver nodedev-reset 重置节点设备 Secret (help keyword 'secret') secret-define define or modify a secret from an XML file secret-dumpxml secret attributes in XML secret-get-value Output a secret value secret-list list secrets secret-set-value set a secret value secret-undefine undefine a secret Snapshot (help keyword 'snapshot') snapshot-create Create a snapshot from XML snapshot-create-as Create a snapshot from a set of args snapshot-current Get or set the current snapshot snapshot-delete Delete a domain snapshot snapshot-dumpxml Dump XML for a domain snapshot snapshot-edit edit XML for a snapshot snapshot-info snapshot information snapshot-list List snapshots for a domain snapshot-parent Get the name of the parent of a snapshot snapshot-revert Revert a domain to a snapshot Storage Pool (help keyword 'pool') find-storage-pool-sources-as 找到潜在存储池源 find-storage-pool-sources 发现潜在存储池源 pool-autostart 自动启动某个池 pool-build 建立池 pool-create-as 从一组变量中创建一个池 pool-create 从一个 XML 文件中创建一个池 pool-define-as 在一组变量中定义池 pool-define 在一个 XML 文件中定义(但不启动)一个池 pool-delete 删除池 pool-destroy destroy (stop) a pool pool-dumpxml XML 中的池信息 pool-edit 为存储池编辑 XML 配置 pool-info 存储池信息 pool-list 列出池 pool-name 将池 UUID 转换为池名称 pool-refresh 刷新池 pool-start 启动一个(以前定义的)非活跃的池 pool-undefine 取消定义一个不活跃的池 pool-uuid 把一个池名称转换为池 UUID Storage Volume (help keyword 'volume') vol-clone clone a volume. vol-create-as 从一组变量中创建卷 vol-create 从一个 XML 文件创建一个卷 vol-create-from create a vol, using another volume as input vol-delete 删除卷 vol-download Download a volume to a file vol-dumpxml XML 中的卷信息 vol-info 存储卷信息 vol-key returns the volume key for a given volume name or path vol-list 列出卷 vol-name returns the volume name for a given volume key or path vol-path returns the volume path for a given volume name or key vol-pool returns the storage pool for a given volume key or path vol-resize resize a vol vol-upload upload a file into a volume vol-wipe wipe a vol Virsh itself (help keyword 'virsh') cd change the current directory echo echo arguments exit 退出这个非交互式终端 help 打印帮助 pwd print the current directory quit 退出这个非交互式终端 (specify help <group> for details about the commands in the group) (使用 --help <command> 来获得这个命令的详细信息) [root@node1 ~]# virsh help connect(查看virsh的子命令connect帮助) NAME connect - 连接(重新连接)到 hypervisor SYNOPSIS connect [<name>] [--readonly](连接到某个hypervisor) DESCRIPTION 连接到本地管理程序。这是在 shell 启动后内建的命令。 OPTIONS [--name] <string> 管理程序连接 URI --readonly 只读连接 [root@node1 ~]# virsh uri(查看当前主机hypervisor访问路径) qemu:///system [root@node1 ~]# virsh sysinfo(打印管理程序的uri) [root@node1 ~]# lftp 172.16.0.1(连接ftp服务器) cd ok, cwd=/pub/Sources lftp 172.16.0.1:/pub/Sources> cd ../images/(切换到images目录) lftp 172.16.0.1:/pub/Sources/images> get boot.iso(下载boot.iso文件) 13840384 bytes transferred lftp 172.16.0.1:/pub/Sources/images> bye(退出) [root@node1 ~]# ls(查看当前目录文件及子目录) anaconda-ks.cfg boot.iso install.log install.log.syslog [root@node1 ~]# virt-install --connect qemu:///system --virt-type kvm --name rhel5 --ram 512 --disk path=/var/lib/libvirt/images/rhel5 .img,size=8,sparse --graphics vnc --cdrom /root/boot.iso(安装虚拟机,--connect连接hypervisor路径,-virt-type类型,--name指定虚拟机名称,--ra m指定内存大小,--disk path=指定磁盘文件,sparse稀疏类型,磁盘大小按需增长,--graphices指定自动打开vnc界面,--cdrom指定光盘镜像文件,) Starting install... ERROR internal error Process exited while reading console log output: char device redirected to /dev/pts/2 qemu-kvm: -drive file=/root/boot.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw: could not open disk image /root/boot .iso: Permission denied Domain installation does not appear to have been successful. If it was, you can restart your domain by running: virsh --connect qemu:///system start rhel5 otherwise, please restart your installation. 提示:报错,internal error Process exited while reading console log output: char device redirected to /dev/pts/2 [root@node1 ~]# vim /etc/libvirt/qemu.conf(编辑qemu.conf配置文件) #user = "root" user = "root" #group = "root" group = "root" #dynamic_ownership = 1 dynamic_ownership = 0 [root@node1 ~]# service libvirtd restart(重启libvirtd服务) 正在关闭 libvirtd 守护进程: [确定] 启动 libvirtd 守护进程: [确定] [root@node1 ~]# virt-install --connect qemu:///system --virt-type kvm --name rhel5 --ram 512 --disk path=/var/lib/libvirt/images/rhel5 .img,size=8,sparse --graphics vnc --cdrom /root/boot.iso(安装虚拟机,--connect连接hypervisor路径,-virt-type类型,--name指定虚拟机名称,--ra m指定内存大小,--disk path=指定磁盘文件,sparse稀疏类型,磁盘大小按需增长,--graphices指定自动打开vnc界面,--cdrom指定光盘镜像文件,) Starting install... Creating domain... | 0 B 00:00
安装成功会启动vnc的图形化安装界面;
[root@node1 ~]# rm /var/lib/libvirt/images/rhel5.img(删除rhel5.img映像文件) rm: remove regular file `/var/lib/libvirt/images/rhel5.img'? y [root@node1 ~]# ps aux | grep qemu(查看所有终端进程只显示qemu相关) root 12137 98.8 1.7 1040248 34236 ? R 06:30 11:01 /usr/libexec/qemu-kvm -name rhel5 -S -M rhel6.4.0 -no-kvm -m 512 -smp 1,sockets=1,cores=1,threads=1 -uuid 31c5311a-b075-e50e-4340-e808a00053a5 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path =/var/lib/libvirt/qemu/rhel5.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-reboot -no-shutd own -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/rhel5.img,if=none,id=drive-ide0-0-0,form at=raw,cache=none -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=2 -drive file=/root/boot.iso,if=none, media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1 -netdev tap,fd=22,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:2a:8e:ea,bus=pci.0,addr=0x3 -chardev pty,id=chars erial0 -device isa-serial,chardev=charserial0,id=serial0 -vnc 127.0.0.1:0 -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0 ,addr=0x4 root 12368 0.0 0.0 103240 872 pts/1 S+ 06:41 0:00 grep qemu [root@node1 ~]# kill -9 12137(杀死12137进程) [root@node1 ~]# virsh undefine rhel5(删除rhel5虚拟机区域名) Domain rhel5 has been undefined [root@node1 ~]# virt-install --connect qemu:///system --virt-type qemu --name rhel5 --ram 512 --disk path=/var/lib/libvirt/images/rhel5. img,size=8,sparse --graphics vnc --cdrom /root.iso(安装虚拟机,--connect连接hypervisor路径,-virt-type类型,--name指定虚拟机名称,--ram指定内存 大小,--disk path=指定磁盘文件,sparse稀疏类型,磁盘大小按需增长,--graphices指定自动打开vnc界面,--cdrom指定光盘镜像文件,) WARNING KVM acceleration not available, using 'qemu' Starting install... Allocating 'rhel5.img' | 8.0 GB 00:00 Creating domain...
安装成功会启动vnc的图形化安装界面;
[root@node1 ~]# ln -sv /usr/libexec/qemu-kvm /usr/bin/qemu(给qemu-kvm文件创建软连接到/usr/bin/qemu,-s软连接,-v显示创建过程) `/usr/bin/qemu' -> `/usr/libexec/qemu-kvm' [root@node1 ~]# mv /root/boot.iso /tmp/(将boot.iso,放到/tmp目录) [root@node1 ~]# vim /etc/libvirt/qemu.conf(编辑qemu.conf配置文件) #user = "root" #group = "root" #dynamic_ownership = 1 提示:关闭使用root用户,root组运行qemu进程,及动态改变文件所有权,1匹配运行qemu进程用户/组,0禁用所有权变化; [root@node1 ~]# service libvirtd restart(重启libvirtd服务) 正在关闭 libvirtd 守护进程: [确定] 启动 libvirtd 守护进程: [确定] [root@node1 ~]# rm /var/lib/libvirt/images/rhel5.img(删除rhel5.img映像文件) rm: remove regular file `/var/lib/libvirt/images/rhel5.img'? y [root@node1 ~]# ps aux | grep qemu(查看所有终端进程只显示qemu相关) root 12137 98.8 1.7 1040248 34236 ? R 06:30 11:01 /usr/libexec/qemu-kvm -name rhel5 -S -M rhel6.4.0 -no-kvm -m 512 -smp 1,sockets=1,cores=1,threads=1 -uuid 31c5311a-b075-e50e-4340-e808a00053a5 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path= /var/lib/libvirt/qemu/rhel5.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-reboot -no-shutdow n -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/rhel5.img,if=none,id=drive-ide0-0-0,format= raw,cache=none -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=2 -drive file=/root/boot.iso,if=none,medi a=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1 -netd ev tap,fd=22,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:2a:8e:ea,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -vnc 127.0.0.1:0 -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr =0x4 root 12368 0.0 0.0 103240 872 pts/1 S+ 06:41 0:00 grep qemu [root@node1 ~]# kill -9 12137(杀死12137进程) [root@node1 ~]# virsh undefine rhel5(删除rhel5虚拟机区域名) Domain rhel5 has been undefined [root@node1 ~]# virt-install --connect qemu:///system --virt-type qemu --name rhel5 --ram 512 --disk path=/var/lib/libvirt/images/rhel5 .img,size=8,sparse --graphics vnc --cdrom /tmp/boot.iso(安装虚拟机,--connect连接hypervisor路径,-virt-type类型,--name指定虚拟机名称,--ram指 定内存大小,--disk path=指定磁盘文件,sparse稀疏类型,磁盘大小按需增长,--graphices指定自动打开vnc界面,--cdrom指定光盘镜像文件,) WARNING KVM acceleration not available, using 'qemu' Starting install... Allocating 'rhel5.img' | 8.0 GB 00:00 Creating domain...
安装成功会启动vnc的图形化安装界面;
[root@node1 tmp]# virsh list(查看运行的虚拟机) Id Name State ---------------------------------------------------- 4 rhel5 running [root@node1 tmp]# virsh destroy rhel5(停止rhel5虚拟机) Domain rhel5 destroyed [root@node1 ~]# virt-install --connect qemu:///system --virt-type qemu --name rhel5 --ram 512 --disk path=/var/lib/libvirt/images/rhel 5.img,size=8 --graphics vnc --location ftp://172.16.100.254 --extra-args "ks=ftp://172.16.100.254/rhel5-ks.cfg"(安装虚拟机,--connect连 接hypervisor路径,-virt-type类型,--name指定虚拟机名称,--ram指定内存大小,--disk path=指定磁盘文件,sparse稀疏类型,磁盘大小按需增长,--graphices指 定自动打开vnc界面,----location指定网络安装文件,--extra-args指定ks自动配置文件) WARNING KVM acceleration not available, using 'qemu' ERROR Guest name 'rhel5' is already in use. 提示:rhel5存在; [root@node1 ~]# virsh list(查看虚拟机) Id Name State ---------------------------------------------------- [root@node1 ~]# virsh --help(查看virsh命令帮助) virsh [options]... [<command_string>] virsh [options]... <command> [args...] options: -c | --connect=URI hypervisor connection URI -r | --readonly connect readonly -d | --debug=NUM debug level [0-4] -h | --help this help -q | --quiet quiet mode -t | --timing print timing information -l | --log=FILE output logging to file -v short version -V long version --version[=TYPE] version, TYPE is short or long (default short) -e | --escape <char> set escape sequence for console commands (non interactive mode): Domain Management (help keyword 'domain') attach-device attach device from an XML file attach-disk attach disk device attach-interface attach network interface autostart autostart a domain blkdeviotune Set or query a block device I/O tuning parameters. blkiotune Get or set blkio parameters blockcommit Start a block commit operation. blockcopy Start a block copy operation. blockjob Manage active block operations blockpull Populate a disk from its backing image. blockresize Resize block device of domain. change-media Change media of CD or floppy drive console connect to the guest console cpu-baseline compute baseline CPU cpu-compare compare host CPU with a CPU described by an XML file cpu-stats show domain cpu statistics create create a domain from an XML file define define (but don't start) a domain from an XML file desc show or set domain's description or title destroy destroy (stop) a domain detach-device detach device from an XML file detach-disk detach disk device detach-interface detach network interface domdisplay domain display connection URI domhostname print the domain's hostname domid convert a domain name or UUID to domain id domif-setlink set link state of a virtual interface domiftune get/set parameters of a virtual interface domjobabort abort active domain job domjobinfo domain job information domname convert a domain id or UUID to domain name dompmsuspend suspend a domain gracefully using power management functions dompmwakeup wakeup a domain from pmsuspended state domuuid convert a domain name or id to domain UUID domxml-from-native Convert native config to domain XML domxml-to-native Convert domain XML to native config dump dump the core of a domain to a file for analysis dumpxml domain information in XML edit edit XML configuration for a domain inject-nmi Inject NMI to the guest send-key Send keycodes to the guest managedsave managed save of a domain state managedsave-remove Remove managed save of a domain maxvcpus connection vcpu maximum memtune Get or set memory parameters migrate migrate domain to another host migrate-setmaxdowntime set maximum tolerable downtime migrate-setspeed Set the maximum migration bandwidth migrate-getspeed Get the maximum migration bandwidth numatune Get or set numa parameters reboot reboot a domain reset reset a domain restore restore a domain from a saved state in a file resume resume a domain save save a domain state to a file save-image-define redefine the XML for a domain's saved state file save-image-dumpxml saved state domain information in XML save-image-edit edit XML for a domain's saved state file schedinfo show/set scheduler parameters screenshot take a screenshot of a current domain console and store it into a file setmaxmem change maximum memory limit setmem change memory allocation setvcpus change number of virtual CPUs shutdown gracefully shutdown a domain start start a (previously defined) inactive domain suspend suspend a domain ttyconsole tty console undefine undefine a domain update-device update device from an XML file vcpucount domain vcpu counts vcpuinfo detailed domain vcpu information vcpupin control or query domain vcpu affinity emulatorpin control or query domain emulator affinity vncdisplay vnc display Domain Monitoring (help keyword 'monitor') domblkerror Show errors on block devices domblkinfo domain block device size information domblklist list all domain blocks domblkstat get device block stats for a domain domcontrol domain control interface state domif-getlink get link state of a virtual interface domiflist list all domain virtual interfaces domifstat get network interface stats for a domain dominfo domain information dommemstat get memory statistics for a domain domstate domain state list list domains Host and Hypervisor (help keyword 'host') capabilities capabilities connect (re)connect to hypervisor freecell NUMA free memory hostname print the hypervisor hostname node-memory-tune Get or set node memory parameters nodecpustats Prints cpu stats of the node. nodeinfo node information nodememstats Prints memory stats of the node. nodesuspend suspend the host node for a given time duration qemu-attach QEMU Attach qemu-monitor-command QEMU Monitor Command qemu-agent-command QEMU Guest Agent Command sysinfo print the hypervisor sysinfo uri print the hypervisor canonical URI version show version Interface (help keyword 'interface') iface-begin create a snapshot of current interfaces settings, which can be later committed (iface-commit) or restored (iface-rollback) iface-bridge create a bridge device and attach an existing network device to it iface-commit commit changes made since iface-begin and free restore point iface-define define (but don't start) a physical host interface from an XML file iface-destroy destroy a physical host interface (disable it / "if-down") iface-dumpxml interface information in XML iface-edit edit XML configuration for a physical host interface iface-list list physical host interfaces iface-mac convert an interface name to interface MAC address iface-name convert an interface MAC address to interface name iface-rollback rollback to previous saved configuration created via iface-begin iface-start start a physical host interface (enable it / "if-up") iface-unbridge undefine a bridge device after detaching its slave device iface-undefine undefine a physical host interface (remove it from configuration) Network Filter (help keyword 'filter') nwfilter-define define or update a network filter from an XML file nwfilter-dumpxml network filter information in XML nwfilter-edit edit XML configuration for a network filter nwfilter-list list network filters nwfilter-undefine undefine a network filter Networking (help keyword 'network') net-autostart autostart a network net-create create a network from an XML file net-define define (but don't start) a network from an XML file net-destroy destroy (stop) a network net-dumpxml network information in XML net-edit edit XML configuration for a network net-info network information net-list list networks net-name convert a network UUID to network name net-start start a (previously defined) inactive network net-undefine undefine an inactive network net-update update parts of an existing network's configuration net-uuid convert a network name to network UUID Node Device (help keyword 'nodedev') nodedev-create create a device defined by an XML file on the node nodedev-destroy destroy (stop) a device on the node nodedev-detach detach node device from its device driver nodedev-dumpxml node device details in XML nodedev-list enumerate devices on this host nodedev-reattach reattach node device to its device driver nodedev-reset reset node device Secret (help keyword 'secret') secret-define define or modify a secret from an XML file secret-dumpxml secret attributes in XML secret-get-value Output a secret value secret-list list secrets secret-set-value set a secret value secret-undefine undefine a secret Snapshot (help keyword 'snapshot') snapshot-create Create a snapshot from XML snapshot-create-as Create a snapshot from a set of args snapshot-current Get or set the current snapshot snapshot-delete Delete a domain snapshot snapshot-dumpxml Dump XML for a domain snapshot snapshot-edit edit XML for a snapshot snapshot-info snapshot information snapshot-list List snapshots for a domain snapshot-parent Get the name of the parent of a snapshot snapshot-revert Revert a domain to a snapshot Storage Pool (help keyword 'pool') find-storage-pool-sources-as find potential storage pool sources find-storage-pool-sources discover potential storage pool sources pool-autostart autostart a pool pool-build build a pool pool-create-as create a pool from a set of args pool-create create a pool from an XML file pool-define-as define a pool from a set of args pool-define define (but don't start) a pool from an XML file pool-delete delete a pool pool-destroy destroy (stop) a pool pool-dumpxml pool information in XML pool-edit edit XML configuration for a storage pool pool-info storage pool information pool-list list pools pool-name convert a pool UUID to pool name pool-refresh refresh a pool pool-start start a (previously defined) inactive pool pool-undefine undefine an inactive pool pool-uuid convert a pool name to pool UUID Storage Volume (help keyword 'volume') vol-clone clone a volume. vol-create-as create a volume from a set of args vol-create create a vol from an XML file vol-create-from create a vol, using another volume as input vol-delete delete a vol vol-download Download a volume to a file vol-dumpxml vol information in XML vol-info storage vol information vol-key returns the volume key for a given volume name or path vol-list list vols vol-name returns the volume name for a given volume key or path vol-path returns the volume path for a given volume name or key vol-pool returns the storage pool for a given volume key or path vol-resize resize a vol vol-upload upload a file into a volume vol-wipe wipe a vol Virsh itself (help keyword 'virsh') cd change the current directory echo echo arguments exit quit this interactive terminal help print help pwd print the current directory quit quit this interactive terminal (specify help <group> for details about the commands in the group) (specify help <command> for details about the command) [root@node1 ~]# cd /etc/libvirt/(切换到/etc/libvirt目录) [root@node1 libvirt]# ls(查看单曲目录文件及子目录) libvirt.conf libvirtd.conf lxc.conf nwfilter qemu qemu.conf storage [root@node1 libvirt]# cd qemu(切换到qemu目录) [root@node1 qemu]# ls(查看当前目录文件及子目录) networks rhel5.xml [root@node1 qemu]# cat rhel5.xml(查看rhel5.xml文件内容) <!-- WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE OVERWRITTEN AND LOST. Changes to this xml configuration should be made using: virsh edit rhel5 or other application using the libvirt API. --> <domain type='qemu'> <name>rhel5</name> <uuid>6b56fe66-e598-5841-2663-005632f8627a</uuid> <memory unit='KiB'>524288</memory> <currentMemory unit='KiB'>524288</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type arch='x86_64' machine='rhel6.4.0'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source file='/var/lib/libvirt/images/rhel5.img'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> <disk type='block' device='cdrom'> <driver name='qemu' type='raw'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='network'> <mac address='52:54:00:a6:57:c8'/> <source network='default'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'/> <video> <model type='cirrus' vram='9216' heads='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </memballoon> </devices> </domain> [root@node1 qemu]# rm rhel5.xml(删除rhel5.xml文件) rm: remove regular file `rhel5.xml'? y [root@node1 ~]# virt-install --connect qemu:///system --virt-type qemu --name rhel5 --ram 512 --disk path=/var/lib/libvirt/images/rhe l5.img,size=8 --graphics vnc --location ftp://172.16.100.254 --extra-args "ks=ftp://172.16.100.254/rhel5-ks.cfg"(安装虚拟机,--connect 连接hypervisor路径,-virt-type类型,--name指定虚拟机名称,--ram指定内存大小,--disk path=指定磁盘文件,sparse稀疏类型,磁盘大小按需增长,--graphices 指定自动打开vnc界面,----location指定网络安装文件,--extra-args指定ks自动配置文件) WARNING KVM acceleration not available, using 'qemu' ERROR Guest name 'rhel5' is already in use. 提示:rhel5存在; [root@node1 qemu]# virsh help(查看virsh的帮助) Grouped commands: Domain Management (help keyword 'domain'): attach-device attach device from an XML file attach-disk attach disk device attach-interface attach network interface autostart autostart a domain blkdeviotune Set or query a block device I/O tuning parameters. blkiotune Get or set blkio parameters blockcommit Start a block commit operation. blockcopy Start a block copy operation. blockjob Manage active block operations blockpull Populate a disk from its backing image. blockresize Resize block device of domain. change-media Change media of CD or floppy drive console connect to the guest console cpu-baseline compute baseline CPU cpu-compare compare host CPU with a CPU described by an XML file cpu-stats show domain cpu statistics create create a domain from an XML file define define (but don't start) a domain from an XML file desc show or set domain's description or title destroy destroy (stop) a domain detach-device detach device from an XML file detach-disk detach disk device detach-interface detach network interface domdisplay domain display connection URI domhostname print the domain's hostname domid convert a domain name or UUID to domain id domif-setlink set link state of a virtual interface domiftune get/set parameters of a virtual interface domjobabort abort active domain job domjobinfo domain job information domname convert a domain id or UUID to domain name dompmsuspend suspend a domain gracefully using power management functions dompmwakeup wakeup a domain from pmsuspended state domuuid convert a domain name or id to domain UUID domxml-from-native Convert native config to domain XML domxml-to-native Convert domain XML to native config dump dump the core of a domain to a file for analysis dumpxml domain information in XML edit edit XML configuration for a domain inject-nmi Inject NMI to the guest send-key Send keycodes to the guest managedsave managed save of a domain state managedsave-remove Remove managed save of a domain maxvcpus connection vcpu maximum memtune Get or set memory parameters migrate migrate domain to another host migrate-setmaxdowntime set maximum tolerable downtime migrate-setspeed Set the maximum migration bandwidth migrate-getspeed Get the maximum migration bandwidth numatune Get or set numa parameters reboot reboot a domain reset reset a domain restore restore a domain from a saved state in a file resume resume a domain save save a domain state to a file save-image-define redefine the XML for a domain's saved state file save-image-dumpxml saved state domain information in XML save-image-edit edit XML for a domain's saved state file schedinfo show/set scheduler parameters screenshot take a screenshot of a current domain console and store it into a file setmaxmem change maximum memory limit setmem change memory allocation setvcpus change number of virtual CPUs shutdown gracefully shutdown a domain start start a (previously defined) inactive domain suspend suspend a domain ttyconsole tty console undefine undefine a domain update-device update device from an XML file vcpucount domain vcpu counts vcpuinfo detailed domain vcpu information vcpupin control or query domain vcpu affinity emulatorpin control or query domain emulator affinity vncdisplay vnc display Domain Monitoring (help keyword 'monitor'): domblkerror Show errors on block devices domblkinfo domain block device size information domblklist list all domain blocks domblkstat get device block stats for a domain domcontrol domain control interface state domif-getlink get link state of a virtual interface domiflist list all domain virtual interfaces domifstat get network interface stats for a domain dominfo domain information dommemstat get memory statistics for a domain domstate domain state list list domains Host and Hypervisor (help keyword 'host'): capabilities capabilities connect (re)connect to hypervisor freecell NUMA free memory hostname print the hypervisor hostname node-memory-tune Get or set node memory parameters nodecpustats Prints cpu stats of the node. nodeinfo node information nodememstats Prints memory stats of the node. nodesuspend suspend the host node for a given time duration qemu-attach QEMU Attach qemu-monitor-command QEMU Monitor Command qemu-agent-command QEMU Guest Agent Command sysinfo print the hypervisor sysinfo uri print the hypervisor canonical URI version show version Interface (help keyword 'interface'): iface-begin create a snapshot of current interfaces settings, which can be later committed (iface-commit) or restored (iface-rollback) iface-bridge create a bridge device and attach an existing network device to it iface-commit commit changes made since iface-begin and free restore point iface-define define (but don't start) a physical host interface from an XML file iface-destroy destroy a physical host interface (disable it / "if-down") iface-dumpxml interface information in XML iface-edit edit XML configuration for a physical host interface iface-list list physical host interfaces iface-mac convert an interface name to interface MAC address iface-name convert an interface MAC address to interface name iface-rollback rollback to previous saved configuration created via iface-begin iface-start start a physical host interface (enable it / "if-up") iface-unbridge undefine a bridge device after detaching its slave device iface-undefine undefine a physical host interface (remove it from configuration) Network Filter (help keyword 'filter'): nwfilter-define define or update a network filter from an XML file nwfilter-dumpxml network filter information in XML nwfilter-edit edit XML configuration for a network filter nwfilter-list list network filters nwfilter-undefine undefine a network filter Networking (help keyword 'network'): net-autostart autostart a network net-create create a network from an XML file net-define define (but don't start) a network from an XML file net-destroy destroy (stop) a network net-dumpxml network information in XML net-edit edit XML configuration for a network net-info network information net-list list networks net-name convert a network UUID to network name net-start start a (previously defined) inactive network net-undefine undefine an inactive network net-update update parts of an existing network's configuration net-uuid convert a network name to network UUID Node Device (help keyword 'nodedev'): nodedev-create create a device defined by an XML file on the node nodedev-destroy destroy (stop) a device on the node nodedev-detach detach node device from its device driver nodedev-dumpxml node device details in XML nodedev-list enumerate devices on this host nodedev-reattach reattach node device to its device driver nodedev-reset reset node device Secret (help keyword 'secret'): secret-define define or modify a secret from an XML file secret-dumpxml secret attributes in XML secret-get-value Output a secret value secret-list list secrets secret-set-value set a secret value secret-undefine undefine a secret Snapshot (help keyword 'snapshot'): snapshot-create Create a snapshot from XML snapshot-create-as Create a snapshot from a set of args snapshot-current Get or set the current snapshot snapshot-delete Delete a domain snapshot snapshot-dumpxml Dump XML for a domain snapshot snapshot-edit edit XML for a snapshot snapshot-info snapshot information snapshot-list List snapshots for a domain snapshot-parent Get the name of the parent of a snapshot snapshot-revert Revert a domain to a snapshot Storage Pool (help keyword 'pool'): find-storage-pool-sources-as find potential storage pool sources find-storage-pool-sources discover potential storage pool sources pool-autostart autostart a pool pool-build build a pool pool-create-as create a pool from a set of args pool-create create a pool from an XML file pool-define-as define a pool from a set of args pool-define define (but don't start) a pool from an XML file pool-delete delete a pool pool-destroy destroy (stop) a pool pool-dumpxml pool information in XML pool-edit edit XML configuration for a storage pool pool-info storage pool information pool-list list pools pool-name convert a pool UUID to pool name pool-refresh refresh a pool pool-start start a (previously defined) inactive pool pool-undefine undefine an inactive pool pool-uuid convert a pool name to pool UUID Storage Volume (help keyword 'volume'): vol-clone clone a volume. vol-create-as create a volume from a set of args vol-create create a vol from an XML file vol-create-from create a vol, using another volume as input vol-delete delete a vol vol-download Download a volume to a file vol-dumpxml vol information in XML vol-info storage vol information vol-key returns the volume key for a given volume name or path vol-list list vols vol-name returns the volume name for a given volume key or path vol-path returns the volume path for a given volume name or key vol-pool returns the storage pool for a given volume key or path vol-resize resize a vol vol-upload upload a file into a volume vol-wipe wipe a vol Virsh itself (help keyword 'virsh'): cd change the current directory echo echo arguments exit quit this interactive terminal help print help pwd print the current directory quit quit this interactive terminal [root@node1 qemu]# virsh help undefine(查看virsh的子命令undefine的帮助) NAME undefine - undefine a domain SYNOPSIS undefine <domain> [--managed-save] [<storage>] [--remove-all-storage] [--wipe-storage] [--snapshots-metadata] DESCRIPTION Undefine an inactive domain, or convert persistent to transient. OPTIONS [--domain] <string> domain name or uuid --managed-save remove domain managed state file [--storage] <string> remove associated storage volumes (comma separated list of targets or source paths) (see domblklist) --remove-all-storage remove all associated storage volumes (use with caution) --wipe-storage wipe data on the removed volumes --snapshots-metadata remove all domain snapshot metadata, if inactive [root@node1 qemu]# virsh undefine rhel5(删除rhel5虚拟机区域名) Domain rhel5 has been undefined [root@node1 qemu]# virt-install --connect qemu:///system --virt-type qemu --name rhel5 --ram 512 --disk path=/var/lib/libvirt/images /rhel5.img,size=8 --graphics vnc --location ftp://172.16.100.30/pub/ --extra-args "ks=http://172.16.100.106/iso/rhel5-ks.cfg"(安装虚 拟机,--connect连接hypervisor路径,-virt-type类型,--name指定虚拟机名称,--ram指定内存大小,--disk path=指定磁盘文件,sparse稀疏类型,磁盘大小按需 增长,--graphices指定自动打开vnc界面,----location指定网络安装文件,--extra-args指定ks自动配置文件) WARNING KVM acceleration not available, using 'qemu' Starting install... Retrieving file .treeinfo... | 876 B 00:00 ... Retrieving file vmlinuz... | 3.6 MB 00:00 ... Retrieving file initrd.img... | 22 MB 00:00 ... Creating domain...
安装成功会启动vnc的图形化安装界面;
提示:没有配置网卡,不能正常执行;
[root@node1 qemu]# virsh list(查看运行的虚拟机) Id Name State ---------------------------------------------------- 5 rhel5 running [root@node1 qemu]# virsh destroy rhel5(停止rhel5虚拟机) Domain rhel5 destroyed [root@node1 qemu]# virsh undefine rhel5(删除rhel5虚拟机) Domain rhel5 has been undefined [root@node1 qemu]# virt-install --connect qemu:///system --virt-type qemu --name rhel5 --ram 512 --disk path=/var/lib/libvirt/images/ rhel5.img,size=8 --graphics vnc --location ftp://172.16.100.30/pub/ --extra-args "ks=http://172.16.100.106/iso/rhel5-ks.cfg" --networ k bridge=br0(安装虚拟机,--connect连接hypervisor路径,-virt-type类型,--name指定虚拟机名称,--ram指定内存大小,--disk path=指定磁盘文件,sparse 稀疏类型,磁盘大小按需增长,--graphices指定自动打开vnc界面,----location指定网络安装文件,--extra-args指定ks自动配置文件,--network指定网卡桥接的交换机)
安装成功会启动vnc的图形化安装界面;
[root@node1 ~]# cd /etc/libvirt/qemu(切换到/etc/libvirt/qemu目录) [root@node1 qemu]# ls(查看当前目录文件及子目录) networks rhel5.xml [root@node1 qemu]# ls networks/(查看network目录文件) autostart default.xml 提示:/etc/lib/virt/qemu/network是创建的虚拟网络; [root@node1 qemu]# ls networks/autostart/(查看networks/autostart目录文件及子目录) default.xml 提示:这里只有默认的虚拟网络; [root@node1 qemu]# cd ..(切换到上级目录) [root@node1 libvirt]# ls(查看当前目录文件及子目录) libvirt.conf(libvirt客户端配置文件) libvirtd.conf(libvirtd服务器端配置文件) lxc.conf nwfilter qemu qemu.conf(qemu的配置文件) storage [root@node1 libvirt]# cat qemu.conf(查看qemu.conf配置文件内容) # Master configuration file for the QEMU driver. # All settings described here are optional - if omitted, sensible # defaults are used. # VNC is configured to listen on 127.0.0.1 by default. # To make it listen on all public interfaces, uncomment # this next option. # # NB, strong recommendation to enable TLS + x509 certificate # verification when allowing public access # #vnc_listen = "0.0.0.0" # Enable this option to have VNC served over an automatically created # unix socket. This prevents unprivileged access from users on the # host machine, though most VNC clients do not support it. # # This will only be enabled for VNC configurations that do not have # a hardcoded 'listen' or 'socket' value. This setting takes preference # over vnc_listen. # #vnc_auto_unix_socket = 1 # Enable use of TLS encryption on the VNC server. This requires # a VNC client which supports the VeNCrypt protocol extension. # Examples include vinagre, virt-viewer, virt-manager and vencrypt # itself. UltraVNC, RealVNC, TightVNC do not support this # # It is necessary to setup CA and issue a server certificate # before enabling this. # #vnc_tls = 1 # Use of TLS requires that x509 certificates be issued. The # default it to keep them in /etc/pki/libvirt-vnc. This directory # must contain # # ca-cert.pem - the CA master certificate # server-cert.pem - the server certificate signed with ca-cert.pem # server-key.pem - the server private key # # This option allows the certificate directory to be changed # #vnc_tls_x509_cert_dir = "/etc/pki/libvirt-vnc" # The default TLS configuration only uses certificates for the server # allowing the client to verify the server's identity and establish # an encrypted channel. # # It is possible to use x509 certificates for authentication too, by # issuing a x509 certificate to every client who needs to connect. # # Enabling this option will reject any client who does not have a # certificate signed by the CA in /etc/pki/libvirt-vnc/ca-cert.pem # #vnc_tls_x509_verify = 1 # The default VNC password. Only 8 letters are significant for # VNC passwords. This parameter is only used if the per-domain # XML config does not already provide a password. To allow # access without passwords, leave this commented out. An empty # string will still enable passwords, but be rejected by QEMU, # effectively preventing any use of VNC. Obviously change this # example here before you set this. # #vnc_password = "XYZ12345" # Enable use of SASL encryption on the VNC server. This requires # a VNC client which supports the SASL protocol extension. # Examples include vinagre, virt-viewer and virt-manager # itself. UltraVNC, RealVNC, TightVNC do not support this # # It is necessary to configure /etc/sasl2/qemu.conf to choose # the desired SASL plugin (eg, GSSPI for Kerberos) # #vnc_sasl = 1 # The default SASL configuration file is located in /etc/sasl2/ # When running libvirtd unprivileged, it may be desirable to # override the configs in this location. Set this parameter to # point to the directory, and create a qemu.conf in that location # #vnc_sasl_dir = "/some/directory/sasl2" # QEMU implements an extension for providing audio over a VNC connection, # though if your VNC client does not support it, your only chance for getting # sound output is through regular audio backends. By default, libvirt will # disable all QEMU sound backends if using VNC, since they can cause # permissions issues. Enabling this option will make libvirtd honor the # QEMU_AUDIO_DRV environment variable when using VNC. # #vnc_allow_host_audio = 0 # SPICE is configured to listen on 127.0.0.1 by default. # To make it listen on all public interfaces, uncomment # this next option. # # NB, strong recommendation to enable TLS + x509 certificate # verification when allowing public access # #spice_listen = "0.0.0.0" # Enable use of TLS encryption on the SPICE server. # # It is necessary to setup CA and issue a server certificate # before enabling this. # #spice_tls = 1 # Use of TLS requires that x509 certificates be issued. The # default it to keep them in /etc/pki/libvirt-spice. This directory # must contain # # ca-cert.pem - the CA master certificate # server-cert.pem - the server certificate signed with ca-cert.pem # server-key.pem - the server private key # # This option allows the certificate directory to be changed. # #spice_tls_x509_cert_dir = "/etc/pki/libvirt-spice" # The default SPICE password. This parameter is only used if the # per-domain XML config does not already provide a password. To # allow access without passwords, leave this commented out. An # empty string will still enable passwords, but be rejected by # QEMU, effectively preventing any use of SPICE. Obviously change # this example here before you set this. # #spice_password = "XYZ12345" # Override the port for creating both VNC and SPICE sessions (min). # This defaults to 5900 and increases for consecutive sessions # or when ports are occupied, until it hits the maximum. # # Minimum must be greater than or equal to 5900 as lower number would # result into negative vnc display number. # # Maximum must be less than 65536, because higher numbers do not make # sense as a port number. # #remote_display_port_min = 5900 #remote_display_port_max = 65535 # The default security driver is SELinux. If SELinux is disabled # on the host, then the security driver will automatically disable # itself. If you wish to disable QEMU SELinux security driver while # leaving SELinux enabled for the host in general, then set this # to 'none' instead. It's also possible to use more than one security # driver at the same time, for this use a list of names separated by # comma and delimited by square brackets. For example: # # security_driver = [ "selinux", "apparmor" ] # # Notes: The DAC security driver is always enabled; as a result, the # value of security_driver cannot contain "dac". The value "none" is # a special value; security_driver can be set to that value in # isolation, but it cannot appear in a list of drivers. # #security_driver = "selinux" # If set to non-zero, then the default security labeling # will make guests confined. If set to zero, then guests # will be unconfined by default. Defaults to 1. #security_default_confined = 1 # If set to non-zero, then attempts to create unconfined # guests will be blocked. Defaults to 0. #security_require_confined = 1 # The user for QEMU processes run by the system instance. It can be # specified as a user name or as a user id. The qemu driver will try to # parse this value first as a name and then, if the name doesn't exist, # as a user id. # # Since a sequence of digits is a valid user name, a leading plus sign # can be used to ensure that a user id will not be interpreted as a user # name. # # Some examples of valid values are: # # user = "qemu" # A user named "qemu" # user = "+0" # Super user (uid=0) # user = "100" # A user named "100" or a user with uid=100 # #user = "root" # The group for QEMU processes run by the system instance. It can be # specified in a similar way to user. #group = "root" # Whether libvirt should dynamically change file ownership # to match the configured user/group above. Defaults to 1. # Set to 0 to disable file ownership changes. #dynamic_ownership = 1 # What cgroup controllers to make use of with QEMU guests # # - 'cpu' - use for schedular tunables # - 'devices' - use for device whitelisting # - 'memory' - use for memory tunables # - 'blkio' - use for block devices I/O tunables # - 'cpuset' - use for CPUs and memory nodes # - 'cpuacct' - use for CPUs statistics. # # NB, even if configured here, they won't be used unless # the administrator has mounted cgroups, e.g.: # # mkdir /dev/cgroup # mount -t cgroup -o devices,cpu,memory,blkio,cpuset none /dev/cgroup # # They can be mounted anywhere, and different controllers # can be mounted in different locations. libvirt will detect # where they are located. # #cgroup_controllers = [ "cpu", "devices", "memory", "blkio", "cpuset", "cpuacct" ] # This is the basic set of devices allowed / required by # all virtual machines. # # As well as this, any configured block backed disks, # all sound device, and all PTY devices are allowed. # # This will only need setting if newer QEMU suddenly # wants some device we don't already know about. # #cgroup_device_acl = [ # "/dev/null", "/dev/full", "/dev/zero", # "/dev/random", "/dev/urandom", # "/dev/ptmx", "/dev/kvm", "/dev/kqemu", # "/dev/rtc","/dev/hpet" #] # The default format for Qemu/KVM guest save images is raw; that is, the # memory from the domain is dumped out directly to a file. If you have # guests with a large amount of memory, however, this can take up quite # a bit of space. If you would like to compress the images while they # are being saved to disk, you can also set "lzop", "gzip", "bzip2", or "xz" # for save_image_format. Note that this means you slow down the process of # saving a domain in order to save disk space; the list above is in descending # order by performance and ascending order by compression ratio. # # save_image_format is used when you use 'virsh save' at scheduled # saving, and it is an error if the specified save_image_format is # not valid, or the requested compression program can't be found. # # dump_image_format is used when you use 'virsh dump' at emergency # crashdump, and if the specified dump_image_format is not valid, or # the requested compression program can't be found, this falls # back to "raw" compression. # #save_image_format = "raw" #dump_image_format = "raw" # When a domain is configured to be auto-dumped when libvirtd receives a # watchdog event from qemu guest, libvirtd will save dump files in directory # specified by auto_dump_path. Default value is /var/lib/libvirt/qemu/dump # #auto_dump_path = "/var/lib/libvirt/qemu/dump" # When a domain is configured to be auto-dumped, enabling this flag # has the same effect as using the VIR_DUMP_BYPASS_CACHE flag with the # virDomainCoreDump API. That is, the system will avoid using the # file system cache while writing the dump file, but may cause # slower operation. # #auto_dump_bypass_cache = 0 # When a domain is configured to be auto-started, enabling this flag # has the same effect as using the VIR_DOMAIN_START_BYPASS_CACHE flag # with the virDomainCreateWithFlags API. That is, the system will # avoid using the file system cache when restoring any managed state # file, but may cause slower operation. # #auto_start_bypass_cache = 0 # If provided by the host and a hugetlbfs mount point is configured, # a guest may request huge page backing. When this mount point is # unspecified here, determination of a host mount point in /proc/mounts # will be attempted. Specifying an explicit mount overrides detection # of the same in /proc/mounts. Setting the mount point to "" will # disable guest hugepage backing. # # NB, within this mount point, guests will create memory backing files # in a location of $MOUNTPOINT/libvirt/qemu # #hugetlbfs_mount = "/dev/hugepages" # If clear_emulator_capabilities is enabled, libvirt will drop all # privileged capabilities of the QEmu/KVM emulator. This is enabled by # default. # # Warning: Disabling this option means that a compromised guest can # exploit the privileges and possibly do damage to the host. # #clear_emulator_capabilities = 1 # If enabled, libvirt will have QEMU set its process name to # "qemu:VM_NAME", where VM_NAME is the name of the VM. The QEMU # process will appear as "qemu:VM_NAME" in process listings and # other system monitoring tools. By default, QEMU does not set # its process title, so the complete QEMU command (emulator and # its arguments) appear in process listings. # #set_process_name = 1 # If max_processes is set to a positive integer, libvirt will use # it to set the maximum number of processes that can be run by qemu # user. This can be used to override default value set by host OS. # The same applies to max_files which sets the limit on the maximum # number of opened files. # #max_processes = 0 #max_files = 0 # mac_filter enables MAC addressed based filtering on bridge ports. # This currently requires ebtables to be installed. # #mac_filter = 1 # By default, PCI devices below non-ACS switch are not allowed to be assigned # to guests. By setting relaxed_acs_check to 1 such devices will be allowed to # be assigned to guests. # #relaxed_acs_check = 1 # If allow_disk_format_probing is enabled, libvirt will probe disk # images to attempt to identify their format, when not otherwise # specified in the XML. This is disabled by default. # # WARNING: Enabling probing is a security hole in almost all # deployments. It is strongly recommended that users update their # guest XML <disk> elements to include <driver type='XXXX'/> # elements instead of enabling this option. # #allow_disk_format_probing = 1 # To enable 'Sanlock' project based locking of the file # content (to prevent two VMs writing to the same # disk), uncomment this # #lock_manager = "sanlock" # Set limit of maximum APIs queued on one domain. All other APIs # over this threshold will fail on acquiring job lock. Specially, # setting to zero turns this feature off. # Note, that job lock is per domain. # #max_queued = 0 ################################################################### # Keepalive protocol: # This allows qemu driver to detect broken connections to remote # libvirtd during peer-to-peer migration. A keepalive message is # sent to the deamon after keepalive_interval seconds of inactivity # to check if the deamon is still responding; keepalive_count is a # maximum number of keepalive messages that are allowed to be sent # to the deamon without getting any response before the connection # is considered broken. In other words, the connection is # automatically closed approximately after # keepalive_interval * (keepalive_count + 1) seconds since the last # message received from the deamon. If keepalive_interval is set to # -1, qemu driver will not send keepalive requests during # peer-to-peer migration; however, the remote libvirtd can still # send them and source libvirtd will send responses. When # keepalive_count is set to 0, connections will be automatically # closed after keepalive_interval seconds of inactivity without # sending any keepalive messages. # #keepalive_interval = 5 #keepalive_count = 5 # Use seccomp syscall whitelisting in QEMU. # 1 = on, 0 = off, -1 = use QEMU default # Defaults to -1. # #seccomp_sandbox = 1 root@node1 libvirt]# cat libvirtd.conf(查看libvirtd.conf配置文件内容) # Master libvirt daemon configuration file # # For further information consult http://libvirt.org/format.html # # NOTE: the tests/daemon-conf regression test script requires # that each "PARAMETER = VALUE" line in this file have the parameter # name just after a leading "#". ################################################################# # # Network connectivity controls # # Flag listening for secure TLS connections on the public TCP/IP port. # NB, must pass the --listen flag to the libvirtd process for this to # have any effect. # # It is necessary to setup a CA and issue server certificates before # using this capability. # # This is enabled by default, uncomment this to disable it #listen_tls = 0 # Listen for unencrypted TCP connections on the public TCP/IP port. # NB, must pass the --listen flag to the libvirtd process for this to # have any effect. # # Using the TCP socket requires SASL authentication by default. Only # SASL mechanisms which support data encryption are allowed. This is # DIGEST_MD5 and GSSAPI (Kerberos5) # # This is disabled by default, uncomment this to enable it. #listen_tcp = 1 # Override the port for accepting secure TLS connections # This can be a port number, or service name # #tls_port = "16514" # Override the port for accepting insecure TCP connections # This can be a port number, or service name # #tcp_port = "16509" # Override the default configuration which binds to all network # interfaces. This can be a numeric IPv4/6 address, or hostname # #listen_addr = "192.168.0.1" # Flag toggling mDNS advertizement of the libvirt service. # # Alternatively can disable for all services on a host by # stopping the Avahi daemon # # This is disabled by default, uncomment this to enable it #mdns_adv = 1 # Override the default mDNS advertizement name. This must be # unique on the immediate broadcast network. # # The default is "Virtualization Host HOSTNAME", where HOSTNAME # is subsituted for the short hostname of the machine (without domain) # #mdns_name = "Virtualization Host Joe Demo" ################################################################# # # UNIX socket access controls # # Set the UNIX domain socket group ownership. This can be used to # allow a 'trusted' set of users access to management capabilities # without becoming root. # # This is restricted to 'root' by default. #unix_sock_group = "libvirt" # Set the UNIX socket permissions for the R/O socket. This is used # for monitoring VM status only # # Default allows any user. If setting group ownership may want to # restrict this to: #unix_sock_ro_perms = "0777" # Set the UNIX socket permissions for the R/W socket. This is used # for full management of VMs # # Default allows only root. If PolicyKit is enabled on the socket, # the default will change to allow everyone (eg, 0777) # # If not using PolicyKit and setting group ownership for access # control then you may want to relax this to: #unix_sock_rw_perms = "0770" # Set the name of the directory in which sockets will be found/created. #unix_sock_dir = "/var/run/libvirt" ################################################################# # # Authentication. # # - none: do not perform auth checks. If you can connect to the # socket you are allowed. This is suitable if there are # restrictions on connecting to the socket (eg, UNIX # socket permissions), or if there is a lower layer in # the network providing auth (eg, TLS/x509 certificates) # # - sasl: use SASL infrastructure. The actual auth scheme is then # controlled from /etc/sasl2/libvirt.conf. For the TCP # socket only GSSAPI & DIGEST-MD5 mechanisms will be used. # For non-TCP or TLS sockets, any scheme is allowed. # # - polkit: use PolicyKit to authenticate. This is only suitable # for use on the UNIX sockets. The default policy will # require a user to supply their own password to gain # full read/write access (aka sudo like), while anyone # is allowed read/only access. # # Set an authentication scheme for UNIX read-only sockets # By default socket permissions allow anyone to connect # # To restrict monitoring of domains you may wish to enable # an authentication mechanism here #auth_unix_ro = "none" # Set an authentication scheme for UNIX read-write sockets # By default socket permissions only allow root. If PolicyKit # support was compiled into libvirt, the default will be to # use 'polkit' auth. # # If the unix_sock_rw_perms are changed you may wish to enable # an authentication mechanism here #auth_unix_rw = "none" # Change the authentication scheme for TCP sockets. # # If you don't enable SASL, then all TCP traffic is cleartext. # Don't do this outside of a dev/test scenario. For real world # use, always enable SASL and use the GSSAPI or DIGEST-MD5 # mechanism in /etc/sasl2/libvirt.conf #auth_tcp = "sasl" # Change the authentication scheme for TLS sockets. # # TLS sockets already have encryption provided by the TLS # layer, and limited authentication is done by certificates # # It is possible to make use of any SASL authentication # mechanism as well, by using 'sasl' for this option #auth_tls = "none" ################################################################# # # TLS x509 certificate configuration # # Override the default server key file path # #key_file = "/etc/pki/libvirt/private/serverkey.pem" # Override the default server certificate file path # #cert_file = "/etc/pki/libvirt/servercert.pem" # Override the default CA certificate path # #ca_file = "/etc/pki/CA/cacert.pem" # Specify a certificate revocation list. # # Defaults to not using a CRL, uncomment to enable it #crl_file = "/etc/pki/CA/crl.pem" ################################################################# # # Authorization controls # # Flag to disable verification of our own server certificates # # When libvirtd starts it performs some sanity checks against # its own certificates. # # Default is to always run sanity checks. Uncommenting this # will disable sanity checks which is not a good idea #tls_no_sanity_certificate = 1 # Flag to disable verification of client certificates # # Client certificate verification is the primary authentication mechanism. # Any client which does not present a certificate signed by the CA # will be rejected. # # Default is to always verify. Uncommenting this will disable # verification - make sure an IP whitelist is set #tls_no_verify_certificate = 1 # A whitelist of allowed x509 Distinguished Names # This list may contain wildcards such as # # "C=GB,ST=London,L=London,O=Red Hat,CN=*" # # See the POSIX fnmatch function for the format of the wildcards. # # NB If this is an empty list, no client can connect, so comment out # entirely rather than using empty list to disable these checks # # By default, no DN's are checked #tls_allowed_dn_list = ["DN1", "DN2"] # A whitelist of allowed SASL usernames. The format for usernames # depends on the SASL authentication mechanism. Kerberos usernames # look like username@REALM # # This list may contain wildcards such as # # "*@EXAMPLE.COM" # # See the POSIX fnmatch function for the format of the wildcards. # # NB If this is an empty list, no client can connect, so comment out # entirely rather than using empty list to disable these checks # # By default, no Username's are checked #sasl_allowed_username_list = ["joe@EXAMPLE.COM", "fred@EXAMPLE.COM" ] ################################################################# # # Processing controls # # The maximum number of concurrent client connections to allow # over all sockets combined. #max_clients = 20 # The minimum limit sets the number of workers to start up # initially. If the number of active clients exceeds this, # then more threads are spawned, upto max_workers limit. # Typically you'd want max_workers to equal maximum number # of clients allowed #min_workers = 5 #max_workers = 20 # The number of priority workers. If all workers from above # pool will stuck, some calls marked as high priority # (notably domainDestroy) can be executed in this pool. #prio_workers = 5 # Total global limit on concurrent RPC calls. Should be # at least as large as max_workers. Beyond this, RPC requests # will be read into memory and queued. This directly impact # memory usage, currently each request requires 256 KB of # memory. So by default upto 5 MB of memory is used # # XXX this isn't actually enforced yet, only the per-client # limit is used so far #max_requests = 20 # Limit on concurrent requests from a single client # connection. To avoid one client monopolizing the server # this should be a small fraction of the global max_requests # and max_workers parameter #max_client_requests = 5 ################################################################# # # Logging controls # # Logging level: 4 errors, 3 warnings, 2 information, 1 debug # basically 1 will log everything possible #log_level = 3 # Logging filters: # A filter allows to select a different logging level for a given category # of logs # The format for a filter is one of: # x:name # x:+name # where name is a string which is matched against source file name, # e.g., "remote", "qemu", or "util/json", the optional "+" prefix # tells libvirt to log stack trace for each message matching name, # and x is the minimal level where matching messages should be logged: # 1: DEBUG # 2: INFO # 3: WARNING # 4: ERROR # # Multiple filter can be defined in a single @filters, they just need to be # separated by spaces. # # e.g. to only get warning or errors from the remote layer and only errors # from the event layer: #log_filters="3:remote 4:event" # Logging outputs: # An output is one of the places to save logging information # The format for an output can be: # x:stderr # output goes to stderr # x:syslog:name # use syslog for the output and use the given name as the ident # x:file:file_path # output to a file, with the given filepath # In all case the x prefix is the minimal level, acting as a filter # 1: DEBUG # 2: INFO # 3: WARNING # 4: ERROR # # Multiple output can be defined, they just need to be separated by spaces. # e.g. to log all warnings and errors to syslog under the libvirtd ident: #log_outputs="3:syslog:libvirtd" # # Log debug buffer size: default 64 # The daemon keeps an internal debug log buffer which will be dumped in case # of crash or upon receiving a SIGUSR2 signal. This setting allows to override # the default buffer size in kilobytes. # If value is 0 or less the debug log buffer is deactivated #log_buffer_size = 64 ################################################################## # # Auditing # # This setting allows usage of the auditing subsystem to be altered: # # audit_level == 0 -> disable all auditing # audit_level == 1 -> enable auditing, only if enabled on host (default) # audit_level == 2 -> enable auditing, and exit if disabled on host # #audit_level = 2 # # If set to 1, then audit messages will also be sent # via libvirt logging infrastructure. Defaults to 0 # #audit_logging = 1 ################################################################### # UUID of the host: # Provide the UUID of the host here in case the command # 'dmidecode -s system-uuid' does not provide a valid uuid. In case # 'dmidecode' does not provide a valid UUID and none is provided here, a # temporary UUID will be generated. # Keep the format of the example UUID below. UUID must not have all digits # be the same. # NB This default all-zeros UUID will not work. Replace # it with the output of the 'uuidgen' command and then # uncomment this entry #host_uuid = "00000000-0000-0000-0000-000000000000" ################################################################### # Keepalive protocol: # This allows libvirtd to detect broken client connections or even # dead client. A keepalive message is sent to a client after # keepalive_interval seconds of inactivity to check if the client is # still responding; keepalive_count is a maximum number of keepalive # messages that are allowed to be sent to the client without getting # any response before the connection is considered broken. In other # words, the connection is automatically closed approximately after # keepalive_interval * (keepalive_count + 1) seconds since the last # message received from the client. If keepalive_interval is set to # -1, libvirtd will never send keepalive requests; however clients # can still send them and the deamon will send responses. When # keepalive_count is set to 0, connections will be automatically # closed after keepalive_interval seconds of inactivity without # sending any keepalive messages. # #keepalive_interval = 5 #keepalive_count = 5 # # If set to 1, libvirtd will refuse to talk to clients that do not # support keepalive protocol. Defaults to 0. # #keepalive_required = 1 [root@node1 libvirt]# virsh list(查看运行的虚拟机) Id 名称 状态 ---------------------------------------------------- 6 rhel5 running [root@node1 libvirt]# virsh destroy rhel5(停止rhel5虚拟机) 域 rhel5 被删除 [root@node1 libvirt]# virsh list(查看运行的虚拟机) Id 名称 状态 ---------------------------------------------------- [root@node1 libvirt]# virsh --help(查看virsh命令帮助) virsh [options]... [<command_string>] virsh [options]... <command> [args...] options: -c | --connect=URI hypervisor connection URI -r | --readonly connect readonly -d | --debug=NUM debug level [0-4] -h | --help this help -q | --quiet quiet mode -t | --timing print timing information -l | --log=FILE output logging to file -v short version -V long version --version[=TYPE] version, TYPE is short or long (default short) -e | --escape <char> set escape sequence for console commands (non interactive mode): Domain Management (help keyword 'domain') attach-device attach device from an XML file attach-disk attach disk device attach-interface attach network interface autostart autostart a domain blkdeviotune Set or query a block device I/O tuning parameters. blkiotune Get or set blkio parameters blockcommit Start a block commit operation. blockcopy Start a block copy operation. blockjob Manage active block operations blockpull Populate a disk from its backing image. blockresize Resize block device of domain. change-media Change media of CD or floppy drive console connect to the guest console(连接到客户端额控制台) cpu-baseline compute baseline CPU cpu-compare compare host CPU with a CPU described by an XML file cpu-stats show domain cpu statistics create create a domain from an XML file(创建虚拟机) define define (but don't start) a domain from an XML file desc show or set domain's description or title destroy destroy (stop) a domain detach-device detach device from an XML file(附加设备) detach-disk detach disk device detach-interface detach network interface domdisplay domain display connection URI domhostname print the domain's hostname domid convert a domain name or UUID to domain id domif-setlink set link state of a virtual interface domiftune get/set parameters of a virtual interface domjobabort abort active domain job domjobinfo domain job information domname convert a domain id or UUID to domain name dompmsuspend suspend a domain gracefully using power management functions dompmwakeup wakeup a domain from pmsuspended state domuuid convert a domain name or id to domain UUID domxml-from-native Convert native config to domain XML domxml-to-native Convert domain XML to native config dump dump the core of a domain to a file for analysis dumpxml domain information in XML edit edit XML configuration for a domain inject-nmi Inject NMI to the guest send-key Send keycodes to the guest managedsave managed save of a domain state managedsave-remove Remove managed save of a domain maxvcpus connection vcpu maximum memtune Get or set memory parameters migrate migrate domain to another host(迁移) migrate-setmaxdowntime set maximum tolerable downtime migrate-setspeed Set the maximum migration bandwidth migrate-getspeed Get the maximum migration bandwidth numatune Get or set numa parameters reboot reboot a domain reset reset a domain restore restore a domain from a saved state in a file resume resume a domain(继续挂起的虚拟机) save save a domain state to a file save-image-define redefine the XML for a domain's saved state file save-image-dumpxml saved state domain information in XML save-image-edit edit XML for a domain's saved state file schedinfo show/set scheduler parameters screenshot take a screenshot of a current domain console and store it into a file setmaxmem change maximum memory limit setmem change memory allocation setvcpus change number of virtual CPUs shutdown gracefully shutdown a domain start start a (previously defined) inactive domain suspend suspend a domain(挂起虚拟机) ttyconsole tty console undefine undefine a domain update-device update device from an XML file vcpucount domain vcpu counts vcpuinfo detailed domain vcpu information vcpupin control or query domain vcpu affinity emulatorpin control or query domain emulator affinity vncdisplay vnc display Domain Monitoring (help keyword 'monitor') domblkerror Show errors on block devices domblkinfo domain block device size information domblklist list all domain blocks domblkstat get device block stats for a domain domcontrol domain control interface state domif-getlink get link state of a virtual interface domiflist list all domain virtual interfaces domifstat get network interface stats for a domain dominfo domain information dommemstat get memory statistics for a domain domstate domain state list list domains Host and Hypervisor (help keyword 'host') capabilities capabilities connect (re)connect to hypervisor freecell NUMA free memory hostname print the hypervisor hostname node-memory-tune Get or set node memory parameters nodecpustats Prints cpu stats of the node. nodeinfo node information nodememstats Prints memory stats of the node. nodesuspend suspend the host node for a given time duration qemu-attach QEMU Attach qemu-monitor-command QEMU Monitor Command qemu-agent-command QEMU Guest Agent Command sysinfo print the hypervisor sysinfo uri print the hypervisor canonical URI version show version Interface (help keyword 'interface') iface-begin create a snapshot of current interfaces settings, which can be later committed (iface-commit) or restored (iface-rollback) iface-bridge create a bridge device and attach an existing network device to it iface-commit commit changes made since iface-begin and free restore point iface-define define (but don't start) a physical host interface from an XML file iface-destroy destroy a physical host interface (disable it / "if-down") iface-dumpxml interface information in XML iface-edit edit XML configuration for a physical host interface iface-list list physical host interfaces iface-mac convert an interface name to interface MAC address iface-name convert an interface MAC address to interface name iface-rollback rollback to previous saved configuration created via iface-begin iface-start start a physical host interface (enable it / "if-up") iface-unbridge undefine a bridge device after detaching its slave device iface-undefine undefine a physical host interface (remove it from configuration) Network Filter (help keyword 'filter') nwfilter-define define or update a network filter from an XML file nwfilter-dumpxml network filter information in XML nwfilter-edit edit XML configuration for a network filter nwfilter-list list network filters nwfilter-undefine undefine a network filter Networking (help keyword 'network') net-autostart autostart a network net-create create a network from an XML file net-define define (but don't start) a network from an XML file net-destroy destroy (stop) a network net-dumpxml network information in XML net-edit edit XML configuration for a network net-info network information net-list list networks net-name convert a network UUID to network name net-start start a (previously defined) inactive network net-undefine undefine an inactive network net-update update parts of an existing network's configuration net-uuid convert a network name to network UUID Node Device (help keyword 'nodedev') nodedev-create create a device defined by an XML file on the node nodedev-destroy destroy (stop) a device on the node nodedev-detach detach node device from its device driver nodedev-dumpxml node device details in XML nodedev-list enumerate devices on this host nodedev-reattach reattach node device to its device driver nodedev-reset reset node device Secret (help keyword 'secret') secret-define define or modify a secret from an XML file secret-dumpxml secret attributes in XML secret-get-value Output a secret value secret-list list secrets secret-set-value set a secret value secret-undefine undefine a secret Snapshot (help keyword 'snapshot')(管理快照的) snapshot-create Create a snapshot from XML snapshot-create-as Create a snapshot from a set of args snapshot-current Get or set the current snapshot snapshot-delete Delete a domain snapshot snapshot-dumpxml Dump XML for a domain snapshot snapshot-edit edit XML for a snapshot snapshot-info snapshot information snapshot-list List snapshots for a domain snapshot-parent Get the name of the parent of a snapshot snapshot-revert Revert a domain to a snapshot Storage Pool (help keyword 'pool')(管理存储池的) find-storage-pool-sources-as find potential storage pool sources find-storage-pool-sources discover potential storage pool sources pool-autostart autostart a pool pool-build build a pool pool-create-as create a pool from a set of args pool-create create a pool from an XML file pool-define-as define a pool from a set of args pool-define define (but don't start) a pool from an XML file pool-delete delete a pool pool-destroy destroy (stop) a pool pool-dumpxml pool information in XML pool-edit edit XML configuration for a storage pool pool-info storage pool information pool-list list pools pool-name convert a pool UUID to pool name pool-refresh refresh a pool pool-start start a (previously defined) inactive pool pool-undefine undefine an inactive pool pool-uuid convert a pool name to pool UUID Storage Volume (help keyword 'volume')(管理卷的) vol-clone clone a volume. vol-create-as create a volume from a set of args vol-create create a vol from an XML file vol-create-from create a vol, using another volume as input vol-delete delete a vol vol-download Download a volume to a file vol-dumpxml vol information in XML vol-info storage vol information vol-key returns the volume key for a given volume name or path vol-list list vols vol-name returns the volume name for a given volume key or path vol-path returns the volume path for a given volume name or key vol-pool returns the storage pool for a given volume key or path vol-resize resize a vol vol-upload upload a file into a volume vol-wipe wipe a vol Virsh itself (help keyword 'virsh') cd change the current directory echo echo arguments exit quit this interactive terminal help print help pwd print the current directory quit quit this interactive terminal (specify help <group> for details about the commands in the group) (specify help <command> for details about the command) [root@node1 libvirt]# cd(切换到用户家目录) [root@node1 ~]# mkdir -pv /kvm/vm1(创建/kvm/vm1目录,-p递归创建,-v显示创建过程) mkdir: created directory `/kvm' mkdir: created directory `/kvm/vm1' [root@node1 ~]# qemu-img create -f raw /kvm/vm1/rhel6.img 8G(创建rhel6.img磁盘映像,8G,) Formatting '/kvm/vm1/rhel6.img', fmt=raw size=8589934592 [root@node1 ~]# losetup -f(寻找未使用的循环设备) /dev/loop0 [root@node1 ~]# losetup /dev/loop0 /kvm/vm1/rhel6.img(挂载rhel6.img到/dev/loop0) [root@node1 ~]# kpartx -av /dev/loop0(装载/dev/loop0设备) [root@node1 ~]# fdisk /dev/loop0(管理/dev/loop0磁盘设备,进入交互式模式) Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xc1e85c51. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): n(创建分区) Command action e extended p primary partition (1-4) p(主分区) Partition number (1-4): 1(分区号) First cylinder (1-1044, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044): +500M(大小为500M) Command (m for help): n(新建分区) Command action e extended p primary partition (1-4) p(主分区) Partition number (1-4): 2(分区号) First cylinder (66-1044, default 66): Using default value 66 Last cylinder, +cylinders or +size{K,M,G} (66-1044, default 1044): +2G(创建2G分区) Command (m for help): w(保存退出) The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 22: Invalid argument. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. [root@node1 ~]# partprobe /dev/loop0(让内核重新加载/dev/loop0分区表) [root@node1 ~]# kpartx /dev/loop0(查看分区表) loop0p1 : 0 1044162 /dev/loop0 63 loop0p2 : 0 4209030 /dev/loop0 1044225 [root@node1 ~]# ls /dev/mapper/(查看/dev/mapper目录文件及子目录) control loop0p1 loop0p2 [root@node1 ~]# mkfs.ext4 /dev/mapper/loop0p1(格式化loop0p1文件系统) mke2fs 1.41.12 (17-May-2010) Discarding device blocks: done Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 130560 inodes, 522080 blocks 26104 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67633152 64 block groups 8192 blocks per group, 8192 fragments per group 2040 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 28 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@node1 ~]# mkfs.ext4 /dev/mapper/loop0p2(格式化loop0p2文件系统) mke2fs 1.41.12 (17-May-2010) Discarding device blocks: done Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131648 inodes, 526128 blocks 26306 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=541065216 17 block groups 32768 blocks per group, 32768 fragments per group 7744 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 21 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@node1 ~]# mkdir /mnt/{boot,sysroot}(创建/mnt下boot和sysroot目录) [root@node1 ~]# mount /dev/mapper/loop0p2 /mnt/sysroot/(挂在/dev/mapper/loop0p2到/mnt/sysroot目录) [root@node1 ~]# ftp 172.16.0.1(连接ftp服务器) ftp 172.16.0.1:/pub/Sources> cd ../Files/scripts/(切换到上级目录的/Files/scripts目录)ftp 172.16.0.1:/pub/Sources/Files/scripts> get bin cp.sh(下载bincp.sh脚本) 10 bytes transferred ftp 172.16.0.1:/pub/Files/scripts> bye(退出) [root@node1 ~]# bash bincp.sh(执行bincp.sh脚本) Your command: init /sbin/init copy lib /lib64/libnih.so.1 finished. copy lib /lib64/libnih-dbus.so.1 finished. copy lib /lib64/libdbus-1.so.3 finished. copy lib /lib64/libpthread.so.0 finished. copy lib /lib64/librt.so.1 finished. copy lib /lib64/libgcc_s.so.1 finished. copy lib /lib64/libc.so.6 finished. copy lib /lib64/ld-linux-x86-64.so.2 finished. copy /sbin/init finished. Continue: bash /bin/bash copy lib /lib64/libtinfo.so.5 finished. copy lib /lib64/libdl.so.2 finished. copy /bin/bash finished. Continue: ls /bin/ls copy lib /lib64/libselinux.so.1 finished. copy lib /lib64/libcap.so.2 finished. copy lib /lib64/libacl.so.1 finished. copy lib /lib64/libattr.so.1 finished. copy /bin/ls finished. Continue: cat /bin/cat copy /bin/cat finished. Continue: q [root@node1 ~]# cd /mnt/sysroot/(切换到/mnt/sysroot目录) [root@node1 sysroot]# mkdir -pv etc/{init,rc.d,} proc sys dev tmp(创建目录) mkdir: created directory `etc/init' mkdir: created directory `etc/rc.d' [root@node1 sysroot]# cp /etc/init/rcS.conf etc/init/(复制rcS.conf文件到etc/init目录) [root@node1 sysroot]# vim etc/init/rcS.conf(编辑rcS.conf配置文件) # rcS - runlevel compatibility # # This task runs the old sysv-rc startup scripts. start on startup stop on runlevel task # Note: there can be no previous runlevel here, if we have one it's bad # information (we enter rc1 not rcS for maintenance). Run /etc/rc.d/rc # without information so that it defaults to previous=N runlevel=S. console output exec /etc/rc.d/rc.sysinit [root@node1 sysroot]# vim etc/rc.d/rc.sysinit(编辑rc.sysinit脚本) #!/bin/bash # echo -e "\tHello Linux." /bin/bash [root@node1 sysroot]# chmod +x etc/rc.d/rc.sysinit(给rc.sysinit文件执行权限) [root@node1 sysroot]# cd(切换到用户家目录) [root@node1 ~]# man virt-install(查看virt-install命令的man帮助) --init=INITPATH(指定init文件路径) Path to a binary that the container guest will init. If a root "--filesystem" is has been specified, virt-install will default to /sbin/init, otherwise will default to /bin/sh. --initrd-inject=PATH(指定使用外部的initrd文件) Add PATH to the root of the initrd fetched with "--location". This can be used to run an automated install without requiring a network hosted kickstart file: --initrd-inject=/path/to/my.ks --extra-args "ks=file:/my.ks" --boot kernel=KERNEL,initrd=INITRD,kernel_args="console=/dev/ttyS0" Have guest permanently boot off a local kernel/initrd pair, with the specified kernel options. [root@node1 ~]# virt-install --name rhel6 --vcpus 2 --ram 128 --disk /kvm/vm1/rhel6.img --boot kernel=/boot/vmlinuz-2.6.32-358.el6.x86 _64,initrd=/boot/initramfs-2.6.32-358.el6.x86_64.img,kernel_args="console=/dev/ttyS0 selinux=0 ro root=/dev/hda2 init=/sbin/init"(安装 虚拟机,--name指定domain名称,--vcpus指定CPU个数,--ram指定内存大小,--disk指定映像文件,--boot指定vmlinuz文件和initrd文件,指定内核参数) Starting install... Creating domain... | 0 B 00:00
提示:没有启动起来;
[root@node1 ~]# virsh list(查看启动的虚拟机) Id Name State ---------------------------------------------------- 7 rhel6 running [root@node1 ~]# virsh destroy rhel6(停止rhel6虚拟机) Domain rhel6 destroyed [root@node1 ~]# virsh undefine rhel6(删除rhel6虚拟机) Domain rhel6 has been undefined [root@node1 ~]# virt-install --name rhel6 --vcpus 2 --ram 128 --disk /kvm/vm1/rhel6.img --boot kernel=/boot/vmlinuz-2.6.32-358.el6.x8 6_64,initrd=/boot/initramfs-2.6.32-358.el6.x86_64.img,kernel_args="console=/dev/ttyS0 selinux=0 ro root=/dev/hda2 init=/sbin/init" - -import --graphics none(安装虚拟机,--name指定domain名称,--vcpus指定CPU个数,--ram指定内存大小,--disk指定映像文件,--boot指定vmlinuz文件和init rd文件,指定内核参数,--import到处,--graphics图形界面) Starting install... Creating domain... | 0 B 00:01 Connected to domain rhel6 Escape character is ^] Google, Inc. Serial Graphics Adapter 07/26/11 SGABIOS $Id: sgabios.S 8 2010-04-22 00:03:40Z nlaredo $ (mockbuild@hs20-bc2-3.build.redhat.com) Tue Jul 26 15:05:08 UTC 2011 Term: 155x18 4 0 [root@node1 ~]# virsh list(查看运行的虚拟机) Id Name State ---------------------------------------------------- 8 rhel6 running [root@node1 ~]# virsh console rhel6(通过console连接rhel6虚拟机) Connected to domain rhel6 Escape character is ^] error: 操作失败: Active console session exists for this domain [root@node1 ~]# virsh list(查看运行的虚拟机) Id Name State ---------------------------------------------------- 9 rhel6 running [root@node1 ~]# virsh destroy rhel6(停止rhel6虚拟机) Domain rhel6 destroyed [root@node1 ~]# ls(查看当前目录文件及子目录) anaconda-ks.cfg bincp.sh install.log install.log.syslog [root@node1 ~]# mount(查看当前系统挂在的所有文件系统) /dev/sda2 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) /dev/sr0 on /media type iso9660 (ro) /dev/mapper/loop0p2 on /mnt/sysroot type ext4 (rw) [root@node1 ~]# mount /dev/mapper/loop0p1 /mnt/boot/(挂在/dev/mapper/loo0p1到/mnt/boot目录) [root@node1 ~]# cp /boot/vmlinuz-2.6.32-358.el6.x86_64 /mnt/boot/vmlinuz(复制vmlinuz-2.6.32-358.el6.x86_64到/mnt/boot叫vmlinuz) [root@node1 ~]# cp /boot/initramfs-2.6.32-358.el6.x86_64.img /mnt/boot/initramfs.img(复制initramfs-2.6.32-358.el6.x86_64.img到/mnt/ boot目录叫initramfs.img) [root@node1 ~]# grub-install --root-directory=/mnt/ /dev/loop0(安装grub到/mnt目录) Probing devices to guess BIOS drives. This may take a long time. /dev/loop0 does not have any corresponding BIOS drive. [root@node1 ~]# vim /mnt/boot/grub/grub.conf(编辑grub.conf配置文件) timout=5 default=0 title Hello root (hd0,0) kernel /vmlinuz ro root=/dev/hda2 selinux=0 init=/sbin/init console=ttyS0 initrd /initramfs.img [root@node1 ~]# sync(同步磁盘写入) [root@node1 ~]# virsh list(查看运行的虚拟机) Id Name State ---------------------------------------------------- [root@node1 ~]# virsh undefine rhel6(删除rhel6虚拟机) Domain rhel6 has been undefined [root@node1 ~]# virt-install --vcpus 2 --ram 128 --name rhel6 --disk /kvm/vm1/rhel6.img --import(安装虚拟机,--vcpus执行cpu个数,--ram指定 内存大小,--name指定虚拟机名字,--disk指定磁盘映像,--import直接导入跳过安装过程) Starting install... Creating domain... | 0 B 00:00
提示:没有启动起来;