格式化磁盘: # echo -n -e"n\np\n3\n\n+5G\nt\n3\n8e\nw\n" |fdisk /dev/sda # partx -a /dev/sda # fdisk -l /dev/sda3 Disk /dev/sda3: 5378 MB, 5378310144 bytes 255 heads, 63 sectors/track, 653 cylinders Units = cylinders of 16065 * 512 = 8225280bytes Sector size (logical/physical): 512 bytes /512 bytes I/O size (minimum/optimal): 512 bytes / 512bytes Disk identifier: 0x00000000
# vim /etc/tgt/targets.conf
#添加如下内容;
<target iqn.2015-02.com.stu31:t1>
backing-store /dev/sda3
initiator-address 172.16.31.0/24
</target>
# tgtadm --lld iscsi -m target -o show
Target 1: iqn.2015-02.com.stu31:t1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 5378 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sda3
Backing store flags:
Account information:
ACL information:
172.16.31.0/24
# service iscsi start # service iscsid start
# iscsiadm -m discovery -t st -p172.16.31.3 172.16.31.3:3260,1 iqn.2015-02.com.stu31:t1
# iscsiadm -m node -Tiqn.2015-02.com.stu31:t1 -p 172.16.31.3 -l Logging in to [iface: default, target:iqn.2015-02.com.stu31:t1, portal: 172.16.31.3,3260] (multiple) Login to [iface: default, target:iqn.2015-02.com.stu31:t1, portal: 172.16.31.3,3260] successful.
# fdisk -l /dev/sdb Disk /dev/sdb: 5378 MB, 5378310144 bytes 166 heads, 62 sectors/track, 1020 cylinders Units = cylinders of 10292 * 512 = 5269504bytes Sector size (logical/physical): 512 bytes /512 bytes I/O size (minimum/optimal): 512 bytes / 512bytes Disk identifier: 0x00000000
# echo -e "n\np\n1\n\n+2G\nw\n"|fdisk /dev/sdb # partx -a /dev/sdb 查看格式化后的磁盘: # fdisk -l /dev/sdb Disk /dev/sdb: 5378 MB, 5378310144 bytes 166 heads, 62 sectors/track, 1020 cylinders Units = cylinders of 10292 * 512 = 5269504bytes Sector size (logical/physical): 512 bytes /512 bytes I/O size (minimum/optimal): 512 bytes / 512bytes Disk identifier: 0x8e1d9dd0 Device Boot Start End Blocks Id System /dev/sdb1 1 409 2104683 83 Linux
# vim /etc/yum.repos.d/xen4.repo [xen4] name=Xen4 For CentOS6 baseurl=ftp://172.16.0.1/pub/Sources/6.x86_64/xen4centos/x86_64/ gpgcheck=0 清空现有yum库缓存: # yum clean all
# vim /etc/grub.conf
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.7.10-1.el6xen.x86_64)
root (hd0,0)
kernel /xen.gz dom0_mem=1024M,max:1024M dom0_max_vcpus=1 dom0_vcpus_pin
cpufreq=xen
module /vmlinuz-3.7.10-1.el6xen.x86_64 ro root=/dev/mapper/vg0-rootrd_NO_LUKS rd_NO_DM.UTF-8 rd_LVM_LV=vg0/swap rd_NO_MDSYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg0/root KEYBOARDTYPE=pc KEYTABLE=us rhgbcrashkernel=auto quiet rhgb quiet
module /initramfs-3.7.10-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=/dev/mapper/vg0-rootrd_NO_LUKS rd_NO_DM.UTF-8 rd_LVM_LV=vg0/swap rd_NO_MDSYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg0/root KEYBOARDTYPE=pc KEYTABLE=us rhgbcrashkernel=auto quiet rhgb quiet
initrd /initramfs-2.6.32-504.el6.x86_64.img
# xm list Name ID Mem VCPUs State Time(s) Domain-0 0 1024 1 r----- 23.7
# xm info host : test2.stu31.com release : 3.7.10-1.el6xen.x86_64 version : #1 SMP Thu Feb 5 12:56:19 CST2015 machine : x86_64 nr_cpus : 1 nr_nodes : 1 cores_per_socket : 1 threads_per_core :1 cpu_mhz : 2272 hw_caps :078bfbff:28100800:00000000:00000140:00000209:00000000:00000001:00000000 virt_caps : total_memory : 2047 free_memory : 998 free_cpus : 0 xen_major : 4 xen_minor : 2 xen_extra : .5-38.el6 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,max:1024Mdom0_max_vcpus=1 dom0_vcpus_pin cpufreq=xen cc_compiler : gcc (GCC) 4.4.7 20120313 (Red Hat4.4.7-11) cc_compile_by : mockbuild cc_compile_domain :centos.org cc_compile_date : Tue Jan 6 12:04:11 CST 2015 xend_config_format : 4
格式化共享存储: # mke2fs -t ext4 /dev/sdb1 创建目录,将存储挂载上: # mkdir /scsistore # mount /dev/sdb1 /scsistore/ 进入目录创建虚拟机磁盘设备: # cd /scsistore # dd if=/dev/zero of=./busybox.img bs=1Moflag=direct seek=1023 count=1 查看设备大小,可以发现实际大小才1MB: # ll -h total 1.1M -rw-r--r-- 1 root root 1.0G Feb 6 20:17 busybox.img drwx------ 2 root root 16K Feb 6 20:05 lost+found 格式化虚拟磁盘设备: # mke2fs -t ext4 /scsistore/busybox.img mke2fs 1.41.12 (17-May-2010) /scsistore/busybox.img is not a blockspecial device. Proceed anyway? (y,n) y 信息略... 挂载虚拟磁盘设备,等待后续操作: # mount -o loop /scsistore/busybox.img /mnt
编译环境需要的开发包组安装: # yum groupinstall -y Developmenttools # yum install -y ncurses-devel glibc-static 获取busybox软件: busybox-1.22.1.tar.bz2 编译安装busybox: # tar xf busybox-1.22.1.tar.bz2 # cd busybox-1.22.1 # make menuconfig
# cp -a _install/* /mnt # cd /mnt # ls bin linuxrc lost+found sbin usr # rm -rf linuxrc # mkdir dev proc sys lib/modules etc/rc.dboot mnt media opt misc -pv
添加网卡桥设备文件: # cd /etc/sysconfig/network-scripts/ # cp ifcfg-eth0 ifcfg-xenbr0 配置桥接设备: # vim ifcfg-xenbr0 DEVICE="xenbr0" BOOTPROTO="static" NM_CONTROLLED="no" ONBOOT="yes" TYPE="Bridge" IPADDR=172.16.31.1 NETMASK=255.255.0.0 GATEWAY=172.16.0.1 配置网卡设备: # vim ifcfg-eth0 DEVICE="eth0" BOOTPROTO="static" HWADDR="08:00:27:16:D9:AA" NM_CONTROLLED="no" ONBOOT="yes" BRIDGE="xenbr0" TYPE="Ethernet" USERCTL="no"
添加网卡桥设备文件: # cd /etc/sysconfig/network-scripts/ # cp ifcfg-eth0 ifcfg-xenbr0 配置桥接设备: # vim ifcfg-xenbr0 DEVICE="xenbr0" BOOTPROTO="static" NM_CONTROLLED="no" ONBOOT="yes" TYPE="Bridge" IPADDR=172.16.31.2 NETMASK=255.255.0.0 GATEWAY=172.16.0.1 配置网卡设备: # vim ifcfg-eth0 DEVICE="eth0" BOOTPROTO="static" HWADDR="08:00:27:6A:9D:57" NM_CONTROLLED="no" ONBOOT="yes" BRIDGE="xenbr0" TYPE="Ethernet" USERCTL="no"
两个节点都需要操作 #chkconfig NetworkManager off #service NetworkManager stop 配置完成后重启网络服务: #service network restart
# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:16:D9:AA
inet6 addr: fe80::a00:27ff:fe16:d9aa/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:37217 errors:0 dropped:7 overruns:0 frame:0
TX packets:4541 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7641467 (7.2 MiB) TXbytes:773075 (754.9 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:12 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:1032 (1.0 KiB) TXbytes:1032 (1.0 KiB)
xenbr0 Link encap:Ethernet HWaddr08:00:27:16:D9:AA
inet addr:172.16.31.1 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fe80::a00:27ff:fe16:d9aa/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1211 errors:0 dropped:0 overruns:0 frame:0
TX packets:90 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:116868 (114.1 KiB) TXbytes:15418 (15.0 KiB)
创建虚拟机配置文件 # vim /etc/xen/busybox kernel ="/boot/vmlinuz-2.6.32-504.el6.x86_64" ramdisk ="/boot/initramfs-2.6.32-504.el6.x86_64.img" name = "busybox" memory = "512" vcpus = 1 disk =['file:/scsistore/busybox.img,xvda,w',] root = "/dev/xvda ro" extra = "selinux=0 init=/bin/sh" vif = ['bridge=xenbr0',] on_crash = "destroy" on_reboot = "destroy" on_shutdown = "destroy"
# modinfo xen-netfront.ko filename: xen-netfront.ko alias: xennet alias: xen:vif license: GPL description: Xen virtual network device frontend srcversion: 5C6FC78BC365D9AF8135201 depends: vermagic: 2.6.32-504.el6.x86_64 SMP mod_unloadmodversions
[root@test2 ~]# iscsiadm -m discovery -t st-p 172.16.31.3 Starting iscsid: [ OK ] 172.16.31.3:3260,1 iqn.2015-02.com.stu31:t1
[root@test2 ~]# iscsiadm -m node -Tiqn.2015-02.com.stu31:t1 -p 172.16.31.3 -l [root@test2 ~]# fdisk -l /dev/sdb Disk /dev/sdb: 5378 MB, 5378310144 bytes 166 heads, 62 sectors/track, 1020 cylinders Units = cylinders of 10292 * 512 = 5269504bytes Sector size (logical/physical): 512 bytes /512 bytes I/O size (minimum/optimal): 512 bytes / 512bytes Disk identifier: 0x8e1d9dd0 Device Boot Start End Blocks Id System /dev/sdb1 1 409 2104683 83 Linux
[root@test2 ~]# mkdir /scsistore [root@test2 ~]# mount /dev/sdb1 /scsistore/ [root@test2 ~]# ls /scsistore/ busybox.img lost+found
test1节点: [root@test1 ~]# mount /dev/sdb1 /scsistore/ [root@test1 ~]# ls /scsistore/ busybox.img lost+found test2节点: [root@test2 ~]# mount /dev/sdb1 /scsistore/ [root@test2 ~]# ls /scsistore/ busybox.img lost+found
[root@test1 ~]# xm create -c busybox
Using config file"/etc/xen/busybox".
Started domain busybox (id=13)
Initializingcgroup 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 Hat4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014
Command line: root=/dev/xvda ro selinux=0init=/bin/sh
#信息略...;加载网卡模块;
/ # insmod /lib/modules/xen-netfront.ko
Initialising Xen virtual ethernet driver.
#设置网卡ip地址;
/ # ifconfig eth0 172.16.31.4 up
/ # ifconfig
eth0 Link encap:Ethernet HWaddr00:16:3E:49:E8:18
inet addr:172.16.31.4 Bcast:172.16.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:42 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:2942 (2.8 KiB) TXbytes:0 (0.0 B)
Interrupt:247
[root@test2 ~]# xm create -c busybox
Using config file"/etc/xen/busybox".
Started domain busybox (id=2)
Initializingcgroup 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 Hat4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014
Command line: root=/dev/xvda ro selinux=0init=/bin/sh
#信息略...
EXT4-fs (xvda): mounted filesystem withordered data mode. Opts:
dracut: Mounted root filesystem /dev/xvda
dracut: Switching root
/bin/sh: can't access tty; job controlturned off
/ # ifconfig
/ # insmod /lib/modules/xen-netfront.ko
Initialising Xen virtual ethernet driver.
/ # ifconfig eth0 172.16.31.5 up
/ # ifconfig
eth0 Link encap:Ethernet HWaddr00:16:3E:41:B0:32
inet addr:172.16.31.5 Bcast:172.16.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:57 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:3412 (3.3 KiB) TXbytes:0 (0.0 B)
Interrupt:247
[root@test1 ~]# grep xend/etc/xen/xend-config.sxp |grep -v "#" (xend-http-server yes) (xend-unix-server yes) (xend-relocation-server yes) (xend-relocation-port 8002) (xend-relocation-address '172.16.31.1') (xend-relocation-hosts-allow '')
[root@test2 ~]# grep xend/etc/xen/xend-config.sxp |grep -v '#' (xend-http-server yes) (xend-unix-server yes) (xend-relocation-server yes) (xend-relocation-port 8002) (xend-relocation-address '172.16.31.2') (xend-relocation-hosts-allow '')
# service xend restart Stopping xend daemon: [ OK ] Starting xend daemon: [ OK ]
# ss -tunl |grep 8002 tcp LISTEN 0 5 172.16.31.2:8002 *:*
#xm create -c busybox
#信息略...
#设置IP地址,以便一会儿迁移后查看有依据;
/ # insmod /lib/modules/xen-netfront.ko
Initialising Xen virtual ethernet driver.
/ # ifconfig eth0 172.16.31.4 up
/ # ifconfig
eth0 Link encap:Ethernet HWaddr00:16:3E:28:BB:F6
inet addr:172.16.31.4 Bcast:172.16.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:921 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:78367 (76.5 KiB) TXbytes:84 (84.0 B)
Interrupt:247
[root@test1 ~]# xm list Name ID Mem VCPUs State Time(s) Domain-0 0 1023 1 r----- 710.1
[root@test2 network-scripts]# xm list Name ID Mem VCPUs State Time(s) Domain-0 0 1023 1 r----- 142.8 [root@test2 network-scripts]# xm list Name ID Mem VCPUs State Time(s) Domain-0 0 1023 1 r----- 147.4 busybox 3 512 0 --p--- 0.0
[root@test2 ~]# xm console busybox
Using NULL legacy PIC
Changing capacity of (202, 0) to 2097152sectors
Changing capacity of (202, 0) to 2097152sectors
/ # ifconfig
eth0 Link encap:Ethernet HWaddr00:16:3E:1D:38:69
inet addr:172.16.31.4 Bcast:172.16.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:350 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:27966 (27.3 KiB) TXbytes:84 (84.0 B)
Interrupt:247
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有