root@ubuntu:/etc/libvirt/qemu# virsh
virsh # define debian7_201.xml #注意使用undefine会删除与客户端关联的文件,先备份
Domain debian7_201 defined from debian7_201.xml
virsh # create debian7_201.xml
Domain debian7_201 created from debian7_201.xml
virsh # start debian7_201
virsh # list
Id Name State
----------------------------------------------------
6 debian7_201 running
查看虚拟机磁盘会发现多了块设备.正好是我们宿主机上卷vm23加入到虚拟机中.
[email protected]:~# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a9969
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 58984447 29491200 83 Linux
/dev/sda2 58984448 62912511 1964032 82 Linux swap / Solaris
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
virsh # define debian7_201.xml
Domain debian7_201 defined from debian7_201.xml
virsh # create debian7_201.xml
Domain debian7_201 created from debian7_201.xml
virsh # start debian7_201
virsh # list
Id Name State
----------------------------------------------------
8 debian7_201 running
[email protected]:~# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a9969
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 58984447 29491200 83 Linux
/dev/sda2 58984448 62912511 1964032 82 Linux swap / Solaris
Disk /dev/sdb: 5368 MB, 5368709120 bytes #这就是我们在宿主机上创建的vm.img镜像
255 heads, 63 sectors/track, 652 cylinders, total 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
以上方法需要重启虚拟机才能生效,还有一种方法可以动态扩展虚拟机磁盘.
root@ubuntu:/etc/libvirt/qemu# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
vm200 vm -wi-ao-- 5.00g
vm201 vm -wi-ao-- 30.00g
vm_21 vm -wi-ao-- 20.00g
vm_22 vm -wi-a--- 20.00g
virsh # attach-disk debian7_201 /dev/vm/vm_21 sdc
Disk attached successfully
[email protected]:~# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a9969
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 58984447 29491200 83 Linux
/dev/sda2 58984448 62912511 1964032 82 Linux swap / Solaris
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders, total 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 21.5 GB, 21474836480 bytes #宿主机上创建的vm_21卷
64 heads, 32 sectors/track, 20480 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc doesn't contain a valid partition table
virsh # detach-disk debian7_201 sdc #动态删除虚拟机上的磁盘
Disk detached successfully
快速高效用:SET SQL_SAFE_UPDATES = 0;下面的就不要看了!
今日用MySQL Workbench进行数据库的管理更新时,执行一个更新的语句碰到以下错误提示:
Error Code: 1175
You are using safe update mode and you tried to update a table without a WHERE that
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Note:You may assume that nums1 has enough space (size that is